his_api_controller.go 1.7MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. )
  35. type HisApiController struct {
  36. controllers.BaseAuthAPIController
  37. }
  38. func HisManagerApiRegistRouters() {
  39. //挂号
  40. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  77. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  78. beego.Router("/api/check", &HisApiController{}, "get:Check")
  79. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  80. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  81. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  82. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  83. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  84. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  85. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  86. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  87. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  88. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  89. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  90. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  91. //beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  92. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  93. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  94. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  95. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  96. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  97. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  98. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  99. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  100. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  101. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  102. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  103. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  106. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  107. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  108. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  109. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  110. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  111. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  112. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  113. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  114. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  115. beego.Router("/api/CFYLJG012", &HisApiController{}, "get:GetCFYLJG12")
  116. beego.Router("/api/CFYLJG013", &HisApiController{}, "get:GetCFYLJG13")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  136. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  137. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  138. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  139. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  140. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  141. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  142. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  143. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  144. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  145. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  146. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  147. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  148. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  149. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  150. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  151. //库盘和变更
  152. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  153. //删除库盘和变更
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  155. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  156. //药品变更
  157. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  158. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  159. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  160. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  161. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  162. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  163. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  164. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  165. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  166. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  167. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  168. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  169. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  170. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  171. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  172. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  173. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  174. beego.Router("/api/5101", &HisApiController{}, "get:Get5101")
  175. beego.Router("/api/5102", &HisApiController{}, "get:Get5102")
  176. }
  177. func (c *HisApiController) Get5101() {
  178. adminUser := c.GetAdminUserInfo()
  179. admin_user_id, _ := c.GetInt64("admin_user_id")
  180. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  181. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  182. if miConfig.MdtrtareaAdmvs == "341203" {
  183. fmt.Println(miConfig.SecretKey)
  184. var res models.Result9001Two
  185. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  186. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  187. resp, requestErr := http.Get(api)
  188. if requestErr != nil {
  189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  190. return
  191. }
  192. body, ioErr := ioutil.ReadAll(resp.Body)
  193. if ioErr != nil {
  194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  196. return
  197. }
  198. var respJSON map[string]interface{}
  199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  202. return
  203. }
  204. status := respJSON["data"].(map[string]interface{})["status"].(string)
  205. if status == "0" {
  206. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  207. c.ServeSuccessJSON(map[string]interface{}{
  208. "failed_code": -10,
  209. "msg": err_msg,
  210. })
  211. return
  212. }
  213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  214. result, _ := json.Marshal(respJSON)
  215. fmt.Println("log")
  216. fmt.Println(string(result))
  217. if err := json.Unmarshal([]byte(result), &res); err != nil {
  218. utils.ErrorLog("解析失败:%v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. if res.Infcode == 0 {
  223. sign := models.HisSignIn{
  224. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  225. SignNo: res.Output.Signinoutb.SignNo,
  226. SignTime: "",
  227. Ctime: time.Now().Unix(),
  228. Mtime: time.Now().Unix(),
  229. Status: 1,
  230. InputLog: "",
  231. OutputLog: "",
  232. FixmedinsCode: miConfig.Code,
  233. }
  234. err := service.CreateSignIn(&sign)
  235. if err == nil {
  236. c.ServeSuccessJSON(map[string]interface{}{
  237. "msg": "签到成功",
  238. })
  239. }
  240. } else {
  241. c.ServeSuccessJSON(map[string]interface{}{
  242. "failed_code": -10,
  243. "msg": res.ErrMsg,
  244. })
  245. return
  246. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  247. //return
  248. }
  249. } else if miConfig.MdtrtareaAdmvs == "340699" {
  250. fmt.Println(miConfig.SecretKey)
  251. var res models.Result9001Two
  252. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  253. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  254. resp, requestErr := http.Get(api)
  255. if requestErr != nil {
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  257. return
  258. }
  259. body, ioErr := ioutil.ReadAll(resp.Body)
  260. if ioErr != nil {
  261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  263. return
  264. }
  265. var respJSON map[string]interface{}
  266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  269. return
  270. }
  271. status := respJSON["data"].(map[string]interface{})["status"].(string)
  272. if status == "0" {
  273. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  274. c.ServeSuccessJSON(map[string]interface{}{
  275. "failed_code": -10,
  276. "msg": err_msg,
  277. })
  278. return
  279. }
  280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  281. result, _ := json.Marshal(respJSON)
  282. fmt.Println("log")
  283. fmt.Println(string(result))
  284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  285. utils.ErrorLog("解析失败:%v", err)
  286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  287. return
  288. }
  289. if res.Infcode == 0 {
  290. sign := models.HisSignIn{
  291. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  292. SignNo: res.Output.Signinoutb.SignNo,
  293. SignTime: "",
  294. Ctime: time.Now().Unix(),
  295. Mtime: time.Now().Unix(),
  296. Status: 1,
  297. InputLog: "",
  298. OutputLog: "",
  299. FixmedinsCode: miConfig.Code,
  300. }
  301. err := service.CreateSignIn(&sign)
  302. if err == nil {
  303. c.ServeSuccessJSON(map[string]interface{}{
  304. "msg": "查询成功",
  305. })
  306. }
  307. } else {
  308. c.ServeSuccessJSON(map[string]interface{}{
  309. "failed_code": -10,
  310. "msg": res.ErrMsg,
  311. })
  312. return
  313. }
  314. }
  315. }
  316. func (c *HisApiController) Get5102() {
  317. adminUser := c.GetAdminUserInfo()
  318. admin_user_id, _ := c.GetInt64("admin_user_id")
  319. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  320. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  321. if miConfig.MdtrtareaAdmvs == "341203" {
  322. fmt.Println(miConfig.SecretKey)
  323. var res models.Result9001Two
  324. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  325. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  326. resp, requestErr := http.Get(api)
  327. if requestErr != nil {
  328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  329. return
  330. }
  331. body, ioErr := ioutil.ReadAll(resp.Body)
  332. if ioErr != nil {
  333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  335. return
  336. }
  337. var respJSON map[string]interface{}
  338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  341. return
  342. }
  343. status := respJSON["data"].(map[string]interface{})["status"].(string)
  344. if status == "0" {
  345. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  346. c.ServeSuccessJSON(map[string]interface{}{
  347. "failed_code": -10,
  348. "msg": err_msg,
  349. })
  350. return
  351. }
  352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  353. result, _ := json.Marshal(respJSON)
  354. fmt.Println("log")
  355. fmt.Println(string(result))
  356. if err := json.Unmarshal([]byte(result), &res); err != nil {
  357. utils.ErrorLog("解析失败:%v", err)
  358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  359. return
  360. }
  361. if res.Infcode == 0 {
  362. sign := models.HisSignIn{
  363. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  364. SignNo: res.Output.Signinoutb.SignNo,
  365. SignTime: "",
  366. Ctime: time.Now().Unix(),
  367. Mtime: time.Now().Unix(),
  368. Status: 1,
  369. InputLog: "",
  370. OutputLog: "",
  371. FixmedinsCode: miConfig.Code,
  372. }
  373. err := service.CreateSignIn(&sign)
  374. if err == nil {
  375. c.ServeSuccessJSON(map[string]interface{}{
  376. "msg": "签到成功",
  377. })
  378. }
  379. } else {
  380. c.ServeSuccessJSON(map[string]interface{}{
  381. "failed_code": -10,
  382. "msg": res.ErrMsg,
  383. })
  384. return
  385. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  386. //return
  387. }
  388. } else if miConfig.MdtrtareaAdmvs == "340699" {
  389. fmt.Println(miConfig.SecretKey)
  390. var res models.Result9001Two
  391. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  392. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  393. resp, requestErr := http.Get(api)
  394. if requestErr != nil {
  395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  396. return
  397. }
  398. body, ioErr := ioutil.ReadAll(resp.Body)
  399. if ioErr != nil {
  400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  402. return
  403. }
  404. var respJSON map[string]interface{}
  405. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  408. return
  409. }
  410. status := respJSON["data"].(map[string]interface{})["status"].(string)
  411. if status == "0" {
  412. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  413. c.ServeSuccessJSON(map[string]interface{}{
  414. "failed_code": -10,
  415. "msg": err_msg,
  416. })
  417. return
  418. }
  419. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  420. result, _ := json.Marshal(respJSON)
  421. fmt.Println("log")
  422. fmt.Println(string(result))
  423. if err := json.Unmarshal([]byte(result), &res); err != nil {
  424. utils.ErrorLog("解析失败:%v", err)
  425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  426. return
  427. }
  428. if res.Infcode == 0 {
  429. sign := models.HisSignIn{
  430. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  431. SignNo: res.Output.Signinoutb.SignNo,
  432. SignTime: "",
  433. Ctime: time.Now().Unix(),
  434. Mtime: time.Now().Unix(),
  435. Status: 1,
  436. InputLog: "",
  437. OutputLog: "",
  438. FixmedinsCode: miConfig.Code,
  439. }
  440. err := service.CreateSignIn(&sign)
  441. if err == nil {
  442. c.ServeSuccessJSON(map[string]interface{}{
  443. "msg": "查询成功",
  444. })
  445. }
  446. } else {
  447. c.ServeSuccessJSON(map[string]interface{}{
  448. "failed_code": -10,
  449. "msg": res.ErrMsg,
  450. })
  451. return
  452. }
  453. }
  454. }
  455. func (c *HisApiController) Get3201() {
  456. adminUser := c.GetAdminUserInfo()
  457. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  458. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  459. var response Response
  460. if err := json.Unmarshal([]byte(result), &response); err != nil {
  461. fmt.Println("Error decoding JSON:", err)
  462. return
  463. }
  464. }
  465. func (c *HisApiController) TestNet() {
  466. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  467. //return
  468. c.ServeSuccessJSON(map[string]interface{}{
  469. "msg": "成功",
  470. })
  471. }
  472. func (c *HisApiController) Get3508() {
  473. admin_user_id, _ := c.GetInt64("admin_user_id")
  474. drug_id, _ := c.GetInt64("id")
  475. start_time := c.GetString("start_time")
  476. end_time := c.GetString("end_time")
  477. adminUser := c.GetAdminUserInfo()
  478. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  479. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  480. drug, _ := service.GetDrugByID(drug_id)
  481. var struct3508 models.Struct3508
  482. struct3508.OrgName = miConfig.OrgName
  483. struct3508.FixmedinsCode = miConfig.Code
  484. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  485. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  486. struct3508.AccessKey = miConfig.AccessKey
  487. struct3508.Opter = curRoles.UserName
  488. struct3508.RequestUrl = miConfig.Url
  489. struct3508.Url = miConfig.Url
  490. struct3508.AppId = miConfig.Cainfo
  491. struct3508.AppSecret = miConfig.AppSecret
  492. struct3508.Enckey = miConfig.EncKey
  493. struct3508.SignKey = miConfig.SignKey
  494. struct3508.SecretKey = miConfig.SecretKey
  495. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  496. struct3508.Begndate = start_time
  497. struct3508.Enddate = end_time
  498. struct3508.Enddate = end_time
  499. struct3508.Enddate = end_time
  500. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  501. result1, result2 := service.Gdyb3508(struct3508, struct3508.SecretKey)
  502. saveLog(result1, result2, "3508", "3508")
  503. var res models.Result3508
  504. var respJSON2 map[string]interface{}
  505. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. userJSONBytes2, _ := json.Marshal(respJSON2)
  511. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  512. utils.ErrorLog("解析失败:%v", err)
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  514. return
  515. }
  516. if res.Infcode == -1 {
  517. c.ServeSuccessJSON(map[string]interface{}{
  518. "failed_code": -10,
  519. "msg": res.ErrMsg,
  520. })
  521. } else {
  522. c.ServeSuccessJSON(map[string]interface{}{
  523. "info": res.Output,
  524. })
  525. }
  526. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  527. result1, result2, _ := service.FJyb3508(struct3508)
  528. saveLog(result1, result2, "3508", "3508")
  529. var res models.Result3508
  530. var respJSON2 map[string]interface{}
  531. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  534. return
  535. }
  536. userJSONBytes2, _ := json.Marshal(respJSON2)
  537. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  538. utils.ErrorLog("解析失败:%v", err)
  539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  540. return
  541. }
  542. if res.Infcode == -1 {
  543. c.ServeSuccessJSON(map[string]interface{}{
  544. "failed_code": -10,
  545. "msg": res.ErrMsg,
  546. })
  547. } else {
  548. c.ServeSuccessJSON(map[string]interface{}{
  549. "info": res.Output,
  550. })
  551. }
  552. }
  553. }
  554. func (c *HisApiController) Get3509() {
  555. admin_user_id, _ := c.GetInt64("admin_user_id")
  556. drug_id, _ := c.GetInt64("id")
  557. start_time := c.GetString("start_time")
  558. end_time := c.GetString("end_time")
  559. adminUser := c.GetAdminUserInfo()
  560. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  561. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  562. drug, _ := service.GetDrugByID(drug_id)
  563. var struct3508 models.Struct3509
  564. struct3508.OrgName = miConfig.OrgName
  565. struct3508.FixmedinsCode = miConfig.Code
  566. struct3508.AccessKey = miConfig.AccessKey
  567. struct3508.Opter = curRoles.UserName
  568. struct3508.RequestUrl = miConfig.Url
  569. struct3508.Url = miConfig.Url
  570. struct3508.AppId = miConfig.Cainfo
  571. struct3508.AppSecret = miConfig.AppSecret
  572. struct3508.Enckey = miConfig.EncKey
  573. struct3508.SignKey = miConfig.SignKey
  574. struct3508.SecretKey = miConfig.SecretKey
  575. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  576. struct3508.Begndate = start_time
  577. struct3508.Enddate = end_time
  578. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  579. result1, result2 := service.Gdyb3509(struct3508, struct3508.SecretKey)
  580. saveLog(result1, result2, "3509", "3509")
  581. var res models.Result3508
  582. var respJSON2 map[string]interface{}
  583. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  586. return
  587. }
  588. userJSONBytes2, _ := json.Marshal(respJSON2)
  589. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  590. utils.ErrorLog("解析失败:%v", err)
  591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  592. return
  593. }
  594. if res.Infcode == -1 {
  595. c.ServeSuccessJSON(map[string]interface{}{
  596. "failed_code": -10,
  597. "msg": res.ErrMsg,
  598. })
  599. } else {
  600. c.ServeSuccessJSON(map[string]interface{}{
  601. "info": res.Output,
  602. })
  603. }
  604. } else {
  605. result1, result2, _ := service.FJyb3509(struct3508)
  606. saveLog(result1, result2, "3509", "3509")
  607. var res models.Result3509
  608. var respJSON2 map[string]interface{}
  609. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  612. return
  613. }
  614. userJSONBytes2, _ := json.Marshal(respJSON2)
  615. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  616. utils.ErrorLog("解析失败:%v", err)
  617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  618. return
  619. }
  620. if res.Infcode == -1 {
  621. c.ServeSuccessJSON(map[string]interface{}{
  622. "failed_code": -10,
  623. "msg": res.ErrMsg,
  624. })
  625. } else {
  626. c.ServeSuccessJSON(map[string]interface{}{
  627. "info": res.Output,
  628. })
  629. }
  630. }
  631. }
  632. func (c *HisApiController) Get3510() {
  633. admin_user_id, _ := c.GetInt64("admin_user_id")
  634. drug_id, _ := c.GetInt64("id")
  635. start_time := c.GetString("start_time")
  636. end_time := c.GetString("end_time")
  637. adminUser := c.GetAdminUserInfo()
  638. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  639. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  640. drug, _ := service.GetDrugByID(drug_id)
  641. var struct3508 models.Struct3510
  642. struct3508.FixmedinsCode = miConfig.Code
  643. struct3508.OrgName = miConfig.OrgName
  644. struct3508.AccessKey = miConfig.AccessKey
  645. struct3508.Opter = curRoles.UserName
  646. struct3508.RequestUrl = miConfig.Url
  647. struct3508.Url = miConfig.Url
  648. struct3508.AppId = miConfig.Cainfo
  649. struct3508.AppSecret = miConfig.AppSecret
  650. struct3508.Enckey = miConfig.EncKey
  651. struct3508.SignKey = miConfig.SignKey
  652. struct3508.SecretKey = miConfig.SecretKey
  653. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  654. struct3508.Begndate = start_time
  655. struct3508.Enddate = end_time
  656. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  657. result1, result2 := service.Gdyb3510(struct3508, struct3508.SecretKey)
  658. saveLog(result1, result2, "3510", "3510")
  659. var res models.Result3510
  660. var respJSON2 map[string]interface{}
  661. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  664. return
  665. }
  666. userJSONBytes2, _ := json.Marshal(respJSON2)
  667. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  668. utils.ErrorLog("解析失败:%v", err)
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. if res.Infcode == -1 {
  673. c.ServeSuccessJSON(map[string]interface{}{
  674. "failed_code": -10,
  675. "msg": res.ErrMsg,
  676. })
  677. } else {
  678. c.ServeSuccessJSON(map[string]interface{}{
  679. "info": res.Output,
  680. })
  681. }
  682. } else {
  683. result1, result2, _ := service.FJyb3510(struct3508)
  684. saveLog(result1, result2, "3510", "3510")
  685. var res models.Result3510
  686. var respJSON2 map[string]interface{}
  687. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  690. return
  691. }
  692. userJSONBytes2, _ := json.Marshal(respJSON2)
  693. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  694. utils.ErrorLog("解析失败:%v", err)
  695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  696. return
  697. }
  698. if res.Infcode == -1 {
  699. c.ServeSuccessJSON(map[string]interface{}{
  700. "failed_code": -10,
  701. "msg": res.ErrMsg,
  702. })
  703. } else {
  704. c.ServeSuccessJSON(map[string]interface{}{
  705. "info": res.Output,
  706. })
  707. }
  708. }
  709. }
  710. func (c *HisApiController) Get3511() {
  711. admin_user_id, _ := c.GetInt64("admin_user_id")
  712. drug_id, _ := c.GetInt64("id")
  713. start_time := c.GetString("start_time")
  714. end_time := c.GetString("end_time")
  715. adminUser := c.GetAdminUserInfo()
  716. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  717. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  718. drug, _ := service.GetDrugByID(drug_id)
  719. var struct3508 models.Struct3511
  720. struct3508.FixmedinsCode = miConfig.Code
  721. struct3508.OrgName = miConfig.OrgName
  722. struct3508.AccessKey = miConfig.AccessKey
  723. struct3508.Opter = curRoles.UserName
  724. struct3508.RequestUrl = miConfig.Url
  725. struct3508.Url = miConfig.Url
  726. struct3508.AppId = miConfig.Cainfo
  727. struct3508.AppSecret = miConfig.AppSecret
  728. struct3508.Enckey = miConfig.EncKey
  729. struct3508.SignKey = miConfig.SignKey
  730. struct3508.SecretKey = miConfig.SecretKey
  731. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  732. struct3508.Begndate = start_time
  733. struct3508.Enddate = end_time
  734. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  735. result1, result2 := service.Gdyb3511(struct3508, struct3508.SecretKey)
  736. saveLog(result1, result2, "3511", "3511")
  737. var res models.Result3511
  738. var respJSON2 map[string]interface{}
  739. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  742. return
  743. }
  744. userJSONBytes2, _ := json.Marshal(respJSON2)
  745. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  746. utils.ErrorLog("解析失败:%v", err)
  747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  748. return
  749. }
  750. if res.Infcode == -1 {
  751. c.ServeSuccessJSON(map[string]interface{}{
  752. "failed_code": -10,
  753. "msg": res.ErrMsg,
  754. })
  755. } else {
  756. c.ServeSuccessJSON(map[string]interface{}{
  757. "info": res.Output,
  758. })
  759. }
  760. } else {
  761. result1, result2, _ := service.FJyb3511(struct3508)
  762. saveLog(result1, result2, "3511", "3511")
  763. var res models.Result3511
  764. var respJSON2 map[string]interface{}
  765. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  768. return
  769. }
  770. userJSONBytes2, _ := json.Marshal(respJSON2)
  771. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  772. utils.ErrorLog("解析失败:%v", err)
  773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  774. return
  775. }
  776. if res.Infcode == -1 {
  777. c.ServeSuccessJSON(map[string]interface{}{
  778. "failed_code": -10,
  779. "msg": res.ErrMsg,
  780. })
  781. } else {
  782. c.ServeSuccessJSON(map[string]interface{}{
  783. "info": res.Output,
  784. })
  785. }
  786. }
  787. }
  788. func (c *HisApiController) Get3512() {
  789. admin_user_id, _ := c.GetInt64("admin_user_id")
  790. drug_id, _ := c.GetInt64("id")
  791. start_time := c.GetString("start_time")
  792. end_time := c.GetString("end_time")
  793. adminUser := c.GetAdminUserInfo()
  794. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  795. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  796. drug, _ := service.GetDrugByID(drug_id)
  797. var struct3508 models.Struct3512
  798. struct3508.FixmedinsCode = miConfig.Code
  799. struct3508.OrgName = miConfig.OrgName
  800. struct3508.AccessKey = miConfig.AccessKey
  801. struct3508.Opter = curRoles.UserName
  802. struct3508.RequestUrl = miConfig.Url
  803. struct3508.Url = miConfig.Url
  804. struct3508.AppId = miConfig.Cainfo
  805. struct3508.AppSecret = miConfig.AppSecret
  806. struct3508.Enckey = miConfig.EncKey
  807. struct3508.SignKey = miConfig.SignKey
  808. struct3508.SecretKey = miConfig.SecretKey
  809. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  810. struct3508.Begndate = start_time
  811. struct3508.Enddate = end_time
  812. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  813. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  814. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  815. result1, result2 := service.Gdyb3512(struct3508, struct3508.SecretKey)
  816. saveLog(result1, result2, "3512", "3512")
  817. var res models.Result3512
  818. var respJSON2 map[string]interface{}
  819. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  822. return
  823. }
  824. userJSONBytes2, _ := json.Marshal(respJSON2)
  825. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  826. utils.ErrorLog("解析失败:%v", err)
  827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  828. return
  829. }
  830. if res.Infcode == -1 {
  831. c.ServeSuccessJSON(map[string]interface{}{
  832. "failed_code": -10,
  833. "msg": res.ErrMsg,
  834. })
  835. } else {
  836. c.ServeSuccessJSON(map[string]interface{}{
  837. "info": res.Output,
  838. })
  839. }
  840. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  841. result1, result2, _ := service.FJyb3512(struct3508)
  842. saveLog(result1, result2, "3512", "3512")
  843. var res models.Result3512
  844. var respJSON2 map[string]interface{}
  845. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  848. return
  849. }
  850. userJSONBytes2, _ := json.Marshal(respJSON2)
  851. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  852. utils.ErrorLog("解析失败:%v", err)
  853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  854. return
  855. }
  856. if res.Infcode == -1 {
  857. c.ServeSuccessJSON(map[string]interface{}{
  858. "failed_code": -10,
  859. "msg": res.ErrMsg,
  860. })
  861. } else {
  862. c.ServeSuccessJSON(map[string]interface{}{
  863. "info": res.Output,
  864. })
  865. }
  866. }
  867. }
  868. func (c *HisApiController) Get3513() {
  869. admin_user_id, _ := c.GetInt64("admin_user_id")
  870. drug_id, _ := c.GetInt64("id")
  871. start_time := c.GetString("start_time")
  872. end_time := c.GetString("end_time")
  873. adminUser := c.GetAdminUserInfo()
  874. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  875. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  876. drug, _ := service.GetDrugByID(drug_id)
  877. var struct3508 models.Struct3513
  878. struct3508.FixmedinsCode = miConfig.Code
  879. struct3508.OrgName = miConfig.OrgName
  880. struct3508.AccessKey = miConfig.AccessKey
  881. struct3508.Opter = curRoles.UserName
  882. struct3508.RequestUrl = miConfig.Url
  883. struct3508.Url = miConfig.Url
  884. struct3508.AppId = miConfig.Cainfo
  885. struct3508.AppSecret = miConfig.AppSecret
  886. struct3508.Enckey = miConfig.EncKey
  887. struct3508.SignKey = miConfig.SignKey
  888. struct3508.SecretKey = miConfig.SecretKey
  889. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  890. struct3508.Begndate = start_time
  891. struct3508.Enddate = end_time
  892. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  893. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  894. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  895. result1, result2 := service.Gdyb3513(struct3508, struct3508.SecretKey)
  896. saveLog(result1, result2, "3513", "3513")
  897. var res models.Result3513
  898. var respJSON2 map[string]interface{}
  899. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  902. return
  903. }
  904. userJSONBytes2, _ := json.Marshal(respJSON2)
  905. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  906. utils.ErrorLog("解析失败:%v", err)
  907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  908. return
  909. }
  910. if res.Infcode == -1 {
  911. c.ServeSuccessJSON(map[string]interface{}{
  912. "failed_code": -10,
  913. "msg": res.ErrMsg,
  914. })
  915. } else {
  916. c.ServeSuccessJSON(map[string]interface{}{
  917. "info": res.Output,
  918. })
  919. }
  920. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  921. result1, result2, _ := service.FJyb3513(struct3508)
  922. saveLog(result1, result2, "3513", "3513")
  923. var res models.Result3513
  924. var respJSON2 map[string]interface{}
  925. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  928. return
  929. }
  930. userJSONBytes2, _ := json.Marshal(respJSON2)
  931. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  932. utils.ErrorLog("解析失败:%v", err)
  933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  934. return
  935. }
  936. if res.Infcode == -1 {
  937. c.ServeSuccessJSON(map[string]interface{}{
  938. "failed_code": -10,
  939. "msg": res.ErrMsg,
  940. })
  941. } else {
  942. c.ServeSuccessJSON(map[string]interface{}{
  943. "info": res.Output,
  944. })
  945. }
  946. }
  947. }
  948. func (c *HisApiController) Get35081() {
  949. admin_user_id, _ := c.GetInt64("admin_user_id")
  950. drug_id, _ := c.GetInt64("id")
  951. //start_time := c.GetString("start_time")
  952. //end_time := c.GetString("end_time")
  953. page, _ := c.GetInt("page")
  954. adminUser := c.GetAdminUserInfo()
  955. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  956. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  957. drug, _ := service.GetDrugByID(drug_id)
  958. var struct3508 models.Struct35081
  959. struct3508.FixmedinsCode = miConfig.Code
  960. struct3508.OrgName = miConfig.OrgName
  961. struct3508.AccessKey = miConfig.AccessKey
  962. struct3508.Opter = curRoles.UserName
  963. struct3508.RequestUrl = miConfig.Url
  964. struct3508.Url = miConfig.Url
  965. struct3508.AppId = miConfig.Cainfo
  966. struct3508.AppSecret = miConfig.AppSecret
  967. struct3508.Enckey = miConfig.EncKey
  968. struct3508.SignKey = miConfig.SignKey
  969. struct3508.SecretKey = miConfig.SecretKey
  970. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  971. struct3508.PageNum = page
  972. struct3508.PageSize = 10
  973. result1, result2, _ := service.FJyb35081(struct3508)
  974. saveLog(result1, result2, "35081", "35081")
  975. var res models.Result35081
  976. var respJSON2 map[string]interface{}
  977. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  980. return
  981. }
  982. userJSONBytes2, _ := json.Marshal(respJSON2)
  983. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  984. utils.ErrorLog("解析失败:%v", err)
  985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  986. return
  987. }
  988. if res.Infcode == -1 {
  989. c.ServeSuccessJSON(map[string]interface{}{
  990. "failed_code": -10,
  991. "msg": res.ErrMsg,
  992. })
  993. } else {
  994. c.ServeSuccessJSON(map[string]interface{}{
  995. "info": res.Output,
  996. })
  997. }
  998. }
  999. func (c *HisApiController) Get35082() {
  1000. admin_user_id, _ := c.GetInt64("admin_user_id")
  1001. drug_id, _ := c.GetInt64("id")
  1002. //start_time := c.GetString("start_time")
  1003. //end_time := c.GetString("end_time")
  1004. page, _ := c.GetInt("page")
  1005. adminUser := c.GetAdminUserInfo()
  1006. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1007. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1008. drug, _ := service.GetDrugByID(drug_id)
  1009. var struct3508 models.Struct35082
  1010. struct3508.FixmedinsCode = miConfig.Code
  1011. struct3508.OrgName = miConfig.OrgName
  1012. struct3508.AccessKey = miConfig.AccessKey
  1013. struct3508.Opter = curRoles.UserName
  1014. struct3508.RequestUrl = miConfig.Url
  1015. struct3508.Url = miConfig.Url
  1016. struct3508.AppId = miConfig.Cainfo
  1017. struct3508.AppSecret = miConfig.AppSecret
  1018. struct3508.Enckey = miConfig.EncKey
  1019. struct3508.SignKey = miConfig.SignKey
  1020. struct3508.SecretKey = miConfig.SecretKey
  1021. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1022. struct3508.PageNum = page
  1023. struct3508.PageSize = 10
  1024. result1, result2, _ := service.FJyb35082(struct3508)
  1025. saveLog(result1, result2, "35082", "35082")
  1026. var res models.Result35082
  1027. var respJSON2 map[string]interface{}
  1028. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1031. return
  1032. }
  1033. userJSONBytes2, _ := json.Marshal(respJSON2)
  1034. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1035. utils.ErrorLog("解析失败:%v", err)
  1036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1037. return
  1038. }
  1039. if res.Infcode == -1 {
  1040. c.ServeSuccessJSON(map[string]interface{}{
  1041. "failed_code": -10,
  1042. "msg": res.ErrMsg,
  1043. })
  1044. } else {
  1045. c.ServeSuccessJSON(map[string]interface{}{
  1046. "info": res.Output,
  1047. })
  1048. }
  1049. }
  1050. func IsDigit(s string) bool {
  1051. re := regexp.MustCompile("^[0-9]+$")
  1052. return re.MatchString(s)
  1053. }
  1054. func (c *HisApiController) FJ3501AND3502() {
  1055. ids := c.GetString("ids")
  1056. admin_user_id, _ := c.GetInt64("admin_user_id")
  1057. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1058. id_arr := strings.Split(ids, ",")
  1059. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1060. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1061. //规则判断
  1062. var errs []string
  1063. for _, drug := range drugs {
  1064. if drug.IsPc == 0 {
  1065. if len(drug.DrugCode) > 0 {
  1066. codes := strings.Split(drug.DrugCode, ",")
  1067. for _, code := range codes {
  1068. if len(code) > 0 {
  1069. if len(code) != 20 {
  1070. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  1071. }
  1072. if IsDigit(code) == false {
  1073. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  1074. }
  1075. }
  1076. }
  1077. }
  1078. }
  1079. }
  1080. if len(errs) > 0 {
  1081. c.ServeSuccessJSON(map[string]interface{}{
  1082. "failed_code": -10,
  1083. "msg": errs,
  1084. })
  1085. return
  1086. }
  1087. //库盘
  1088. for _, drug := range drugs {
  1089. if drug.IsPc == 0 {
  1090. var res2 ResultSix
  1091. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  1092. var struct3501 models.Struct3501
  1093. struct3501.Code = miConfig.Code
  1094. struct3501.OrgName = miConfig.OrgName
  1095. struct3501.AccessKey = miConfig.AccessKey
  1096. struct3501.Opter = roles.UserName
  1097. struct3501.RequestUrl = miConfig.Url
  1098. struct3501.Url = miConfig.Url
  1099. struct3501.AppId = miConfig.Cainfo
  1100. struct3501.AppSecret = miConfig.AppSecret
  1101. struct3501.Enckey = miConfig.EncKey
  1102. struct3501.SignKey = miConfig.SignKey
  1103. struct3501.SecretKey = miConfig.SecretKey
  1104. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1105. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1106. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1107. struct3501.RxFlag = "1"
  1108. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  1109. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1110. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1111. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1112. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  1113. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  1114. struct3501.FixmedinsBchno = number
  1115. struct3501.DrugTracCodg = drug.DrugCode
  1116. memo := make(map[string]interface{})
  1117. memo["pric"] = drug.Price
  1118. bytesData, _ := json.Marshal(memo)
  1119. struct3501.Memo = string(bytesData)
  1120. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  1121. result1, result2, _ := service.FJyb3501(struct3501)
  1122. saveLog(result1, result2, "3501", "3501")
  1123. //saveLog(result, requestLog, "2201", "挂号")
  1124. var respJSON2 map[string]interface{}
  1125. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1128. return
  1129. }
  1130. userJSONBytes2, _ := json.Marshal(respJSON2)
  1131. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1132. utils.ErrorLog("解析失败:%v", err)
  1133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1134. return
  1135. }
  1136. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  1137. data := make(map[string]interface{})
  1138. data["struct_3501s"] = struct3501
  1139. client := &http.Client{}
  1140. bytesData, _ := json.Marshal(data)
  1141. var req *http.Request
  1142. if miConfig.MdtrtareaAdmvs == "320830" {
  1143. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  1144. } else {
  1145. if miConfig.MdtrtareaAdmvs == "320921" {
  1146. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1147. } else {
  1148. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1149. }
  1150. }
  1151. resp, _ := client.Do(req)
  1152. defer resp.Body.Close()
  1153. body, ioErr := ioutil.ReadAll(resp.Body)
  1154. if ioErr != nil {
  1155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1156. }
  1157. var respJSON map[string]interface{}
  1158. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1161. return
  1162. }
  1163. var resSix10265 ResultSix10265 //1101结果
  1164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1165. result, _ := json.Marshal(respJSON)
  1166. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1167. utils.ErrorLog("解析失败:%v", err)
  1168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1169. return
  1170. }
  1171. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1172. res2.Output = resSix10265.Output
  1173. res2.ErrMsg = resSix10265.ErrMsg
  1174. res2.Cainfo = resSix10265.Cainfo
  1175. res2.WarnMsg = resSix10265.WarnMsg
  1176. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1177. res2.Infcode = infocode
  1178. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  1179. data := make(map[string]interface{})
  1180. data["struct_3501s"] = struct3501
  1181. client := &http.Client{}
  1182. bytesData, _ := json.Marshal(data)
  1183. var req *http.Request
  1184. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1185. resp, _ := client.Do(req)
  1186. defer resp.Body.Close()
  1187. body, ioErr := ioutil.ReadAll(resp.Body)
  1188. if ioErr != nil {
  1189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1190. }
  1191. var respJSON map[string]interface{}
  1192. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1195. return
  1196. }
  1197. var resSix10265 ResultSix10265 //1101结果
  1198. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1199. result, _ := json.Marshal(respJSON)
  1200. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1201. utils.ErrorLog("解析失败:%v", err)
  1202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1203. return
  1204. }
  1205. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1206. res2.Output = resSix10265.Output
  1207. res2.ErrMsg = resSix10265.ErrMsg
  1208. res2.Cainfo = resSix10265.Cainfo
  1209. res2.WarnMsg = resSix10265.WarnMsg
  1210. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1211. res2.Infcode = infocode
  1212. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  1213. data := make(map[string]interface{})
  1214. data["struct_3501s"] = struct3501
  1215. client := &http.Client{}
  1216. bytesData, _ := json.Marshal(data)
  1217. var req *http.Request
  1218. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  1219. resp, _ := client.Do(req)
  1220. defer resp.Body.Close()
  1221. body, ioErr := ioutil.ReadAll(resp.Body)
  1222. if ioErr != nil {
  1223. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1224. }
  1225. var respJSON map[string]interface{}
  1226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1229. return
  1230. }
  1231. var resSix10265 ResultSix10265 //1101结果
  1232. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1233. result, _ := json.Marshal(respJSON)
  1234. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1235. utils.ErrorLog("解析失败:%v", err)
  1236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1237. return
  1238. }
  1239. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1240. res2.Output = resSix10265.Output
  1241. res2.ErrMsg = resSix10265.ErrMsg
  1242. res2.Cainfo = resSix10265.Cainfo
  1243. res2.WarnMsg = resSix10265.WarnMsg
  1244. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1245. res2.Infcode = infocode
  1246. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  1247. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  1248. saveLog(result1, result2, "3501", "3501")
  1249. //saveLog(result, requestLog, "2201", "挂号")
  1250. var respJSON2 map[string]interface{}
  1251. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1254. return
  1255. }
  1256. userJSONBytes2, _ := json.Marshal(respJSON2)
  1257. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1258. utils.ErrorLog("解析失败:%v", err)
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1260. return
  1261. }
  1262. }
  1263. utils.ErrorLog("解析失败:%v", res2.Infcode)
  1264. if res2.Infcode != -1 {
  1265. drug.IsPc = 1
  1266. drug.Bchno = number
  1267. drug.PcDate = time.Now().Unix()
  1268. service.SaveW(drug)
  1269. //if err == nil {
  1270. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  1271. // var struct3502 models.Struct3502
  1272. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1273. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1274. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1275. // struct3502.FixmedinsCode = miConfig.Code
  1276. // struct3502.Code = miConfig.Code
  1277. //
  1278. // struct3502.RxFlag = "0"
  1279. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1280. // struct3502.OrgName = miConfig.OrgName
  1281. // struct3502.Opter = roles.UserName
  1282. // struct3502.AccessKey = miConfig.AccessKey
  1283. // struct3502.RequestUrl = miConfig.Url
  1284. // struct3502.SecretKey = miConfig.SecretKey
  1285. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1286. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1287. // struct3502.Url = miConfig.Url
  1288. // struct3502.AppId = miConfig.Cainfo
  1289. // struct3502.AppSecret = miConfig.AppSecret
  1290. // struct3502.Enckey = miConfig.EncKey
  1291. // struct3502.SignKey = miConfig.SignKey
  1292. // struct3502.SecretKey = miConfig.SecretKey
  1293. // struct3502.DrugTracCodg = drug.DrugCode
  1294. //
  1295. // struct3502.Memo = ""
  1296. // struct3502.InvChgType = "108"
  1297. // struct3502.FixmedinsBchno = bg_number
  1298. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  1299. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  1300. //
  1301. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  1302. // result11, result22, _ := service.FJyb3502(struct3502)
  1303. // saveLog(result11, result22, "3502", "3502")
  1304. //
  1305. // var respJSON3 map[string]interface{}
  1306. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1307. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1309. // return
  1310. // }
  1311. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1312. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1313. // utils.ErrorLog("解析失败:%v", err)
  1314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1315. // return
  1316. // }
  1317. //
  1318. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1319. // data := make(map[string]interface{})
  1320. // data["struct_3502s"] = struct3502
  1321. // client := &http.Client{}
  1322. // bytesData, _ := json.Marshal(data)
  1323. // var req *http.Request
  1324. // if miConfig.MdtrtareaAdmvs == "320830" {
  1325. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  1326. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  1327. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1328. // } else {
  1329. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1330. // }
  1331. //
  1332. // resp, _ := client.Do(req)
  1333. // defer resp.Body.Close()
  1334. // body, ioErr := ioutil.ReadAll(resp.Body)
  1335. // if ioErr != nil {
  1336. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1337. // }
  1338. // var respJSON map[string]interface{}
  1339. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1340. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1341. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1342. // return
  1343. // }
  1344. // var resSix10265 ResultSix10265 //1101结果
  1345. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1346. // result, _ := json.Marshal(respJSON)
  1347. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1348. // utils.ErrorLog("解析失败:%v", err)
  1349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1350. // return
  1351. // }
  1352. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1353. // res3.Output = resSix10265.Output
  1354. // res3.ErrMsg = resSix10265.ErrMsg
  1355. // res3.Cainfo = resSix10265.Cainfo
  1356. // res3.WarnMsg = resSix10265.WarnMsg
  1357. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1358. // res3.Infcode = infocode
  1359. //
  1360. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1361. //
  1362. // data := make(map[string]interface{})
  1363. // data["struct_3502s"] = struct3502
  1364. // client := &http.Client{}
  1365. // bytesData, _ := json.Marshal(data)
  1366. // var req *http.Request
  1367. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  1368. // resp, _ := client.Do(req)
  1369. // defer resp.Body.Close()
  1370. // body, ioErr := ioutil.ReadAll(resp.Body)
  1371. // if ioErr != nil {
  1372. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1373. // }
  1374. // var respJSON map[string]interface{}
  1375. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1376. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1378. // return
  1379. // }
  1380. // var resSix10265 ResultSix10265 //1101结果
  1381. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1382. // result, _ := json.Marshal(respJSON)
  1383. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1384. // utils.ErrorLog("解析失败:%v", err)
  1385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1386. // return
  1387. // }
  1388. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1389. // res3.Output = resSix10265.Output
  1390. // res3.ErrMsg = resSix10265.ErrMsg
  1391. // res3.Cainfo = resSix10265.Cainfo
  1392. // res3.WarnMsg = resSix10265.WarnMsg
  1393. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1394. // res3.Infcode = infocode
  1395. //
  1396. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1397. //
  1398. // data := make(map[string]interface{})
  1399. // data["struct_3501s"] = struct3501
  1400. // client := &http.Client{}
  1401. // bytesData, _ := json.Marshal(data)
  1402. // var req *http.Request
  1403. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1404. // resp, _ := client.Do(req)
  1405. // defer resp.Body.Close()
  1406. // body, ioErr := ioutil.ReadAll(resp.Body)
  1407. // if ioErr != nil {
  1408. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1409. // }
  1410. // var respJSON map[string]interface{}
  1411. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1412. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1414. // return
  1415. // }
  1416. // var resSix10265 ResultSix10265 //1101结果
  1417. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1418. // result, _ := json.Marshal(respJSON)
  1419. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1420. // utils.ErrorLog("解析失败:%v", err)
  1421. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1422. // return
  1423. // }
  1424. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  1425. // res2.Output = resSix10265.Output
  1426. // res2.ErrMsg = resSix10265.ErrMsg
  1427. // res2.Cainfo = resSix10265.Cainfo
  1428. // res2.WarnMsg = resSix10265.WarnMsg
  1429. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1430. // res2.Infcode = infocode
  1431. //
  1432. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1433. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  1434. // saveLog(result11, result22, "3502", "3502")
  1435. //
  1436. // var respJSON3 map[string]interface{}
  1437. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1438. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1439. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1440. // return
  1441. // }
  1442. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1443. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1444. // utils.ErrorLog("解析失败:%v", err)
  1445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1446. // return
  1447. // }
  1448. // }
  1449. // if res3.Infcode == -1 {
  1450. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1451. // c.ServeSuccessJSON(map[string]interface{}{
  1452. // "failed_code": -10,
  1453. // "msg": res3.ErrMsg,
  1454. // })
  1455. // } else {
  1456. // drug.IsBg = 1
  1457. // drug.BgBchno = bg_number
  1458. // service.SaveW(drug)
  1459. // }
  1460. //}
  1461. //} else {
  1462. } else {
  1463. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  1464. }
  1465. }
  1466. //变更
  1467. }
  1468. if len(errs) == 0 {
  1469. c.ServeSuccessJSON(map[string]interface{}{
  1470. "msg": "盘存变更成功",
  1471. })
  1472. } else {
  1473. c.ServeSuccessJSON(map[string]interface{}{
  1474. "failed_code": -10,
  1475. "msg": errs,
  1476. })
  1477. }
  1478. }
  1479. func (c *HisApiController) DeletePCandBG() {
  1480. ids := c.GetString("ids")
  1481. id_arr := strings.Split(ids, ",")
  1482. admin_user_id, _ := c.GetInt64("admin_user_id")
  1483. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1484. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1485. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1486. var err []string
  1487. for _, item := range drugs {
  1488. if item.IsPc == 1 {
  1489. var res FJ3507Result
  1490. var struct3507 models.Struct3507
  1491. struct3507.FixmedinsBchno = item.Bchno
  1492. struct3507.InvDataType = "1"
  1493. struct3507.Opter = roles.UserName
  1494. struct3507.OrgName = miConfig.OrgName
  1495. struct3507.AccessKey = miConfig.AccessKey
  1496. struct3507.RequestUrl = miConfig.Url
  1497. struct3507.FixmedinsCode = miConfig.Code
  1498. struct3507.Code = miConfig.Code
  1499. struct3507.SecretKey = miConfig.SecretKey
  1500. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1501. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1502. struct3507.Url = miConfig.Url
  1503. struct3507.AppId = miConfig.Cainfo
  1504. struct3507.AppSecret = miConfig.AppSecret
  1505. struct3507.Enckey = miConfig.EncKey
  1506. struct3507.SignKey = miConfig.SignKey
  1507. struct3507.SecretKey = miConfig.SecretKey
  1508. if miConfig.MdtrtareaAdmvs == "350500" {
  1509. result, result1, _ := service.FJyb3507(struct3507)
  1510. saveLog(result, result1, "3507", "3507")
  1511. var respJSON2 map[string]interface{}
  1512. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1515. return
  1516. }
  1517. userJSONBytes2, _ := json.Marshal(respJSON2)
  1518. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1519. utils.ErrorLog("解析失败:%v", err)
  1520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1521. return
  1522. }
  1523. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1524. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  1525. saveLog(result2, result1, "3507", "3507")
  1526. var respJSON2 map[string]interface{}
  1527. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1530. return
  1531. }
  1532. userJSONBytes2, _ := json.Marshal(respJSON2)
  1533. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1534. utils.ErrorLog("解析失败:%v", err)
  1535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1536. return
  1537. }
  1538. } else {
  1539. data := make(map[string]interface{})
  1540. data["struct_3507s"] = struct3507
  1541. client := &http.Client{}
  1542. bytesData, _ := json.Marshal(data)
  1543. var req *http.Request
  1544. if miConfig.MdtrtareaAdmvs == "320830" {
  1545. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1546. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1547. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1548. } else {
  1549. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1550. }
  1551. resp, _ := client.Do(req)
  1552. defer resp.Body.Close()
  1553. body, ioErr := ioutil.ReadAll(resp.Body)
  1554. if ioErr != nil {
  1555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1556. }
  1557. var respJSON map[string]interface{}
  1558. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1561. return
  1562. }
  1563. var resSix10265 ResultSix10265 //1101结果
  1564. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1565. result, _ := json.Marshal(respJSON)
  1566. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1567. utils.ErrorLog("解析失败:%v", err)
  1568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1569. return
  1570. }
  1571. res.InfRefmsgid = resSix10265.InfRefmsgid
  1572. //res.Output = resSix10265.Output
  1573. res.ErrMsg = resSix10265.ErrMsg
  1574. res.Cainfo = resSix10265.Cainfo
  1575. res.WarnMsg = resSix10265.WarnMsg
  1576. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1577. res.Infcode = infocode
  1578. }
  1579. if res.Infcode == 0 {
  1580. item.IsPc = 0
  1581. service.SaveW(item)
  1582. } else {
  1583. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1584. }
  1585. }
  1586. }
  1587. if len(err) == 0 {
  1588. c.ServeSuccessJSON(map[string]interface{}{
  1589. "msg": "删除盘存变更成功",
  1590. })
  1591. } else {
  1592. c.ServeSuccessJSON(map[string]interface{}{
  1593. "failed_code": -10,
  1594. "msg": err,
  1595. })
  1596. }
  1597. }
  1598. func (c *HisApiController) DeleteXSandBG() {
  1599. ids := c.GetString("ids")
  1600. id_arr := strings.Split(ids, ",")
  1601. admin_user_id, _ := c.GetInt64("admin_user_id")
  1602. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1603. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1604. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1605. var err []string
  1606. for _, item := range flows {
  1607. if item.IsSale == 1 && item.IsChange == 1 {
  1608. var res FJ3507Result
  1609. var res2 FJ3507Result
  1610. var struct3507 models.Struct3507
  1611. struct3507.FixmedinsBchno = item.Bchno
  1612. struct3507.InvDataType = "4"
  1613. struct3507.Opter = roles.UserName
  1614. struct3507.OrgName = miConfig.OrgName
  1615. struct3507.AccessKey = miConfig.AccessKey
  1616. struct3507.RequestUrl = miConfig.Url
  1617. struct3507.FixmedinsCode = miConfig.Code
  1618. struct3507.SecretKey = miConfig.SecretKey
  1619. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1620. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1621. struct3507.Url = miConfig.Url
  1622. struct3507.AppId = miConfig.Cainfo
  1623. struct3507.AppSecret = miConfig.AppSecret
  1624. struct3507.Enckey = miConfig.EncKey
  1625. struct3507.SignKey = miConfig.SignKey
  1626. struct3507.SecretKey = miConfig.SecretKey
  1627. //result, result1, _ := service.FJyb3507(struct3507)
  1628. //saveLog(result, result1, "3507", "3507")
  1629. if miConfig.MdtrtareaAdmvs == "350500" {
  1630. result, result1, _ := service.FJyb3507(struct3507)
  1631. saveLog(result, result1, "3507", "3507")
  1632. var respJSON2 map[string]interface{}
  1633. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1636. return
  1637. }
  1638. userJSONBytes2, _ := json.Marshal(respJSON2)
  1639. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1640. utils.ErrorLog("解析失败:%v", err)
  1641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1642. return
  1643. }
  1644. } else {
  1645. data := make(map[string]interface{})
  1646. data["struct_3507s"] = struct3507
  1647. client := &http.Client{}
  1648. bytesData, _ := json.Marshal(data)
  1649. var req *http.Request
  1650. if miConfig.MdtrtareaAdmvs == "320830" {
  1651. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1652. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1653. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1654. } else {
  1655. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1656. }
  1657. resp, _ := client.Do(req)
  1658. defer resp.Body.Close()
  1659. body, ioErr := ioutil.ReadAll(resp.Body)
  1660. if ioErr != nil {
  1661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1662. }
  1663. var respJSON map[string]interface{}
  1664. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1667. return
  1668. }
  1669. var resSix10265 ResultSix10265 //1101结果
  1670. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1671. result, _ := json.Marshal(respJSON)
  1672. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1673. utils.ErrorLog("解析失败:%v", err)
  1674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1675. return
  1676. }
  1677. res.InfRefmsgid = resSix10265.InfRefmsgid
  1678. //res.Output = resSix10265.Output
  1679. res.ErrMsg = resSix10265.ErrMsg
  1680. res.Cainfo = resSix10265.Cainfo
  1681. res.WarnMsg = resSix10265.WarnMsg
  1682. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1683. res.Infcode = infocode
  1684. }
  1685. if res.Infcode == 0 {
  1686. item.IsSale = 0
  1687. item.SaleDate = ""
  1688. item.Bchno = ""
  1689. err2 := service.SaveDF(item)
  1690. if err2 == nil {
  1691. var struct3507_2 models.Struct3507
  1692. struct3507_2.OrgName = miConfig.OrgName
  1693. struct3507_2.AccessKey = miConfig.AccessKey
  1694. struct3507_2.RequestUrl = miConfig.Url
  1695. struct3507_2.Opter = roles.UserName
  1696. struct3507_2.FixmedinsCode = miConfig.Code
  1697. struct3507_2.Code = miConfig.Code
  1698. struct3507_2.SecretKey = miConfig.SecretKey
  1699. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1700. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1701. struct3507_2.Url = miConfig.Url
  1702. struct3507_2.AppId = miConfig.Cainfo
  1703. struct3507_2.AppSecret = miConfig.AppSecret
  1704. struct3507_2.Enckey = miConfig.EncKey
  1705. struct3507_2.SignKey = miConfig.SignKey
  1706. struct3507_2.SecretKey = miConfig.SecretKey
  1707. struct3507_2.FixmedinsBchno = item.BgBchno
  1708. struct3507_2.InvDataType = "2"
  1709. if miConfig.MdtrtareaAdmvs == "350500" {
  1710. result11, result22, _ := service.FJyb3507(struct3507_2)
  1711. saveLog(result11, result22, "3507", "3507")
  1712. var respJSON3 map[string]interface{}
  1713. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1716. return
  1717. }
  1718. userJSONBytes3, _ := json.Marshal(respJSON3)
  1719. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1720. utils.ErrorLog("解析失败:%v", err)
  1721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1722. return
  1723. }
  1724. } else {
  1725. data := make(map[string]interface{})
  1726. data["struct_3507s"] = struct3507_2
  1727. client := &http.Client{}
  1728. bytesData, _ := json.Marshal(data)
  1729. var req *http.Request
  1730. if miConfig.MdtrtareaAdmvs == "320830" {
  1731. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1732. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1733. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1734. } else {
  1735. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1736. }
  1737. resp, _ := client.Do(req)
  1738. defer resp.Body.Close()
  1739. body, ioErr := ioutil.ReadAll(resp.Body)
  1740. if ioErr != nil {
  1741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1742. }
  1743. var respJSON map[string]interface{}
  1744. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1747. return
  1748. }
  1749. var resSix10265 ResultSix10265 //1101结果
  1750. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1751. result, _ := json.Marshal(respJSON)
  1752. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1753. utils.ErrorLog("解析失败:%v", err)
  1754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1755. return
  1756. }
  1757. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1758. //res.Output = resSix10265.Output
  1759. res2.ErrMsg = resSix10265.ErrMsg
  1760. res2.Cainfo = resSix10265.Cainfo
  1761. res2.WarnMsg = resSix10265.WarnMsg
  1762. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1763. res2.Infcode = infocode
  1764. }
  1765. if res2.Infcode == 0 {
  1766. item.IsChange = 0
  1767. item.BgBchno = ""
  1768. service.SaveDF2(item)
  1769. } else {
  1770. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1771. }
  1772. }
  1773. } else {
  1774. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1775. }
  1776. }
  1777. if item.IsSale == 2 && item.IsChange == 1 {
  1778. var res FJ3507Result
  1779. var res2 FJ3507Result
  1780. var struct3507 models.Struct3507
  1781. struct3507.FixmedinsBchno = item.Bchno
  1782. struct3507.InvDataType = "4"
  1783. struct3507.Opter = roles.UserName
  1784. struct3507.OrgName = miConfig.OrgName
  1785. struct3507.AccessKey = miConfig.AccessKey
  1786. struct3507.RequestUrl = miConfig.Url
  1787. struct3507.FixmedinsCode = miConfig.Code
  1788. struct3507.Code = miConfig.Code
  1789. struct3507.SecretKey = miConfig.SecretKey
  1790. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1791. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1792. struct3507.Url = miConfig.Url
  1793. struct3507.AppId = miConfig.Cainfo
  1794. struct3507.AppSecret = miConfig.AppSecret
  1795. struct3507.Enckey = miConfig.EncKey
  1796. struct3507.SignKey = miConfig.SignKey
  1797. struct3507.SecretKey = miConfig.SecretKey
  1798. //result, result1, _ := service.FJyb3507(struct3507)
  1799. //saveLog(result, result1, "3507", "3507")
  1800. //
  1801. //var respJSON2 map[string]interface{}
  1802. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1803. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1804. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1805. // return
  1806. //}
  1807. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1808. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1809. // utils.ErrorLog("解析失败:%v", err)
  1810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1811. // return
  1812. //}
  1813. if miConfig.MdtrtareaAdmvs == "350500" {
  1814. result, result1, _ := service.FJyb3507(struct3507)
  1815. saveLog(result, result1, "3507", "3507")
  1816. var respJSON2 map[string]interface{}
  1817. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1820. return
  1821. }
  1822. userJSONBytes2, _ := json.Marshal(respJSON2)
  1823. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1824. utils.ErrorLog("解析失败:%v", err)
  1825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1826. return
  1827. }
  1828. } else {
  1829. data := make(map[string]interface{})
  1830. data["struct_3507s"] = struct3507
  1831. client := &http.Client{}
  1832. bytesData, _ := json.Marshal(data)
  1833. var req *http.Request
  1834. if miConfig.MdtrtareaAdmvs == "320830" {
  1835. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1836. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1837. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1838. } else {
  1839. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1840. }
  1841. resp, _ := client.Do(req)
  1842. defer resp.Body.Close()
  1843. body, ioErr := ioutil.ReadAll(resp.Body)
  1844. if ioErr != nil {
  1845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1846. }
  1847. var respJSON map[string]interface{}
  1848. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1851. return
  1852. }
  1853. var resSix10265 ResultSix10265 //1101结果
  1854. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1855. result, _ := json.Marshal(respJSON)
  1856. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1857. utils.ErrorLog("解析失败:%v", err)
  1858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1859. return
  1860. }
  1861. res.InfRefmsgid = resSix10265.InfRefmsgid
  1862. //res.Output = resSix10265.Output
  1863. res.ErrMsg = resSix10265.ErrMsg
  1864. res.Cainfo = resSix10265.Cainfo
  1865. res.WarnMsg = resSix10265.WarnMsg
  1866. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1867. res.Infcode = infocode
  1868. }
  1869. if res.Infcode == 0 {
  1870. item.IsSale = 0
  1871. item.SaleDate = ""
  1872. item.Bchno = ""
  1873. err2 := service.SaveDF(item)
  1874. if err2 == nil {
  1875. var struct3507_2 models.Struct3507
  1876. struct3507_2.OrgName = miConfig.OrgName
  1877. struct3507_2.AccessKey = miConfig.AccessKey
  1878. struct3507_2.RequestUrl = miConfig.Url
  1879. struct3507_2.Opter = roles.UserName
  1880. struct3507_2.FixmedinsCode = miConfig.Code
  1881. struct3507_2.Code = miConfig.Code
  1882. struct3507_2.SecretKey = miConfig.SecretKey
  1883. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1884. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1885. struct3507_2.Url = miConfig.Url
  1886. struct3507_2.AppId = miConfig.Cainfo
  1887. struct3507_2.AppSecret = miConfig.AppSecret
  1888. struct3507_2.Enckey = miConfig.EncKey
  1889. struct3507_2.SignKey = miConfig.SignKey
  1890. struct3507_2.SecretKey = miConfig.SecretKey
  1891. struct3507_2.FixmedinsBchno = item.BgBchno
  1892. struct3507_2.InvDataType = "2"
  1893. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1894. //saveLog(result11, result22, "3507", "3507")
  1895. //var respJSON3 map[string]interface{}
  1896. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1897. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1899. // return
  1900. //}
  1901. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1902. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1903. // utils.ErrorLog("解析失败:%v", err)
  1904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1905. // return
  1906. //}
  1907. if miConfig.MdtrtareaAdmvs == "350500" {
  1908. result11, result22, _ := service.FJyb3507(struct3507_2)
  1909. saveLog(result11, result22, "3507", "3507")
  1910. var respJSON3 map[string]interface{}
  1911. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1914. return
  1915. }
  1916. userJSONBytes3, _ := json.Marshal(respJSON3)
  1917. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1918. utils.ErrorLog("解析失败:%v", err)
  1919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1920. return
  1921. }
  1922. } else {
  1923. data := make(map[string]interface{})
  1924. data["struct_3507s"] = struct3507_2
  1925. client := &http.Client{}
  1926. bytesData, _ := json.Marshal(data)
  1927. var req *http.Request
  1928. if miConfig.MdtrtareaAdmvs == "320830" {
  1929. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1930. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1931. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1932. } else {
  1933. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1934. }
  1935. resp, _ := client.Do(req)
  1936. defer resp.Body.Close()
  1937. body, ioErr := ioutil.ReadAll(resp.Body)
  1938. if ioErr != nil {
  1939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1940. }
  1941. var respJSON map[string]interface{}
  1942. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1945. return
  1946. }
  1947. var resSix10265 ResultSix10265 //1101结果
  1948. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1949. result, _ := json.Marshal(respJSON)
  1950. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1951. utils.ErrorLog("解析失败:%v", err)
  1952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1953. return
  1954. }
  1955. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1956. //res.Output = resSix10265.Output
  1957. res2.ErrMsg = resSix10265.ErrMsg
  1958. res2.Cainfo = resSix10265.Cainfo
  1959. res2.WarnMsg = resSix10265.WarnMsg
  1960. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1961. res2.Infcode = infocode
  1962. }
  1963. if res2.Infcode == 0 {
  1964. item.IsChange = 0
  1965. item.BgBchno = ""
  1966. service.SaveDF2(item)
  1967. } else {
  1968. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1969. }
  1970. }
  1971. } else {
  1972. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1973. }
  1974. }
  1975. if item.IsSale == 1 && item.IsChange == 0 {
  1976. var res FJ3507Result
  1977. var struct3507 models.Struct3507
  1978. struct3507.FixmedinsBchno = item.Bchno
  1979. struct3507.InvDataType = "4"
  1980. struct3507.Opter = roles.UserName
  1981. struct3507.FixmedinsCode = miConfig.Code
  1982. struct3507.Code = miConfig.Code
  1983. struct3507.OrgName = miConfig.OrgName
  1984. struct3507.AccessKey = miConfig.AccessKey
  1985. struct3507.RequestUrl = miConfig.Url
  1986. struct3507.SecretKey = miConfig.SecretKey
  1987. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1988. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1989. struct3507.Url = miConfig.Url
  1990. struct3507.AppId = miConfig.Cainfo
  1991. struct3507.AppSecret = miConfig.AppSecret
  1992. struct3507.Enckey = miConfig.EncKey
  1993. struct3507.SignKey = miConfig.SignKey
  1994. struct3507.SecretKey = miConfig.SecretKey
  1995. //result, result1, _ := service.FJyb3507(struct3507)
  1996. //saveLog(result, result1, "3507", "3507")
  1997. //
  1998. //var respJSON3 map[string]interface{}
  1999. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2000. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2002. // return
  2003. //}
  2004. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2005. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2006. // utils.ErrorLog("解析失败:%v", err)
  2007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2008. // return
  2009. //}
  2010. if miConfig.MdtrtareaAdmvs == "350500" {
  2011. result, result1, _ := service.FJyb3507(struct3507)
  2012. saveLog(result, result1, "3507", "3507")
  2013. var respJSON2 map[string]interface{}
  2014. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2017. return
  2018. }
  2019. userJSONBytes2, _ := json.Marshal(respJSON2)
  2020. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2021. utils.ErrorLog("解析失败:%v", err)
  2022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2023. return
  2024. }
  2025. } else {
  2026. data := make(map[string]interface{})
  2027. data["struct_3507s"] = struct3507
  2028. client := &http.Client{}
  2029. bytesData, _ := json.Marshal(data)
  2030. var req *http.Request
  2031. if miConfig.MdtrtareaAdmvs == "320830" {
  2032. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2033. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2034. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2035. } else {
  2036. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2037. }
  2038. resp, _ := client.Do(req)
  2039. defer resp.Body.Close()
  2040. body, ioErr := ioutil.ReadAll(resp.Body)
  2041. if ioErr != nil {
  2042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2043. }
  2044. var respJSON map[string]interface{}
  2045. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2048. return
  2049. }
  2050. var resSix10265 ResultSix10265 //1101结果
  2051. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2052. result, _ := json.Marshal(respJSON)
  2053. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2054. utils.ErrorLog("解析失败:%v", err)
  2055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2056. return
  2057. }
  2058. res.InfRefmsgid = resSix10265.InfRefmsgid
  2059. //res.Output = resSix10265.Output
  2060. res.ErrMsg = resSix10265.ErrMsg
  2061. res.Cainfo = resSix10265.Cainfo
  2062. res.WarnMsg = resSix10265.WarnMsg
  2063. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2064. res.Infcode = infocode
  2065. }
  2066. if res.Infcode == 0 {
  2067. item.IsSale = 0
  2068. item.SaleDate = ""
  2069. service.SaveDF(item)
  2070. } else {
  2071. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2072. }
  2073. }
  2074. if item.IsSale == 2 && item.IsChange == 0 {
  2075. var res FJ3507Result
  2076. var struct3507 models.Struct3507
  2077. struct3507.FixmedinsBchno = item.Bchno
  2078. struct3507.InvDataType = "4"
  2079. struct3507.Opter = roles.UserName
  2080. struct3507.FixmedinsCode = miConfig.Code
  2081. struct3507.Code = miConfig.Code
  2082. struct3507.OrgName = miConfig.OrgName
  2083. struct3507.AccessKey = miConfig.AccessKey
  2084. struct3507.RequestUrl = miConfig.Url
  2085. struct3507.SecretKey = miConfig.SecretKey
  2086. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2087. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2088. struct3507.Url = miConfig.Url
  2089. struct3507.AppId = miConfig.Cainfo
  2090. struct3507.AppSecret = miConfig.AppSecret
  2091. struct3507.Enckey = miConfig.EncKey
  2092. struct3507.SignKey = miConfig.SignKey
  2093. struct3507.SecretKey = miConfig.SecretKey
  2094. //result, result1, _ := service.FJyb3507(struct3507)
  2095. //saveLog(result, result1, "3507", "3507")
  2096. //
  2097. //var respJSON3 map[string]interface{}
  2098. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2099. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2101. // return
  2102. //}
  2103. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2104. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2105. // utils.ErrorLog("解析失败:%v", err)
  2106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2107. // return
  2108. //}
  2109. if miConfig.MdtrtareaAdmvs == "350500" {
  2110. result, result1, _ := service.FJyb3507(struct3507)
  2111. saveLog(result, result1, "3507", "3507")
  2112. var respJSON2 map[string]interface{}
  2113. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2116. return
  2117. }
  2118. userJSONBytes2, _ := json.Marshal(respJSON2)
  2119. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2120. utils.ErrorLog("解析失败:%v", err)
  2121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2122. return
  2123. }
  2124. } else {
  2125. data := make(map[string]interface{})
  2126. data["struct_3507s"] = struct3507
  2127. client := &http.Client{}
  2128. bytesData, _ := json.Marshal(data)
  2129. var req *http.Request
  2130. if miConfig.MdtrtareaAdmvs == "320830" {
  2131. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2132. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2133. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2134. } else {
  2135. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2136. }
  2137. resp, _ := client.Do(req)
  2138. defer resp.Body.Close()
  2139. body, ioErr := ioutil.ReadAll(resp.Body)
  2140. if ioErr != nil {
  2141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2142. }
  2143. var respJSON map[string]interface{}
  2144. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2147. return
  2148. }
  2149. var resSix10265 ResultSix10265 //1101结果
  2150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2151. result, _ := json.Marshal(respJSON)
  2152. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2153. utils.ErrorLog("解析失败:%v", err)
  2154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2155. return
  2156. }
  2157. res.InfRefmsgid = resSix10265.InfRefmsgid
  2158. //res.Output = resSix10265.Output
  2159. res.ErrMsg = resSix10265.ErrMsg
  2160. res.Cainfo = resSix10265.Cainfo
  2161. res.WarnMsg = resSix10265.WarnMsg
  2162. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2163. res.Infcode = infocode
  2164. }
  2165. if res.Infcode == 0 {
  2166. item.IsSale = 0
  2167. item.SaleDate = ""
  2168. item.Bchno = ""
  2169. service.SaveDF(item)
  2170. } else {
  2171. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2172. }
  2173. }
  2174. if item.IsSale == 0 && item.IsChange == 1 {
  2175. var res FJ3507Result
  2176. var struct3507 models.Struct3507
  2177. struct3507.FixmedinsBchno = item.BgBchno
  2178. struct3507.InvDataType = "2"
  2179. struct3507.Opter = roles.UserName
  2180. struct3507.FixmedinsCode = miConfig.Code
  2181. struct3507.Code = miConfig.Code
  2182. struct3507.OrgName = miConfig.OrgName
  2183. struct3507.AccessKey = miConfig.AccessKey
  2184. struct3507.RequestUrl = miConfig.Url
  2185. struct3507.SecretKey = miConfig.SecretKey
  2186. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2187. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2188. struct3507.Url = miConfig.Url
  2189. struct3507.AppId = miConfig.Cainfo
  2190. struct3507.AppSecret = miConfig.AppSecret
  2191. struct3507.Enckey = miConfig.EncKey
  2192. struct3507.SignKey = miConfig.SignKey
  2193. struct3507.SecretKey = miConfig.SecretKey
  2194. //result, result1, _ := service.FJyb3507(struct3507)
  2195. //saveLog(result, result1, "3507", "3507")
  2196. //
  2197. //var respJSON3 map[string]interface{}
  2198. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2199. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2201. // return
  2202. //}
  2203. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2204. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2205. // utils.ErrorLog("解析失败:%v", err)
  2206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2207. // return
  2208. //}
  2209. if miConfig.MdtrtareaAdmvs == "350500" {
  2210. result, result1, _ := service.FJyb3507(struct3507)
  2211. saveLog(result, result1, "3507", "3507")
  2212. var respJSON2 map[string]interface{}
  2213. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2216. return
  2217. }
  2218. userJSONBytes2, _ := json.Marshal(respJSON2)
  2219. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2220. utils.ErrorLog("解析失败:%v", err)
  2221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2222. return
  2223. }
  2224. } else {
  2225. data := make(map[string]interface{})
  2226. data["struct_3507s"] = struct3507
  2227. client := &http.Client{}
  2228. bytesData, _ := json.Marshal(data)
  2229. var req *http.Request
  2230. if miConfig.MdtrtareaAdmvs == "320830" {
  2231. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2232. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2233. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2234. } else {
  2235. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2236. }
  2237. resp, _ := client.Do(req)
  2238. defer resp.Body.Close()
  2239. body, ioErr := ioutil.ReadAll(resp.Body)
  2240. if ioErr != nil {
  2241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2242. }
  2243. var respJSON map[string]interface{}
  2244. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2247. return
  2248. }
  2249. var resSix10265 ResultSix10265 //1101结果
  2250. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2251. result, _ := json.Marshal(respJSON)
  2252. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2253. utils.ErrorLog("解析失败:%v", err)
  2254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2255. return
  2256. }
  2257. res.InfRefmsgid = resSix10265.InfRefmsgid
  2258. //res.Output = resSix10265.Output
  2259. res.ErrMsg = resSix10265.ErrMsg
  2260. res.Cainfo = resSix10265.Cainfo
  2261. res.WarnMsg = resSix10265.WarnMsg
  2262. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2263. res.Infcode = infocode
  2264. }
  2265. if res.Infcode == 0 {
  2266. item.IsChange = 0
  2267. item.BgBchno = ""
  2268. service.SaveDF2(item)
  2269. } else {
  2270. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2271. }
  2272. }
  2273. }
  2274. if len(err) == 0 {
  2275. c.ServeSuccessJSON(map[string]interface{}{
  2276. "msg": "删除销售变更成功",
  2277. })
  2278. } else {
  2279. c.ServeSuccessJSON(map[string]interface{}{
  2280. "failed_code": -10,
  2281. "msg": err,
  2282. })
  2283. }
  2284. }
  2285. //func (c *HisApiController) BatchFJ3501AND3502() {
  2286. // //ids := c.GetString("ids")
  2287. // start_time := c.GetString("start_time")
  2288. // end_time := c.GetString("end_time")
  2289. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2290. //
  2291. //
  2292. // timeLayout := "2006-01-02"
  2293. // loc, _ := time.LoadLocation("Local")
  2294. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2295. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2296. //
  2297. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2298. // //id_arr := strings.Split(ids, ",")
  2299. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2300. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2301. // //库盘
  2302. // var errs []string
  2303. // for _, drug := range drugs {
  2304. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2305. // var res2 ResultSix
  2306. // var res3 ResultSix
  2307. //
  2308. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2309. // var struct3501 models.Struct3501
  2310. // struct3501.Code = miConfig.Code
  2311. // struct3501.OrgName = miConfig.OrgName
  2312. // struct3501.AccessKey = miConfig.AccessKey
  2313. // struct3501.Opter = roles.UserName
  2314. // struct3501.RequestUrl = miConfig.Url
  2315. // struct3501.Url = miConfig.Url
  2316. // struct3501.AppId = miConfig.Cainfo
  2317. // struct3501.AppSecret = miConfig.AppSecret
  2318. // struct3501.Enckey = miConfig.EncKey
  2319. // struct3501.SignKey = miConfig.SignKey
  2320. // struct3501.SecretKey = miConfig.SecretKey
  2321. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2322. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2323. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2324. // struct3501.RxFlag = "1"
  2325. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2326. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2327. //
  2328. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2329. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2330. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2331. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2332. // struct3501.FixmedinsBchno = number
  2333. // struct3501.DrugTracCodg = drug.DrugCode
  2334. // memo := make(map[string]interface{})
  2335. // memo["pric"] = drug.Price
  2336. // bytesData, _ := json.Marshal(memo)
  2337. // struct3501.Memo = string(bytesData)
  2338. //
  2339. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2340. //
  2341. // result1, result2, _ := service.FJyb3501(struct3501)
  2342. // saveLog(result1, result2, "3501", "3501")
  2343. // //saveLog(result, requestLog, "2201", "挂号")
  2344. //
  2345. // var respJSON2 map[string]interface{}
  2346. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2347. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2348. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2349. // return
  2350. // }
  2351. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2352. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2353. // utils.ErrorLog("解析失败:%v", err)
  2354. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2355. // return
  2356. // }
  2357. //
  2358. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2359. // data := make(map[string]interface{})
  2360. // data["struct_3501s"] = struct3501
  2361. // client := &http.Client{}
  2362. // bytesData, _ := json.Marshal(data)
  2363. // var req *http.Request
  2364. // if miConfig.MdtrtareaAdmvs == "320921" {
  2365. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2366. // } else {
  2367. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2368. // }
  2369. //
  2370. // resp, _ := client.Do(req)
  2371. // defer resp.Body.Close()
  2372. // body, ioErr := ioutil.ReadAll(resp.Body)
  2373. // if ioErr != nil {
  2374. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2375. // }
  2376. // var respJSON map[string]interface{}
  2377. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. // return
  2381. // }
  2382. // var resSix10265 ResultSix10265 //1101结果
  2383. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2384. // result, _ := json.Marshal(respJSON)
  2385. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2386. // utils.ErrorLog("解析失败:%v", err)
  2387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2388. // return
  2389. // }
  2390. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2391. // res2.Output = resSix10265.Output
  2392. // res2.ErrMsg = resSix10265.ErrMsg
  2393. // res2.Cainfo = resSix10265.Cainfo
  2394. // res2.WarnMsg = resSix10265.WarnMsg
  2395. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2396. // res2.Infcode = infocode
  2397. //
  2398. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2399. // data := make(map[string]interface{})
  2400. // data["struct_3501s"] = struct3501
  2401. // client := &http.Client{}
  2402. // bytesData, _ := json.Marshal(data)
  2403. // var req *http.Request
  2404. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2405. // resp, _ := client.Do(req)
  2406. // defer resp.Body.Close()
  2407. // body, ioErr := ioutil.ReadAll(resp.Body)
  2408. // if ioErr != nil {
  2409. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2410. // }
  2411. // var respJSON map[string]interface{}
  2412. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2413. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2415. // return
  2416. // }
  2417. // var resSix10265 ResultSix10265 //1101结果
  2418. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2419. // result, _ := json.Marshal(respJSON)
  2420. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2421. // utils.ErrorLog("解析失败:%v", err)
  2422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2423. // return
  2424. // }
  2425. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2426. // res2.Output = resSix10265.Output
  2427. // res2.ErrMsg = resSix10265.ErrMsg
  2428. // res2.Cainfo = resSix10265.Cainfo
  2429. // res2.WarnMsg = resSix10265.WarnMsg
  2430. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2431. // res2.Infcode = infocode
  2432. //
  2433. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2434. // data := make(map[string]interface{})
  2435. // data["struct_3501s"] = struct3501
  2436. // client := &http.Client{}
  2437. // bytesData, _ := json.Marshal(data)
  2438. // var req *http.Request
  2439. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2440. // resp, _ := client.Do(req)
  2441. // defer resp.Body.Close()
  2442. // body, ioErr := ioutil.ReadAll(resp.Body)
  2443. // if ioErr != nil {
  2444. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2445. // }
  2446. // var respJSON map[string]interface{}
  2447. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2448. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2450. // return
  2451. // }
  2452. // var resSix10265 ResultSix10265 //1101结果
  2453. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2454. // result, _ := json.Marshal(respJSON)
  2455. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2456. // utils.ErrorLog("解析失败:%v", err)
  2457. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2458. // return
  2459. // }
  2460. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2461. // res2.Output = resSix10265.Output
  2462. // res2.ErrMsg = resSix10265.ErrMsg
  2463. // res2.Cainfo = resSix10265.Cainfo
  2464. // res2.WarnMsg = resSix10265.WarnMsg
  2465. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2466. // res2.Infcode = infocode
  2467. //
  2468. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2469. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2470. // saveLog(result1, result2, "3501", "3501")
  2471. // //saveLog(result, requestLog, "2201", "挂号")
  2472. //
  2473. // var respJSON2 map[string]interface{}
  2474. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2475. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2477. // return
  2478. // }
  2479. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2480. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2481. // utils.ErrorLog("解析失败:%v", err)
  2482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2483. // return
  2484. // }
  2485. //
  2486. // }
  2487. //
  2488. // if res2.Infcode != -1 {
  2489. // drug.IsPc = 1
  2490. // drug.Bchno = number
  2491. // drug.PcDate = time.Now().Unix()
  2492. // err := service.SaveW(drug)
  2493. // if err == nil {
  2494. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2495. // var struct3502 models.Struct3502
  2496. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2497. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2498. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2499. // struct3502.FixmedinsCode = miConfig.Code
  2500. // struct3502.Code = miConfig.Code
  2501. //
  2502. // struct3502.RxFlag = "0"
  2503. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2504. // struct3502.OrgName = miConfig.OrgName
  2505. // struct3502.Opter = roles.UserName
  2506. // struct3502.AccessKey = miConfig.AccessKey
  2507. // struct3502.RequestUrl = miConfig.Url
  2508. // struct3502.SecretKey = miConfig.SecretKey
  2509. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2510. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2511. // struct3502.Url = miConfig.Url
  2512. // struct3502.AppId = miConfig.Cainfo
  2513. // struct3502.AppSecret = miConfig.AppSecret
  2514. // struct3502.Enckey = miConfig.EncKey
  2515. // struct3502.SignKey = miConfig.SignKey
  2516. // struct3502.SecretKey = miConfig.SecretKey
  2517. // struct3502.DrugTracCodg = drug.DrugCode
  2518. //
  2519. // struct3502.Memo = ""
  2520. // struct3502.InvChgType = "108"
  2521. // struct3502.FixmedinsBchno = bg_number
  2522. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2523. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2524. //
  2525. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2526. // result11, result22, _ := service.FJyb3502(struct3502)
  2527. // saveLog(result11, result22, "3502", "3502")
  2528. //
  2529. // var respJSON3 map[string]interface{}
  2530. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2531. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2533. // return
  2534. // }
  2535. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2536. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2537. // utils.ErrorLog("解析失败:%v", err)
  2538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2539. // return
  2540. // }
  2541. //
  2542. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2543. // data := make(map[string]interface{})
  2544. // data["struct_3502s"] = struct3502
  2545. // client := &http.Client{}
  2546. // bytesData, _ := json.Marshal(data)
  2547. // var req *http.Request
  2548. // if miConfig.MdtrtareaAdmvs == "320921" {
  2549. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2550. // } else {
  2551. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2552. // }
  2553. //
  2554. // resp, _ := client.Do(req)
  2555. // defer resp.Body.Close()
  2556. // body, ioErr := ioutil.ReadAll(resp.Body)
  2557. // if ioErr != nil {
  2558. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2559. // }
  2560. // var respJSON map[string]interface{}
  2561. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2562. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2564. // return
  2565. // }
  2566. // var resSix10265 ResultSix10265 //1101结果
  2567. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2568. // result, _ := json.Marshal(respJSON)
  2569. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2570. // utils.ErrorLog("解析失败:%v", err)
  2571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2572. // return
  2573. // }
  2574. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2575. // res3.Output = resSix10265.Output
  2576. // res3.ErrMsg = resSix10265.ErrMsg
  2577. // res3.Cainfo = resSix10265.Cainfo
  2578. // res3.WarnMsg = resSix10265.WarnMsg
  2579. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2580. // res3.Infcode = infocode
  2581. //
  2582. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2583. //
  2584. // data := make(map[string]interface{})
  2585. // data["struct_3502s"] = struct3502
  2586. // client := &http.Client{}
  2587. // bytesData, _ := json.Marshal(data)
  2588. // var req *http.Request
  2589. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2590. // resp, _ := client.Do(req)
  2591. // defer resp.Body.Close()
  2592. // body, ioErr := ioutil.ReadAll(resp.Body)
  2593. // if ioErr != nil {
  2594. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2595. // }
  2596. // var respJSON map[string]interface{}
  2597. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2598. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2600. // return
  2601. // }
  2602. // var resSix10265 ResultSix10265 //1101结果
  2603. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2604. // result, _ := json.Marshal(respJSON)
  2605. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2606. // utils.ErrorLog("解析失败:%v", err)
  2607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2608. // return
  2609. // }
  2610. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2611. // res3.Output = resSix10265.Output
  2612. // res3.ErrMsg = resSix10265.ErrMsg
  2613. // res3.Cainfo = resSix10265.Cainfo
  2614. // res3.WarnMsg = resSix10265.WarnMsg
  2615. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2616. // res3.Infcode = infocode
  2617. //
  2618. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2619. //
  2620. // data := make(map[string]interface{})
  2621. // data["struct_3501s"] = struct3501
  2622. // client := &http.Client{}
  2623. // bytesData, _ := json.Marshal(data)
  2624. // var req *http.Request
  2625. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2626. // resp, _ := client.Do(req)
  2627. // defer resp.Body.Close()
  2628. // body, ioErr := ioutil.ReadAll(resp.Body)
  2629. // if ioErr != nil {
  2630. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2631. // }
  2632. // var respJSON map[string]interface{}
  2633. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2634. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2636. // return
  2637. // }
  2638. // var resSix10265 ResultSix10265 //1101结果
  2639. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2640. // result, _ := json.Marshal(respJSON)
  2641. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2642. // utils.ErrorLog("解析失败:%v", err)
  2643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2644. // return
  2645. // }
  2646. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2647. // res2.Output = resSix10265.Output
  2648. // res2.ErrMsg = resSix10265.ErrMsg
  2649. // res2.Cainfo = resSix10265.Cainfo
  2650. // res2.WarnMsg = resSix10265.WarnMsg
  2651. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2652. // res2.Infcode = infocode
  2653. //
  2654. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2655. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2656. // saveLog(result11, result22, "3502", "3502")
  2657. //
  2658. // var respJSON3 map[string]interface{}
  2659. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2660. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2661. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2662. // return
  2663. // }
  2664. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2665. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2666. // utils.ErrorLog("解析失败:%v", err)
  2667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2668. // return
  2669. // }
  2670. // }
  2671. // if res3.Infcode == -1 {
  2672. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2673. // c.ServeSuccessJSON(map[string]interface{}{
  2674. // "failed_code": -10,
  2675. // "msg": res3.ErrMsg,
  2676. // })
  2677. // } else {
  2678. // drug.IsBg = 1
  2679. // drug.BgBchno = bg_number
  2680. // service.SaveW(drug)
  2681. // }
  2682. // }
  2683. // } else {
  2684. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2685. // }
  2686. // }
  2687. // //变更
  2688. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2689. // var res3 ResultSix
  2690. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2691. //
  2692. // var struct3502 models.Struct3502
  2693. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2694. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2695. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2696. // struct3502.FixmedinsCode = miConfig.Code
  2697. // struct3502.Code = miConfig.Code
  2698. //
  2699. // struct3502.Opter = roles.UserName
  2700. // struct3502.RxFlag = "0"
  2701. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2702. // struct3502.OrgName = miConfig.OrgName
  2703. // struct3502.AccessKey = miConfig.AccessKey
  2704. // struct3502.RequestUrl = miConfig.Url
  2705. // struct3502.SecretKey = miConfig.SecretKey
  2706. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2707. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2708. // struct3502.InvChgType = "108"
  2709. // struct3502.DrugTracCodg = drug.DrugCode
  2710. //
  2711. // struct3502.Url = miConfig.Url
  2712. // struct3502.AppId = miConfig.Cainfo
  2713. // struct3502.AppSecret = miConfig.AppSecret
  2714. // struct3502.Enckey = miConfig.EncKey
  2715. // struct3502.SignKey = miConfig.SignKey
  2716. // struct3502.SecretKey = miConfig.SecretKey
  2717. //
  2718. // struct3502.FixmedinsBchno = bg_number
  2719. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2720. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2721. //
  2722. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2723. // result1, result2, _ := service.FJyb3502(struct3502)
  2724. // saveLog(result1, result2, "3502", "3502")
  2725. // var respJSON3 map[string]interface{}
  2726. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2727. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2728. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2729. // return
  2730. // }
  2731. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2732. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2733. // utils.ErrorLog("解析失败:%v", err)
  2734. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2735. // return
  2736. // }
  2737. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2738. // data := make(map[string]interface{})
  2739. // data["struct_3502s"] = struct3502
  2740. // client := &http.Client{}
  2741. // bytesData, _ := json.Marshal(data)
  2742. // var req *http.Request
  2743. // if miConfig.MdtrtareaAdmvs == "320921" {
  2744. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2745. // } else {
  2746. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2747. // }
  2748. // resp, _ := client.Do(req)
  2749. // defer resp.Body.Close()
  2750. // body, ioErr := ioutil.ReadAll(resp.Body)
  2751. // if ioErr != nil {
  2752. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2753. // }
  2754. // var respJSON map[string]interface{}
  2755. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2756. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2758. // return
  2759. // }
  2760. // var resSix10265 ResultSix10265 //1101结果
  2761. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2762. // result, _ := json.Marshal(respJSON)
  2763. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2764. // utils.ErrorLog("解析失败:%v", err)
  2765. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2766. // return
  2767. // }
  2768. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2769. // res3.Output = resSix10265.Output
  2770. // res3.ErrMsg = resSix10265.ErrMsg
  2771. // res3.Cainfo = resSix10265.Cainfo
  2772. // res3.WarnMsg = resSix10265.WarnMsg
  2773. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2774. // res3.Infcode = infocode
  2775. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2776. //
  2777. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2778. //
  2779. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2780. //
  2781. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2782. //
  2783. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2784. // saveLog(result1, result2, "3501", "3501")
  2785. // //saveLog(result, requestLog, "2201", "挂号")
  2786. //
  2787. // var respJSON2 map[string]interface{}
  2788. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2789. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2790. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2791. // return
  2792. // }
  2793. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2794. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2795. // utils.ErrorLog("解析失败:%v", err)
  2796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2797. // return
  2798. // }
  2799. //
  2800. // }
  2801. // if res3.Infcode == -1 {
  2802. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2803. // } else {
  2804. // drug.IsBg = 1
  2805. // drug.BgBchno = bg_number
  2806. // service.SaveW(drug)
  2807. // }
  2808. // }
  2809. // }
  2810. //
  2811. // if len(errs) == 0 {
  2812. // c.ServeSuccessJSON(map[string]interface{}{
  2813. // "msg": "盘存变更成功",
  2814. // })
  2815. // } else {
  2816. // c.ServeSuccessJSON(map[string]interface{}{
  2817. // "failed_code": -10,
  2818. // "msg": errs,
  2819. // })
  2820. // }
  2821. //}
  2822. func (c *HisApiController) DeleteXSandBGTwo() {
  2823. patient_id, _ := c.GetInt64("patient_id")
  2824. admin_user_id, _ := c.GetInt64("admin_user_id")
  2825. times := c.GetString("time", "")
  2826. timeLayout := "2006-01-02"
  2827. loc, _ := time.LoadLocation("Local")
  2828. var stime, etime int64
  2829. if times == "" {
  2830. stime, etime = GetNowTime()
  2831. } else {
  2832. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2833. stime = stmp.Unix()
  2834. etime = stime + 86399
  2835. }
  2836. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2837. var flows []*models.DrugFlow
  2838. for _, item := range advicelist {
  2839. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2840. flows = append(flows, flow...)
  2841. }
  2842. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2843. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2845. var err []string
  2846. for _, item := range flows {
  2847. if item.IsSale == 1 {
  2848. var res FJ3507Result
  2849. var struct3507 models.Struct3507
  2850. struct3507.FixmedinsBchno = item.Bchno
  2851. struct3507.InvDataType = "4"
  2852. struct3507.Opter = roles.UserName
  2853. struct3507.OrgName = miConfig.OrgName
  2854. struct3507.AccessKey = miConfig.AccessKey
  2855. struct3507.RequestUrl = miConfig.Url
  2856. struct3507.FixmedinsCode = miConfig.Code
  2857. struct3507.SecretKey = miConfig.SecretKey
  2858. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2859. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2860. struct3507.Url = miConfig.Url
  2861. struct3507.AppId = miConfig.Cainfo
  2862. struct3507.AppSecret = miConfig.AppSecret
  2863. struct3507.Enckey = miConfig.EncKey
  2864. struct3507.SignKey = miConfig.SignKey
  2865. struct3507.SecretKey = miConfig.SecretKey
  2866. if miConfig.MdtrtareaAdmvs == "350500" {
  2867. result, result1, _ := service.FJyb3507(struct3507)
  2868. saveLog(result, result1, "3507", "3507")
  2869. var respJSON2 map[string]interface{}
  2870. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2873. return
  2874. }
  2875. userJSONBytes2, _ := json.Marshal(respJSON2)
  2876. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2877. utils.ErrorLog("解析失败:%v", err)
  2878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2879. return
  2880. }
  2881. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  2882. data := make(map[string]interface{})
  2883. data["struct_3507s"] = struct3507
  2884. client := &http.Client{}
  2885. bytesData, _ := json.Marshal(data)
  2886. var req *http.Request
  2887. if miConfig.MdtrtareaAdmvs == "320830" {
  2888. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2889. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2890. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2891. } else {
  2892. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2893. }
  2894. resp, _ := client.Do(req)
  2895. defer resp.Body.Close()
  2896. body, ioErr := ioutil.ReadAll(resp.Body)
  2897. if ioErr != nil {
  2898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2899. }
  2900. var respJSON map[string]interface{}
  2901. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2904. return
  2905. }
  2906. var resSix10265 ResultSix10265 //1101结果
  2907. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2908. result, _ := json.Marshal(respJSON)
  2909. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2910. utils.ErrorLog("解析失败:%v", err)
  2911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2912. return
  2913. }
  2914. res.InfRefmsgid = resSix10265.InfRefmsgid
  2915. //res.Output = resSix10265.Output
  2916. res.ErrMsg = resSix10265.ErrMsg
  2917. res.Cainfo = resSix10265.Cainfo
  2918. res.WarnMsg = resSix10265.WarnMsg
  2919. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2920. res.Infcode = infocode
  2921. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2922. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2923. saveLog(result2, result1, "3507", "3507")
  2924. var respJSON2 map[string]interface{}
  2925. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2928. return
  2929. }
  2930. userJSONBytes2, _ := json.Marshal(respJSON2)
  2931. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2932. utils.ErrorLog("解析失败:%v", err)
  2933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2934. return
  2935. }
  2936. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2937. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2938. saveLog(result2, result1, "3507", "3507")
  2939. var respJSON2 map[string]interface{}
  2940. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2943. return
  2944. }
  2945. userJSONBytes2, _ := json.Marshal(respJSON2)
  2946. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2947. utils.ErrorLog("解析失败:%v", err)
  2948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2949. return
  2950. }
  2951. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2952. result1, result2 := service.Jxyb3507(struct3507)
  2953. saveLog(result2, result1, "3507", "3507")
  2954. var respJSON2 map[string]interface{}
  2955. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2958. return
  2959. }
  2960. userJSONBytes2, _ := json.Marshal(respJSON2)
  2961. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2962. utils.ErrorLog("解析失败:%v", err)
  2963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2964. return
  2965. }
  2966. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2967. result1, result2 := service.AHyb3507(struct3507)
  2968. saveLog(result2, result1, "3507", "3507")
  2969. var respJSON2 map[string]interface{}
  2970. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2973. return
  2974. }
  2975. userJSONBytes2, _ := json.Marshal(respJSON2)
  2976. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2977. utils.ErrorLog("解析失败:%v", err)
  2978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2979. return
  2980. }
  2981. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2982. data := make(map[string]interface{})
  2983. data["struct_3507s"] = struct3507
  2984. client := &http.Client{}
  2985. bytesData, _ := json.Marshal(data)
  2986. var req *http.Request
  2987. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2988. resp, _ := client.Do(req)
  2989. defer resp.Body.Close()
  2990. body, ioErr := ioutil.ReadAll(resp.Body)
  2991. if ioErr != nil {
  2992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2993. }
  2994. var respJSON map[string]interface{}
  2995. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2997. }
  2998. var resSix10265 ResultSix10265 //1101结果
  2999. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3000. result, _ := json.Marshal(respJSON)
  3001. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3002. utils.ErrorLog("解析失败:%v", err)
  3003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3004. return
  3005. }
  3006. res.InfRefmsgid = resSix10265.InfRefmsgid
  3007. res.ErrMsg = resSix10265.ErrMsg
  3008. res.Cainfo = resSix10265.Cainfo
  3009. res.WarnMsg = resSix10265.WarnMsg
  3010. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3011. res.Infcode = infocode
  3012. }
  3013. if res.Infcode == 0 {
  3014. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3015. item.IsSale = 0
  3016. item.SaleDate = ""
  3017. item.Bchno = ""
  3018. service.SaveDF(item)
  3019. } else {
  3020. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3021. }
  3022. }
  3023. }
  3024. c.ServeSuccessJSON(map[string]interface{}{
  3025. "msg": "删除销售数据成功",
  3026. })
  3027. }
  3028. // 删除
  3029. func (c *HisApiController) DeleteXSandBGThree() {
  3030. id, _ := c.GetInt64("id")
  3031. admin_user_id, _ := c.GetInt64("admin_user_id")
  3032. advicelist, _ := service.FinddelHisAdviceDocAdvice(id)
  3033. var flows []*models.DrugFlow
  3034. for _, item := range advicelist {
  3035. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3036. flows = append(flows, flow...)
  3037. }
  3038. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3039. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3040. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3041. var err []string
  3042. for _, item := range flows {
  3043. if item.IsSale == 1 {
  3044. var res FJ3507Result
  3045. var struct3507 models.Struct3507
  3046. struct3507.FixmedinsBchno = item.Bchno
  3047. struct3507.InvDataType = "4"
  3048. struct3507.Opter = roles.UserName
  3049. struct3507.OrgName = miConfig.OrgName
  3050. struct3507.AccessKey = miConfig.AccessKey
  3051. struct3507.RequestUrl = miConfig.Url
  3052. struct3507.FixmedinsCode = miConfig.Code
  3053. struct3507.SecretKey = miConfig.SecretKey
  3054. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3055. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3056. struct3507.Url = miConfig.Url
  3057. struct3507.AppId = miConfig.Cainfo
  3058. struct3507.AppSecret = miConfig.AppSecret
  3059. struct3507.Enckey = miConfig.EncKey
  3060. struct3507.SignKey = miConfig.SignKey
  3061. struct3507.SecretKey = miConfig.SecretKey
  3062. if miConfig.MdtrtareaAdmvs == "350500" {
  3063. result, result1, _ := service.FJyb3507(struct3507)
  3064. saveLog(result, result1, "3507", "3507")
  3065. var respJSON2 map[string]interface{}
  3066. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3069. return
  3070. }
  3071. userJSONBytes2, _ := json.Marshal(respJSON2)
  3072. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3073. utils.ErrorLog("解析失败:%v", err)
  3074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3075. return
  3076. }
  3077. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  3078. data := make(map[string]interface{})
  3079. data["struct_3507s"] = struct3507
  3080. client := &http.Client{}
  3081. bytesData, _ := json.Marshal(data)
  3082. var req *http.Request
  3083. if miConfig.MdtrtareaAdmvs == "320830" {
  3084. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  3085. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3086. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3087. } else {
  3088. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3089. }
  3090. resp, _ := client.Do(req)
  3091. defer resp.Body.Close()
  3092. body, ioErr := ioutil.ReadAll(resp.Body)
  3093. if ioErr != nil {
  3094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3095. }
  3096. var respJSON map[string]interface{}
  3097. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3100. return
  3101. }
  3102. var resSix10265 ResultSix10265 //1101结果
  3103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3104. result, _ := json.Marshal(respJSON)
  3105. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3106. utils.ErrorLog("解析失败:%v", err)
  3107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3108. return
  3109. }
  3110. res.InfRefmsgid = resSix10265.InfRefmsgid
  3111. //res.Output = resSix10265.Output
  3112. res.ErrMsg = resSix10265.ErrMsg
  3113. res.Cainfo = resSix10265.Cainfo
  3114. res.WarnMsg = resSix10265.WarnMsg
  3115. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3116. res.Infcode = infocode
  3117. } else if miConfig.MdtrtareaAdmvs == "440100" {
  3118. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3119. saveLog(result2, result1, "3507", "3507")
  3120. var respJSON2 map[string]interface{}
  3121. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3124. return
  3125. }
  3126. userJSONBytes2, _ := json.Marshal(respJSON2)
  3127. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3128. utils.ErrorLog("解析失败:%v", err)
  3129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3130. return
  3131. }
  3132. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3133. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3134. saveLog(result2, result1, "3507", "3507")
  3135. var respJSON2 map[string]interface{}
  3136. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3139. return
  3140. }
  3141. userJSONBytes2, _ := json.Marshal(respJSON2)
  3142. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3143. utils.ErrorLog("解析失败:%v", err)
  3144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3145. return
  3146. }
  3147. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3148. result1, result2 := service.Jxyb3507(struct3507)
  3149. saveLog(result2, result1, "3507", "3507")
  3150. var respJSON2 map[string]interface{}
  3151. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3154. return
  3155. }
  3156. userJSONBytes2, _ := json.Marshal(respJSON2)
  3157. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3158. utils.ErrorLog("解析失败:%v", err)
  3159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3160. return
  3161. }
  3162. } else if miConfig.MdtrtareaAdmvs == "340699" {
  3163. result1, result2 := service.AHyb3507(struct3507)
  3164. saveLog(result2, result1, "3507", "3507")
  3165. var respJSON2 map[string]interface{}
  3166. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3169. return
  3170. }
  3171. userJSONBytes2, _ := json.Marshal(respJSON2)
  3172. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3173. utils.ErrorLog("解析失败:%v", err)
  3174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3175. return
  3176. }
  3177. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3178. data := make(map[string]interface{})
  3179. data["struct_3507s"] = struct3507
  3180. client := &http.Client{}
  3181. bytesData, _ := json.Marshal(data)
  3182. var req *http.Request
  3183. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3184. resp, _ := client.Do(req)
  3185. defer resp.Body.Close()
  3186. body, ioErr := ioutil.ReadAll(resp.Body)
  3187. if ioErr != nil {
  3188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3189. }
  3190. var respJSON map[string]interface{}
  3191. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3193. }
  3194. var resSix10265 ResultSix10265 //1101结果
  3195. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3196. result, _ := json.Marshal(respJSON)
  3197. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3198. utils.ErrorLog("解析失败:%v", err)
  3199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3200. return
  3201. }
  3202. res.InfRefmsgid = resSix10265.InfRefmsgid
  3203. res.ErrMsg = resSix10265.ErrMsg
  3204. res.Cainfo = resSix10265.Cainfo
  3205. res.WarnMsg = resSix10265.WarnMsg
  3206. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3207. res.Infcode = infocode
  3208. }
  3209. if res.Infcode == 0 {
  3210. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3211. item.IsSale = 0
  3212. item.SaleDate = ""
  3213. item.Bchno = ""
  3214. service.SaveDF(item)
  3215. } else {
  3216. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3217. }
  3218. }
  3219. }
  3220. c.ServeSuccessJSON(map[string]interface{}{
  3221. "msg": "删除销售数据成功",
  3222. })
  3223. }
  3224. // 获取当天起止时间戳
  3225. func GetNowTime() (int64, int64) {
  3226. t := time.Now()
  3227. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3228. timesamp := addTime.Unix()
  3229. return timesamp, timesamp + 86399
  3230. }
  3231. func (c *HisApiController) ChangeDrugfour() {
  3232. patient_id, _ := c.GetInt64("patient_id")
  3233. admin_user_id, _ := c.GetInt64("admin_user_id")
  3234. times := c.GetString("time", "")
  3235. timeLayout := "2006-01-02"
  3236. loc, _ := time.LoadLocation("Local")
  3237. var stime, etime int64
  3238. if times == "" {
  3239. stime, etime = GetNowTime()
  3240. } else {
  3241. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3242. stime = stmp.Unix()
  3243. etime = stime + 86399
  3244. }
  3245. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3246. var flows []*models.DrugFlow
  3247. for _, item := range advicelist {
  3248. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  3249. flows = append(flows, flow...)
  3250. }
  3251. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3252. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3253. var err []string
  3254. for _, item := range flows {
  3255. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3256. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3257. if prescription.OrderStatus == 2 {
  3258. if item.IsSale == 0 {
  3259. var res FJ3507Result
  3260. var res3507for10188 FJ3507ResultFor10188
  3261. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3262. //进行商品销售接口
  3263. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3264. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3265. var respJSON3 map[string]interface{}
  3266. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3269. return
  3270. }
  3271. userJSONBytes3, _ := json.Marshal(respJSON3)
  3272. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3273. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3274. utils.ErrorLog("解析失败:%v", err)
  3275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3276. return
  3277. }
  3278. //if res3507for10188.Infcode
  3279. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3280. //res.Output = resSix10265.Output
  3281. res.ErrMsg = res3507for10188.ErrMsg
  3282. res.Cainfo = res3507for10188.Cainfo
  3283. res.WarnMsg = res3507for10188.WarnMsg
  3284. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3285. res.Infcode = infocode
  3286. } else {
  3287. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3288. utils.ErrorLog("解析失败:%v", err)
  3289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3290. return
  3291. }
  3292. }
  3293. if res.Infcode == 0 {
  3294. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3295. item.IsSale = 1
  3296. item.Bchno = number
  3297. item.SaleDate = time.Now().Format("2006-01-02")
  3298. service.SaveDF(item)
  3299. } else {
  3300. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3301. }
  3302. }
  3303. } else { //还没结,提示用户去结算,并药品追溯上传
  3304. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3305. }
  3306. }
  3307. }
  3308. str := strings.Join(err, " ")
  3309. saveLog(str, str, "3505", "3505自动上传日志")
  3310. c.ServeSuccessJSON(map[string]interface{}{
  3311. "status": "1",
  3312. "msg": err,
  3313. })
  3314. }
  3315. func (c *HisApiController) ChangeDrugFive() {
  3316. id := c.GetString("id")
  3317. ids := strings.Split(id, ",")
  3318. admin_user_id, _ := c.GetInt64("admin_user_id")
  3319. var errs []string
  3320. //校验gui'ge
  3321. for _, value := range ids {
  3322. intValue, _ := strconv.ParseInt(value, 10, 64)
  3323. //file := strconv.FormatInt(int64(num), 10)
  3324. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3325. var flows []*models.DrugFlow
  3326. for _, item := range advicelist {
  3327. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3328. flows = append(flows, flow...)
  3329. }
  3330. //roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3331. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3332. for _, item := range flows {
  3333. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3334. if prescription.OrderStatus != 2 {
  3335. // 将时间戳转换为time.Time类型
  3336. t := time.Unix(item.HisDoctorAdviceInfo.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3337. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.HisDoctorAdviceInfo.PatientId)
  3338. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"医嘱没结算无法上传")
  3339. }
  3340. if len(item.HisDoctorAdviceInfo.DrugCode) > 0 {
  3341. t := time.Unix(item.HisDoctorAdviceInfo.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3342. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.HisDoctorAdviceInfo.PatientId)
  3343. codes := strings.Split(item.HisDoctorAdviceInfo.DrugCode, ",")
  3344. for _, code := range codes {
  3345. if len(code) > 0 {
  3346. if len(code) != 20 {
  3347. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  3348. }
  3349. if IsDigit(code) == false {
  3350. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  3351. }
  3352. }
  3353. }
  3354. }
  3355. }
  3356. }
  3357. utils.ErrorLog("接口返回数据解析JSON失败: %v", errs)
  3358. if len(errs) > 0 {
  3359. c.ServeSuccessJSON(map[string]interface{}{
  3360. "failed_code": -10,
  3361. "msg": errs,
  3362. })
  3363. return
  3364. }
  3365. for _, value := range ids {
  3366. intValue, _ := strconv.ParseInt(value, 10, 64)
  3367. //file := strconv.FormatInt(int64(num), 10)
  3368. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3369. var flows []*models.DrugFlow
  3370. for _, item := range advicelist {
  3371. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3372. flows = append(flows, flow...)
  3373. }
  3374. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3375. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3376. for _, item := range flows {
  3377. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3378. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3379. if prescription.OrderStatus == 2 {
  3380. if item.IsSale == 0 {
  3381. var res FJ3507Result
  3382. var res3507for10188 FJ3507ResultFor10188
  3383. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3384. //进行商品销售接口
  3385. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3386. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3387. var respJSON3 map[string]interface{}
  3388. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3391. return
  3392. }
  3393. userJSONBytes3, _ := json.Marshal(respJSON3)
  3394. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3395. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3396. utils.ErrorLog("解析失败:%v", err)
  3397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3398. return
  3399. }
  3400. //if res3507for10188.Infcode
  3401. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3402. //res.Output = resSix10265.Output
  3403. res.ErrMsg = res3507for10188.ErrMsg
  3404. res.Cainfo = res3507for10188.Cainfo
  3405. res.WarnMsg = res3507for10188.WarnMsg
  3406. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3407. res.Infcode = infocode
  3408. } else {
  3409. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3410. utils.ErrorLog("解析失败:%v", err)
  3411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3412. return
  3413. }
  3414. }
  3415. if res.Infcode == 0 {
  3416. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3417. item.IsSale = 1
  3418. item.Bchno = number
  3419. item.SaleDate = time.Now().Format("2006-01-02")
  3420. service.SaveDF(item)
  3421. } else {
  3422. errs = append(errs, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3423. }
  3424. }
  3425. } else { //还没结,提示用户去结算,并药品追溯上传
  3426. errs = append(errs, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3427. }
  3428. }
  3429. }
  3430. str := strings.Join(errs, " ")
  3431. saveLog(str, str, "3505", "3505自动上传日志")
  3432. }
  3433. c.ServeSuccessJSON(map[string]interface{}{
  3434. "status": "1",
  3435. "msg": errs,
  3436. })
  3437. }
  3438. //func (c *HisApiController) ChangeDrugfour() {
  3439. // patient_id, _ := c.GetInt64("patient_id")
  3440. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3441. // //id_arr := strings.Split(ids, ",")
  3442. // times := c.GetString("time", "")
  3443. // timeLayout := "2006-01-02"
  3444. // loc, _ := time.LoadLocation("Local")
  3445. // var stime, etime int64
  3446. // if times == "" {
  3447. // stime, etime = GetNowTime()
  3448. // } else {
  3449. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3450. // stime = stmp.Unix()
  3451. // etime = stime + 86399
  3452. // }
  3453. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3454. // var flows []*models.DrugFlow
  3455. // for _, item := range advicelist {
  3456. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3457. // flows = append(flows, flow...)
  3458. // }
  3459. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3460. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3461. // var err []string
  3462. //
  3463. // for _, item := range flows {
  3464. // var res3 ResultSix
  3465. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3466. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3467. // if prescription.OrderStatus == 2 {
  3468. // //已经结算
  3469. // //判断是否已经销售
  3470. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3471. // //是否已经变更 1是 0否
  3472. // if item.IsChange == 0 { //没变更,进行变更操作
  3473. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3474. //
  3475. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3476. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3477. // var respJSON3 map[string]interface{}
  3478. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3479. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3481. // return
  3482. // }
  3483. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3484. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3485. // utils.ErrorLog("解析失败:%v", err)
  3486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3487. // return
  3488. // }
  3489. // if res3.Infcode == 0 {
  3490. // item.IsChange = 1
  3491. // item.BgBchno = bg_number
  3492. // service.SaveDF2(item)
  3493. // } else {
  3494. //
  3495. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3496. // }
  3497. // }
  3498. // } else { //没销售,
  3499. // var res FJ3507Result
  3500. // var res3507for10188 FJ3507ResultFor10188
  3501. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3502. //
  3503. // //进行商品销售接口
  3504. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3505. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3506. // var respJSON3 map[string]interface{}
  3507. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3508. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3510. // return
  3511. // }
  3512. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3513. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3514. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3515. // utils.ErrorLog("解析失败:%v", err)
  3516. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3517. // return
  3518. // }
  3519. // //if res3507for10188.Infcode
  3520. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3521. // //res.Output = resSix10265.Output
  3522. // res.ErrMsg = res3507for10188.ErrMsg
  3523. // res.Cainfo = res3507for10188.Cainfo
  3524. // res.WarnMsg = res3507for10188.WarnMsg
  3525. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3526. // res.Infcode = infocode
  3527. // } else {
  3528. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3529. // utils.ErrorLog("解析失败:%v", err)
  3530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3531. // return
  3532. // }
  3533. //
  3534. // }
  3535. // if res.Infcode == 0 {
  3536. // item.IsSale = 1
  3537. // item.Bchno = number
  3538. // item.SaleDate = time.Now().Format("2006-01-02")
  3539. //
  3540. // err5 := service.SaveDF(item)
  3541. // if err5 == nil {
  3542. // if item.IsChange == 0 { //没变更,进行变更操作
  3543. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3544. //
  3545. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3546. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3547. //
  3548. // var respJSON3 map[string]interface{}
  3549. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3550. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3552. // return
  3553. // }
  3554. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3555. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3556. // utils.ErrorLog("解析失败:%v", err)
  3557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3558. // return
  3559. // }
  3560. // //if res3507for10188.Infcode
  3561. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3562. // //res.Output = resSix10265.Output
  3563. // res3.ErrMsg = res3507for10188.ErrMsg
  3564. // res3.Cainfo = res3507for10188.Cainfo
  3565. // res3.WarnMsg = res3507for10188.WarnMsg
  3566. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3567. // res3.Infcode = infocode
  3568. // } else {
  3569. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3570. // utils.ErrorLog("解析失败:%v", err)
  3571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3572. // return
  3573. // }
  3574. // }
  3575. // if res3.Infcode == 0 {
  3576. // item.IsChange = 1
  3577. // item.BgBchno = bg_number
  3578. // service.SaveDF2(item)
  3579. // } else {
  3580. //
  3581. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3582. // }
  3583. // }
  3584. // }
  3585. // } else {
  3586. //
  3587. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3588. // }
  3589. // }
  3590. //
  3591. // } else { //还没结,提示用户去结算,并药品追溯上传
  3592. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3593. // }
  3594. // }
  3595. // }
  3596. // if len(err) == 0 {
  3597. // c.ServeSuccessJSON(map[string]interface{}{
  3598. // "msg": "销售变更成功",
  3599. // })
  3600. // } else {
  3601. // c.ServeSuccessJSON(map[string]interface{}{
  3602. // "failed_code": -10,
  3603. // "msg": err,
  3604. // })
  3605. // }
  3606. //}
  3607. func (c *HisApiController) ChangeDrug() {
  3608. ids := c.GetString("ids")
  3609. id_arr := strings.Split(ids, ",")
  3610. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3611. admin_user_id, _ := c.GetInt64("admin_user_id")
  3612. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3613. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3614. var err []string
  3615. for _, item := range flows {
  3616. var res3 ResultSix
  3617. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3618. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3619. if prescription.OrderStatus == 2 {
  3620. //已经结算
  3621. //判断是否已经销售
  3622. if item.IsSale == 1 { //是否已经销售,1是 0否
  3623. //是否已经变更 1是 0否
  3624. if item.IsChange == 0 { //没变更,进行变更操作
  3625. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3626. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3627. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3628. var respJSON3 map[string]interface{}
  3629. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3632. return
  3633. }
  3634. userJSONBytes3, _ := json.Marshal(respJSON3)
  3635. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3636. utils.ErrorLog("解析失败:%v", err)
  3637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3638. return
  3639. }
  3640. if res3.Infcode == 0 {
  3641. item.IsChange = 1
  3642. item.BgBchno = bg_number
  3643. service.SaveDF2(item)
  3644. } else {
  3645. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3646. }
  3647. }
  3648. } else { //没销售,
  3649. var res FJ3507Result
  3650. var res3507for10188 FJ3507ResultFor10188
  3651. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3652. //进行商品销售接口
  3653. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3654. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3655. var respJSON3 map[string]interface{}
  3656. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3659. return
  3660. }
  3661. userJSONBytes3, _ := json.Marshal(respJSON3)
  3662. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3663. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3664. utils.ErrorLog("解析失败:%v", err)
  3665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3666. return
  3667. }
  3668. //if res3507for10188.Infcode
  3669. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3670. //res.Output = resSix10265.Output
  3671. res.ErrMsg = res3507for10188.ErrMsg
  3672. res.Cainfo = res3507for10188.Cainfo
  3673. res.WarnMsg = res3507for10188.WarnMsg
  3674. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3675. res.Infcode = infocode
  3676. } else {
  3677. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3678. utils.ErrorLog("解析失败:%v", err)
  3679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3680. return
  3681. }
  3682. }
  3683. if res.Infcode == 0 {
  3684. item.IsSale = 1
  3685. item.Bchno = number
  3686. item.SaleDate = time.Now().Format("2006-01-02")
  3687. err5 := service.SaveDF(item)
  3688. if err5 == nil {
  3689. if item.IsChange == 0 { //没变更,进行变更操作
  3690. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3691. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3692. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3693. var respJSON3 map[string]interface{}
  3694. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3697. return
  3698. }
  3699. userJSONBytes3, _ := json.Marshal(respJSON3)
  3700. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3701. utils.ErrorLog("解析失败:%v", err)
  3702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3703. return
  3704. }
  3705. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3706. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3707. utils.ErrorLog("解析失败:%v", err)
  3708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3709. return
  3710. }
  3711. //if res3507for10188.Infcode
  3712. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3713. //res.Output = resSix10265.Output
  3714. res3.ErrMsg = res3507for10188.ErrMsg
  3715. res3.Cainfo = res3507for10188.Cainfo
  3716. res3.WarnMsg = res3507for10188.WarnMsg
  3717. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3718. res3.Infcode = infocode
  3719. } else {
  3720. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3721. utils.ErrorLog("解析失败:%v", err)
  3722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3723. return
  3724. }
  3725. }
  3726. if res3.Infcode == 0 {
  3727. item.IsChange = 1
  3728. item.BgBchno = bg_number
  3729. service.SaveDF2(item)
  3730. } else {
  3731. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3732. }
  3733. }
  3734. }
  3735. } else {
  3736. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3737. }
  3738. }
  3739. } else { //还没结算
  3740. var res3507for10188 FJ3507ResultFor10188
  3741. if item.IsChange == 0 { //没变更,进行变更操作
  3742. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3743. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3744. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3745. var respJSON3 map[string]interface{}
  3746. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3749. return
  3750. }
  3751. userJSONBytes3, _ := json.Marshal(respJSON3)
  3752. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3753. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3754. utils.ErrorLog("解析失败:%v", err)
  3755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3756. return
  3757. }
  3758. //if res3507for10188.Infcode
  3759. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3760. //res.Output = resSix10265.Output
  3761. res3.ErrMsg = res3507for10188.ErrMsg
  3762. res3.Cainfo = res3507for10188.Cainfo
  3763. res3.WarnMsg = res3507for10188.WarnMsg
  3764. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3765. res3.Infcode = infocode
  3766. } else {
  3767. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3768. utils.ErrorLog("解析失败:%v", err)
  3769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3770. return
  3771. }
  3772. }
  3773. if res3.Infcode == 0 {
  3774. item.IsChange = 1
  3775. item.BgBchno = bg_number
  3776. service.SaveDF2(item)
  3777. } else {
  3778. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3779. }
  3780. }
  3781. }
  3782. } else if item.ConsumableType == 7 {
  3783. var res3507for10188 FJ3507ResultFor10188
  3784. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3785. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3786. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3787. //判断是否已经销售
  3788. if item.IsSale == 2 { //是否已经销售,1是 0否
  3789. //是否已经变更 1是 0否
  3790. if item.IsChange == 0 { //没变更,进行变更操作
  3791. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3792. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3793. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3794. var respJSON3 map[string]interface{}
  3795. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3798. return
  3799. }
  3800. userJSONBytes3, _ := json.Marshal(respJSON3)
  3801. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3802. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3803. utils.ErrorLog("解析失败:%v", err)
  3804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3805. return
  3806. }
  3807. //if res3507for10188.Infcode
  3808. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3809. //res.Output = resSix10265.Output
  3810. res3.ErrMsg = res3507for10188.ErrMsg
  3811. res3.Cainfo = res3507for10188.Cainfo
  3812. res3.WarnMsg = res3507for10188.WarnMsg
  3813. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3814. res3.Infcode = infocode
  3815. } else {
  3816. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3817. utils.ErrorLog("解析失败:%v", err)
  3818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3819. return
  3820. }
  3821. }
  3822. if res3.Infcode == 0 {
  3823. item.IsChange = 1
  3824. item.BgBchno = bg_number
  3825. service.SaveDF2(item)
  3826. } else {
  3827. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3828. }
  3829. }
  3830. } else { //没销售,
  3831. //进行商品销售退货接口
  3832. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3833. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3834. saveLog(result111, result222, "3506", "销售退货")
  3835. var res7 FJ3507Result
  3836. //进行商品销售接口
  3837. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3838. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3839. var respJSON3 map[string]interface{}
  3840. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3843. return
  3844. }
  3845. userJSONBytes3, _ := json.Marshal(respJSON3)
  3846. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3847. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3848. utils.ErrorLog("解析失败:%v", err)
  3849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3850. return
  3851. }
  3852. //if res3507for10188.Infcode
  3853. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3854. //res.Output = resSix10265.Output
  3855. res7.ErrMsg = res3507for10188.ErrMsg
  3856. res7.Cainfo = res3507for10188.Cainfo
  3857. res7.WarnMsg = res3507for10188.WarnMsg
  3858. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3859. res7.Infcode = infocode
  3860. } else {
  3861. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3862. utils.ErrorLog("解析失败:%v", err)
  3863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3864. return
  3865. }
  3866. }
  3867. if res7.Infcode == 0 {
  3868. item.IsSale = 2
  3869. item.SaleDate = item.SaleDate
  3870. item.Bchno = number
  3871. service.SaveDF(item)
  3872. if item.IsChange == 0 { //没变更,进行变更操作
  3873. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3874. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3875. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3876. var respJSON3 map[string]interface{}
  3877. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3880. return
  3881. }
  3882. userJSONBytes3, _ := json.Marshal(respJSON3)
  3883. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3884. // utils.ErrorLog("解析失败:%v", err)
  3885. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3886. // return
  3887. //}
  3888. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3889. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3890. utils.ErrorLog("解析失败:%v", err)
  3891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3892. return
  3893. }
  3894. //if res3507for10188.Infcode
  3895. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3896. //res.Output = resSix10265.Output
  3897. res3.ErrMsg = res3507for10188.ErrMsg
  3898. res3.Cainfo = res3507for10188.Cainfo
  3899. res3.WarnMsg = res3507for10188.WarnMsg
  3900. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3901. res3.Infcode = infocode
  3902. } else {
  3903. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3904. utils.ErrorLog("解析失败:%v", err)
  3905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3906. return
  3907. }
  3908. }
  3909. if res3.Infcode == 0 {
  3910. item.IsChange = 1
  3911. item.BgBchno = bg_number
  3912. service.SaveDF2(item)
  3913. } else {
  3914. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3915. }
  3916. }
  3917. } else {
  3918. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3919. }
  3920. }
  3921. } else { //还没结算
  3922. if item.IsChange == 0 { //没变更,进行变更操作
  3923. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3924. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3925. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3926. var respJSON3 map[string]interface{}
  3927. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3930. return
  3931. }
  3932. userJSONBytes3, _ := json.Marshal(respJSON3)
  3933. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3934. // utils.ErrorLog("解析失败:%v", err)
  3935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3936. // return
  3937. //}
  3938. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3939. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3940. utils.ErrorLog("解析失败:%v", err)
  3941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3942. return
  3943. }
  3944. //if res3507for10188.Infcode
  3945. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3946. //res.Output = resSix10265.Output
  3947. res3.ErrMsg = res3507for10188.ErrMsg
  3948. res3.Cainfo = res3507for10188.Cainfo
  3949. res3.WarnMsg = res3507for10188.WarnMsg
  3950. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3951. res3.Infcode = infocode
  3952. } else {
  3953. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3954. utils.ErrorLog("解析失败:%v", err)
  3955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3956. return
  3957. }
  3958. }
  3959. if res3.Infcode == 0 {
  3960. item.IsChange = 1
  3961. item.BgBchno = bg_number
  3962. service.SaveDF2(item)
  3963. } else {
  3964. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3965. }
  3966. }
  3967. }
  3968. }
  3969. }
  3970. if len(err) == 0 {
  3971. c.ServeSuccessJSON(map[string]interface{}{
  3972. "msg": "销售变更成功",
  3973. })
  3974. } else {
  3975. c.ServeSuccessJSON(map[string]interface{}{
  3976. "failed_code": -10,
  3977. "msg": err,
  3978. })
  3979. }
  3980. }
  3981. func (c *HisApiController) ChangeDrugtwo() {
  3982. //ids := c.GetString("ids")
  3983. //id_arr := strings.Split(ids, ",")
  3984. flows, _ := service.GetNewDrugFlowInfothree123()
  3985. admin_user_id, _ := c.GetInt64("admin_user_id")
  3986. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3987. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3988. var err []string
  3989. for _, item := range flows {
  3990. var res3 ResultSix
  3991. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3992. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3993. if prescription.OrderStatus == 2 {
  3994. //已经结算
  3995. //判断是否已经销售
  3996. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3997. // //是否已经变更 1是 0否
  3998. // if item.IsChange == 0 { //没变更,进行变更操作
  3999. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4000. //
  4001. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4002. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4003. // var respJSON3 map[string]interface{}
  4004. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4005. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4006. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4007. // return
  4008. // }
  4009. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4010. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4011. // utils.ErrorLog("解析失败:%v", err)
  4012. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4013. // return
  4014. // }
  4015. // if res3.Infcode == 0 {
  4016. // item.IsChange = 1
  4017. // item.BgBchno = bg_number
  4018. // service.SaveDF2(item)
  4019. // } else {
  4020. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4021. // }
  4022. // }
  4023. //}
  4024. //else
  4025. { //没销售,
  4026. var res FJ3507Result
  4027. var res3507for10188 FJ3507ResultFor10188
  4028. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4029. //进行商品销售接口
  4030. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4031. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4032. var respJSON3 map[string]interface{}
  4033. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4036. return
  4037. }
  4038. userJSONBytes3, _ := json.Marshal(respJSON3)
  4039. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4040. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4041. utils.ErrorLog("解析失败:%v", err)
  4042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4043. return
  4044. }
  4045. //if res3507for10188.Infcode
  4046. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4047. //res.Output = resSix10265.Output
  4048. res.ErrMsg = res3507for10188.ErrMsg
  4049. res.Cainfo = res3507for10188.Cainfo
  4050. res.WarnMsg = res3507for10188.WarnMsg
  4051. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4052. res.Infcode = infocode
  4053. } else {
  4054. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4055. utils.ErrorLog("解析失败:%v", err)
  4056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4057. return
  4058. }
  4059. }
  4060. if res.Infcode == 0 {
  4061. item.IsSale = 1
  4062. item.Bchno = number
  4063. item.SaleDate = time.Now().Format("2006-01-02")
  4064. service.SaveDF(item)
  4065. //if err5 == nil {
  4066. // if item.IsChange == 0 { //没变更,进行变更操作
  4067. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4068. //
  4069. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4070. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4071. //
  4072. // var respJSON3 map[string]interface{}
  4073. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4074. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4075. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4076. // return
  4077. // }
  4078. //
  4079. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4080. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4081. // utils.ErrorLog("解析失败:%v", err)
  4082. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4083. // return
  4084. // }
  4085. // //if res3507for10188.Infcode
  4086. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4087. // //res.Output = resSix10265.Output
  4088. // res3.ErrMsg = res3507for10188.ErrMsg
  4089. // res3.Cainfo = res3507for10188.Cainfo
  4090. // res3.WarnMsg = res3507for10188.WarnMsg
  4091. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4092. // res3.Infcode = infocode
  4093. // } else {
  4094. //
  4095. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4096. // utils.ErrorLog("解析失败:%v", err)
  4097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4098. // return
  4099. // }
  4100. //
  4101. // }
  4102. //
  4103. // if res3.Infcode == 0 {
  4104. // item.IsChange = 1
  4105. // item.BgBchno = bg_number
  4106. // service.SaveDF2(item)
  4107. // } else {
  4108. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4109. // }
  4110. // }
  4111. //}
  4112. } else {
  4113. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4114. }
  4115. }
  4116. } else { //还没结算
  4117. var res3507for10188 FJ3507ResultFor10188
  4118. if item.IsChange == 0 { //没变更,进行变更操作
  4119. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4120. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4121. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4122. var respJSON3 map[string]interface{}
  4123. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4126. return
  4127. }
  4128. userJSONBytes3, _ := json.Marshal(respJSON3)
  4129. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4130. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4131. utils.ErrorLog("解析失败:%v", err)
  4132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4133. return
  4134. }
  4135. //if res3507for10188.Infcode
  4136. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4137. //res.Output = resSix10265.Output
  4138. res3.ErrMsg = res3507for10188.ErrMsg
  4139. res3.Cainfo = res3507for10188.Cainfo
  4140. res3.WarnMsg = res3507for10188.WarnMsg
  4141. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4142. res3.Infcode = infocode
  4143. } else {
  4144. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4145. utils.ErrorLog("解析失败:%v", err)
  4146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4147. return
  4148. }
  4149. }
  4150. if res3.Infcode == 0 {
  4151. item.IsChange = 1
  4152. item.BgBchno = bg_number
  4153. service.SaveDF2(item)
  4154. } else {
  4155. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4156. }
  4157. }
  4158. }
  4159. }
  4160. //if item.ConsumableType == 7 {
  4161. // var res3507for10188 FJ3507ResultFor10188
  4162. //
  4163. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4164. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4165. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4166. // //判断是否已经销售
  4167. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4168. // //是否已经变更 1是 0否
  4169. // if item.IsChange == 0 { //没变更,进行变更操作
  4170. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4171. //
  4172. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4173. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4174. //
  4175. // var respJSON3 map[string]interface{}
  4176. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4177. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4179. // return
  4180. // }
  4181. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4182. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4183. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4184. // utils.ErrorLog("解析失败:%v", err)
  4185. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4186. // return
  4187. // }
  4188. // //if res3507for10188.Infcode
  4189. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4190. // //res.Output = resSix10265.Output
  4191. // res3.ErrMsg = res3507for10188.ErrMsg
  4192. // res3.Cainfo = res3507for10188.Cainfo
  4193. // res3.WarnMsg = res3507for10188.WarnMsg
  4194. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4195. // res3.Infcode = infocode
  4196. // } else {
  4197. //
  4198. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4199. // utils.ErrorLog("解析失败:%v", err)
  4200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4201. // return
  4202. // }
  4203. //
  4204. // }
  4205. // if res3.Infcode == 0 {
  4206. // item.IsChange = 1
  4207. // item.BgBchno = bg_number
  4208. // service.SaveDF2(item)
  4209. // } else {
  4210. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4211. // }
  4212. // }
  4213. // } else { //没销售,
  4214. // //进行商品销售退货接口
  4215. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4216. //
  4217. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4218. // saveLog(result111, result222, "3506", "销售退货")
  4219. // var res7 FJ3507Result
  4220. //
  4221. // //进行商品销售接口
  4222. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4223. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4224. // var respJSON3 map[string]interface{}
  4225. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4226. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4228. // return
  4229. // }
  4230. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4231. //
  4232. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4233. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4234. // utils.ErrorLog("解析失败:%v", err)
  4235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4236. // return
  4237. // }
  4238. // //if res3507for10188.Infcode
  4239. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4240. // //res.Output = resSix10265.Output
  4241. // res7.ErrMsg = res3507for10188.ErrMsg
  4242. // res7.Cainfo = res3507for10188.Cainfo
  4243. // res7.WarnMsg = res3507for10188.WarnMsg
  4244. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4245. // res7.Infcode = infocode
  4246. // } else {
  4247. //
  4248. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4249. // utils.ErrorLog("解析失败:%v", err)
  4250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4251. // return
  4252. // }
  4253. //
  4254. // }
  4255. // if res7.Infcode == 0 {
  4256. // item.IsSale = 2
  4257. // item.SaleDate = item.SaleDate
  4258. // item.Bchno = number
  4259. // service.SaveDF(item)
  4260. // if item.IsChange == 0 { //没变更,进行变更操作
  4261. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4262. //
  4263. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4264. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4265. //
  4266. // var respJSON3 map[string]interface{}
  4267. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4268. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4269. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4270. // return
  4271. // }
  4272. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4273. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4274. // // utils.ErrorLog("解析失败:%v", err)
  4275. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4276. // // return
  4277. // //}
  4278. //
  4279. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4280. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4281. // utils.ErrorLog("解析失败:%v", err)
  4282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4283. // return
  4284. // }
  4285. // //if res3507for10188.Infcode
  4286. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4287. // //res.Output = resSix10265.Output
  4288. // res3.ErrMsg = res3507for10188.ErrMsg
  4289. // res3.Cainfo = res3507for10188.Cainfo
  4290. // res3.WarnMsg = res3507for10188.WarnMsg
  4291. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4292. // res3.Infcode = infocode
  4293. // } else {
  4294. //
  4295. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4296. // utils.ErrorLog("解析失败:%v", err)
  4297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4298. // return
  4299. // }
  4300. //
  4301. // }
  4302. // if res3.Infcode == 0 {
  4303. // item.IsChange = 1
  4304. // item.BgBchno = bg_number
  4305. // service.SaveDF2(item)
  4306. // } else {
  4307. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4308. // }
  4309. // }
  4310. // } else {
  4311. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4312. // }
  4313. // }
  4314. // } else { //还没结算
  4315. // if item.IsChange == 0 { //没变更,进行变更操作
  4316. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4317. //
  4318. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4319. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4320. //
  4321. // var respJSON3 map[string]interface{}
  4322. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4323. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4325. // return
  4326. // }
  4327. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4328. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4329. // // utils.ErrorLog("解析失败:%v", err)
  4330. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4331. // // return
  4332. // //}
  4333. //
  4334. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4335. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4336. // utils.ErrorLog("解析失败:%v", err)
  4337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4338. // return
  4339. // }
  4340. // //if res3507for10188.Infcode
  4341. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4342. // //res.Output = resSix10265.Output
  4343. // res3.ErrMsg = res3507for10188.ErrMsg
  4344. // res3.Cainfo = res3507for10188.Cainfo
  4345. // res3.WarnMsg = res3507for10188.WarnMsg
  4346. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4347. // res3.Infcode = infocode
  4348. // } else {
  4349. //
  4350. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4351. // utils.ErrorLog("解析失败:%v", err)
  4352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4353. // return
  4354. // }
  4355. //
  4356. // }
  4357. // if res3.Infcode == 0 {
  4358. // item.IsChange = 1
  4359. // item.BgBchno = bg_number
  4360. // service.SaveDF2(item)
  4361. // } else {
  4362. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4363. // }
  4364. // }
  4365. // }
  4366. //}
  4367. }
  4368. if len(err) == 0 {
  4369. c.ServeSuccessJSON(map[string]interface{}{
  4370. "msg": "销售变更成功",
  4371. })
  4372. } else {
  4373. c.ServeSuccessJSON(map[string]interface{}{
  4374. "failed_code": -10,
  4375. "msg": err,
  4376. })
  4377. }
  4378. }
  4379. func (c *HisApiController) ChangeDrugthree() {
  4380. //ids := c.GetString("ids")
  4381. //id_arr := strings.Split(ids, ",")
  4382. flows, _ := service.GetNewDrugFlowInfothree()
  4383. admin_user_id, _ := c.GetInt64("admin_user_id")
  4384. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4385. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4386. var err []string
  4387. for _, item := range flows {
  4388. var res3 ResultSix
  4389. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4390. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4391. if prescription.OrderStatus == 2 {
  4392. //已经结算
  4393. //判断是否已经销售
  4394. if item.IsSale == 1 { //是否已经销售,1是 0否
  4395. //是否已经变更 1是 0否
  4396. if item.IsChange == 0 { //没变更,进行变更操作
  4397. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4398. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4399. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4400. var respJSON3 map[string]interface{}
  4401. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4404. return
  4405. }
  4406. userJSONBytes3, _ := json.Marshal(respJSON3)
  4407. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4408. utils.ErrorLog("解析失败:%v", err)
  4409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4410. return
  4411. }
  4412. if res3.Infcode == 0 {
  4413. item.IsChange = 1
  4414. item.BgBchno = bg_number
  4415. service.SaveDF2(item)
  4416. } else {
  4417. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4418. }
  4419. }
  4420. } else { //没销售,
  4421. var res FJ3507Result
  4422. var res3507for10188 FJ3507ResultFor10188
  4423. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4424. //进行商品销售接口
  4425. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4426. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4427. var respJSON3 map[string]interface{}
  4428. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4431. return
  4432. }
  4433. userJSONBytes3, _ := json.Marshal(respJSON3)
  4434. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4435. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4436. utils.ErrorLog("解析失败:%v", err)
  4437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4438. return
  4439. }
  4440. //if res3507for10188.Infcode
  4441. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4442. //res.Output = resSix10265.Output
  4443. res.ErrMsg = res3507for10188.ErrMsg
  4444. res.Cainfo = res3507for10188.Cainfo
  4445. res.WarnMsg = res3507for10188.WarnMsg
  4446. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4447. res.Infcode = infocode
  4448. } else {
  4449. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4450. utils.ErrorLog("解析失败:%v", err)
  4451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4452. return
  4453. }
  4454. }
  4455. if res.Infcode == 0 {
  4456. item.IsSale = 1
  4457. item.Bchno = number
  4458. item.SaleDate = time.Now().Format("2006-01-02")
  4459. err5 := service.SaveDF(item)
  4460. if err5 == nil {
  4461. if item.IsChange == 0 { //没变更,进行变更操作
  4462. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4463. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4464. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4465. var respJSON3 map[string]interface{}
  4466. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4469. return
  4470. }
  4471. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4472. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4473. utils.ErrorLog("解析失败:%v", err)
  4474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4475. return
  4476. }
  4477. //if res3507for10188.Infcode
  4478. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4479. //res.Output = resSix10265.Output
  4480. res3.ErrMsg = res3507for10188.ErrMsg
  4481. res3.Cainfo = res3507for10188.Cainfo
  4482. res3.WarnMsg = res3507for10188.WarnMsg
  4483. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4484. res3.Infcode = infocode
  4485. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4486. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4487. utils.ErrorLog("解析失败:%v", err)
  4488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4489. return
  4490. }
  4491. //if res3507for10188.Infcode
  4492. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4493. //res.Output = resSix10265.Output
  4494. res3.ErrMsg = res3507for10188.ErrMsg
  4495. res3.Cainfo = res3507for10188.Cainfo
  4496. res3.WarnMsg = res3507for10188.WarnMsg
  4497. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4498. res3.Infcode = infocode
  4499. } else {
  4500. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4501. utils.ErrorLog("解析失败:%v", err)
  4502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4503. return
  4504. }
  4505. }
  4506. if res3.Infcode == 0 {
  4507. item.IsChange = 1
  4508. item.BgBchno = bg_number
  4509. service.SaveDF2(item)
  4510. } else {
  4511. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4512. }
  4513. }
  4514. }
  4515. } else {
  4516. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4517. }
  4518. }
  4519. } else { //还没结算
  4520. var res3507for10188 FJ3507ResultFor10188
  4521. if item.IsChange == 0 { //没变更,进行变更操作
  4522. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4523. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4524. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4525. var respJSON3 map[string]interface{}
  4526. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. userJSONBytes3, _ := json.Marshal(respJSON3)
  4532. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4533. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4534. utils.ErrorLog("解析失败:%v", err)
  4535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4536. return
  4537. }
  4538. //if res3507for10188.Infcode
  4539. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4540. //res.Output = resSix10265.Output
  4541. res3.ErrMsg = res3507for10188.ErrMsg
  4542. res3.Cainfo = res3507for10188.Cainfo
  4543. res3.WarnMsg = res3507for10188.WarnMsg
  4544. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4545. res3.Infcode = infocode
  4546. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4547. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4548. utils.ErrorLog("解析失败:%v", err)
  4549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4550. return
  4551. }
  4552. //if res3507for10188.Infcode
  4553. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4554. //res.Output = resSix10265.Output
  4555. res3.ErrMsg = res3507for10188.ErrMsg
  4556. res3.Cainfo = res3507for10188.Cainfo
  4557. res3.WarnMsg = res3507for10188.WarnMsg
  4558. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4559. res3.Infcode = infocode
  4560. } else {
  4561. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4562. utils.ErrorLog("解析失败:%v", err)
  4563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4564. return
  4565. }
  4566. }
  4567. if res3.Infcode == 0 {
  4568. item.IsChange = 1
  4569. item.BgBchno = bg_number
  4570. service.SaveDF2(item)
  4571. } else {
  4572. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4573. }
  4574. }
  4575. }
  4576. } else if item.ConsumableType == 7 {
  4577. var res3507for10188 FJ3507ResultFor10188
  4578. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4579. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4580. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4581. //判断是否已经销售
  4582. if item.IsSale == 2 { //是否已经销售,1是 0否
  4583. //是否已经变更 1是 0否
  4584. if item.IsChange == 0 { //没变更,进行变更操作
  4585. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4586. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4587. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4588. var respJSON3 map[string]interface{}
  4589. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4592. return
  4593. }
  4594. userJSONBytes3, _ := json.Marshal(respJSON3)
  4595. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4596. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4597. utils.ErrorLog("解析失败:%v", err)
  4598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4599. return
  4600. }
  4601. //if res3507for10188.Infcode
  4602. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4603. //res.Output = resSix10265.Output
  4604. res3.ErrMsg = res3507for10188.ErrMsg
  4605. res3.Cainfo = res3507for10188.Cainfo
  4606. res3.WarnMsg = res3507for10188.WarnMsg
  4607. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4608. res3.Infcode = infocode
  4609. } else {
  4610. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4611. utils.ErrorLog("解析失败:%v", err)
  4612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4613. return
  4614. }
  4615. }
  4616. if res3.Infcode == 0 {
  4617. item.IsChange = 1
  4618. item.BgBchno = bg_number
  4619. service.SaveDF2(item)
  4620. } else {
  4621. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4622. }
  4623. }
  4624. } else { //没销售,
  4625. //进行商品销售退货接口
  4626. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4627. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4628. saveLog(result111, result222, "3506", "销售退货")
  4629. var res7 FJ3507Result
  4630. //进行商品销售接口
  4631. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4632. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4633. var respJSON3 map[string]interface{}
  4634. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4637. return
  4638. }
  4639. userJSONBytes3, _ := json.Marshal(respJSON3)
  4640. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4641. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4642. utils.ErrorLog("解析失败:%v", err)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. //if res3507for10188.Infcode
  4647. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4648. //res.Output = resSix10265.Output
  4649. res7.ErrMsg = res3507for10188.ErrMsg
  4650. res7.Cainfo = res3507for10188.Cainfo
  4651. res7.WarnMsg = res3507for10188.WarnMsg
  4652. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4653. res7.Infcode = infocode
  4654. } else {
  4655. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4656. utils.ErrorLog("解析失败:%v", err)
  4657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4658. return
  4659. }
  4660. }
  4661. if res7.Infcode == 0 {
  4662. item.IsSale = 2
  4663. item.SaleDate = item.SaleDate
  4664. item.Bchno = number
  4665. service.SaveDF(item)
  4666. if item.IsChange == 0 { //没变更,进行变更操作
  4667. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4668. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4669. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4670. var respJSON3 map[string]interface{}
  4671. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4674. return
  4675. }
  4676. userJSONBytes3, _ := json.Marshal(respJSON3)
  4677. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4678. // utils.ErrorLog("解析失败:%v", err)
  4679. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4680. // return
  4681. //}
  4682. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4683. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4684. utils.ErrorLog("解析失败:%v", err)
  4685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4686. return
  4687. }
  4688. //if res3507for10188.Infcode
  4689. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4690. //res.Output = resSix10265.Output
  4691. res3.ErrMsg = res3507for10188.ErrMsg
  4692. res3.Cainfo = res3507for10188.Cainfo
  4693. res3.WarnMsg = res3507for10188.WarnMsg
  4694. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4695. res3.Infcode = infocode
  4696. } else {
  4697. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4698. utils.ErrorLog("解析失败:%v", err)
  4699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4700. return
  4701. }
  4702. }
  4703. if res3.Infcode == 0 {
  4704. item.IsChange = 1
  4705. item.BgBchno = bg_number
  4706. service.SaveDF2(item)
  4707. } else {
  4708. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4709. }
  4710. }
  4711. } else {
  4712. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4713. }
  4714. }
  4715. } else { //还没结算
  4716. if item.IsChange == 0 { //没变更,进行变更操作
  4717. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4718. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4719. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4720. var respJSON3 map[string]interface{}
  4721. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4724. return
  4725. }
  4726. userJSONBytes3, _ := json.Marshal(respJSON3)
  4727. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4728. // utils.ErrorLog("解析失败:%v", err)
  4729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4730. // return
  4731. //}
  4732. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4733. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4734. utils.ErrorLog("解析失败:%v", err)
  4735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4736. return
  4737. }
  4738. //if res3507for10188.Infcode
  4739. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4740. //res.Output = resSix10265.Output
  4741. res3.ErrMsg = res3507for10188.ErrMsg
  4742. res3.Cainfo = res3507for10188.Cainfo
  4743. res3.WarnMsg = res3507for10188.WarnMsg
  4744. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4745. res3.Infcode = infocode
  4746. } else {
  4747. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4748. utils.ErrorLog("解析失败:%v", err)
  4749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4750. return
  4751. }
  4752. }
  4753. if res3.Infcode == 0 {
  4754. item.IsChange = 1
  4755. item.BgBchno = bg_number
  4756. service.SaveDF2(item)
  4757. } else {
  4758. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4759. }
  4760. }
  4761. }
  4762. }
  4763. }
  4764. if len(err) == 0 {
  4765. c.ServeSuccessJSON(map[string]interface{}{
  4766. "msg": "销售变更成功",
  4767. })
  4768. } else {
  4769. c.ServeSuccessJSON(map[string]interface{}{
  4770. "failed_code": -10,
  4771. "msg": err,
  4772. })
  4773. }
  4774. }
  4775. func (c *HisApiController) ChangeDrugTen() {
  4776. start_time_str := c.GetString("start_time")
  4777. end_time_str := c.GetString("end_time")
  4778. //ids := c.GetString("ids")
  4779. //id_arr := strings.Split(ids, ",")
  4780. timeLayout := "2006-01-02"
  4781. loc, _ := time.LoadLocation("Local")
  4782. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4783. recordStartTime := theStartTime.Unix()
  4784. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4785. recordEndTime := theEndTime.Unix()
  4786. //timestamp := int64(1729612800)
  4787. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4788. admin_user_id, _ := c.GetInt64("admin_user_id")
  4789. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4790. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4791. var err []string
  4792. for _, item := range flows {
  4793. var res3 ResultSix
  4794. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4795. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4796. continue
  4797. }
  4798. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4799. continue
  4800. }
  4801. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4802. if prescription.OrderStatus == 2 {
  4803. //已经结算
  4804. //判断 是否已经销售
  4805. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4806. ////是否已经变更 1是 0否
  4807. //if item.IsChange == 0 { //没变更,进行变更操作
  4808. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4809. //
  4810. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4811. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4812. // var respJSON3 map[string]interface{}
  4813. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4814. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4816. // return
  4817. // }
  4818. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4819. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4820. // utils.ErrorLog("解析失败:%v", err)
  4821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4822. // return
  4823. // }
  4824. // if res3.Infcode == 0 {
  4825. // item.IsChange = 1
  4826. // item.BgBchno = bg_number
  4827. // service.SaveDF2(item)
  4828. // } else {
  4829. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4830. // }
  4831. //}
  4832. //} else
  4833. if item.IsSale == 0 { //没销售,
  4834. var res FJ3507Result
  4835. var res3507for10188 FJ3507ResultFor10188
  4836. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4837. //进行商品销售接口
  4838. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4839. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4840. var respJSON3 map[string]interface{}
  4841. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4844. return
  4845. }
  4846. userJSONBytes3, _ := json.Marshal(respJSON3)
  4847. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4848. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4849. utils.ErrorLog("解析失败:%v", err)
  4850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4851. return
  4852. }
  4853. //if res3507for10188.Infcode
  4854. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4855. //res.Output = resSix10265.Output
  4856. res.ErrMsg = res3507for10188.ErrMsg
  4857. res.Cainfo = res3507for10188.Cainfo
  4858. res.WarnMsg = res3507for10188.WarnMsg
  4859. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4860. res.Infcode = infocode
  4861. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4862. } else {
  4863. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4864. utils.ErrorLog("解析失败:%v", err)
  4865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4866. return
  4867. }
  4868. }
  4869. if res.Infcode == 0 {
  4870. item.IsSale = 1
  4871. item.Bchno = number
  4872. item.SaleDate = time.Now().Format("2006-01-02")
  4873. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  4874. err5 := service.SaveDF(item)
  4875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4876. //if err5 == nil {
  4877. //
  4878. // if item.IsChange == 1 { //没变更,进行变更操作
  4879. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4880. //
  4881. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4882. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4883. //
  4884. // var respJSON3 map[string]interface{}
  4885. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4886. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4888. // return
  4889. // }
  4890. //
  4891. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4892. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4893. // utils.ErrorLog("解析失败:%v", err)
  4894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4895. // return
  4896. // }
  4897. // //if res3507for10188.Infcode
  4898. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4899. // //res.Output = resSix10265.Output
  4900. // res3.ErrMsg = res3507for10188.ErrMsg
  4901. // res3.Cainfo = res3507for10188.Cainfo
  4902. // res3.WarnMsg = res3507for10188.WarnMsg
  4903. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4904. // res3.Infcode = infocode
  4905. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4906. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4907. // utils.ErrorLog("解析失败:%v", err)
  4908. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4909. // return
  4910. // }
  4911. // //if res3507for10188.Infcode
  4912. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4913. // //res.Output = resSix10265.Output
  4914. // res3.ErrMsg = res3507for10188.ErrMsg
  4915. // res3.Cainfo = res3507for10188.Cainfo
  4916. // res3.WarnMsg = res3507for10188.WarnMsg
  4917. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4918. // res3.Infcode = infocode
  4919. //
  4920. // } else {
  4921. //
  4922. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4923. // utils.ErrorLog("解析失败:%v", err)
  4924. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4925. // return
  4926. // }
  4927. //
  4928. // }
  4929. //
  4930. // if res3.Infcode == 0 {
  4931. // item.IsChange = 1
  4932. // item.BgBchno = bg_number
  4933. // service.SaveDF2(item)
  4934. // return
  4935. // } else {
  4936. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4937. // }
  4938. // }
  4939. //}
  4940. } else {
  4941. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4942. }
  4943. }
  4944. }
  4945. } else if item.ConsumableType == 7 {
  4946. var res3507for10188 FJ3507ResultFor10188
  4947. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4948. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4949. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4950. //判断是否已经销售
  4951. if item.IsSale == 2 { //是否已经销售,1是 0否
  4952. //是否已经变更 1是 0否
  4953. if item.IsChange == 0 { //没变更,进行变更操作
  4954. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4955. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4956. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4957. var respJSON3 map[string]interface{}
  4958. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4961. return
  4962. }
  4963. userJSONBytes3, _ := json.Marshal(respJSON3)
  4964. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4965. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4966. utils.ErrorLog("解析失败:%v", err)
  4967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4968. return
  4969. }
  4970. //if res3507for10188.Infcode
  4971. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4972. //res.Output = resSix10265.Output
  4973. res3.ErrMsg = res3507for10188.ErrMsg
  4974. res3.Cainfo = res3507for10188.Cainfo
  4975. res3.WarnMsg = res3507for10188.WarnMsg
  4976. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4977. res3.Infcode = infocode
  4978. } else {
  4979. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4980. utils.ErrorLog("解析失败:%v", err)
  4981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4982. return
  4983. }
  4984. }
  4985. if res3.Infcode == 0 {
  4986. item.IsChange = 1
  4987. item.BgBchno = bg_number
  4988. service.SaveDF2(item)
  4989. } else {
  4990. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4991. }
  4992. }
  4993. } else { //没销售,
  4994. //进行商品销售退货接口
  4995. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4996. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4997. saveLog(result111, result222, "3506", "销售退货")
  4998. var res7 FJ3507Result
  4999. //进行商品销售接口
  5000. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  5001. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  5002. var respJSON3 map[string]interface{}
  5003. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  5004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5006. return
  5007. }
  5008. userJSONBytes3, _ := json.Marshal(respJSON3)
  5009. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5010. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5011. utils.ErrorLog("解析失败:%v", err)
  5012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5013. return
  5014. }
  5015. //if res3507for10188.Infcode
  5016. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  5017. //res.Output = resSix10265.Output
  5018. res7.ErrMsg = res3507for10188.ErrMsg
  5019. res7.Cainfo = res3507for10188.Cainfo
  5020. res7.WarnMsg = res3507for10188.WarnMsg
  5021. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5022. res7.Infcode = infocode
  5023. } else {
  5024. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  5025. utils.ErrorLog("解析失败:%v", err)
  5026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5027. return
  5028. }
  5029. }
  5030. if res7.Infcode == 0 {
  5031. item.IsSale = 2
  5032. item.SaleDate = item.SaleDate
  5033. item.Bchno = number
  5034. service.SaveDF(item)
  5035. if item.IsChange == 0 { //没变更,进行变更操作
  5036. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5037. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5038. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5039. var respJSON3 map[string]interface{}
  5040. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5043. return
  5044. }
  5045. userJSONBytes3, _ := json.Marshal(respJSON3)
  5046. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5047. // utils.ErrorLog("解析失败:%v", err)
  5048. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5049. // return
  5050. //}
  5051. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5052. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5053. utils.ErrorLog("解析失败:%v", err)
  5054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5055. return
  5056. }
  5057. //if res3507for10188.Infcode
  5058. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5059. //res.Output = resSix10265.Output
  5060. res3.ErrMsg = res3507for10188.ErrMsg
  5061. res3.Cainfo = res3507for10188.Cainfo
  5062. res3.WarnMsg = res3507for10188.WarnMsg
  5063. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5064. res3.Infcode = infocode
  5065. } else {
  5066. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5067. utils.ErrorLog("解析失败:%v", err)
  5068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5069. return
  5070. }
  5071. }
  5072. if res3.Infcode == 0 {
  5073. item.IsChange = 1
  5074. item.BgBchno = bg_number
  5075. service.SaveDF2(item)
  5076. } else {
  5077. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5078. }
  5079. }
  5080. } else {
  5081. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5082. }
  5083. }
  5084. } else { //还没结算
  5085. if item.IsChange == 0 { //没变更,进行变更操作
  5086. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5087. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5088. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5089. var respJSON3 map[string]interface{}
  5090. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5093. return
  5094. }
  5095. userJSONBytes3, _ := json.Marshal(respJSON3)
  5096. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5097. // utils.ErrorLog("解析失败:%v", err)
  5098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5099. // return
  5100. //}
  5101. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5102. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5103. utils.ErrorLog("解析失败:%v", err)
  5104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5105. return
  5106. }
  5107. //if res3507for10188.Infcode
  5108. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5109. //res.Output = resSix10265.Output
  5110. res3.ErrMsg = res3507for10188.ErrMsg
  5111. res3.Cainfo = res3507for10188.Cainfo
  5112. res3.WarnMsg = res3507for10188.WarnMsg
  5113. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5114. res3.Infcode = infocode
  5115. } else {
  5116. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5117. utils.ErrorLog("解析失败:%v", err)
  5118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5119. return
  5120. }
  5121. }
  5122. if res3.Infcode == 0 {
  5123. item.IsChange = 1
  5124. item.BgBchno = bg_number
  5125. service.SaveDF2(item)
  5126. } else {
  5127. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5128. }
  5129. }
  5130. }
  5131. }
  5132. }
  5133. if len(err) == 0 {
  5134. c.ServeSuccessJSON(map[string]interface{}{
  5135. "msg": "销售变更成功",
  5136. })
  5137. } else {
  5138. c.ServeSuccessJSON(map[string]interface{}{
  5139. "failed_code": -10,
  5140. "msg": err,
  5141. })
  5142. }
  5143. }
  5144. func ChangeDrugTenone() {
  5145. //ids := c.GetString("ids")
  5146. //id_arr := strings.Split(ids, ",")
  5147. now := time.Now()
  5148. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  5149. //timestamp := int64(1729612800)
  5150. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  5151. admin_user_id := int64(2463)
  5152. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  5153. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  5154. var err []string
  5155. for _, item := range flows {
  5156. var res3 ResultSix
  5157. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  5158. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5159. continue
  5160. }
  5161. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5162. continue
  5163. }
  5164. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5165. if prescription.OrderStatus == 2 {
  5166. //已经结算
  5167. //判断是否已经销售
  5168. if item.IsSale == 1 { //是否已经销售,1是 0否
  5169. //是否已经变更 1是 0否
  5170. if item.IsChange == 0 { //没变更,进行变更操作
  5171. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5172. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5173. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  5174. var respJSON3 map[string]interface{}
  5175. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5177. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5178. return
  5179. }
  5180. userJSONBytes3, _ := json.Marshal(respJSON3)
  5181. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5182. utils.ErrorLog("解析失败:%v", err)
  5183. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5184. return
  5185. }
  5186. if res3.Infcode == 0 {
  5187. item.IsChange = 1
  5188. item.BgBchno = bg_number
  5189. service.SaveDF2(item)
  5190. } else {
  5191. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5192. }
  5193. }
  5194. } else { //没销售,
  5195. var res FJ3507Result
  5196. var res3507for10188 FJ3507ResultFor10188
  5197. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  5198. //进行商品销售接口
  5199. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  5200. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  5201. var respJSON3 map[string]interface{}
  5202. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  5203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5204. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5205. return
  5206. }
  5207. userJSONBytes3, _ := json.Marshal(respJSON3)
  5208. {
  5209. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5210. utils.ErrorLog("解析失败:%v", err)
  5211. return
  5212. }
  5213. //if res3507for10188.Infcode
  5214. res.InfRefmsgid = res3507for10188.InfRefmsgid
  5215. //res.Output = resSix10265.Output
  5216. res.ErrMsg = res3507for10188.ErrMsg
  5217. res.Cainfo = res3507for10188.Cainfo
  5218. res.WarnMsg = res3507for10188.WarnMsg
  5219. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5220. res.Infcode = infocode
  5221. }
  5222. if res.Infcode == 0 {
  5223. item.IsSale = 1
  5224. item.Bchno = number
  5225. item.SaleDate = time.Now().Format("2006-01-02")
  5226. err5 := service.SaveDF(item)
  5227. if err5 == nil {
  5228. if item.IsChange == 1 { //没变更,进行变更操作
  5229. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5230. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5231. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5232. var respJSON3 map[string]interface{}
  5233. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5235. return
  5236. }
  5237. {
  5238. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5239. utils.ErrorLog("解析失败:%v", err)
  5240. return
  5241. }
  5242. //if res3507for10188.Infcode
  5243. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5244. //res.Output = resSix10265.Output
  5245. res3.ErrMsg = res3507for10188.ErrMsg
  5246. res3.Cainfo = res3507for10188.Cainfo
  5247. res3.WarnMsg = res3507for10188.WarnMsg
  5248. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5249. res3.Infcode = infocode
  5250. }
  5251. if res3.Infcode == 0 {
  5252. item.IsChange = 1
  5253. item.BgBchno = bg_number
  5254. service.SaveDF2(item)
  5255. } else {
  5256. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5257. }
  5258. }
  5259. }
  5260. } else {
  5261. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5262. }
  5263. }
  5264. }
  5265. }
  5266. }
  5267. }
  5268. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5269. var struct3502 models.Struct3502
  5270. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5271. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5272. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5273. struct3502.FixmedinsCode = miConfig.Code
  5274. struct3502.Code = miConfig.Code
  5275. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5276. struct3502.Opter = role.UserName
  5277. struct3502.RxFlag = "1"
  5278. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5279. struct3502.OrgName = miConfig.OrgName
  5280. struct3502.AccessKey = miConfig.AccessKey
  5281. struct3502.RequestUrl = miConfig.Url
  5282. struct3502.SecretKey = miConfig.SecretKey
  5283. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5284. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5285. struct3502.Url = miConfig.Url
  5286. struct3502.AppId = miConfig.Cainfo
  5287. struct3502.AppSecret = miConfig.AppSecret
  5288. struct3502.Enckey = miConfig.EncKey
  5289. struct3502.SignKey = miConfig.SignKey
  5290. struct3502.SecretKey = miConfig.SecretKey
  5291. struct3502.InvChgType = chgType
  5292. struct3502.FixmedinsBchno = number
  5293. struct3502.Cnt = strconv.FormatInt(count, 10)
  5294. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5295. //result1, result2, _ := service.FJyb3502(struct3502)
  5296. if miConfig.MdtrtareaAdmvs == "350500" {
  5297. result1, result2, _ := service.FJyb3502(struct3502)
  5298. //saveLog(result1, result2, "3502", "3502")
  5299. return result1, result2
  5300. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5301. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5302. return result1, result2
  5303. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5304. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5305. return result1, result2
  5306. } else {
  5307. data := make(map[string]interface{})
  5308. data["struct_3502s"] = struct3502
  5309. client := &http.Client{}
  5310. bytesData, _ := json.Marshal(data)
  5311. var req *http.Request
  5312. if miConfig.MdtrtareaAdmvs == "320830" {
  5313. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  5314. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5315. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5316. } else {
  5317. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5318. }
  5319. resp, _ := client.Do(req)
  5320. defer resp.Body.Close()
  5321. body, ioErr := ioutil.ReadAll(resp.Body)
  5322. if ioErr != nil {
  5323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5324. }
  5325. var respJSON map[string]interface{}
  5326. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5328. }
  5329. //var resSix10265 ResultSix10265 //1101结果
  5330. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5331. result, _ := json.Marshal(respJSON)
  5332. return string(result), ""
  5333. }
  5334. }
  5335. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5336. var struct3505 models.Struct3505
  5337. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5338. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5339. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5340. struct3505.FixmedinsBchno = number
  5341. struct3505.Opter = role.UserName
  5342. struct3505.Bchno = "---"
  5343. struct3505.FixmedinsCode = miConfig.Code
  5344. struct3505.Code = miConfig.Code
  5345. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.HisDoctorAdviceInfo.Price, 'f', -1, 64)
  5346. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5347. struct3505.PrscDrName = roles.UserName
  5348. if org_id == 10191 {
  5349. struct3505.PharName = "刘水山"
  5350. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5351. }
  5352. if org_id == 10188 {
  5353. struct3505.PharName = "李汉清"
  5354. struct3505.PharPracCertNo = "30220200932022010034"
  5355. }
  5356. if org_id == 10217 {
  5357. struct3505.PharName = "张敏"
  5358. struct3505.PharPracCertNo = "30220230432090100108"
  5359. }
  5360. if org_id == 10318 {
  5361. struct3505.PharName = "邹刘阳"
  5362. struct3505.PharPracCertNo = "210441200001378"
  5363. }
  5364. if org_id == 10402 {
  5365. struct3505.PharName = "刘韶健"
  5366. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5367. }
  5368. if org_id == 9919 {
  5369. struct3505.PharName = "周君权"
  5370. struct3505.PharPracCertNo = "089644396094401375"
  5371. }
  5372. if org_id == 10644 {
  5373. struct3505.PharName = "陈金娣"
  5374. struct3505.PharPracCertNo = "20181441500320100066"
  5375. }
  5376. if org_id == 10567 {
  5377. struct3505.PharName = "范小兰"
  5378. struct3505.PharPracCertNo = "0200102079485"
  5379. }
  5380. if org_id == 10721 {
  5381. struct3505.PharName = "孙莉侠"
  5382. struct3505.PharPracCertNo = "060399"
  5383. }
  5384. if org_id == 10726 {
  5385. struct3505.PharName = "彭建福"
  5386. struct3505.PharPracCertNo = "D445281006261"
  5387. }
  5388. if org_id == 10697 {
  5389. struct3505.PharName = "陶海兰"
  5390. struct3505.PharPracCertNo = "0010933"
  5391. }
  5392. if org_id == 10265 {
  5393. struct3505.PharName = "李彩星"
  5394. struct3505.PharPracCertNo = "20171110600110100019"
  5395. }
  5396. if org_id == 10028 {
  5397. struct3505.PharName = "曾细平"
  5398. struct3505.PharPracCertNo = "D440307022134"
  5399. }
  5400. if org_id == 10138 {
  5401. struct3505.PharName = "彭斯遥"
  5402. struct3505.PharPracCertNo = "30220200943042010052"
  5403. }
  5404. if org_id == 10278 {
  5405. struct3505.PharName = "彭斯遥"
  5406. struct3505.PharPracCertNo = "30220200943042010052"
  5407. }
  5408. if org_id == 10610 {
  5409. struct3505.PharName = "彭斯遥"
  5410. struct3505.PharPracCertNo = "30220200943042010052"
  5411. }
  5412. if org_id == 10537 {
  5413. struct3505.PharName = "彭斯遥"
  5414. struct3505.PharPracCertNo = "30220200943042010052"
  5415. }
  5416. if org_id == 9504 {
  5417. struct3505.PharName = "资美红"
  5418. struct3505.PharPracCertNo = "D440904006635"
  5419. }
  5420. if org_id == 10480 {
  5421. struct3505.PharName = "陈思"
  5422. struct3505.PharPracCertNo = "30220240434110010470"
  5423. }
  5424. if org_id == 10653 {
  5425. struct3505.PharName = "邓树英"
  5426. struct3505.PharPracCertNo = "201910026440004734"
  5427. }
  5428. if org_id == 10571 {
  5429. struct3505.PharName = "廖志平"
  5430. struct3505.PharPracCertNo = "0136425"
  5431. }
  5432. if org_id == 10387 {
  5433. struct3505.PharName = "易圣"
  5434. struct3505.PharPracCertNo = "D430726002209"
  5435. }
  5436. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5437. struct3505.SetlId = order.SetlId
  5438. struct3505.MdtrtSn = order.MdtrtId
  5439. struct3505.ManuLotnum = drug.BatchNumber
  5440. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5441. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5442. struct3505.RxFlag = "1"
  5443. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5444. struct3505.TrdnFlag = "0"
  5445. } else {
  5446. struct3505.TrdnFlag = "1"
  5447. }
  5448. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5449. struct3505.TrdnFlag = "1"
  5450. }
  5451. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5452. struct3505.TrdnFlag = "0"
  5453. }
  5454. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 {
  5455. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 1 {
  5456. struct3505.TrdnFlag = "1"
  5457. }
  5458. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 2 {
  5459. struct3505.TrdnFlag = "0"
  5460. }
  5461. }
  5462. struct3505.RtalDocno = order.Number
  5463. struct3505.PsnCertType = "01"
  5464. struct3505.CertNo = order.Certno
  5465. struct3505.PsnNo = order.PsnNo
  5466. struct3505.PsnName = order.PsnName
  5467. struct3505.Url = miConfig.Url
  5468. struct3505.AppId = miConfig.Cainfo
  5469. struct3505.AppSecret = miConfig.AppSecret
  5470. struct3505.Enckey = miConfig.EncKey
  5471. struct3505.SignKey = miConfig.SignKey
  5472. struct3505.SecretKey = miConfig.SecretKey
  5473. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5474. struct3505.SelRetnCnt = strValue
  5475. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5476. struct3505.SelRetnOpterName = role.UserName
  5477. if order.IsMedicineInsurance == 1 {
  5478. struct3505.MdtrtSetlType = "1"
  5479. } else {
  5480. struct3505.MdtrtSetlType = "2"
  5481. }
  5482. struct3505.OrgName = miConfig.OrgName
  5483. struct3505.AccessKey = miConfig.AccessKey
  5484. struct3505.RequestUrl = miConfig.Url
  5485. struct3505.SecretKey = miConfig.SecretKey
  5486. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5487. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5488. struct3505.Cainfo = miConfig.Cainfo
  5489. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5490. if miConfig.MdtrtareaAdmvs == "350500" {
  5491. result1, result2, _ := service.FJyb3505(struct3505)
  5492. return result1, result2
  5493. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5494. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5495. return result1, result2
  5496. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5497. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5498. return result1, result2
  5499. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5500. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5501. return result1, result2
  5502. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5503. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5504. return result1, result2
  5505. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5506. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5507. return result1, result2
  5508. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5509. data := make(map[string]interface{})
  5510. data["struct_3505s"] = struct3505
  5511. client := &http.Client{}
  5512. bytesData, _ := json.Marshal(data)
  5513. var req *http.Request
  5514. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5515. resp, _ := client.Do(req)
  5516. defer resp.Body.Close()
  5517. body, ioErr := ioutil.ReadAll(resp.Body)
  5518. if ioErr != nil {
  5519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5520. }
  5521. var respJSON map[string]interface{}
  5522. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5524. }
  5525. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5526. result, _ := json.Marshal(respJSON)
  5527. return string(result), ""
  5528. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5529. data := make(map[string]interface{})
  5530. data["struct_3505s"] = struct3505
  5531. client := &http.Client{}
  5532. bytesData, _ := json.Marshal(data)
  5533. var req *http.Request
  5534. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5535. resp, _ := client.Do(req)
  5536. defer resp.Body.Close()
  5537. body, ioErr := ioutil.ReadAll(resp.Body)
  5538. if ioErr != nil {
  5539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5540. }
  5541. var respJSON map[string]interface{}
  5542. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5544. }
  5545. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5546. if status == "0" {
  5547. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5548. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5549. }
  5550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5551. result, _ := json.Marshal(respJSON)
  5552. return string(result), ""
  5553. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5554. result1, result2 := service.Hnyb3505(struct3505)
  5555. return result1, result2
  5556. } else {
  5557. data := make(map[string]interface{})
  5558. data["struct_3505s"] = struct3505
  5559. client := &http.Client{}
  5560. bytesData, _ := json.Marshal(data)
  5561. var req *http.Request
  5562. if miConfig.MdtrtareaAdmvs == "320830" {
  5563. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5564. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5565. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5566. } else {
  5567. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5568. }
  5569. resp, _ := client.Do(req)
  5570. defer resp.Body.Close()
  5571. body, ioErr := ioutil.ReadAll(resp.Body)
  5572. if ioErr != nil {
  5573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5574. }
  5575. var respJSON map[string]interface{}
  5576. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5578. }
  5579. //var resSix10265 ResultSix10265 //1101结果
  5580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5581. result, _ := json.Marshal(respJSON)
  5582. return string(result), ""
  5583. }
  5584. }
  5585. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5586. var struct3505 models.Struct3505
  5587. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5588. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5589. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5590. struct3505.FixmedinsBchno = number
  5591. struct3505.Opter = role.UserName
  5592. struct3505.FixmedinsCode = miConfig.Code
  5593. struct3505.Code = miConfig.Code
  5594. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5595. struct3505.PrscDrName = roles.UserName
  5596. if org_id == 10191 {
  5597. struct3505.PharName = "刘水山"
  5598. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5599. }
  5600. if org_id == 10188 {
  5601. struct3505.PharName = "李汉清"
  5602. struct3505.PharPracCertNo = "30220200932022010034"
  5603. }
  5604. if org_id == 10217 {
  5605. struct3505.PharName = "张敏"
  5606. struct3505.PharPracCertNo = "30220230432090100108"
  5607. }
  5608. if org_id == 10318 {
  5609. struct3505.PharName = "邹刘阳"
  5610. struct3505.PharPracCertNo = "210441200001378"
  5611. }
  5612. if org_id == 10402 {
  5613. struct3505.PharName = "刘韶健"
  5614. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5615. }
  5616. if org_id == 9919 {
  5617. struct3505.PharName = "周君权"
  5618. struct3505.PharPracCertNo = "089644396094401375"
  5619. }
  5620. if org_id == 10644 {
  5621. struct3505.PharName = "陈金娣"
  5622. struct3505.PharPracCertNo = "20181441500320100066"
  5623. }
  5624. if org_id == 10567 {
  5625. struct3505.PharName = "范小兰"
  5626. struct3505.PharPracCertNo = "0200102079485"
  5627. }
  5628. if org_id == 10721 {
  5629. struct3505.PharName = "孙莉侠"
  5630. struct3505.PharPracCertNo = "060399"
  5631. }
  5632. if org_id == 10726 {
  5633. struct3505.PharName = "彭建福"
  5634. struct3505.PharPracCertNo = "D445281006261"
  5635. }
  5636. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5637. struct3505.SetlId = order.SetlId
  5638. struct3505.MdtrtSn = order.MdtrtId
  5639. struct3505.ManuLotnum = drug.Number
  5640. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5641. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5642. struct3505.RxFlag = "1"
  5643. struct3505.TrdnFlag = "0"
  5644. struct3505.RtalDocno = order.Number
  5645. struct3505.PsnCertType = "01"
  5646. struct3505.CertNo = order.Certno
  5647. struct3505.PsnNo = order.PsnNo
  5648. struct3505.PsnName = order.PsnName
  5649. struct3505.Url = miConfig.Url
  5650. struct3505.AppId = miConfig.Cainfo
  5651. struct3505.AppSecret = miConfig.AppSecret
  5652. struct3505.Enckey = miConfig.EncKey
  5653. struct3505.SignKey = miConfig.SignKey
  5654. struct3505.SecretKey = miConfig.SecretKey
  5655. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5656. struct3505.SelRetnCnt = strValue
  5657. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5658. struct3505.SelRetnOpterName = role.UserName
  5659. if order.IsMedicineInsurance == 1 {
  5660. struct3505.MdtrtSetlType = "1"
  5661. } else {
  5662. struct3505.MdtrtSetlType = "2"
  5663. }
  5664. struct3505.OrgName = miConfig.OrgName
  5665. struct3505.AccessKey = miConfig.AccessKey
  5666. struct3505.RequestUrl = miConfig.Url
  5667. struct3505.SecretKey = miConfig.SecretKey
  5668. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5669. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5670. struct3505.Cainfo = miConfig.Cainfo
  5671. struct3505.DrugTracCodg = drug.DrugCode
  5672. if miConfig.MdtrtareaAdmvs == "350500" {
  5673. result1, result2, _ := service.FJyb3505(struct3505)
  5674. return result1, result2
  5675. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5676. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5677. return result1, result2
  5678. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5679. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5680. return result1, result2
  5681. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5682. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5683. return result1, result2
  5684. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5685. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5686. return result1, result2
  5687. } else {
  5688. data := make(map[string]interface{})
  5689. data["struct_3505s"] = struct3505
  5690. client := &http.Client{}
  5691. bytesData, _ := json.Marshal(data)
  5692. var req *http.Request
  5693. if miConfig.MdtrtareaAdmvs == "320830" {
  5694. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5695. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5696. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5697. } else {
  5698. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5699. }
  5700. resp, _ := client.Do(req)
  5701. defer resp.Body.Close()
  5702. body, ioErr := ioutil.ReadAll(resp.Body)
  5703. if ioErr != nil {
  5704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5705. }
  5706. var respJSON map[string]interface{}
  5707. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5709. }
  5710. //var resSix10265 ResultSix10265 //1101结果
  5711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5712. result, _ := json.Marshal(respJSON)
  5713. return string(result), ""
  5714. }
  5715. }
  5716. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5717. var struct3506 models.Struct3506
  5718. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5719. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5720. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5721. struct3506.FixmedinsCode = miConfig.Code
  5722. struct3506.Code = miConfig.Code
  5723. struct3506.FixmedinsBchno = number
  5724. struct3506.Opter = role.UserName
  5725. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5726. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5727. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5728. struct3506.MdtrtSn = order.MdtrtId
  5729. struct3506.ExpyEnd = ""
  5730. struct3506.RxFlag = "0"
  5731. struct3506.TrdnFlag = "1"
  5732. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5733. struct3506.SelRetnCnt = strValue
  5734. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5735. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5736. struct3506.SelRetnOpterName = role.UserName
  5737. struct3506.OrgName = miConfig.OrgName
  5738. struct3506.AccessKey = miConfig.AccessKey
  5739. struct3506.RequestUrl = miConfig.Url
  5740. struct3506.SecretKey = miConfig.SecretKey
  5741. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5742. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5743. struct3506.Url = miConfig.Url
  5744. struct3506.AppId = miConfig.Cainfo
  5745. struct3506.AppSecret = miConfig.AppSecret
  5746. struct3506.Enckey = miConfig.EncKey
  5747. struct3506.SignKey = miConfig.SignKey
  5748. struct3506.SecretKey = miConfig.SecretKey
  5749. struct3506.DrugTracCodg = drug.DrugCode
  5750. if miConfig.MdtrtareaAdmvs == "350500" {
  5751. result1, result2, _ := service.FJyb3506(struct3506)
  5752. return result1, result2
  5753. } else {
  5754. data := make(map[string]interface{})
  5755. data["struct_3506s"] = struct3506
  5756. client := &http.Client{}
  5757. bytesData, _ := json.Marshal(data)
  5758. var req *http.Request
  5759. if miConfig.MdtrtareaAdmvs == "320830" {
  5760. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3506", bytes.NewReader(bytesData))
  5761. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5762. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5763. } else {
  5764. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5765. }
  5766. resp, _ := client.Do(req)
  5767. defer resp.Body.Close()
  5768. body, ioErr := ioutil.ReadAll(resp.Body)
  5769. if ioErr != nil {
  5770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5771. }
  5772. var respJSON map[string]interface{}
  5773. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5775. }
  5776. //var resSix10265 ResultSix10265 //1101结果
  5777. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5778. result, _ := json.Marshal(respJSON)
  5779. return string(result), ""
  5780. }
  5781. }
  5782. func (c *HisApiController) Get1318() {
  5783. adminUser := c.GetAdminUserInfo()
  5784. admin_user_id, _ := c.GetInt64("admin_user_id")
  5785. code := c.GetString("code")
  5786. code = ""
  5787. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5788. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5789. api := ""
  5790. if miConfig.MdtrtareaAdmvs == "320830" {
  5791. api = miConfig.AppSecret + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5792. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5793. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5794. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5795. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5796. } else {
  5797. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5798. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5799. }
  5800. resp, requestErr := http.Get(api)
  5801. if requestErr != nil {
  5802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5803. return
  5804. }
  5805. body, ioErr := ioutil.ReadAll(resp.Body)
  5806. if ioErr != nil {
  5807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5809. return
  5810. }
  5811. var respJSON map[string]interface{}
  5812. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5815. return
  5816. }
  5817. //var res Result2406
  5818. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5819. result, _ := json.Marshal(respJSON)
  5820. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5821. utils.ErrorLog("解析失败:%v", err)
  5822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5823. return
  5824. }
  5825. if res.Infcode == "0" {
  5826. c.ServeSuccessJSON(map[string]interface{}{
  5827. "result": "",
  5828. })
  5829. } else {
  5830. c.ServeSuccessJSON(map[string]interface{}{
  5831. "failed_code": -10,
  5832. "msg": res.ErrMsg,
  5833. })
  5834. */return
  5835. //}
  5836. }
  5837. func (c *HisApiController) Get2503() {
  5838. adminUser := c.GetAdminUserInfo()
  5839. admin_user_id, _ := c.GetInt64("admin_user_id")
  5840. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5841. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5842. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5843. }
  5844. func (c *HisApiController) Get2406() {
  5845. id, _ := c.GetInt64("id")
  5846. record_time := c.GetString("record_time")
  5847. his_patient_id, _ := c.GetInt64("his_patient_id")
  5848. admin_user_id, _ := c.GetInt64("admin_user_id")
  5849. diagnosis_id := c.GetString("diagnosis")
  5850. timeLayout := "2006-01-02"
  5851. loc, _ := time.LoadLocation("Local")
  5852. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5853. if err != nil {
  5854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5855. return
  5856. }
  5857. recordDateTime := theTime.Unix()
  5858. adminUser := c.GetAdminUserInfo()
  5859. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5860. var config []*models.HisXtDiagnoseConfig
  5861. for _, item := range diagnosis_ids {
  5862. id, _ := strconv.ParseInt(item, 10, 64)
  5863. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5864. config = append(config, &diagnosisConfig)
  5865. }
  5866. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5867. fmt.Println(his_patient_id)
  5868. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5869. //timestamp := time.Now().Unix()
  5870. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5871. var patientPrescription models.HisPrescriptionInfo
  5872. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5873. if patientPrescription.ID == 0 {
  5874. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5875. }
  5876. var res2 Result2406
  5877. if miConfig.MdtrtareaAdmvs == "341203" {
  5878. data := make(map[string]interface{})
  5879. client := &http.Client{}
  5880. data["psn_no"] = his.PsnNo
  5881. data["mdtrt_id"] = his.Number
  5882. data["operator"] = roles.UserName
  5883. data["cert_no"] = his.IdCardNo
  5884. data["org_name"] = miConfig.OrgName
  5885. data["psn_name"] = his.Name
  5886. data["ipt_otp_no"] = his.IptOtpNo
  5887. data["ipt_psn_sp_flag_type"] = "0901"
  5888. data["ipt_psn_sp_flag"] = "1"
  5889. data["fixmedins_code"] = miConfig.Code
  5890. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5891. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5892. data["url"] = miConfig.Url
  5893. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5894. bytesData, _ := json.Marshal(data)
  5895. var req *http.Request
  5896. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5897. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5898. resp, _ := client.Do(req)
  5899. defer resp.Body.Close()
  5900. body, ioErr := ioutil.ReadAll(resp.Body)
  5901. if ioErr != nil {
  5902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5904. return
  5905. }
  5906. var respJSON map[string]interface{}
  5907. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5910. return
  5911. }
  5912. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5913. if status == "0" {
  5914. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5915. c.ServeSuccessJSON(map[string]interface{}{
  5916. "failed_code": -10,
  5917. "msg": err_msg,
  5918. })
  5919. return
  5920. }
  5921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5922. userJSONBytes, _ := json.Marshal(respJSON)
  5923. fmt.Println("log")
  5924. fmt.Println(string(userJSONBytes))
  5925. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5926. utils.ErrorLog("解析失败:%v", err)
  5927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5928. return
  5929. }
  5930. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5931. data := make(map[string]interface{})
  5932. client := &http.Client{}
  5933. data["psn_no"] = his.PsnNo
  5934. data["mdtrt_id"] = his.Number
  5935. data["operator"] = roles.UserName
  5936. data["cert_no"] = his.IdCardNo
  5937. data["org_name"] = miConfig.OrgName
  5938. data["psn_name"] = his.Name
  5939. data["ipt_otp_no"] = his.IptOtpNo
  5940. data["ipt_psn_sp_flag_type"] = "0901"
  5941. data["ipt_psn_sp_flag"] = "1"
  5942. data["fixmedins_code"] = miConfig.Code
  5943. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5944. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5945. data["url"] = miConfig.Url
  5946. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5947. bytesData, _ := json.Marshal(data)
  5948. var req *http.Request
  5949. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5950. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5951. resp, _ := client.Do(req)
  5952. defer resp.Body.Close()
  5953. body, ioErr := ioutil.ReadAll(resp.Body)
  5954. if ioErr != nil {
  5955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5957. return
  5958. }
  5959. var respJSON map[string]interface{}
  5960. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5963. return
  5964. }
  5965. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5966. if status == "0" {
  5967. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5968. c.ServeSuccessJSON(map[string]interface{}{
  5969. "failed_code": -10,
  5970. "msg": err_msg,
  5971. })
  5972. return
  5973. }
  5974. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5975. userJSONBytes, _ := json.Marshal(respJSON)
  5976. fmt.Println("log")
  5977. fmt.Println(string(userJSONBytes))
  5978. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5979. utils.ErrorLog("解析失败:%v", err)
  5980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5981. return
  5982. }
  5983. }
  5984. if res2.Infcode != 0 {
  5985. adminUser := c.GetAdminUserInfo()
  5986. errlog := &models.HisOrderError{
  5987. UserOrgId: adminUser.CurrentOrgId,
  5988. Ctime: time.Now().Unix(),
  5989. Mtime: time.Now().Unix(),
  5990. ErrMsg: res2.ErrMsg,
  5991. Status: 1,
  5992. PatientId: id,
  5993. RecordTime: recordDateTime,
  5994. Stage: 3,
  5995. }
  5996. service.CreateErrMsgLog(errlog)
  5997. c.ServeSuccessJSON(map[string]interface{}{
  5998. "failed_code": -10,
  5999. "msg": res2.ErrMsg,
  6000. })
  6001. return
  6002. } else {
  6003. c.ServeSuccessJSON(map[string]interface{}{
  6004. "msg": "上传成功",
  6005. })
  6006. return
  6007. }
  6008. }
  6009. func (c *HisApiController) Get4105() {
  6010. }
  6011. func (c *HisApiController) Post5302() {
  6012. patient_id, _ := c.GetInt64("id")
  6013. admin_user_id, _ := c.GetInt64("admin_user_id")
  6014. p, _ := service.GetHisPatientById(patient_id)
  6015. adminUser := c.GetAdminUserInfo()
  6016. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6017. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6018. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6019. }
  6020. func (c *HisApiController) Get4104() {
  6021. }
  6022. type Output struct {
  6023. CertNo string `json:"certno"`
  6024. PsnName string `json:"psn_name"`
  6025. CardNo string `json:"card_no"`
  6026. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6027. CardSN string `json:"card_sn"`
  6028. PsnCertType string `json:"psn_cert_type"`
  6029. MdtrtCertNo string `json:"mdtrt_cert_no"`
  6030. MdtrtCertType string `json:"mdtrt_cert_type"`
  6031. QRCode string `json:"qrCode"`
  6032. EcToken string `json:"ecToken"`
  6033. }
  6034. type AHResponse struct {
  6035. Body AHBody `json:"body"`
  6036. Code int `json:"code"`
  6037. CSBCode int `json:"csbCode"`
  6038. Message string `json:"message"`
  6039. RequestID string `json:"requestId"`
  6040. State struct{} `json:"state"`
  6041. }
  6042. type AHBody struct {
  6043. ErrMsg string `json:"err_msg"`
  6044. InfRefMsgID string `json:"inf_refmsgid"`
  6045. InfCode int `json:"infcode"`
  6046. Output struct {
  6047. Result []struct {
  6048. BasMednFlag string `json:"bas_medn_flag"`
  6049. ChldMedcFlag string `json:"chld_medc_flag"`
  6050. ChrgitmLv string `json:"chrgitm_lv"`
  6051. Cnt float64 `json:"cnt"`
  6052. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6053. DrtReimFlag string `json:"drt_reim_flag"`
  6054. FeedetlSn string `json:"feedetl_sn"`
  6055. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6056. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6057. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6058. ListSpItemFlag string `json:"list_sp_item_flag"`
  6059. LmtUsedFlag string `json:"lmt_used_flag"`
  6060. MedChrgitmType string `json:"med_chrgitm_type"`
  6061. Memo string `json:"memo"`
  6062. OverlmtAmt float64 `json:"overlmt_amt"`
  6063. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6064. Pric float64 `json:"pric"`
  6065. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6066. SelfpayProp float64 `json:"selfpay_prop"`
  6067. } `json:"result"`
  6068. } `json:"output"`
  6069. }
  6070. type Response struct {
  6071. Output Output `json:"output"`
  6072. Infcode int `json:"infcode"`
  6073. InfRefMsgID string `json:"inf_refmsgid"`
  6074. RefMsgTime string `json:"refmsg_time"`
  6075. RespondTime string `json:"respond_time"`
  6076. ErrMsg string `json:"err_msg"`
  6077. WarnMsg string `json:"warn_msg"`
  6078. SignType string `json:"signtype"`
  6079. CAInfo string `json:"cainfo"`
  6080. }
  6081. func (c *HisApiController) Getquerydata() {
  6082. query_type, _ := c.GetInt64("type")
  6083. refd_setl_flag := c.GetString("refd_setl_flag")
  6084. med_type := c.GetString("med_type")
  6085. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6086. cert_no := c.GetString("cert_no")
  6087. psn_no := c.GetString("psn_no")
  6088. start_time := c.GetString("start_time")
  6089. end_time := c.GetString("end_time")
  6090. page, _ := c.GetInt64("page")
  6091. limit, _ := c.GetInt64("limit")
  6092. var bp models.BusinessParams5262
  6093. bp.RefdSetlFlag = refd_setl_flag
  6094. bp.MedType = med_type
  6095. bp.Certno = cert_no
  6096. bp.Psnno = psn_no
  6097. bp.QBegntime = start_time
  6098. bp.QEndtime = end_time
  6099. if query_type == 1 { //本地
  6100. Post5262(c, bp, page, limit)
  6101. } else { //异地
  6102. Post5267(c, bp, page, limit)
  6103. }
  6104. }
  6105. func (c *HisApiController) Drugscheck() {
  6106. admin_user_id, _ := c.GetInt64("admin_user_id")
  6107. adminUser := c.GetAdminUserInfo()
  6108. var queryResult []QueryResult
  6109. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6110. for _, item := range drugs {
  6111. result := QueryResult{
  6112. ID: item.ID,
  6113. Name: item.DrugName,
  6114. Code: item.MedicalInsuranceNumber,
  6115. List_type_code: "101",
  6116. }
  6117. queryResult = append(queryResult, result)
  6118. }
  6119. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6120. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6121. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6122. for _, item := range queryResult {
  6123. 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)
  6124. }
  6125. }
  6126. func (c *HisApiController) Goodcheck() {
  6127. admin_user_id, _ := c.GetInt64("admin_user_id")
  6128. adminUser := c.GetAdminUserInfo()
  6129. var queryResult []QueryResult
  6130. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6131. for _, item := range goods {
  6132. result := QueryResult{
  6133. ID: item.ID,
  6134. Name: item.GoodName,
  6135. Code: item.SocialSecurityDirectoryCode,
  6136. List_type_code: "301",
  6137. }
  6138. queryResult = append(queryResult, result)
  6139. }
  6140. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6141. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6142. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6143. for _, item := range queryResult {
  6144. 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)
  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. }
  6147. }
  6148. func (c *HisApiController) Projectcheck() {
  6149. admin_user_id, _ := c.GetInt64("admin_user_id")
  6150. adminUser := c.GetAdminUserInfo()
  6151. var queryResult []QueryResult
  6152. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6153. for _, item := range projects {
  6154. result := QueryResult{
  6155. ID: item.ID,
  6156. Name: item.ProjectName,
  6157. Code: item.MedicalCode,
  6158. List_type_code: "201",
  6159. }
  6160. queryResult = append(queryResult, result)
  6161. }
  6162. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6163. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6164. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6165. for _, item := range queryResult {
  6166. 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)
  6167. }
  6168. }
  6169. //func (c *HisApiController)CancleDia(){
  6170. //
  6171. // id, _ := c.GetInt64("id")
  6172. // record_time := c.GetString("record_time")
  6173. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6174. //
  6175. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6176. //
  6177. // diagnosis_id := c.GetString("diagnosis")
  6178. // sick_type, _ := c.GetInt64("sick_type")
  6179. // reg_type, _ := c.GetInt64("p_type")
  6180. // begin_time := c.GetString("begin_time")
  6181. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6182. //
  6183. //
  6184. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6185. //
  6186. // fmt.Println(acct_used_flag)
  6187. //
  6188. //
  6189. // timeLayout := "2006-01-02"
  6190. // loc, _ := time.LoadLocation("Local")
  6191. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6192. // if err != nil {
  6193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6194. // return
  6195. // }
  6196. // recordDateTime := theTime.Unix()
  6197. // adminUser := c.GetAdminUserInfo()
  6198. //
  6199. //
  6200. //
  6201. //
  6202. //
  6203. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6204. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6205. // var patientPrescription models.HisPrescriptionInfo
  6206. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6207. // if patientPrescription.ID == 0 {
  6208. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6209. // }
  6210. // //if patientPrescription.Do
  6211. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6212. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6213. //
  6214. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6215. //
  6216. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6217. //
  6218. // var config []*models.HisXtDiagnoseConfig
  6219. // for _, item := range diagnosis_ids {
  6220. // id, _ := strconv.ParseInt(item, 10, 64)
  6221. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6222. // config = append(config, &diagnosisConfig)
  6223. // }
  6224. //
  6225. // sickConfig, _ := service.FindSickById(sick_type)
  6226. //
  6227. //
  6228. // data := make(map[string]interface{})
  6229. // client := &http.Client{}
  6230. // data["psn_no"] = his.PsnNo
  6231. // data["mdtrt_id"] = his.Number
  6232. // data["doctor"] = roles.UserName
  6233. // data["department"] = department.Name
  6234. // data["org_name"] = miConfig.OrgName
  6235. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6236. // data["doctor_id"] = doctor_info.DoctorNumber
  6237. // data["new_doctor_name"] = doctor_info.UserName
  6238. // data["fixmedins_code"] = miConfig.Code
  6239. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6240. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6241. // data["secret_key"] = miConfig.SecretKey
  6242. // data["sick_code"] = sickConfig.CountryCode
  6243. // data["sick_name"] = sickConfig.ClassName
  6244. // data["url"] = miConfig.Url
  6245. // data["ak"] = miConfig.AccessKey
  6246. // data["begin_time"] = begin_time
  6247. // data["cainfo"] = miConfig.Cainfo
  6248. // data["is_vaild"] = "0"
  6249. //
  6250. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6251. // data["config"] = config
  6252. // bytesData, _ := json.Marshal(data)
  6253. //
  6254. // var req *http.Request
  6255. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6256. // resp, _ := client.Do(req)
  6257. // defer resp.Body.Close()
  6258. // body, ioErr := ioutil.ReadAll(resp.Body)
  6259. // if ioErr != nil {
  6260. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6262. // return
  6263. // }
  6264. // var respJSON map[string]interface{}
  6265. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6266. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6268. // return
  6269. // }
  6270. //
  6271. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6272. // userJSONBytes, _ := json.Marshal(respJSON)
  6273. // fmt.Println("log")
  6274. // fmt.Println(string(userJSONBytes))
  6275. //
  6276. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6277. // utils.ErrorLog("解析失败:%v", err)
  6278. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6279. // return
  6280. // }
  6281. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6282. // res2.Output = ressix10265.Output
  6283. // res2.ErrMsg = ressix10265.ErrMsg
  6284. // res2.Cainfo = ressix10265.Cainfo
  6285. // res2.WarnMsg = ressix10265.WarnMsg
  6286. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6287. // res2.Infcode = infocode
  6288. //
  6289. //}
  6290. func (c *HisApiController) Get4102() {
  6291. order_id, _ := c.GetInt64("order_id")
  6292. admin_user_id, _ := c.GetInt64("admin_user_id")
  6293. stas_type := c.GetString("stas_type")
  6294. order, _ := service.GetHisOrderByIDTwo(order_id)
  6295. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6296. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6297. var pp models.PublicParams
  6298. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6299. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6300. pp.FixmedinsName = miConfig.OrgName
  6301. pp.FixmedinsCode = miConfig.Code
  6302. pp.RequestUrl = miConfig.Url
  6303. pp.Cainfo = miConfig.Cainfo
  6304. pp.SecretKey = miConfig.SecretKey
  6305. pp.AccessKey = miConfig.AccessKey
  6306. pp.OpterName = curRoles.UserName
  6307. if miConfig.MdtrtareaAdmvs == "350500" {
  6308. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6309. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6310. saveLog(result, request, "4102", "清单确认")
  6311. var dat map[string]interface{}
  6312. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6313. fmt.Println(dat)
  6314. } else {
  6315. fmt.Println(err)
  6316. }
  6317. var empty ResultFourteen
  6318. userJSONBytes, _ := json.Marshal(dat)
  6319. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6320. utils.ErrorLog("解析失败:%v", err)
  6321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6322. return
  6323. }
  6324. if empty.Infcode == 0 {
  6325. c.ServeSuccessJSON(map[string]interface{}{
  6326. "msg": "确认成功",
  6327. })
  6328. return
  6329. }
  6330. } else {
  6331. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6332. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6333. result3, request3 := service.Jxyb4105(pp)
  6334. saveLog(result, request, "4102", "清单确认")
  6335. saveLog(result2, request2, "4103", "清单确认")
  6336. saveLog(result3, request3, "4105", "清单统计")
  6337. var dat map[string]interface{}
  6338. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6339. fmt.Println(dat)
  6340. } else {
  6341. fmt.Println(err)
  6342. }
  6343. var empty ResultFourteen
  6344. userJSONBytes, _ := json.Marshal(dat)
  6345. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6346. utils.ErrorLog("解析失败:%v", err)
  6347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6348. return
  6349. }
  6350. if empty.Infcode == 0 {
  6351. c.ServeSuccessJSON(map[string]interface{}{
  6352. "msg": "确认成功",
  6353. })
  6354. return
  6355. }
  6356. }
  6357. }
  6358. // 对账权限查询
  6359. func (c *HisApiController) Get3260() {
  6360. admin_user_id, _ := c.GetInt64("admin_user_id")
  6361. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6362. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6363. var api string
  6364. var res models.JSResult3260
  6365. if miConfig.MdtrtareaAdmvs == "320830" {
  6366. api = miConfig.AppSecret + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6367. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6368. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6369. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6370. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6371. } else {
  6372. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6373. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6374. }
  6375. resp, requestErr := http.Get(api)
  6376. if requestErr != nil {
  6377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6378. return
  6379. }
  6380. body, ioErr := ioutil.ReadAll(resp.Body)
  6381. if ioErr != nil {
  6382. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6384. return
  6385. }
  6386. var respJSON map[string]interface{}
  6387. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6390. return
  6391. }
  6392. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6393. result, _ := json.Marshal(respJSON)
  6394. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6395. utils.ErrorLog("解析失败:%v", err)
  6396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6397. return
  6398. }
  6399. if res.Infcode == "0" {
  6400. c.ServeSuccessJSON(map[string]interface{}{
  6401. "result": res.Output.Data,
  6402. })
  6403. } else {
  6404. c.ServeSuccessJSON(map[string]interface{}{
  6405. "failed_code": -10,
  6406. "msg": res.ErrMsg,
  6407. })
  6408. return
  6409. }
  6410. }
  6411. func (c *HisApiController) Get3261() {
  6412. admin_user_id, _ := c.GetInt64("admin_user_id")
  6413. //month := c.GetString("month")
  6414. startTime := c.GetString("start_time")
  6415. //endTime, _ := c.GetString("end_time")
  6416. times := strings.Split(startTime, "-")
  6417. stmt_mon := times[0] + times[1]
  6418. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6419. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6420. var api string
  6421. var res models.JSResult3261
  6422. //var res10265 Result5301For10265
  6423. if miConfig.MdtrtareaAdmvs == "320830" {
  6424. api = miConfig.AppSecret + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6425. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6426. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6427. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6428. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6429. } else {
  6430. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6431. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6432. }
  6433. resp, requestErr := http.Get(api)
  6434. if requestErr != nil {
  6435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6436. return
  6437. }
  6438. body, ioErr := ioutil.ReadAll(resp.Body)
  6439. if ioErr != nil {
  6440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6442. return
  6443. }
  6444. var respJSON map[string]interface{}
  6445. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6448. return
  6449. }
  6450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6451. result, _ := json.Marshal(respJSON)
  6452. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6453. utils.ErrorLog("解析失败:%v", err)
  6454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6455. return
  6456. }
  6457. if res.Infcode == "0" {
  6458. c.ServeSuccessJSON(map[string]interface{}{
  6459. "result": res.Output,
  6460. })
  6461. } else {
  6462. c.ServeSuccessJSON(map[string]interface{}{
  6463. "failed_code": -10,
  6464. "msg": res.ErrMsg,
  6465. })
  6466. return
  6467. }
  6468. }
  6469. type TempFun struct {
  6470. FundKey string
  6471. FundCode string
  6472. }
  6473. func (c *HisApiController) Get3262() {
  6474. admin_user_id, _ := c.GetInt64("admin_user_id")
  6475. startTime := c.GetString("start_time")
  6476. endTime := c.GetString("end_time")
  6477. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6478. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6479. //timeLayout := "2006-01-02"
  6480. //loc, _ := time.LoadLocation("Local")
  6481. //var theStartTIme int64
  6482. //if len(startTime) > 0 {
  6483. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6484. // if err != nil {
  6485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6486. // return
  6487. // }
  6488. // theStartTIme = theTime.Unix()
  6489. //}
  6490. //var theEndtTIme int64
  6491. //if len(endTime) > 0 {
  6492. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6493. // if err != nil {
  6494. // utils.ErrorLog(err.Error())
  6495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6496. // return
  6497. // }
  6498. // theEndtTIme = theTime.Unix()
  6499. //}
  6500. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6501. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6502. for _, team := range datas {
  6503. fmt.Println(team.PsnTime)
  6504. for _, team_two := range datas_two {
  6505. fmt.Println(team_two.PsnTime)
  6506. if team.FundKey == team_two.FundKey {
  6507. fmt.Println(team_two.PsnTime)
  6508. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6509. fmt.Println(team.PsnTime)
  6510. }
  6511. }
  6512. }
  6513. fmt.Println("1111")
  6514. fmt.Println(datas)
  6515. fmt.Println("1111")
  6516. var twos []models.FixMonRecDetailFileInTwo
  6517. for _, team := range datas {
  6518. var two models.FixMonRecDetailFileInTwo
  6519. two.MedType = team.MedType
  6520. two.Insutype = team.Insutype
  6521. two.PsnType = team.PsnType
  6522. two.MedType = team.MedType
  6523. two.FixBlngAdmdvs = "999999"
  6524. two.InsuAdmdvs = "555555"
  6525. two.PsnTime = team.PsnTime
  6526. two.PsnCnt = team.PsnCnt
  6527. two.FundKey = team.FundKey
  6528. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6529. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6530. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6531. two.MedfeeSumAmt = ms
  6532. two.InscpAmt = ia
  6533. two.FundPaySumAmt = fps
  6534. twos = append(twos, two)
  6535. }
  6536. //startTime := c.GetString("start_time")
  6537. //endTime, _ := c.GetString("end_time")
  6538. times := strings.Split(startTime, "-")
  6539. stmt_mon := times[0] + times[1]
  6540. var funs []models.FundDetail
  6541. for _, item := range datas {
  6542. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6543. funs = append(funs, fun...)
  6544. }
  6545. var funInfos []models.Fund
  6546. //for _, item := range funs {
  6547. // var rf []models.FundInfo
  6548. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6549. // for _, subitem := range rf {
  6550. // var fund models.Fund
  6551. // fund.FundCode = subitem.FundPayType
  6552. // fund.FundName = subitem.FundPayTypeName
  6553. // fund.FundAmt = subitem.FundPayAmt
  6554. // fund.FundKey = item.FundKey
  6555. // fund.InsuAdmdvs = "555555"
  6556. // fund.FixBlngAdmdvs = "999999"
  6557. // funInfos = append(funInfos, fund)
  6558. // }
  6559. //}
  6560. var tempFuns []TempFun
  6561. for _, funInfo := range funInfos {
  6562. var tempFun TempFun
  6563. tempFun.FundKey = funInfo.FundKey
  6564. tempFun.FundCode = funInfo.FundCode
  6565. tempFuns = append(tempFuns, tempFun)
  6566. }
  6567. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6568. fmt.Println(tempFuns)
  6569. var funInfosTwo []models.Fund
  6570. decimal.DivisionPrecision = 2
  6571. for _, item := range tempFuns {
  6572. var fund models.Fund
  6573. for _, subItem := range funInfos {
  6574. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6575. fund.FundKey = subItem.FundKey
  6576. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6577. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6578. fund.FundName = subItem.FundName
  6579. fund.FundCode = subItem.FundCode
  6580. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6581. }
  6582. }
  6583. funInfosTwo = append(funInfosTwo, fund)
  6584. }
  6585. fmt.Println("funInfosTwo")
  6586. fmt.Println(funInfosTwo)
  6587. var upld_btch string
  6588. var empty models.JSResultEmpty
  6589. data := make(map[string]interface{})
  6590. data["org_name"] = miConfig.OrgName
  6591. data["doctor"] = curRoles.UserName
  6592. data["doctor_name"] = curRoles.UserName
  6593. data["fixmedins_code"] = miConfig.Code
  6594. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6595. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6596. data["secret_key"] = miConfig.SecretKey
  6597. data["url"] = miConfig.Url
  6598. data["ak"] = miConfig.AccessKey
  6599. data["cainfo"] = miConfig.Cainfo
  6600. data["datas"] = twos
  6601. data["fund"] = funInfosTwo
  6602. fmt.Println(twos)
  6603. month := time.Unix(1557042972, 0).Format("1")
  6604. year := time.Now().Format("2006")
  6605. month = time.Now().Format("01")
  6606. day := time.Now().Format("02")
  6607. hour := time.Now().Format("15")
  6608. min := time.Now().Format("04")
  6609. sec := time.Now().Format("05")
  6610. fix_fill_date := year + month + day + hour + min + sec
  6611. data["fix_fill_dept"] = miConfig.OrgName
  6612. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6613. data["fix_fill_psn"] = curRoles.UserName
  6614. data["fix_fill_date"] = fix_fill_date
  6615. data["stmt_loc"] = "2"
  6616. data["setl_mon"] = stmt_mon
  6617. upld_btch = "0"
  6618. data["upld_btch"] = upld_btch
  6619. //fmt.Println(data)
  6620. client := &http.Client{}
  6621. bytesData, _ := json.Marshal(data)
  6622. var req *http.Request
  6623. if miConfig.MdtrtareaAdmvs == "320830" {
  6624. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3262", bytes.NewReader(bytesData))
  6625. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6626. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6627. } else {
  6628. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6629. }
  6630. resp, _ := client.Do(req)
  6631. defer resp.Body.Close()
  6632. body, ioErr := ioutil.ReadAll(resp.Body)
  6633. if ioErr != nil {
  6634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6636. }
  6637. var respJSON map[string]interface{}
  6638. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6641. }
  6642. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6643. //fmt.Println(respJSON)
  6644. result, _ := json.Marshal(respJSON)
  6645. //fmt.Println(result)
  6646. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6647. utils.ErrorLog("解析失败:%v", err)
  6648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6649. }
  6650. if empty.Infcode != "0" {
  6651. c.ServeSuccessJSON(map[string]interface{}{
  6652. "failed_code": -10,
  6653. "msg": empty.ErrMsg,
  6654. })
  6655. return
  6656. } else {
  6657. c.ServeSuccessJSON(map[string]interface{}{
  6658. "msg": "上传成功",
  6659. })
  6660. return
  6661. }
  6662. }
  6663. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6664. newArr = make([]TempFun, 0)
  6665. for i := 0; i < len(arr); i++ {
  6666. repeat := false
  6667. for j := i + 1; j < len(arr); j++ {
  6668. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6669. repeat = true
  6670. break
  6671. }
  6672. }
  6673. if !repeat {
  6674. newArr = append(newArr, arr[i])
  6675. }
  6676. }
  6677. return
  6678. }
  6679. func (c *HisApiController) Get3263() {
  6680. admin_user_id, _ := c.GetInt64("admin_user_id")
  6681. startTime := c.GetString("start_time")
  6682. //endTime, _ := c.GetString("end_time")
  6683. times := strings.Split(startTime, "-")
  6684. setl_mon := times[0] + times[1]
  6685. upld_btch := "0"
  6686. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6687. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6688. var result3263 models.JSResult3263
  6689. data := make(map[string]interface{})
  6690. data["org_name"] = miConfig.OrgName
  6691. data["doctor"] = curRoles.UserName
  6692. data["doctor_name"] = curRoles.UserName
  6693. data["fixmedins_code"] = miConfig.Code
  6694. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6695. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6696. data["secret_key"] = miConfig.SecretKey
  6697. data["url"] = miConfig.Url
  6698. data["ak"] = miConfig.AccessKey
  6699. data["cainfo"] = miConfig.Cainfo
  6700. data["setl_mon"] = setl_mon
  6701. data["stmt_loc"] = "2"
  6702. data["upld_btch"] = upld_btch
  6703. client := &http.Client{}
  6704. bytesData, _ := json.Marshal(data)
  6705. var req *http.Request
  6706. if miConfig.MdtrtareaAdmvs == "320830" {
  6707. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6708. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6709. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6710. } else {
  6711. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6712. }
  6713. resp, _ := client.Do(req)
  6714. defer resp.Body.Close()
  6715. body, ioErr := ioutil.ReadAll(resp.Body)
  6716. if ioErr != nil {
  6717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6719. }
  6720. var respJSON map[string]interface{}
  6721. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6724. }
  6725. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6726. fmt.Println(respJSON)
  6727. result, _ := json.Marshal(respJSON)
  6728. fmt.Println(result)
  6729. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6730. utils.ErrorLog("解析失败:%v", err)
  6731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6732. }
  6733. if result3263.Infcode != "0" {
  6734. c.ServeSuccessJSON(map[string]interface{}{
  6735. "failed_code": -10,
  6736. "msg": result3263.ErrMsg,
  6737. })
  6738. return
  6739. } else {
  6740. c.ServeSuccessJSON(map[string]interface{}{
  6741. "list": result3263.Output,
  6742. })
  6743. return
  6744. }
  6745. }
  6746. func (c *HisApiController) Get3264() {
  6747. admin_user_id, _ := c.GetInt64("admin_user_id")
  6748. startTime := c.GetString("start_time")
  6749. //endTime, _ := c.GetString("end_time")
  6750. times := strings.Split(startTime, "-")
  6751. setl_mon := times[0] + times[1]
  6752. upld_btch := "0"
  6753. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6754. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6755. //solidify_id := []
  6756. var result3263 models.JSResult3263
  6757. data := make(map[string]interface{})
  6758. data["org_name"] = miConfig.OrgName
  6759. data["doctor"] = curRoles.UserName
  6760. data["doctor_name"] = curRoles.UserName
  6761. data["fixmedins_code"] = miConfig.Code
  6762. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6763. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6764. data["secret_key"] = miConfig.SecretKey
  6765. data["url"] = miConfig.Url
  6766. data["ak"] = miConfig.AccessKey
  6767. data["cainfo"] = miConfig.Cainfo
  6768. data["setl_mon"] = setl_mon
  6769. data["stmt_loc"] = "2"
  6770. data["upld_btch"] = upld_btch
  6771. client := &http.Client{}
  6772. bytesData, _ := json.Marshal(data)
  6773. var req3263 *http.Request
  6774. if miConfig.MdtrtareaAdmvs == "320830" {
  6775. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6776. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6777. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6778. } else {
  6779. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6780. }
  6781. resp, _ := client.Do(req3263)
  6782. defer resp.Body.Close()
  6783. body, ioErr := ioutil.ReadAll(resp.Body)
  6784. if ioErr != nil {
  6785. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6787. }
  6788. var respJSON3263 map[string]interface{}
  6789. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6792. }
  6793. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6794. fmt.Println(respJSON3263)
  6795. result, _ := json.Marshal(respJSON3263)
  6796. fmt.Println(result)
  6797. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6798. utils.ErrorLog("解析失败:%v", err)
  6799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6800. }
  6801. var ids []string
  6802. for _, item := range result3263.Output {
  6803. ids = append(ids, item.SolidifyID)
  6804. }
  6805. var empty models.JSResultEmpty
  6806. data2 := make(map[string]interface{})
  6807. data2["org_name"] = miConfig.OrgName
  6808. data2["doctor"] = curRoles.UserName
  6809. data2["doctor_name"] = curRoles.UserName
  6810. data2["fixmedins_code"] = miConfig.Code
  6811. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6812. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6813. data2["secret_key"] = miConfig.SecretKey
  6814. data2["url"] = miConfig.Url
  6815. data2["ak"] = miConfig.AccessKey
  6816. data2["cainfo"] = miConfig.Cainfo
  6817. data2["setl_mon"] = setl_mon
  6818. data2["stmt_loc"] = "2"
  6819. data2["upld_btch"] = upld_btch
  6820. data2["solidify_id"] = ids
  6821. client2 := &http.Client{}
  6822. bytesData2, _ := json.Marshal(data2)
  6823. var req *http.Request
  6824. if miConfig.MdtrtareaAdmvs == "320830" {
  6825. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3264", bytes.NewReader(bytesData))
  6826. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6827. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6828. } else {
  6829. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6830. }
  6831. resp2, _ := client2.Do(req)
  6832. defer resp.Body.Close()
  6833. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6834. if ioErr2 != nil {
  6835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6837. }
  6838. var respJSON map[string]interface{}
  6839. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6842. }
  6843. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6844. fmt.Println(respJSON)
  6845. result2, _ := json.Marshal(respJSON)
  6846. fmt.Println(result2)
  6847. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6848. utils.ErrorLog("解析失败:%v", err)
  6849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6850. }
  6851. if empty.Infcode != "0" {
  6852. c.ServeSuccessJSON(map[string]interface{}{
  6853. "failed_code": -10,
  6854. "msg": empty.ErrMsg,
  6855. })
  6856. return
  6857. } else {
  6858. c.ServeSuccessJSON(map[string]interface{}{
  6859. "msg": "",
  6860. })
  6861. return
  6862. }
  6863. }
  6864. func (c *HisApiController) Get3265() {
  6865. admin_user_id, _ := c.GetInt64("admin_user_id")
  6866. startTime := c.GetString("start_time")
  6867. //endTime, _ := c.GetString("end_time")
  6868. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6869. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6870. times := strings.Split(startTime, "-")
  6871. setl_mon := times[0] + times[1]
  6872. var upld_btch string
  6873. upld_btch = "0"
  6874. //var empty models.JSResultEmpty
  6875. var result3265 models.JSResult3264
  6876. var result3263 models.JSResult3263
  6877. data2 := make(map[string]interface{})
  6878. data2["org_name"] = miConfig.OrgName
  6879. data2["doctor"] = curRoles.UserName
  6880. data2["doctor_name"] = curRoles.UserName
  6881. data2["fixmedins_code"] = miConfig.Code
  6882. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6883. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6884. data2["secret_key"] = miConfig.SecretKey
  6885. data2["url"] = miConfig.Url
  6886. data2["ak"] = miConfig.AccessKey
  6887. data2["cainfo"] = miConfig.Cainfo
  6888. data2["setl_mon"] = setl_mon
  6889. data2["stmt_loc"] = "2"
  6890. data2["upld_btch"] = upld_btch
  6891. client2 := &http.Client{}
  6892. bytesData2, _ := json.Marshal(data2)
  6893. var req3263 *http.Request
  6894. if miConfig.MdtrtareaAdmvs == "320830" {
  6895. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData2))
  6896. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6897. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6898. } else {
  6899. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6900. }
  6901. resp2, _ := client2.Do(req3263)
  6902. defer resp2.Body.Close()
  6903. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6904. if ioErr2 != nil {
  6905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. }
  6908. var respJSON3263 map[string]interface{}
  6909. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6912. }
  6913. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6914. fmt.Println(respJSON3263)
  6915. result2, _ := json.Marshal(respJSON3263)
  6916. fmt.Println(result2)
  6917. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6918. utils.ErrorLog("解析失败:%v", err)
  6919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6920. }
  6921. var ids []string
  6922. for _, item := range result3263.Output {
  6923. ids = append(ids, item.SolidifyID)
  6924. }
  6925. data := make(map[string]interface{})
  6926. data["org_name"] = miConfig.OrgName
  6927. data["doctor"] = curRoles.UserName
  6928. data["doctor_name"] = curRoles.UserName
  6929. data["fixmedins_code"] = miConfig.Code
  6930. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6931. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6932. data["secret_key"] = miConfig.SecretKey
  6933. data["url"] = miConfig.Url
  6934. data["ak"] = miConfig.AccessKey
  6935. data["cainfo"] = miConfig.Cainfo
  6936. data["setl_mon"] = setl_mon
  6937. data["solidify_id"] = ids
  6938. month := time.Unix(1557042972, 0).Format("1")
  6939. year := time.Now().Format("2006")
  6940. month = time.Now().Format("01")
  6941. day := time.Now().Format("02")
  6942. hour := time.Now().Format("15")
  6943. min := time.Now().Format("04")
  6944. sec := time.Now().Format("05")
  6945. fix_fill_date := year + month + day + hour + min + sec
  6946. data["fix_fill_dept"] = miConfig.OrgName
  6947. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6948. data["fix_fill_psn"] = curRoles.UserName
  6949. data["fix_fill_date"] = fix_fill_date
  6950. data["stmt_loc"] = "2"
  6951. data["upld_btch"] = upld_btch
  6952. client := &http.Client{}
  6953. bytesData, _ := json.Marshal(data)
  6954. var req *http.Request
  6955. if miConfig.MdtrtareaAdmvs == "320830" {
  6956. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3265", bytes.NewReader(bytesData2))
  6957. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6958. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6959. } else {
  6960. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6961. }
  6962. resp, _ := client.Do(req)
  6963. defer resp.Body.Close()
  6964. body, ioErr := ioutil.ReadAll(resp.Body)
  6965. if ioErr != nil {
  6966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6968. }
  6969. var respJSON map[string]interface{}
  6970. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6973. }
  6974. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6975. fmt.Println(respJSON)
  6976. result, _ := json.Marshal(respJSON)
  6977. fmt.Println(result)
  6978. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6979. utils.ErrorLog("解析失败:%v", err)
  6980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6981. }
  6982. if result3265.Infcode != "0" {
  6983. c.ServeSuccessJSON(map[string]interface{}{
  6984. "failed_code": -10,
  6985. "msg": result3265.ErrMsg,
  6986. })
  6987. return
  6988. } else {
  6989. c.ServeSuccessJSON(map[string]interface{}{
  6990. "info": result3265.Output,
  6991. })
  6992. return
  6993. }
  6994. }
  6995. func (c *HisApiController) Get3266() {
  6996. admin_user_id, _ := c.GetInt64("admin_user_id")
  6997. startTime := c.GetString("start_time")
  6998. //endTime, _ := c.GetString("end_time")
  6999. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7000. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7001. times := strings.Split(startTime, "-")
  7002. stmt_mon := times[0] + times[1]
  7003. var upld_btch string
  7004. //var empty models.JSResultEmpty
  7005. var result3265 models.JSResult3264
  7006. data := make(map[string]interface{})
  7007. data["org_name"] = miConfig.OrgName
  7008. data["doctor"] = curRoles.UserName
  7009. data["doctor_name"] = curRoles.UserName
  7010. data["fixmedins_code"] = miConfig.Code
  7011. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7012. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7013. data["secret_key"] = miConfig.SecretKey
  7014. data["url"] = miConfig.Url
  7015. data["ak"] = miConfig.AccessKey
  7016. data["cainfo"] = miConfig.Cainfo
  7017. data["setl_mon"] = stmt_mon
  7018. month := time.Unix(1557042972, 0).Format("1")
  7019. year := time.Now().Format("2006")
  7020. month = time.Now().Format("01")
  7021. day := time.Now().Format("02")
  7022. hour := time.Now().Format("15")
  7023. min := time.Now().Format("04")
  7024. sec := time.Now().Format("05")
  7025. fix_fill_date := year + month + day + hour + min + sec
  7026. data["fix_fill_dept"] = miConfig.OrgName
  7027. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7028. data["fix_fill_psn"] = curRoles.UserName
  7029. data["fix_fill_date"] = fix_fill_date
  7030. data["stmt_loc"] = "2"
  7031. upld_btch = "0"
  7032. data["upld_btch"] = upld_btch
  7033. client := &http.Client{}
  7034. bytesData, _ := json.Marshal(data)
  7035. var req *http.Request
  7036. if miConfig.MdtrtareaAdmvs == "320830" {
  7037. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3266", bytes.NewReader(bytesData))
  7038. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7039. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7040. } else {
  7041. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7042. }
  7043. resp, _ := client.Do(req)
  7044. defer resp.Body.Close()
  7045. body, ioErr := ioutil.ReadAll(resp.Body)
  7046. if ioErr != nil {
  7047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7049. }
  7050. var respJSON map[string]interface{}
  7051. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7054. }
  7055. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7056. fmt.Println(respJSON)
  7057. result, _ := json.Marshal(respJSON)
  7058. fmt.Println(result)
  7059. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7060. utils.ErrorLog("解析失败:%v", err)
  7061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7062. }
  7063. if result3265.Infcode != "0" {
  7064. c.ServeSuccessJSON(map[string]interface{}{
  7065. "failed_code": -10,
  7066. "msg": result3265.ErrMsg,
  7067. })
  7068. return
  7069. } else {
  7070. c.ServeSuccessJSON(map[string]interface{}{
  7071. "info": result3265.Output,
  7072. })
  7073. return
  7074. }
  7075. }
  7076. func (c *HisApiController) Get3267() {
  7077. admin_user_id, _ := c.GetInt64("admin_user_id")
  7078. startTime := c.GetString("start_time")
  7079. //endTime, _ := c.GetString("end_time")
  7080. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7081. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7082. times := strings.Split(startTime, "-")
  7083. setl_mon := times[0] + times[1]
  7084. var upld_btch string
  7085. //var empty models.JSResultEmpty
  7086. var result3265 models.JSResult3264
  7087. upld_btch = "0"
  7088. data := make(map[string]interface{})
  7089. data["org_name"] = miConfig.OrgName
  7090. data["doctor"] = curRoles.UserName
  7091. data["doctor_name"] = curRoles.UserName
  7092. data["fixmedins_code"] = miConfig.Code
  7093. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7094. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7095. data["secret_key"] = miConfig.SecretKey
  7096. data["url"] = miConfig.Url
  7097. data["ak"] = miConfig.AccessKey
  7098. data["cainfo"] = miConfig.Cainfo
  7099. data["setl_mon"] = setl_mon
  7100. data["stmt_loc"] = "2"
  7101. data["upld_btch"] = upld_btch
  7102. client := &http.Client{}
  7103. bytesData, _ := json.Marshal(data)
  7104. var req *http.Request
  7105. if miConfig.MdtrtareaAdmvs == "320830" {
  7106. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3267", bytes.NewReader(bytesData))
  7107. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7108. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7109. } else {
  7110. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7111. }
  7112. resp, _ := client.Do(req)
  7113. defer resp.Body.Close()
  7114. body, ioErr := ioutil.ReadAll(resp.Body)
  7115. if ioErr != nil {
  7116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7118. }
  7119. var respJSON map[string]interface{}
  7120. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7123. }
  7124. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7125. fmt.Println(respJSON)
  7126. result, _ := json.Marshal(respJSON)
  7127. fmt.Println(result)
  7128. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7129. utils.ErrorLog("解析失败:%v", err)
  7130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7131. }
  7132. if result3265.Infcode != "0" {
  7133. c.ServeSuccessJSON(map[string]interface{}{
  7134. "failed_code": -10,
  7135. "msg": result3265.ErrMsg,
  7136. })
  7137. return
  7138. } else {
  7139. c.ServeSuccessJSON(map[string]interface{}{
  7140. "info": result3265.Output.Data,
  7141. })
  7142. return
  7143. }
  7144. }
  7145. func (c *HisApiController) Get3268() {
  7146. admin_user_id, _ := c.GetInt64("admin_user_id")
  7147. startTime := c.GetString("start_time")
  7148. endTime := c.GetString("end_time")
  7149. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7150. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7151. times := strings.Split(startTime, "-")
  7152. setl_mon := times[0] + times[1]
  7153. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7154. var twos []models.FixMonRecDetailFileInTwo
  7155. var funs []models.FundDetail
  7156. for _, item := range datas {
  7157. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7158. funs = append(funs, fun...)
  7159. }
  7160. var funInfos []models.Fund
  7161. //for _, item := range funs {
  7162. // var rf []models.FundInfo
  7163. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7164. // for _, subitem := range rf {
  7165. // var fund models.Fund
  7166. // fund.FundCode = subitem.FundPayType
  7167. // fund.FundName = subitem.FundPayTypeName
  7168. // fund.FundAmt = subitem.FundPayAmt
  7169. // fund.FundKey = item.FundKey
  7170. // fund.InsuAdmdvs = "555555"
  7171. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7172. // funInfos = append(funInfos, fund)
  7173. // }
  7174. //}
  7175. for _, team := range datas {
  7176. var two models.FixMonRecDetailFileInTwo
  7177. two.SetlDate = time.Now().Format("2006-01-02")
  7178. two.MedType = team.MedType
  7179. two.Insutype = team.Insutype
  7180. two.PsnType = team.PsnType
  7181. two.MedType = team.MedType
  7182. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7183. two.InsuAdmdvs = team.InsuAdmdvs
  7184. two.PsnTime = team.PsnTime
  7185. two.PsnCnt = team.PsnCnt
  7186. two.FundKey = team.FundKey
  7187. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7188. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7189. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7190. two.MedfeeSumAmt = ms
  7191. two.InscpAmt = ia
  7192. two.FundPaySumAmt = fps
  7193. twos = append(twos, two)
  7194. }
  7195. var upld_btch string
  7196. upld_btch = "0"
  7197. var empty models.JSResultEmpty
  7198. data := make(map[string]interface{})
  7199. data["org_name"] = miConfig.OrgName
  7200. data["doctor"] = curRoles.UserName
  7201. data["doctor_name"] = curRoles.UserName
  7202. data["fixmedins_code"] = miConfig.Code
  7203. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7204. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7205. data["secret_key"] = miConfig.SecretKey
  7206. data["url"] = miConfig.Url
  7207. data["ak"] = miConfig.AccessKey
  7208. data["cainfo"] = miConfig.Cainfo
  7209. data["datas"] = twos
  7210. data["fund"] = funInfos
  7211. data["setl_mon"] = setl_mon
  7212. month := time.Unix(1557042972, 0).Format("1")
  7213. year := time.Now().Format("2006")
  7214. month = time.Now().Format("01")
  7215. day := time.Now().Format("02")
  7216. hour := time.Now().Format("15")
  7217. min := time.Now().Format("04")
  7218. sec := time.Now().Format("05")
  7219. fix_fill_date := year + month + day + hour + min + sec
  7220. data["fix_fill_dept"] = miConfig.OrgName
  7221. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7222. data["fix_fill_psn"] = curRoles.UserName
  7223. data["fix_fill_date"] = fix_fill_date
  7224. data["stmt_loc"] = "2"
  7225. data["upld_btch"] = upld_btch
  7226. client := &http.Client{}
  7227. bytesData, _ := json.Marshal(data)
  7228. var req *http.Request
  7229. if miConfig.MdtrtareaAdmvs == "320830" {
  7230. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3268", bytes.NewReader(bytesData))
  7231. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7232. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7233. } else {
  7234. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7235. }
  7236. resp, _ := client.Do(req)
  7237. defer resp.Body.Close()
  7238. body, ioErr := ioutil.ReadAll(resp.Body)
  7239. if ioErr != nil {
  7240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7242. }
  7243. var respJSON map[string]interface{}
  7244. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7247. }
  7248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7249. fmt.Println(respJSON)
  7250. result, _ := json.Marshal(respJSON)
  7251. fmt.Println(result)
  7252. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7253. utils.ErrorLog("解析失败:%v", err)
  7254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7255. }
  7256. if empty.Infcode != "0" {
  7257. c.ServeSuccessJSON(map[string]interface{}{
  7258. "failed_code": -10,
  7259. "msg": empty.ErrMsg,
  7260. })
  7261. return
  7262. } else {
  7263. c.ServeSuccessJSON(map[string]interface{}{
  7264. "msg": "上传成功",
  7265. })
  7266. return
  7267. }
  7268. }
  7269. func (c *HisApiController) Get3269() {
  7270. admin_user_id, _ := c.GetInt64("admin_user_id")
  7271. startTime := c.GetString("start_time")
  7272. //endTime, _ := c.GetString("end_time")
  7273. times := strings.Split(startTime, "-")
  7274. setl_mon := times[0] + times[1]
  7275. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7276. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7277. var result3263 models.JSResult3263
  7278. data := make(map[string]interface{})
  7279. data["org_name"] = miConfig.OrgName
  7280. data["doctor"] = curRoles.UserName
  7281. data["doctor_name"] = curRoles.UserName
  7282. data["fixmedins_code"] = miConfig.Code
  7283. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7284. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7285. data["secret_key"] = miConfig.SecretKey
  7286. data["url"] = miConfig.Url
  7287. data["ak"] = miConfig.AccessKey
  7288. data["cainfo"] = miConfig.Cainfo
  7289. data["setl_mon"] = setl_mon
  7290. data["stmt_loc"] = "2"
  7291. client := &http.Client{}
  7292. bytesData, _ := json.Marshal(data)
  7293. var req *http.Request
  7294. if miConfig.MdtrtareaAdmvs == "320830" {
  7295. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData))
  7296. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7297. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7298. } else {
  7299. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7300. }
  7301. resp, _ := client.Do(req)
  7302. defer resp.Body.Close()
  7303. body, ioErr := ioutil.ReadAll(resp.Body)
  7304. if ioErr != nil {
  7305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7307. }
  7308. var respJSON map[string]interface{}
  7309. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7312. }
  7313. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7314. fmt.Println(respJSON)
  7315. result, _ := json.Marshal(respJSON)
  7316. fmt.Println(result)
  7317. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7318. utils.ErrorLog("解析失败:%v", err)
  7319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7320. }
  7321. if result3263.Infcode != "0" {
  7322. c.ServeSuccessJSON(map[string]interface{}{
  7323. "failed_code": -10,
  7324. "msg": result3263.ErrMsg,
  7325. })
  7326. return
  7327. } else {
  7328. c.ServeSuccessJSON(map[string]interface{}{
  7329. "msg": "上传成功",
  7330. })
  7331. return
  7332. }
  7333. }
  7334. func (c *HisApiController) Get3270() {
  7335. admin_user_id, _ := c.GetInt64("admin_user_id")
  7336. startTime := c.GetString("start_time")
  7337. //endTime, _ := c.GetString("end_time")
  7338. times := strings.Split(startTime, "-")
  7339. setl_mon := times[0] + times[1]
  7340. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7341. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7342. var result3263 models.JSResult3263
  7343. data2 := make(map[string]interface{})
  7344. data2["org_name"] = miConfig.OrgName
  7345. data2["doctor"] = curRoles.UserName
  7346. data2["doctor_name"] = curRoles.UserName
  7347. data2["fixmedins_code"] = miConfig.Code
  7348. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7349. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7350. data2["secret_key"] = miConfig.SecretKey
  7351. data2["url"] = miConfig.Url
  7352. data2["ak"] = miConfig.AccessKey
  7353. data2["cainfo"] = miConfig.Cainfo
  7354. data2["setl_mon"] = setl_mon
  7355. data2["stmt_loc"] = "2"
  7356. client2 := &http.Client{}
  7357. bytesData2, _ := json.Marshal(data2)
  7358. var req3263 *http.Request
  7359. if miConfig.MdtrtareaAdmvs == "320830" {
  7360. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7361. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7362. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7363. } else {
  7364. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7365. }
  7366. resp2, _ := client2.Do(req3263)
  7367. defer resp2.Body.Close()
  7368. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7369. if ioErr2 != nil {
  7370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7372. }
  7373. var respJSON3263 map[string]interface{}
  7374. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7377. }
  7378. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7379. fmt.Println(respJSON3263)
  7380. result2, _ := json.Marshal(respJSON3263)
  7381. fmt.Println(result2)
  7382. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7383. utils.ErrorLog("解析失败:%v", err)
  7384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7385. }
  7386. var ids []string
  7387. for _, item := range result3263.Output {
  7388. ids = append(ids, item.SolidifyID)
  7389. }
  7390. var result3264 models.JSResult3264
  7391. data := make(map[string]interface{})
  7392. data["org_name"] = miConfig.OrgName
  7393. data["doctor"] = curRoles.UserName
  7394. data["doctor_name"] = curRoles.UserName
  7395. data["fixmedins_code"] = miConfig.Code
  7396. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7397. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7398. data["secret_key"] = miConfig.SecretKey
  7399. data["url"] = miConfig.Url
  7400. data["ak"] = miConfig.AccessKey
  7401. data["cainfo"] = miConfig.Cainfo
  7402. data["setl_mon"] = setl_mon
  7403. data["stmt_loc"] = "2"
  7404. data["solidify_id"] = ids
  7405. client := &http.Client{}
  7406. bytesData, _ := json.Marshal(data)
  7407. var req *http.Request
  7408. if miConfig.MdtrtareaAdmvs == "320830" {
  7409. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3270", bytes.NewReader(bytesData))
  7410. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7411. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7412. } else {
  7413. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7414. }
  7415. resp, _ := client.Do(req)
  7416. defer resp.Body.Close()
  7417. body, ioErr := ioutil.ReadAll(resp.Body)
  7418. if ioErr != nil {
  7419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7421. }
  7422. var respJSON map[string]interface{}
  7423. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7426. }
  7427. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7428. fmt.Println(respJSON)
  7429. result, _ := json.Marshal(respJSON)
  7430. fmt.Println(result)
  7431. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7432. utils.ErrorLog("解析失败:%v", err)
  7433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7434. }
  7435. if result3264.Infcode != "0" {
  7436. c.ServeSuccessJSON(map[string]interface{}{
  7437. "failed_code": -10,
  7438. "msg": result3264.ErrMsg,
  7439. })
  7440. return
  7441. } else {
  7442. c.ServeSuccessJSON(map[string]interface{}{
  7443. "info": result3264.Output,
  7444. })
  7445. return
  7446. }
  7447. }
  7448. func (c *HisApiController) Get3271() {
  7449. admin_user_id, _ := c.GetInt64("admin_user_id")
  7450. startTime := c.GetString("start_time")
  7451. //endTime, _ := c.GetString("end_time")
  7452. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7453. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7454. times := strings.Split(startTime, "-")
  7455. setl_mon := times[0] + times[1]
  7456. //var empty models.JSResultEmpty
  7457. var result3265 models.JSResult3264
  7458. var result3263 models.JSResult3263
  7459. data2 := make(map[string]interface{})
  7460. data2["org_name"] = miConfig.OrgName
  7461. data2["doctor"] = curRoles.UserName
  7462. data2["doctor_name"] = curRoles.UserName
  7463. data2["fixmedins_code"] = miConfig.Code
  7464. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7465. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7466. data2["secret_key"] = miConfig.SecretKey
  7467. data2["url"] = miConfig.Url
  7468. data2["ak"] = miConfig.AccessKey
  7469. data2["cainfo"] = miConfig.Cainfo
  7470. data2["setl_mon"] = setl_mon
  7471. data2["stmt_loc"] = "2"
  7472. client2 := &http.Client{}
  7473. bytesData2, _ := json.Marshal(data2)
  7474. var req3263 *http.Request
  7475. if miConfig.MdtrtareaAdmvs == "320830" {
  7476. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7477. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7478. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7479. } else {
  7480. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7481. }
  7482. resp2, _ := client2.Do(req3263)
  7483. defer resp2.Body.Close()
  7484. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7485. if ioErr2 != nil {
  7486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7488. }
  7489. var respJSON3263 map[string]interface{}
  7490. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7493. }
  7494. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7495. fmt.Println(respJSON3263)
  7496. result2, _ := json.Marshal(respJSON3263)
  7497. fmt.Println(result2)
  7498. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7499. utils.ErrorLog("解析失败:%v", err)
  7500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7501. }
  7502. var ids []string
  7503. for _, item := range result3263.Output {
  7504. ids = append(ids, item.SolidifyID)
  7505. }
  7506. data := make(map[string]interface{})
  7507. data["org_name"] = miConfig.OrgName
  7508. data["doctor"] = curRoles.UserName
  7509. data["doctor_name"] = curRoles.UserName
  7510. data["fixmedins_code"] = miConfig.Code
  7511. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7512. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7513. data["secret_key"] = miConfig.SecretKey
  7514. data["url"] = miConfig.Url
  7515. data["ak"] = miConfig.AccessKey
  7516. data["cainfo"] = miConfig.Cainfo
  7517. data["setl_mon"] = setl_mon
  7518. data["solidify_id"] = ids
  7519. month := time.Unix(1557042972, 0).Format("1")
  7520. year := time.Now().Format("2006")
  7521. month = time.Now().Format("01")
  7522. day := time.Now().Format("02")
  7523. hour := time.Now().Format("15")
  7524. min := time.Now().Format("04")
  7525. sec := time.Now().Format("05")
  7526. fix_fill_date := year + month + day + hour + min + sec
  7527. data["fix_fill_dept"] = miConfig.OrgName
  7528. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7529. data["fix_fill_psn"] = curRoles.UserName
  7530. data["fix_fill_date"] = fix_fill_date
  7531. data["stmt_loc"] = "2"
  7532. client := &http.Client{}
  7533. bytesData, _ := json.Marshal(data)
  7534. var req *http.Request
  7535. if miConfig.MdtrtareaAdmvs == "320830" {
  7536. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3271", bytes.NewReader(bytesData2))
  7537. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7538. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7539. } else {
  7540. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7541. }
  7542. resp, _ := client.Do(req)
  7543. defer resp.Body.Close()
  7544. body, ioErr := ioutil.ReadAll(resp.Body)
  7545. if ioErr != nil {
  7546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7548. }
  7549. var respJSON map[string]interface{}
  7550. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7553. }
  7554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7555. fmt.Println(respJSON)
  7556. result, _ := json.Marshal(respJSON)
  7557. fmt.Println(result)
  7558. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7559. utils.ErrorLog("解析失败:%v", err)
  7560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7561. }
  7562. if result3265.Infcode != "0" {
  7563. c.ServeSuccessJSON(map[string]interface{}{
  7564. "failed_code": -10,
  7565. "msg": result3265.ErrMsg,
  7566. })
  7567. return
  7568. } else {
  7569. c.ServeSuccessJSON(map[string]interface{}{
  7570. "info": result3265.Output.Data,
  7571. })
  7572. return
  7573. }
  7574. }
  7575. func (c *HisApiController) Get3272() {
  7576. admin_user_id, _ := c.GetInt64("admin_user_id")
  7577. startTime := c.GetString("start_time")
  7578. //endTime, _ := c.GetString("end_time")
  7579. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7580. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7581. times := strings.Split(startTime, "-")
  7582. setl_mon := times[0] + times[1]
  7583. var upld_btch string
  7584. //var empty models.JSResultEmpty
  7585. var result3265 models.JSResult3264
  7586. data := make(map[string]interface{})
  7587. data["org_name"] = miConfig.OrgName
  7588. data["doctor"] = curRoles.UserName
  7589. data["doctor_name"] = curRoles.UserName
  7590. data["fixmedins_code"] = miConfig.Code
  7591. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7592. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7593. data["secret_key"] = miConfig.SecretKey
  7594. data["url"] = miConfig.Url
  7595. data["ak"] = miConfig.AccessKey
  7596. data["cainfo"] = miConfig.Cainfo
  7597. data["setl_mon"] = setl_mon
  7598. month := time.Unix(1557042972, 0).Format("1")
  7599. year := time.Now().Format("2006")
  7600. month = time.Now().Format("01")
  7601. day := time.Now().Format("02")
  7602. hour := time.Now().Format("15")
  7603. min := time.Now().Format("04")
  7604. sec := time.Now().Format("05")
  7605. fix_fill_date := year + month + day + hour + min + sec
  7606. data["fix_fill_dept"] = miConfig.OrgName
  7607. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7608. data["fix_fill_psn"] = curRoles.UserName
  7609. data["fix_fill_date"] = fix_fill_date
  7610. data["stmt_loc"] = "2"
  7611. data["upld_btch"] = upld_btch
  7612. client := &http.Client{}
  7613. bytesData, _ := json.Marshal(data)
  7614. var req *http.Request
  7615. if miConfig.MdtrtareaAdmvs == "320830" {
  7616. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3272", bytes.NewReader(bytesData))
  7617. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7618. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7619. } else {
  7620. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7621. }
  7622. resp, _ := client.Do(req)
  7623. defer resp.Body.Close()
  7624. body, ioErr := ioutil.ReadAll(resp.Body)
  7625. if ioErr != nil {
  7626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7628. }
  7629. var respJSON map[string]interface{}
  7630. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7633. }
  7634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7635. fmt.Println(respJSON)
  7636. result, _ := json.Marshal(respJSON)
  7637. fmt.Println(result)
  7638. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7639. utils.ErrorLog("解析失败:%v", err)
  7640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7641. }
  7642. if result3265.Infcode != "0" {
  7643. c.ServeSuccessJSON(map[string]interface{}{
  7644. "failed_code": -10,
  7645. "msg": result3265.ErrMsg,
  7646. })
  7647. return
  7648. } else {
  7649. c.ServeSuccessJSON(map[string]interface{}{
  7650. "info": result3265.Output,
  7651. })
  7652. return
  7653. }
  7654. }
  7655. func (c *HisApiController) Get3273() {
  7656. admin_user_id, _ := c.GetInt64("admin_user_id")
  7657. startTime := c.GetString("start_time")
  7658. //endTime, _ := c.GetString("end_time")
  7659. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7660. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7661. times := strings.Split(startTime, "-")
  7662. setl_mon := times[0] + times[1]
  7663. var result3265 models.JSResult3264
  7664. data := make(map[string]interface{})
  7665. data["org_name"] = miConfig.OrgName
  7666. data["doctor"] = curRoles.UserName
  7667. data["doctor_name"] = curRoles.UserName
  7668. data["fixmedins_code"] = miConfig.Code
  7669. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7670. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7671. data["secret_key"] = miConfig.SecretKey
  7672. data["url"] = miConfig.Url
  7673. data["ak"] = miConfig.AccessKey
  7674. data["cainfo"] = miConfig.Cainfo
  7675. data["setl_mon"] = setl_mon
  7676. data["stmt_loc"] = "2"
  7677. client := &http.Client{}
  7678. bytesData, _ := json.Marshal(data)
  7679. var req *http.Request
  7680. if miConfig.MdtrtareaAdmvs == "320921" {
  7681. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7682. } else {
  7683. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7684. }
  7685. resp, _ := client.Do(req)
  7686. defer resp.Body.Close()
  7687. body, ioErr := ioutil.ReadAll(resp.Body)
  7688. if ioErr != nil {
  7689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7691. }
  7692. var respJSON map[string]interface{}
  7693. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7696. }
  7697. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7698. fmt.Println(respJSON)
  7699. result, _ := json.Marshal(respJSON)
  7700. fmt.Println(result)
  7701. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7702. utils.ErrorLog("解析失败:%v", err)
  7703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7704. }
  7705. if result3265.Infcode != "0" {
  7706. c.ServeSuccessJSON(map[string]interface{}{
  7707. "failed_code": -10,
  7708. "msg": result3265.ErrMsg,
  7709. })
  7710. return
  7711. } else {
  7712. c.ServeSuccessJSON(map[string]interface{}{
  7713. "info": result3265.Output.Data,
  7714. })
  7715. return
  7716. }
  7717. }
  7718. func (c *HisApiController) Get3274() {
  7719. //if miConfig.MdtrtareaAdmvs == "320921" {
  7720. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7721. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7722. // "&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
  7723. //
  7724. //} else {
  7725. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7726. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7727. // "&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
  7728. //
  7729. //}
  7730. }
  7731. func (c *HisApiController) Get3275() {
  7732. //if miConfig.MdtrtareaAdmvs == "320921" {
  7733. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7734. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7735. // "&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
  7736. //
  7737. //} else {
  7738. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7739. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7740. // "&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
  7741. //
  7742. //}
  7743. }
  7744. func (c *HisApiController) Get3276() {
  7745. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7746. //month := c.GetString("month")
  7747. //
  7748. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7749. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7750. //var api string
  7751. //var res Result5301
  7752. //
  7753. //if miConfig.MdtrtareaAdmvs == "320921" {
  7754. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7755. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7756. //} else {
  7757. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7758. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7759. //}
  7760. //
  7761. //resp, requestErr := http.Get(api)
  7762. //if requestErr != nil {
  7763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7764. // return
  7765. //}
  7766. //
  7767. //body, ioErr := ioutil.ReadAll(resp.Body)
  7768. //if ioErr != nil {
  7769. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7771. // return
  7772. //}
  7773. //var respJSON map[string]interface{}
  7774. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7775. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7777. // return
  7778. //}
  7779. //
  7780. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7781. //result, _ := json.Marshal(respJSON)
  7782. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7783. // utils.ErrorLog("解析失败:%v", err)
  7784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. // return
  7786. //}
  7787. }
  7788. func (c *HisApiController) Get3277() {
  7789. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7790. //month := c.GetString("month")
  7791. //
  7792. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7793. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7794. //var api string
  7795. //var res Result5301
  7796. //
  7797. //if miConfig.MdtrtareaAdmvs == "320921" {
  7798. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7799. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7800. //} else {
  7801. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7802. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7803. //}
  7804. //
  7805. //resp, requestErr := http.Get(api)
  7806. //if requestErr != nil {
  7807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7808. // return
  7809. //}
  7810. //
  7811. //body, ioErr := ioutil.ReadAll(resp.Body)
  7812. //if ioErr != nil {
  7813. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7815. // return
  7816. //}
  7817. //var respJSON map[string]interface{}
  7818. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7819. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7820. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7821. // return
  7822. //}
  7823. //
  7824. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7825. //result, _ := json.Marshal(respJSON)
  7826. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7827. // utils.ErrorLog("解析失败:%v", err)
  7828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7829. // return
  7830. //}
  7831. }
  7832. func (c *HisApiController) GetCFYLJG001() {
  7833. admin_user_id, _ := c.GetInt64("admin_user_id")
  7834. patient_id, _ := c.GetInt64("patient_id")
  7835. his_patient_id, _ := c.GetInt64("his_patient_id")
  7836. record_time := c.GetString("record_time")
  7837. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7838. psn, _ := service.GetPsnByPatientId(patient_id)
  7839. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7840. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7841. var cFYLJG001 models.CFYLJG001
  7842. timeLayout := "2006-01-02"
  7843. loc, _ := time.LoadLocation("Local")
  7844. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7845. if err != nil {
  7846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7847. return
  7848. }
  7849. recordDateTime := theTime.Unix()
  7850. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7851. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7852. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7853. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7854. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7855. for _, item := range prescriptions {
  7856. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7857. if his.IdCardType == 1 {
  7858. bas := strings.Split(psn.CardInfo, "|")
  7859. basNumber := bas[1]
  7860. fmt.Println(basNumber)
  7861. card_sn := bas[3]
  7862. card_no := bas[2]
  7863. cFYLJG001.MdtrtCertType = "03"
  7864. cFYLJG001.CardSn = card_sn
  7865. cFYLJG001.MdtrtCertNo = card_no
  7866. cFYLJG001.EcToken = ""
  7867. cFYLJG001.AuthNo = ""
  7868. } else if his.IdCardType == 2 {
  7869. cFYLJG001.MdtrtCertType = "02"
  7870. cFYLJG001.CardSn = ""
  7871. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7872. cFYLJG001.EcToken = ""
  7873. cFYLJG001.AuthNo = ""
  7874. } else if his.IdCardType == 4 {
  7875. cFYLJG001.MdtrtCertType = "01"
  7876. cFYLJG001.CardSn = ""
  7877. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7878. cFYLJG001.EcToken = psn.VerifyNumber
  7879. cFYLJG001.AuthNo = ""
  7880. }
  7881. cFYLJG001.BizTypeCode = "01"
  7882. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7883. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7884. cFYLJG001.RxTypeCode = "1"
  7885. tempTime := time.Unix(item.PreTime, 0)
  7886. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7887. cFYLJG001.PrscTime = timeFormatOne
  7888. var count float64
  7889. if item.Type == 1 {
  7890. for _, sumItem := range item.HisDoctorAdviceInfo {
  7891. count = count + sumItem.PrescribingNumber
  7892. }
  7893. }
  7894. cFYLJG001.RxDrugCnt = count
  7895. cFYLJG001.ValiDays = "2"
  7896. ts := time.Unix(item.PreTime, 0)
  7897. record_time2 := ts.AddDate(0, 0, int(2)).Unix()
  7898. tempTime3 := time.Unix(record_time2, 0)
  7899. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7900. cFYLJG001.ValiEndTime = timeFormat3
  7901. cFYLJG001.RxCotnFlag = "0"
  7902. for _, subItem := range item.HisDoctorAdviceInfo {
  7903. var drug models.RxDrug
  7904. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7905. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7906. drug.RxItemTypeCode = "11"
  7907. drug.DrugDosform = "剂" //TODO
  7908. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7909. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7910. }
  7911. drug.MedcWayDscr = subItem.DeliveryWay
  7912. tempTime2 := time.Unix(subItem.StartTime, 0)
  7913. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7914. drug.MedcBegntime = timeFormatTwo
  7915. if subItem.Day > 0 {
  7916. ts := time.Unix(subItem.StartTime, 0)
  7917. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7918. tempTime4 := time.Unix(record_time, 0)
  7919. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7920. drug.MedcEndtime = timeFormat5
  7921. } else {
  7922. tempTime2 := time.Unix(subItem.StartTime, 0)
  7923. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7924. drug.MedcEndtime = timeFormatTwo
  7925. }
  7926. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7927. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7928. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7929. drug.DrugCnt = subItem.PrescribingNumber
  7930. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7931. drug.DrugGenname = subItem.AdviceName
  7932. drug.MedcWayCodg = subItem.DeliveryWay
  7933. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7934. drug.SinDoscnt = subItem.SingleDose
  7935. drug.SinDosunt = subItem.SingleDoseUnit
  7936. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7937. drug.UsedFrquName = subItem.ExecutionFrequency
  7938. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7939. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7940. drug.HospApprFlag = "1"
  7941. cFYLJG001.List = append(cFYLJG001.List, drug)
  7942. }
  7943. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7944. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  7945. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7946. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7947. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7948. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7949. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7950. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7951. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7952. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7953. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7954. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7955. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7956. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7957. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7958. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7959. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7960. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7961. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7962. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7963. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7964. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7965. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7966. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7967. tempTime2 := time.Now().Unix()
  7968. tempTime6 := time.Unix(tempTime2, 0)
  7969. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7970. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7971. cFYLJG001.Mdtrtinfo.DiseCodg = ""
  7972. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7973. cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
  7974. cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
  7975. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7976. var config []*models.HisXtDiagnoseConfig
  7977. for _, item := range diagnosis_ids {
  7978. id, _ := strconv.ParseInt(item, 10, 64)
  7979. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7980. config = append(config, &diagnosisConfig)
  7981. }
  7982. for index, subitem := range config {
  7983. if index == 0 {
  7984. var dia models.DiseInfo
  7985. dia.DiagType = "1"
  7986. dia.MaindiagFlag = "1"
  7987. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7988. dia.DiagCode = subitem.CountryCode
  7989. dia.DiagName = subitem.ClassName
  7990. dia.DiagDept = "肾内科"
  7991. dia.DiagDrNo = doctor.DoctorNumber
  7992. dia.DiagDrName = doctor.UserName
  7993. tempTime3 := time.Unix(item.PreTime, 0)
  7994. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7995. dia.DiagTime = timeFormatTwo
  7996. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7997. } else {
  7998. var dia models.DiseInfo
  7999. dia.DiagType = "1"
  8000. dia.MaindiagFlag = "0"
  8001. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8002. dia.DiagCode = subitem.CountryCode
  8003. dia.DiagName = subitem.ClassName
  8004. dia.DiagDept = "肾内科"
  8005. dia.DiagDrNo = doctor.DoctorNumber
  8006. dia.DiagDrName = doctor.UserName
  8007. tempTime3 := time.Unix(item.PreTime, 0)
  8008. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8009. dia.DiagTime = timeFormatTwo
  8010. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8011. }
  8012. }
  8013. if miConfig.MdtrtareaAdmvs == "340699" {
  8014. result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
  8015. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8016. var res ResultCFYLJG001AH
  8017. var respJSON2 map[string]interface{}
  8018. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8021. return
  8022. }
  8023. userJSONBytes2, _ := json.Marshal(respJSON2)
  8024. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8025. utils.ErrorLog("解析失败:%v", err)
  8026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8027. return
  8028. }
  8029. var flow models.HisPrescriptionFlow
  8030. flow.Ctime = time.Now().Unix()
  8031. flow.SignDigest = ""
  8032. flow.RxTraceCode = res.RxTraceCode
  8033. flow.HiRxno = res.HiRxno
  8034. flow.MID = his.Number
  8035. flow.Status = 1
  8036. flow.DCode = doctor_info.DoctorNumber
  8037. flow.OriginalRxFile = ""
  8038. flow.OriginalValue = ""
  8039. flow.SignCertDn = ""
  8040. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8041. flow.SignCertSn = ""
  8042. flow.Mtime = time.Now().Unix()
  8043. service.Createflow(&flow)
  8044. c.ServeSuccessJSON(map[string]interface{}{
  8045. "msg": "上传成功",
  8046. })
  8047. } else {
  8048. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  8049. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8050. var res ResultCFYLJG001
  8051. var respJSON2 map[string]interface{}
  8052. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8055. return
  8056. }
  8057. userJSONBytes2, _ := json.Marshal(respJSON2)
  8058. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8059. utils.ErrorLog("解析失败:%v", err)
  8060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8061. return
  8062. }
  8063. if res.Infcode == -1 {
  8064. c.ServeSuccessJSON(map[string]interface{}{
  8065. "failed_code": -10,
  8066. "msg": res.ErrMsg,
  8067. })
  8068. return
  8069. } else {
  8070. var flow models.HisPrescriptionFlow
  8071. flow.Ctime = time.Now().Unix()
  8072. flow.SignDigest = ""
  8073. flow.RxTraceCode = res.Output.RxTraceCode
  8074. flow.HiRxno = res.Output.HiRxno
  8075. flow.MID = his.Number
  8076. flow.Status = 1
  8077. flow.DCode = doctor_info.DoctorNumber
  8078. flow.OriginalRxFile = ""
  8079. flow.OriginalValue = ""
  8080. flow.SignCertDn = ""
  8081. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8082. flow.SignCertSn = ""
  8083. flow.Mtime = time.Now().Unix()
  8084. service.Createflow(&flow)
  8085. c.ServeSuccessJSON(map[string]interface{}{
  8086. "msg": "上传成功",
  8087. })
  8088. }
  8089. }
  8090. }
  8091. }
  8092. func (c *HisApiController) GetCFYLJG12() {
  8093. admin_user_id, _ := c.GetInt64("admin_user_id")
  8094. his_patient_id, _ := c.GetInt64("his_patient_id")
  8095. record_time := c.GetString("record_time")
  8096. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8097. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8098. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8099. flow, _ := service.Getflowtwo(his.Number)
  8100. patient_id, _ := c.GetInt64("patient_id")
  8101. timeLayout := "2006-01-02"
  8102. loc, _ := time.LoadLocation("Local")
  8103. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8104. if err != nil {
  8105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8106. return
  8107. }
  8108. recordDateTime := theTime.Unix()
  8109. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8110. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8111. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8112. dept, _ := service.GetDepartMentDetail(info.Departments)
  8113. inputData := make(map[string]interface{})
  8114. inputData["rxTraceCode"] = flow.RxTraceCode
  8115. inputData["hiRxno"] = flow.HiRxno
  8116. inputData["mdtrtId"] = flow.MID
  8117. inputData["patnName"] = his.PsnName
  8118. inputData["psnCertType"] = his.PsnCertType
  8119. inputData["certno"] = his.Certno
  8120. inputData["fixmedinsName"] = miConfig.OrgName
  8121. inputData["fixmedinsCode"] = miConfig.Code
  8122. inputData["drCode"] = doctor_info.DoctorNumber
  8123. inputData["prscDrName"] = doctor_info.UserName
  8124. inputData["pharDeptName"] = dept.Name
  8125. inputData["pharDeptCode"] = dept.Number
  8126. inputData["pharProfttlCodg"] = ""
  8127. inputData["pharProfttlName"] = ""
  8128. inputData["pharCode"] = "HY340621000425"
  8129. inputData["pharCertType"] = "01"
  8130. inputData["pharCertno"] = ""
  8131. inputData["pharName"] = "孙莉侠"
  8132. inputData["pharPracCertNo"] = ""
  8133. tempTime2 := time.Unix(info.Ctime, 0)
  8134. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8135. inputData["pharChkTime"] = timeFormatTwo
  8136. bytesData, _ := json.Marshal(inputData)
  8137. fmt.Println(string(bytesData))
  8138. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8139. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8140. if err != nil {
  8141. fmt.Println("Error reading PDF file:", err)
  8142. return
  8143. }
  8144. // 将 PDF 文件内容进行 Base64 编码
  8145. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8146. fmt.Println(err)
  8147. if miConfig.MdtrtareaAdmvs == "340699" {
  8148. data := make(map[string]interface{})
  8149. data["rx_encoded"] = rx_encoded
  8150. data["code"] = miConfig.Code
  8151. data["url"] = "http://10.66.149.64:8080/epc/api"
  8152. data["encoded"] = encoded
  8153. client := &http.Client{}
  8154. bytesData, _ := json.Marshal(data)
  8155. var req *http.Request
  8156. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/02", bytes.NewReader(bytesData))
  8157. resp, _ := client.Do(req)
  8158. defer resp.Body.Close()
  8159. body, ioErr := ioutil.ReadAll(resp.Body)
  8160. if ioErr != nil {
  8161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8162. }
  8163. var respJSON map[string]interface{}
  8164. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8167. return
  8168. }
  8169. var resSix10265 ResultSix10265 //1101结果
  8170. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8171. result, _ := json.Marshal(respJSON)
  8172. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8173. utils.ErrorLog("解析失败:%v", err)
  8174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8175. return
  8176. }
  8177. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8178. //saveLog(result, "", "GetCFYLJG002", "GetCFYLJG002")
  8179. } else {
  8180. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8181. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8182. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8183. var res2 AhResult002
  8184. var respJSON2 map[string]interface{}
  8185. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8188. return
  8189. }
  8190. userJSONBytes2, _ := json.Marshal(respJSON2)
  8191. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8192. utils.ErrorLog("解析失败:%v", err)
  8193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8194. return
  8195. }
  8196. flow.Ctime = time.Now().Unix()
  8197. flow.SignDigest = res2.SignDigest
  8198. flow.RxFile = res2.RxFile
  8199. flow.MID = his.Number
  8200. flow.Status = 1
  8201. flow.DCode = doctor_info.DoctorNumber
  8202. flow.OriginalRxFile = rx_encoded
  8203. flow.OriginalValue = encoded
  8204. flow.SignCertDn = res2.SignCertDn
  8205. flow.SignCertSn = res2.SignCertSn
  8206. flow.Mtime = time.Now().Unix()
  8207. service.Saveflow(flow)
  8208. c.ServeSuccessJSON(map[string]interface{}{
  8209. "msg": "预签名成功",
  8210. })
  8211. }
  8212. }
  8213. func (c *HisApiController) GetCFYLJG13() {
  8214. admin_user_id, _ := c.GetInt64("admin_user_id")
  8215. his_patient_id, _ := c.GetInt64("his_patient_id")
  8216. record_time := c.GetString("record_time")
  8217. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8218. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8219. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8220. flow, _ := service.Getflowtwo(his.Number)
  8221. patient_id, _ := c.GetInt64("patient_id")
  8222. timeLayout := "2006-01-02"
  8223. loc, _ := time.LoadLocation("Local")
  8224. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8225. if err != nil {
  8226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8227. return
  8228. }
  8229. recordDateTime := theTime.Unix()
  8230. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8231. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8232. dept, _ := service.GetDepartMentDetail(info.Departments)
  8233. var cFYLJG003 models.CFYLJG003
  8234. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8235. cFYLJG003.HiRxno = flow.HiRxno
  8236. cFYLJG003.MdtrtID = flow.MID
  8237. cFYLJG003.PatnName = his.Name
  8238. cFYLJG003.Certno = his.Certno
  8239. cFYLJG003.FixmedinsName = miConfig.OrgName
  8240. cFYLJG003.FixmedinsCode = miConfig.Code
  8241. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8242. cFYLJG003.PrscDrName = doctor_info.UserName
  8243. cFYLJG003.PharDeptName = dept.Name
  8244. cFYLJG003.PharDeptCode = dept.Number
  8245. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8246. cFYLJG003.PharName = "孙莉侠"
  8247. cFYLJG003.PharPracCertNo = "060399"
  8248. cFYLJG003.PharCode = "HY340621000425"
  8249. cFYLJG003.PharCertType = "01"
  8250. cFYLJG003.PharCertno = ""
  8251. } else {
  8252. cFYLJG003.PharName = "彭斯遥"
  8253. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8254. cFYLJG003.PharCode = "HY440309002107"
  8255. cFYLJG003.PharCertType = "01"
  8256. cFYLJG003.PharCertno = "430482199408260023"
  8257. }
  8258. cFYLJG003.PsnCertType = "01"
  8259. cFYLJG003.RxFile = flow.RxFile
  8260. cFYLJG003.SignDigest = flow.SignDigest
  8261. cFYLJG003.FixmedinsCode = miConfig.Code
  8262. cFYLJG003.PsnCertType = "01"
  8263. cFYLJG003.PharProfttlCodg = dept.Name
  8264. tempTime2 := time.Unix(info.Ctime, 0)
  8265. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8266. cFYLJG003.PharChkTime = timeFormatTwo
  8267. if miConfig.MdtrtareaAdmvs == "340699" {
  8268. data := make(map[string]interface{})
  8269. data["url"] = "http://10.66.149.64:8080/epc/api"
  8270. data["13"] = cFYLJG003
  8271. client := &http.Client{}
  8272. bytesData, _ := json.Marshal(data)
  8273. var req *http.Request
  8274. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/03", bytes.NewReader(bytesData))
  8275. resp, _ := client.Do(req)
  8276. defer resp.Body.Close()
  8277. body, ioErr := ioutil.ReadAll(resp.Body)
  8278. if ioErr != nil {
  8279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8280. }
  8281. var respJSON map[string]interface{}
  8282. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8285. return
  8286. }
  8287. var resSix10265 ResultSix10265 //1101结果
  8288. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8289. result, _ := json.Marshal(respJSON)
  8290. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8291. utils.ErrorLog("解析失败:%v", err)
  8292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8293. return
  8294. }
  8295. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8296. //saveLog(result, "", "GetCFYLJG013", "GetCFYLJG013")
  8297. } else {
  8298. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8299. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8300. var res ResultCFYLJG003
  8301. var respJSON2 map[string]interface{}
  8302. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8305. return
  8306. }
  8307. userJSONBytes2, _ := json.Marshal(respJSON2)
  8308. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8309. utils.ErrorLog("解析失败:%v", err)
  8310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8311. return
  8312. }
  8313. if res.Infcode == -1 {
  8314. c.ServeSuccessJSON(map[string]interface{}{
  8315. "failed_code": -10,
  8316. "msg": res.ErrMsg,
  8317. })
  8318. return
  8319. } else {
  8320. c.ServeSuccessJSON(map[string]interface{}{
  8321. "info": res.Output,
  8322. })
  8323. }
  8324. }
  8325. }
  8326. func (c *HisApiController) GetCFYLJG002() {
  8327. admin_user_id, _ := c.GetInt64("admin_user_id")
  8328. his_patient_id, _ := c.GetInt64("his_patient_id")
  8329. record_time := c.GetString("record_time")
  8330. admin_user_id = 3626
  8331. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8332. //id, _ := c.GetInt64("id")
  8333. admin_user_id = 3626
  8334. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8335. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8336. flow, _ := service.Getflowtwo(his.Number)
  8337. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8338. //record_time := c.GetString("record_time")
  8339. patient_id, _ := c.GetInt64("patient_id")
  8340. //patient_id = 23834
  8341. //record_time = "2023-09-18"
  8342. timeLayout := "2006-01-02"
  8343. loc, _ := time.LoadLocation("Local")
  8344. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8345. if err != nil {
  8346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8347. return
  8348. }
  8349. recordDateTime := theTime.Unix()
  8350. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8351. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8352. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8353. dept, _ := service.GetDepartMentDetail(info.Departments)
  8354. inputData := make(map[string]interface{})
  8355. inputData["rxTraceCode"] = flow.RxTraceCode
  8356. inputData["hiRxno"] = flow.HiRxno
  8357. inputData["mdtrtId"] = flow.MID
  8358. inputData["patnName"] = his.PsnName
  8359. inputData["psnCertType"] = his.PsnCertType
  8360. inputData["certno"] = his.Certno
  8361. inputData["fixmedinsName"] = miConfig.OrgName
  8362. inputData["fixmedinsCode"] = miConfig.Code
  8363. inputData["drCode"] = doctor_info.DoctorNumber
  8364. inputData["prscDrName"] = doctor_info.UserName
  8365. inputData["pharDeptName"] = dept.Name
  8366. inputData["pharDeptCode"] = dept.Number
  8367. inputData["pharProfttlCodg"] = ""
  8368. inputData["pharProfttlName"] = ""
  8369. inputData["pharCode"] = "HY340621000425"
  8370. inputData["pharCertType"] = "01"
  8371. inputData["pharCertno"] = ""
  8372. inputData["pharName"] = "孙莉侠"
  8373. inputData["pharPracCertNo"] = "060399"
  8374. tempTime2 := time.Unix(info.Ctime, 0)
  8375. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8376. inputData["pharChkTime"] = timeFormatTwo
  8377. bytesData, _ := json.Marshal(inputData)
  8378. fmt.Println(string(bytesData))
  8379. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8380. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8381. if err != nil {
  8382. fmt.Println("Error reading PDF file:", err)
  8383. return
  8384. }
  8385. // 将 PDF 文件内容进行 Base64 编码
  8386. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8387. fmt.Println(err)
  8388. if miConfig.MdtrtareaAdmvs == "340699" {
  8389. result, request := service.GetAHCFYLJG002(miConfig.Code, "http://10.66.149.64:8080/epc/api", encoded, rx_encoded, "")
  8390. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8391. var res2 AhResult002
  8392. var respJSON2 map[string]interface{}
  8393. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8396. return
  8397. }
  8398. userJSONBytes2, _ := json.Marshal(respJSON2)
  8399. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8400. utils.ErrorLog("解析失败:%v", err)
  8401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8402. return
  8403. }
  8404. flow.Ctime = time.Now().Unix()
  8405. flow.SignDigest = res2.SignDigest
  8406. flow.RxFile = res2.RxFile
  8407. flow.MID = his.Number
  8408. flow.Status = 1
  8409. flow.DCode = doctor_info.DoctorNumber
  8410. flow.OriginalRxFile = rx_encoded
  8411. flow.OriginalValue = encoded
  8412. flow.SignCertDn = res2.SignCertDn
  8413. flow.SignCertSn = res2.SignCertSn
  8414. flow.Mtime = time.Now().Unix()
  8415. service.Saveflow(flow)
  8416. c.ServeSuccessJSON(map[string]interface{}{
  8417. "msg": "预签名成功",
  8418. })
  8419. } else {
  8420. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8421. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8422. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8423. var res2 Result002
  8424. var respJSON2 map[string]interface{}
  8425. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8428. return
  8429. }
  8430. userJSONBytes2, _ := json.Marshal(respJSON2)
  8431. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8432. utils.ErrorLog("解析失败:%v", err)
  8433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8434. return
  8435. }
  8436. if res2.Infcode == 0 {
  8437. flow.Ctime = time.Now().Unix()
  8438. flow.SignDigest = res2.Output.SignDigest
  8439. flow.RxFile = res2.Output.RxFile
  8440. flow.MID = his.Number
  8441. flow.Status = 1
  8442. flow.DCode = doctor_info.DoctorNumber
  8443. flow.OriginalRxFile = rx_encoded
  8444. flow.OriginalValue = encoded
  8445. flow.SignCertDn = res2.Output.SignCertDn
  8446. flow.SignCertSn = res2.Output.SignCertSn
  8447. flow.Mtime = time.Now().Unix()
  8448. service.Saveflow(flow)
  8449. c.ServeSuccessJSON(map[string]interface{}{
  8450. "msg": "预签名成功",
  8451. })
  8452. } else {
  8453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8454. return
  8455. }
  8456. }
  8457. }
  8458. func (c *HisApiController) GetCFYLJG003() {
  8459. admin_user_id, _ := c.GetInt64("admin_user_id")
  8460. his_patient_id, _ := c.GetInt64("his_patient_id")
  8461. record_time := c.GetString("record_time")
  8462. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8463. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8464. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8465. flow, _ := service.Getflowtwo(his.Number)
  8466. patient_id, _ := c.GetInt64("patient_id")
  8467. timeLayout := "2006-01-02"
  8468. loc, _ := time.LoadLocation("Local")
  8469. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8470. if err != nil {
  8471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8472. return
  8473. }
  8474. recordDateTime := theTime.Unix()
  8475. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8476. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8477. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8478. dept, _ := service.GetDepartMentDetail(info.Departments)
  8479. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8480. var cFYLJG003 models.CFYLJG003
  8481. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8482. cFYLJG003.HiRxno = flow.HiRxno
  8483. cFYLJG003.MdtrtID = flow.MID
  8484. cFYLJG003.PatnName = his.PsnName
  8485. cFYLJG003.Certno = his.Certno
  8486. cFYLJG003.FixmedinsName = miConfig.OrgName
  8487. cFYLJG003.FixmedinsCode = miConfig.Code
  8488. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8489. cFYLJG003.PrscDrName = doctor_info.UserName
  8490. cFYLJG003.PharDeptName = dept.Name
  8491. cFYLJG003.PharDeptCode = dept.Number
  8492. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8493. cFYLJG003.PharName = "孙莉侠"
  8494. cFYLJG003.PharPracCertNo = "060399"
  8495. cFYLJG003.PharCode = "HY340621000425"
  8496. cFYLJG003.PharCertType = "01"
  8497. cFYLJG003.PharCertno = ""
  8498. } else {
  8499. cFYLJG003.PharName = "彭斯遥"
  8500. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8501. cFYLJG003.PharCode = "HY440309002107"
  8502. cFYLJG003.PharCertType = "01"
  8503. cFYLJG003.PharCertno = "430482199408260023"
  8504. }
  8505. cFYLJG003.RxFile = flow.RxFile
  8506. cFYLJG003.SignDigest = flow.SignDigest
  8507. cFYLJG003.FixmedinsCode = miConfig.Code
  8508. cFYLJG003.PsnCertType = his.PsnCertType
  8509. tempTime2 := time.Unix(info.Ctime, 0)
  8510. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8511. cFYLJG003.PharChkTime = timeFormatTwo
  8512. if miConfig.MdtrtareaAdmvs == "340699" {
  8513. result, request := service.GetAHCFYLJG003("http://10.66.149.64:8080/epc/api", cFYLJG003)
  8514. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  8515. var res AHResult003
  8516. var respJSON2 map[string]interface{}
  8517. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8520. return
  8521. }
  8522. userJSONBytes2, _ := json.Marshal(respJSON2)
  8523. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8524. utils.ErrorLog("解析失败:%v", err)
  8525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8526. return
  8527. }
  8528. {
  8529. c.ServeSuccessJSON(map[string]interface{}{
  8530. "info": res,
  8531. })
  8532. }
  8533. } else {
  8534. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8535. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8536. var res ResultCFYLJG003
  8537. var respJSON2 map[string]interface{}
  8538. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8541. return
  8542. }
  8543. userJSONBytes2, _ := json.Marshal(respJSON2)
  8544. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8545. utils.ErrorLog("解析失败:%v", err)
  8546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8547. return
  8548. }
  8549. if res.Infcode == -1 {
  8550. c.ServeSuccessJSON(map[string]interface{}{
  8551. "failed_code": -10,
  8552. "msg": res.ErrMsg,
  8553. })
  8554. return
  8555. } else {
  8556. c.ServeSuccessJSON(map[string]interface{}{
  8557. "info": res.Output,
  8558. })
  8559. }
  8560. }
  8561. }
  8562. func (c *HisApiController) GetCFYLJG004() {
  8563. admin_user_id, _ := c.GetInt64("admin_user_id")
  8564. his_patient_id, _ := c.GetInt64("his_patient_id")
  8565. record_time := c.GetString("record_time")
  8566. admin_user_id = 3626
  8567. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8568. //id, _ := c.GetInt64("id")
  8569. admin_user_id = 3626
  8570. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8571. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8572. flow, _ := service.Getflowtwo(his.Number)
  8573. //id = 3
  8574. patient_id, _ := c.GetInt64("patient_id")
  8575. //patient_id = 23834
  8576. //record_time = "2023-09-18"
  8577. timeLayout := "2006-01-02"
  8578. loc, _ := time.LoadLocation("Local")
  8579. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8580. if err != nil {
  8581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8582. return
  8583. }
  8584. recordDateTime := theTime.Unix()
  8585. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8586. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8587. var cFYLJG004 models.CFYLJG004
  8588. cFYLJG004.HiRxno = flow.HiRxno
  8589. cFYLJG004.FixmedinsCode = miConfig.Code
  8590. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8591. cFYLJG004.UndoDrCertType = "01"
  8592. cFYLJG004.UndoRea = "撤销处方"
  8593. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8594. cFYLJG004.UndoDrName = doctor_info.UserName
  8595. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8596. if miConfig.MdtrtareaAdmvs == "340699" {
  8597. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8598. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8599. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  8600. } else {
  8601. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8602. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8603. var res ResultCFYLJG004
  8604. var respJSON2 map[string]interface{}
  8605. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8608. return
  8609. }
  8610. userJSONBytes2, _ := json.Marshal(respJSON2)
  8611. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8612. utils.ErrorLog("解析失败:%v", err)
  8613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8614. return
  8615. }
  8616. if res.Infcode == -1 {
  8617. c.ServeSuccessJSON(map[string]interface{}{
  8618. "failed_code": -10,
  8619. "msg": res.ErrMsg,
  8620. })
  8621. return
  8622. } else {
  8623. flow.Status = 0
  8624. service.Saveflow(flow)
  8625. c.ServeSuccessJSON(map[string]interface{}{
  8626. "msg": "撤销成功",
  8627. })
  8628. return
  8629. }
  8630. }
  8631. }
  8632. func (c *HisApiController) GetCFYLJG005() {
  8633. admin_user_id, _ := c.GetInt64("admin_user_id")
  8634. his_patient_id, _ := c.GetInt64("his_patient_id")
  8635. //record_time := c.GetString("record_time")
  8636. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8637. //id, _ := c.GetInt64("id")
  8638. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8639. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8640. flow, _ := service.Getflowtwo(his.Number)
  8641. //id = 3
  8642. var cFYLJG005 models.CFYLJG005
  8643. //patient_id, _ := c.GetInt64("patient_id")
  8644. cFYLJG005.HiRxno = flow.HiRxno
  8645. cFYLJG005.MdtrtID = flow.MID
  8646. cFYLJG005.EcToken = ""
  8647. cFYLJG005.PsnName = his.Name
  8648. cFYLJG005.PsnCertType = "01"
  8649. cFYLJG005.Certno = his.IdCardNo
  8650. if miConfig.MdtrtareaAdmvs == "340699" {
  8651. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8652. result, request := service.GetAHCFYLJG005(miConfig.Code, cFYLJG005)
  8653. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8654. } else {
  8655. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8656. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8657. var res ResultCFYLJG005
  8658. var respJSON2 map[string]interface{}
  8659. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8662. return
  8663. }
  8664. userJSONBytes2, _ := json.Marshal(respJSON2)
  8665. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8666. utils.ErrorLog("解析失败:%v", err)
  8667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8668. return
  8669. }
  8670. if res.Infcode == -1 {
  8671. c.ServeSuccessJSON(map[string]interface{}{
  8672. "failed_code": -10,
  8673. "msg": res.ErrMsg,
  8674. })
  8675. return
  8676. } else {
  8677. c.ServeSuccessJSON(map[string]interface{}{
  8678. "info": res.Output,
  8679. })
  8680. return
  8681. }
  8682. }
  8683. }
  8684. func (c *HisApiController) GetCFYLJG006() {
  8685. admin_user_id, _ := c.GetInt64("admin_user_id")
  8686. his_patient_id, _ := c.GetInt64("his_patient_id")
  8687. admin_user_id = 3626
  8688. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8689. //id, _ := c.GetInt64("id")
  8690. admin_user_id = 3626
  8691. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8692. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8693. flow, _ := service.Getflowtwo(his.Number)
  8694. //id = 3
  8695. patient_id, _ := c.GetInt64("patient_id")
  8696. var cFYLJG006 models.CFYLJG006
  8697. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8698. cFYLJG006.HiRxno = flow.HiRxno
  8699. cFYLJG006.MdtrtID = flow.MID
  8700. cFYLJG006.PsnName = patient.Name
  8701. cFYLJG006.PsnCertType = "01"
  8702. cFYLJG006.Certno = patient.IdCardNo
  8703. if miConfig.MdtrtareaAdmvs == "340699" {
  8704. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8705. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8706. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8707. } else {
  8708. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8709. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8710. var res ResultCFYLJG006
  8711. var respJSON2 map[string]interface{}
  8712. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8715. return
  8716. }
  8717. userJSONBytes2, _ := json.Marshal(respJSON2)
  8718. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8719. utils.ErrorLog("解析失败:%v", err)
  8720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8721. return
  8722. }
  8723. if res.Infcode == -1 {
  8724. c.ServeSuccessJSON(map[string]interface{}{
  8725. "failed_code": -10,
  8726. "msg": res.ErrMsg,
  8727. })
  8728. return
  8729. } else {
  8730. c.ServeSuccessJSON(map[string]interface{}{
  8731. "info": res.Output,
  8732. })
  8733. return
  8734. }
  8735. }
  8736. }
  8737. func (c *HisApiController) GetCFYLJG007() {
  8738. admin_user_id, _ := c.GetInt64("admin_user_id")
  8739. his_patient_id, _ := c.GetInt64("his_patient_id")
  8740. admin_user_id = 3626
  8741. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8742. //id, _ := c.GetInt64("id")
  8743. admin_user_id = 3626
  8744. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8745. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8746. flow, _ := service.Getflowtwo(his.Number)
  8747. //id = 3
  8748. patient_id, _ := c.GetInt64("patient_id")
  8749. var cFYLJG007 models.CFYLJG007
  8750. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8751. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8752. cFYLJG007.HiRxno = flow.HiRxno
  8753. cFYLJG007.MdtrtID = flow.MID
  8754. cFYLJG007.PsnNo = his.PsnNo
  8755. cFYLJG007.PsnCertType = "01"
  8756. cFYLJG007.Certno = patient.IdCardNo
  8757. cFYLJG007.PsnName = patient.Name
  8758. if miConfig.MdtrtareaAdmvs == "340699" {
  8759. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8760. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8761. } else {
  8762. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8763. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8764. var res ResultCFYLJG007
  8765. var respJSON2 map[string]interface{}
  8766. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8769. return
  8770. }
  8771. userJSONBytes2, _ := json.Marshal(respJSON2)
  8772. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8773. utils.ErrorLog("解析失败:%v", err)
  8774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8775. return
  8776. }
  8777. if res.Infcode == -1 {
  8778. c.ServeSuccessJSON(map[string]interface{}{
  8779. "failed_code": -10,
  8780. "msg": res.ErrMsg,
  8781. })
  8782. return
  8783. } else {
  8784. c.ServeSuccessJSON(map[string]interface{}{
  8785. "info": res,
  8786. })
  8787. return
  8788. }
  8789. }
  8790. }
  8791. func (c *HisApiController) GetCFYLJG008() {
  8792. admin_user_id, _ := c.GetInt64("admin_user_id")
  8793. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8794. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8795. var cFYLJG008 models.CFYLJG008
  8796. //id, _ := c.GetInt64("id")
  8797. patient_id, _ := c.GetInt64("patient_id")
  8798. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8799. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8800. //id = 3
  8801. //flow, _ := service.Getflow(id)
  8802. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8803. //
  8804. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8805. //patient_id, _ := c.GetInt64("patient_id")
  8806. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8807. record_time := c.GetString("record_time")
  8808. admin_user_id = 3626
  8809. patient_id = 19424
  8810. //his_patient_id = 263947
  8811. record_time = "2023-08-29"
  8812. timeLayout := "2006-01-02"
  8813. loc, _ := time.LoadLocation("Local")
  8814. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8815. if err != nil {
  8816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8817. return
  8818. }
  8819. recordDateTime := theTime.Unix()
  8820. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8821. cFYLJG008.FixmedinsName = ""
  8822. cFYLJG008.Lat = ""
  8823. cFYLJG008.Lng = ""
  8824. cFYLJG008.OrderType = "1"
  8825. cFYLJG008.PoolareaNo = ""
  8826. cFYLJG008.Lng = ""
  8827. cFYLJG008.PageNum = 1
  8828. cFYLJG008.PageSize = 10
  8829. var MPI models.MedinsProdInvChgDDTO
  8830. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8831. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8832. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8833. if miConfig.MdtrtareaAdmvs == "340699" {
  8834. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8835. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8836. } else {
  8837. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8838. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8839. var res ResultCFYLJG008
  8840. var respJSON2 map[string]interface{}
  8841. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8844. return
  8845. }
  8846. userJSONBytes2, _ := json.Marshal(respJSON2)
  8847. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8848. utils.ErrorLog("解析失败:%v", err)
  8849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8850. return
  8851. }
  8852. if res.Infcode == -1 {
  8853. c.ServeSuccessJSON(map[string]interface{}{
  8854. "failed_code": -10,
  8855. "msg": res.ErrMsg,
  8856. })
  8857. return
  8858. } else {
  8859. c.ServeSuccessJSON(map[string]interface{}{
  8860. "info": res.Output,
  8861. })
  8862. return
  8863. }
  8864. }
  8865. }
  8866. func (c *HisApiController) GetBL4201A() {
  8867. order_id, _ := c.GetInt64("order_id")
  8868. admin_user_id, _ := c.GetInt64("admin_user_id")
  8869. order, _ := service.GetHisOrderByIDTwo(order_id)
  8870. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8871. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8872. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8873. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8874. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8875. department, _ := service.GetDepartMentDetail(his.Departments)
  8876. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8877. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8878. if order.ID == 0 {
  8879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8880. return
  8881. }
  8882. var struct4201A models.Struct4201A
  8883. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8884. for _, items := range order_info {
  8885. memo := make(map[string]interface{})
  8886. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8887. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8888. fsiOPFLD.MedType = "14"
  8889. fsiOPFLD.BkkpSn = items.FeedetlSn
  8890. fsiOPFLD.FixmedinsCode = miConfig.Code
  8891. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8892. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8893. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8894. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8895. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8896. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8897. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8898. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8899. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8900. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8901. fsiOPFLD.BilgDeptName = department.Name
  8902. fsiOPFLD.BilgDeptCodg = department.Number
  8903. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8904. fsiOPFLD.BilgDrName = doctor.UserName
  8905. fsiOPFLD.MedChrgitmType = "09"
  8906. memo["hosp_appr_flag"] = "1"
  8907. memo["invoice_no"] = order.MdtrtId
  8908. memo["memo"] = "自费"
  8909. bytesData, _ := json.Marshal(memo)
  8910. fsiOPFLD.Memo = string(bytesData)
  8911. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8912. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8913. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8914. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8915. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8916. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8917. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8918. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8919. fsiOPFLD.BilgDeptName = department.Name
  8920. fsiOPFLD.BilgDeptCodg = department.Number
  8921. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8922. fsiOPFLD.BilgDrName = doctor.UserName
  8923. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8924. case 0:
  8925. break
  8926. case 1:
  8927. fsiOPFLD.MedChrgitmType = "14"
  8928. break
  8929. case 2:
  8930. fsiOPFLD.MedChrgitmType = "05"
  8931. break
  8932. case 3:
  8933. fsiOPFLD.MedChrgitmType = "03"
  8934. break
  8935. case 4:
  8936. fsiOPFLD.MedChrgitmType = "03"
  8937. break
  8938. case 5:
  8939. fsiOPFLD.MedChrgitmType = "08"
  8940. break
  8941. case 6:
  8942. fsiOPFLD.MedChrgitmType = "14"
  8943. break
  8944. case 7:
  8945. fsiOPFLD.MedChrgitmType = "14"
  8946. break
  8947. case 8:
  8948. fsiOPFLD.MedChrgitmType = "03"
  8949. break
  8950. case 9:
  8951. fsiOPFLD.MedChrgitmType = "14"
  8952. break
  8953. case 10:
  8954. fsiOPFLD.MedChrgitmType = "14"
  8955. break
  8956. case 11:
  8957. fsiOPFLD.MedChrgitmType = "06"
  8958. break
  8959. case 12:
  8960. fsiOPFLD.MedChrgitmType = "12"
  8961. break
  8962. case 13:
  8963. fsiOPFLD.MedChrgitmType = "01"
  8964. break
  8965. case 14:
  8966. fsiOPFLD.MedChrgitmType = "04"
  8967. break
  8968. case 15:
  8969. fsiOPFLD.MedChrgitmType = "14"
  8970. break
  8971. }
  8972. memo["hosp_appr_flag"] = "1"
  8973. memo["invoice_no"] = order.MdtrtId
  8974. memo["memo"] = "自费"
  8975. bytesData, _ := json.Marshal(memo)
  8976. fsiOPFLD.Memo = string(bytesData)
  8977. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8978. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8979. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8980. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8981. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8982. fsiOPFLD.BilgDeptName = department.Name
  8983. fsiOPFLD.BilgDeptCodg = department.Number
  8984. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8985. fsiOPFLD.BilgDrName = doctor.UserName
  8986. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8987. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8988. fsiOPFLD.MedChrgitmType = "08"
  8989. memo["hosp_appr_flag"] = "1"
  8990. memo["invoice_no"] = order.MdtrtId
  8991. memo["memo"] = "自费"
  8992. bytesData, _ := json.Marshal(memo)
  8993. fsiOPFLD.Memo = string(bytesData)
  8994. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8995. }
  8996. }
  8997. }
  8998. for _, items := range order_info_two {
  8999. memo := make(map[string]interface{})
  9000. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9001. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9002. fsiOPFLD.MedType = "14"
  9003. fsiOPFLD.BkkpSn = items.FeedetlSn
  9004. fsiOPFLD.FixmedinsCode = miConfig.Code
  9005. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9006. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9007. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9008. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9009. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9010. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9011. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9012. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9013. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9014. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9015. fsiOPFLD.BilgDeptName = department.Name
  9016. fsiOPFLD.BilgDeptCodg = department.Number
  9017. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9018. fsiOPFLD.BilgDrName = doctor.UserName
  9019. fsiOPFLD.MedChrgitmType = "09"
  9020. memo["hosp_appr_flag"] = "1"
  9021. memo["invoice_no"] = order.MdtrtId
  9022. memo["memo"] = "自费"
  9023. bytesData, _ := json.Marshal(memo)
  9024. fsiOPFLD.Memo = string(bytesData)
  9025. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9026. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9027. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9028. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9029. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9030. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9031. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9032. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9033. fsiOPFLD.BilgDeptName = department.Name
  9034. fsiOPFLD.BilgDeptCodg = department.Number
  9035. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9036. fsiOPFLD.BilgDrName = doctor.UserName
  9037. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9038. case 0:
  9039. break
  9040. case 1:
  9041. fsiOPFLD.MedChrgitmType = "14"
  9042. break
  9043. case 2:
  9044. fsiOPFLD.MedChrgitmType = "05"
  9045. break
  9046. case 3:
  9047. fsiOPFLD.MedChrgitmType = "03"
  9048. break
  9049. case 4:
  9050. fsiOPFLD.MedChrgitmType = "03"
  9051. break
  9052. case 5:
  9053. fsiOPFLD.MedChrgitmType = "08"
  9054. break
  9055. case 6:
  9056. fsiOPFLD.MedChrgitmType = "14"
  9057. break
  9058. case 7:
  9059. fsiOPFLD.MedChrgitmType = "14"
  9060. break
  9061. case 8:
  9062. fsiOPFLD.MedChrgitmType = "03"
  9063. break
  9064. case 9:
  9065. fsiOPFLD.MedChrgitmType = "14"
  9066. break
  9067. case 10:
  9068. fsiOPFLD.MedChrgitmType = "14"
  9069. break
  9070. case 11:
  9071. fsiOPFLD.MedChrgitmType = "06"
  9072. break
  9073. case 12:
  9074. fsiOPFLD.MedChrgitmType = "12"
  9075. break
  9076. case 13:
  9077. fsiOPFLD.MedChrgitmType = "01"
  9078. break
  9079. case 14:
  9080. fsiOPFLD.MedChrgitmType = "04"
  9081. break
  9082. case 15:
  9083. fsiOPFLD.MedChrgitmType = "14"
  9084. break
  9085. }
  9086. memo["hosp_appr_flag"] = "1"
  9087. memo["invoice_no"] = order.MdtrtId
  9088. memo["memo"] = "自费"
  9089. bytesData, _ := json.Marshal(memo)
  9090. fsiOPFLD.Memo = string(bytesData)
  9091. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9092. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9093. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9094. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9095. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9096. fsiOPFLD.BilgDeptName = department.Name
  9097. fsiOPFLD.BilgDeptCodg = department.Number
  9098. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9099. fsiOPFLD.BilgDrName = doctor.UserName
  9100. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9101. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9102. fsiOPFLD.MedChrgitmType = "08"
  9103. memo["hosp_appr_flag"] = "1"
  9104. memo["invoice_no"] = order.MdtrtId
  9105. memo["memo"] = "自费"
  9106. bytesData, _ := json.Marshal(memo)
  9107. fsiOPFLD.Memo = string(bytesData)
  9108. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9109. }
  9110. }
  9111. }
  9112. fmt.Println(fsiOPFLDs)
  9113. struct4201A.Fopfd = fsiOPFLDs
  9114. fmt.Println(struct4201A.Fopfd)
  9115. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9116. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9117. var res2 ResultSix
  9118. var respJSON2 map[string]interface{}
  9119. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9122. return
  9123. }
  9124. userJSONBytes2, _ := json.Marshal(respJSON2)
  9125. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9126. utils.ErrorLog("解析失败:%v", err)
  9127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9128. return
  9129. }
  9130. if res2.Infcode != 0 {
  9131. c.ServeSuccessJSON(map[string]interface{}{
  9132. "failed_code": -10,
  9133. "msg": res2.ErrMsg,
  9134. })
  9135. return
  9136. } else {
  9137. order.IsUploadOrderInfo = 1
  9138. service.UpdateOrder(order)
  9139. c.ServeSuccessJSON(map[string]interface{}{
  9140. "msg": "上传成功",
  9141. })
  9142. }
  9143. }
  9144. func (c *HisApiController) Get3103() {
  9145. admin_user_id, _ := c.GetInt64("admin_user_id")
  9146. warm_type, _ := c.GetInt64("warm_type")
  9147. fk_state, _ := c.GetInt64("fk_state")
  9148. warm_ids := c.GetString("warm_ids")
  9149. desc := c.GetString("desc")
  9150. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9151. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9152. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  9153. saveLog(result, requestLog, "3103", "反馈")
  9154. var res2 ResultSix3103
  9155. var respJSON2 map[string]interface{}
  9156. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9159. return
  9160. }
  9161. userJSONBytes2, _ := json.Marshal(respJSON2)
  9162. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9163. utils.ErrorLog("解析失败:%v", err)
  9164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9165. return
  9166. }
  9167. if res2.Infcode != 0 {
  9168. c.ServeSuccessJSON(map[string]interface{}{
  9169. "failed_code": -10,
  9170. "msg": res2.ErrMsg,
  9171. })
  9172. return
  9173. } else {
  9174. c.ServeSuccessJSON(map[string]interface{}{
  9175. "msg": "反馈成功",
  9176. })
  9177. return
  9178. }
  9179. }
  9180. func (c *HisApiController) Get4201A() {
  9181. order_id, _ := c.GetInt64("order_id")
  9182. admin_user_id, _ := c.GetInt64("admin_user_id")
  9183. order, _ := service.GetHisOrderByIDTwo(order_id)
  9184. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9185. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9186. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9187. //order_info = append(order_info, order_info_two...)
  9188. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9189. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9190. department, _ := service.GetDepartMentDetail(his.Departments)
  9191. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9192. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9193. if order.ID == 0 {
  9194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9195. return
  9196. }
  9197. var struct4201A models.Struct4201A
  9198. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9199. for _, items := range order_info {
  9200. memo := make(map[string]interface{})
  9201. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9202. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9203. fsiOPFLD.MedType = "14"
  9204. fsiOPFLD.BkkpSn = items.FeedetlSn
  9205. fsiOPFLD.FixmedinsCode = miConfig.Code
  9206. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9207. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9208. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9209. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9210. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9211. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9212. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9213. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9214. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9215. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9216. fsiOPFLD.BilgDeptName = department.Name
  9217. fsiOPFLD.BilgDeptCodg = department.Number
  9218. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9219. fsiOPFLD.BilgDrName = doctor.UserName
  9220. fsiOPFLD.MedChrgitmType = "09"
  9221. memo["hosp_appr_flag"] = "1"
  9222. memo["invoice_no"] = order.MdtrtId
  9223. memo["memo"] = "自费"
  9224. bytesData, _ := json.Marshal(memo)
  9225. fsiOPFLD.Memo = string(bytesData)
  9226. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9227. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9228. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9229. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9230. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9231. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9232. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9233. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9234. fsiOPFLD.BilgDeptName = department.Name
  9235. fsiOPFLD.BilgDeptCodg = department.Number
  9236. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9237. fsiOPFLD.BilgDrName = doctor.UserName
  9238. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9239. case 0:
  9240. break
  9241. case 1:
  9242. fsiOPFLD.MedChrgitmType = "14"
  9243. break
  9244. case 2:
  9245. fsiOPFLD.MedChrgitmType = "05"
  9246. break
  9247. case 3:
  9248. fsiOPFLD.MedChrgitmType = "03"
  9249. break
  9250. case 4:
  9251. fsiOPFLD.MedChrgitmType = "03"
  9252. break
  9253. case 5:
  9254. fsiOPFLD.MedChrgitmType = "08"
  9255. break
  9256. case 6:
  9257. fsiOPFLD.MedChrgitmType = "14"
  9258. break
  9259. case 7:
  9260. fsiOPFLD.MedChrgitmType = "14"
  9261. break
  9262. case 8:
  9263. fsiOPFLD.MedChrgitmType = "03"
  9264. break
  9265. case 9:
  9266. fsiOPFLD.MedChrgitmType = "14"
  9267. break
  9268. case 10:
  9269. fsiOPFLD.MedChrgitmType = "14"
  9270. break
  9271. case 11:
  9272. fsiOPFLD.MedChrgitmType = "06"
  9273. break
  9274. case 12:
  9275. fsiOPFLD.MedChrgitmType = "12"
  9276. break
  9277. case 13:
  9278. fsiOPFLD.MedChrgitmType = "01"
  9279. break
  9280. case 14:
  9281. fsiOPFLD.MedChrgitmType = "04"
  9282. break
  9283. case 15:
  9284. fsiOPFLD.MedChrgitmType = "14"
  9285. break
  9286. }
  9287. memo["hosp_appr_flag"] = "1"
  9288. memo["invoice_no"] = order.MdtrtId
  9289. memo["memo"] = "自费"
  9290. bytesData, _ := json.Marshal(memo)
  9291. fsiOPFLD.Memo = string(bytesData)
  9292. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9293. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9294. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9295. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9296. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9297. fsiOPFLD.BilgDeptName = department.Name
  9298. fsiOPFLD.BilgDeptCodg = department.Number
  9299. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9300. fsiOPFLD.BilgDrName = doctor.UserName
  9301. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9302. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9303. fsiOPFLD.MedChrgitmType = "08"
  9304. memo["hosp_appr_flag"] = "1"
  9305. memo["invoice_no"] = order.MdtrtId
  9306. memo["memo"] = "自费"
  9307. bytesData, _ := json.Marshal(memo)
  9308. fsiOPFLD.Memo = string(bytesData)
  9309. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9310. }
  9311. }
  9312. }
  9313. for _, items := range order_info_two {
  9314. memo := make(map[string]interface{})
  9315. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9316. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9317. fsiOPFLD.MedType = "14"
  9318. fsiOPFLD.BkkpSn = items.FeedetlSn
  9319. fsiOPFLD.FixmedinsCode = miConfig.Code
  9320. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9321. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9322. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9323. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9324. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9325. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9326. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9327. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9328. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9329. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9330. fsiOPFLD.BilgDeptName = department.Name
  9331. fsiOPFLD.BilgDeptCodg = department.Number
  9332. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9333. fsiOPFLD.BilgDrName = doctor.UserName
  9334. fsiOPFLD.MedChrgitmType = "09"
  9335. memo["hosp_appr_flag"] = "1"
  9336. memo["invoice_no"] = order.MdtrtId
  9337. memo["memo"] = "自费"
  9338. bytesData, _ := json.Marshal(memo)
  9339. fsiOPFLD.Memo = string(bytesData)
  9340. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9341. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9342. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9343. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9344. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9345. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9346. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9347. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9348. fsiOPFLD.BilgDeptName = department.Name
  9349. fsiOPFLD.BilgDeptCodg = department.Number
  9350. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9351. fsiOPFLD.BilgDrName = doctor.UserName
  9352. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9353. case 0:
  9354. break
  9355. case 1:
  9356. fsiOPFLD.MedChrgitmType = "14"
  9357. break
  9358. case 2:
  9359. fsiOPFLD.MedChrgitmType = "05"
  9360. break
  9361. case 3:
  9362. fsiOPFLD.MedChrgitmType = "03"
  9363. break
  9364. case 4:
  9365. fsiOPFLD.MedChrgitmType = "03"
  9366. break
  9367. case 5:
  9368. fsiOPFLD.MedChrgitmType = "08"
  9369. break
  9370. case 6:
  9371. fsiOPFLD.MedChrgitmType = "14"
  9372. break
  9373. case 7:
  9374. fsiOPFLD.MedChrgitmType = "14"
  9375. break
  9376. case 8:
  9377. fsiOPFLD.MedChrgitmType = "03"
  9378. break
  9379. case 9:
  9380. fsiOPFLD.MedChrgitmType = "14"
  9381. break
  9382. case 10:
  9383. fsiOPFLD.MedChrgitmType = "14"
  9384. break
  9385. case 11:
  9386. fsiOPFLD.MedChrgitmType = "06"
  9387. break
  9388. case 12:
  9389. fsiOPFLD.MedChrgitmType = "12"
  9390. break
  9391. case 13:
  9392. fsiOPFLD.MedChrgitmType = "01"
  9393. break
  9394. case 14:
  9395. fsiOPFLD.MedChrgitmType = "04"
  9396. break
  9397. case 15:
  9398. fsiOPFLD.MedChrgitmType = "14"
  9399. break
  9400. }
  9401. memo["hosp_appr_flag"] = "1"
  9402. memo["invoice_no"] = order.MdtrtId
  9403. memo["memo"] = "自费"
  9404. bytesData, _ := json.Marshal(memo)
  9405. fsiOPFLD.Memo = string(bytesData)
  9406. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9407. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9408. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9409. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9410. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9411. fsiOPFLD.BilgDeptName = department.Name
  9412. fsiOPFLD.BilgDeptCodg = department.Number
  9413. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9414. fsiOPFLD.BilgDrName = doctor.UserName
  9415. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9416. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9417. fsiOPFLD.MedChrgitmType = "08"
  9418. memo["hosp_appr_flag"] = "1"
  9419. memo["invoice_no"] = order.MdtrtId
  9420. memo["memo"] = "自费"
  9421. bytesData, _ := json.Marshal(memo)
  9422. fsiOPFLD.Memo = string(bytesData)
  9423. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9424. }
  9425. }
  9426. }
  9427. fmt.Println(fsiOPFLDs)
  9428. struct4201A.Fopfd = fsiOPFLDs
  9429. fmt.Println(struct4201A.Fopfd)
  9430. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9431. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9432. var res2 ResultSix
  9433. var respJSON2 map[string]interface{}
  9434. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9437. return
  9438. }
  9439. userJSONBytes2, _ := json.Marshal(respJSON2)
  9440. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9441. utils.ErrorLog("解析失败:%v", err)
  9442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9443. return
  9444. }
  9445. if res2.Infcode != 0 {
  9446. c.ServeSuccessJSON(map[string]interface{}{
  9447. "failed_code": -10,
  9448. "msg": res2.ErrMsg,
  9449. })
  9450. return
  9451. } else {
  9452. order.IsUploadOrderInfo = 1
  9453. service.UpdateOrder(order)
  9454. c.ServeSuccessJSON(map[string]interface{}{
  9455. "msg": "上传成功",
  9456. })
  9457. }
  9458. }
  9459. func (c *HisApiController) Get4202() {
  9460. order_id, _ := c.GetInt64("order_id")
  9461. admin_user_id, _ := c.GetInt64("admin_user_id")
  9462. order, _ := service.GetHisOrderByIDTwo(order_id)
  9463. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9464. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9465. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9466. if order.ID == 0 {
  9467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9468. return
  9469. }
  9470. var struct4202 models.Struct4202
  9471. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9472. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9473. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9474. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9475. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9476. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9477. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9478. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9479. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9480. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9481. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9482. var config []*models.HisXtDiagnoseConfig
  9483. for _, item := range diagnosis_ids {
  9484. id, _ := strconv.ParseInt(item, 10, 64)
  9485. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9486. config = append(config, &diagnosisConfig)
  9487. }
  9488. var tempDiaginfos []models.OwnPayPatnDiagListD
  9489. for index, item := range config {
  9490. if index == 0 {
  9491. var tempDiaginfo models.OwnPayPatnDiagListD
  9492. tempDiaginfo.InoutDiagType = "1"
  9493. tempDiaginfo.DiagCode = item.CountryCode
  9494. tempDiaginfo.DiagName = item.CountryContentName
  9495. tempDiaginfo.DiagType = "1"
  9496. tempDiaginfo.DiagSrtNo = "1"
  9497. tempDiaginfo.MaindiagFlag = "1"
  9498. tempDiaginfo.ValiFlag = "1"
  9499. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9500. } else {
  9501. var tempDiaginfo models.OwnPayPatnDiagListD
  9502. tempDiaginfo.DiagCode = item.CountryCode
  9503. tempDiaginfo.DiagName = item.CountryContentName
  9504. tempDiaginfo.DiagType = "2"
  9505. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9506. tempDiaginfo.MaindiagFlag = "0"
  9507. tempDiaginfo.ValiFlag = "1"
  9508. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9509. }
  9510. }
  9511. struct4202.ODiagListD = tempDiaginfos
  9512. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9513. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9514. var res2 ResultSix
  9515. var respJSON2 map[string]interface{}
  9516. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9519. return
  9520. }
  9521. userJSONBytes2, _ := json.Marshal(respJSON2)
  9522. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9523. utils.ErrorLog("解析失败:%v", err)
  9524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9525. return
  9526. }
  9527. if res2.Infcode != 0 {
  9528. c.ServeSuccessJSON(map[string]interface{}{
  9529. "failed_code": -10,
  9530. "msg": res2.ErrMsg,
  9531. })
  9532. return
  9533. } else {
  9534. order.IsUploadDiagnose = 1
  9535. service.UpdateOrder(order)
  9536. c.ServeSuccessJSON(map[string]interface{}{
  9537. "msg": "上传成功",
  9538. })
  9539. }
  9540. }
  9541. func (c *HisApiController) Get4203() {
  9542. admin_user_id, _ := c.GetInt64("admin_user_id")
  9543. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9544. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9545. order_id, _ := c.GetInt64("order_id")
  9546. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9547. number := ""
  9548. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9549. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9550. if his.ID == 0 {
  9551. number = hospital.Number
  9552. } else {
  9553. number = his.Number
  9554. }
  9555. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9556. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9557. var res2 ResultSix
  9558. var respJSON2 map[string]interface{}
  9559. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9562. return
  9563. }
  9564. userJSONBytes2, _ := json.Marshal(respJSON2)
  9565. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9566. utils.ErrorLog("解析失败:%v", err)
  9567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9568. return
  9569. }
  9570. if res2.Infcode != 0 {
  9571. c.ServeSuccessJSON(map[string]interface{}{
  9572. "failed_code": -10,
  9573. "msg": res2.ErrMsg,
  9574. })
  9575. return
  9576. } else {
  9577. order.IsUploadSuccess = 1
  9578. service.UpdateOrderTwo(order)
  9579. c.ServeSuccessJSON(map[string]interface{}{
  9580. "msg": "上传成功",
  9581. })
  9582. }
  9583. }
  9584. func (c *HisApiController) Get4205() {
  9585. order_id, _ := c.GetInt64("order_id")
  9586. admin_user_id, _ := c.GetInt64("admin_user_id")
  9587. fapiao_code := c.GetString("fapiao_code")
  9588. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9589. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9590. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9591. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9592. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9593. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9594. //order_info = append(order_info, order_info_two...)
  9595. department, _ := service.GetDepartMentDetail(his.Departments)
  9596. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9597. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9598. if order.ID == 0 {
  9599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9600. return
  9601. }
  9602. var struct4201A models.Struct4201A
  9603. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9604. for _, items := range order_info {
  9605. memo := make(map[string]interface{})
  9606. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9607. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9608. fsiOPFLD.MedType = pre.MedType
  9609. fsiOPFLD.FixmedinsCode = miConfig.Code
  9610. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9611. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9612. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9613. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9614. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9615. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.StartTime, 0).Format("2006-01-02 15:04:05")
  9616. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9617. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9618. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9619. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9620. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9621. fsiOPFLD.BilgDeptName = department.Name
  9622. fsiOPFLD.BilgDeptCodg = department.Number
  9623. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9624. fsiOPFLD.BilgDrName = doctor.UserName
  9625. fsiOPFLD.MedChrgitmType = "09"
  9626. memo["hosp_appr_flag"] = "1"
  9627. memo["invoice_no"] = fapiao_code
  9628. memo["memo"] = "自费"
  9629. bytesData, _ := json.Marshal(memo)
  9630. fsiOPFLD.Memo = string(bytesData)
  9631. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9632. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9633. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9634. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9635. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.StartTime, 0).Format("2006-01-02 15:04:05")
  9636. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9637. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9638. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9639. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9640. fsiOPFLD.BilgDeptName = department.Name
  9641. fsiOPFLD.BilgDeptCodg = department.Number
  9642. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9643. fsiOPFLD.BilgDrName = doctor.UserName
  9644. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9645. case 0:
  9646. break
  9647. case 1:
  9648. fsiOPFLD.MedChrgitmType = "14"
  9649. break
  9650. case 2:
  9651. fsiOPFLD.MedChrgitmType = "05"
  9652. break
  9653. case 3:
  9654. fsiOPFLD.MedChrgitmType = "03"
  9655. break
  9656. case 4:
  9657. fsiOPFLD.MedChrgitmType = "03"
  9658. break
  9659. case 5:
  9660. fsiOPFLD.MedChrgitmType = "08"
  9661. break
  9662. case 6:
  9663. fsiOPFLD.MedChrgitmType = "14"
  9664. break
  9665. case 7:
  9666. fsiOPFLD.MedChrgitmType = "14"
  9667. break
  9668. case 8:
  9669. fsiOPFLD.MedChrgitmType = "03"
  9670. break
  9671. case 9:
  9672. fsiOPFLD.MedChrgitmType = "14"
  9673. break
  9674. case 10:
  9675. fsiOPFLD.MedChrgitmType = "14"
  9676. break
  9677. case 11:
  9678. fsiOPFLD.MedChrgitmType = "06"
  9679. break
  9680. case 12:
  9681. fsiOPFLD.MedChrgitmType = "12"
  9682. break
  9683. case 13:
  9684. fsiOPFLD.MedChrgitmType = "01"
  9685. break
  9686. case 14:
  9687. fsiOPFLD.MedChrgitmType = "04"
  9688. break
  9689. case 15:
  9690. fsiOPFLD.MedChrgitmType = "14"
  9691. break
  9692. }
  9693. memo["hosp_appr_flag"] = "1"
  9694. memo["invoice_no"] = fapiao_code
  9695. memo["memo"] = "自费"
  9696. bytesData, _ := json.Marshal(memo)
  9697. fsiOPFLD.Memo = string(bytesData)
  9698. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9699. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9700. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9701. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9702. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9703. fsiOPFLD.BilgDeptName = department.Name
  9704. fsiOPFLD.BilgDeptCodg = department.Number
  9705. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9706. fsiOPFLD.BilgDrName = doctor.UserName
  9707. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9708. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9709. fsiOPFLD.MedChrgitmType = "08"
  9710. memo["hosp_appr_flag"] = "1"
  9711. memo["invoice_no"] = fapiao_code
  9712. memo["memo"] = "自费"
  9713. bytesData, _ := json.Marshal(memo)
  9714. fsiOPFLD.Memo = string(bytesData)
  9715. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9716. }
  9717. }
  9718. }
  9719. for _, items := range order_info_two {
  9720. memo := make(map[string]interface{})
  9721. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9722. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9723. fsiOPFLD.MedType = pre.MedType
  9724. fsiOPFLD.BkkpSn = items.FeedetlSn
  9725. fsiOPFLD.FixmedinsCode = miConfig.Code
  9726. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9727. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9728. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9729. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9730. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9731. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9732. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9733. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9734. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9735. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9736. fsiOPFLD.BilgDeptName = department.Name
  9737. fsiOPFLD.BilgDeptCodg = department.Number
  9738. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9739. fsiOPFLD.BilgDrName = doctor.UserName
  9740. fsiOPFLD.MedChrgitmType = "09"
  9741. memo["hosp_appr_flag"] = "1"
  9742. memo["invoice_no"] = fapiao_code
  9743. memo["memo"] = "自费"
  9744. bytesData, _ := json.Marshal(memo)
  9745. fsiOPFLD.Memo = string(bytesData)
  9746. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9747. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9748. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9749. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9750. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9751. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9752. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9753. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9754. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9755. fsiOPFLD.BilgDeptName = department.Name
  9756. fsiOPFLD.BilgDeptCodg = department.Number
  9757. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9758. fsiOPFLD.BilgDrName = doctor.UserName
  9759. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9760. case 0:
  9761. break
  9762. case 1:
  9763. fsiOPFLD.MedChrgitmType = "14"
  9764. break
  9765. case 2:
  9766. fsiOPFLD.MedChrgitmType = "05"
  9767. break
  9768. case 3:
  9769. fsiOPFLD.MedChrgitmType = "03"
  9770. break
  9771. case 4:
  9772. fsiOPFLD.MedChrgitmType = "03"
  9773. break
  9774. case 5:
  9775. fsiOPFLD.MedChrgitmType = "08"
  9776. break
  9777. case 6:
  9778. fsiOPFLD.MedChrgitmType = "14"
  9779. break
  9780. case 7:
  9781. fsiOPFLD.MedChrgitmType = "14"
  9782. break
  9783. case 8:
  9784. fsiOPFLD.MedChrgitmType = "03"
  9785. break
  9786. case 9:
  9787. fsiOPFLD.MedChrgitmType = "14"
  9788. break
  9789. case 10:
  9790. fsiOPFLD.MedChrgitmType = "14"
  9791. break
  9792. case 11:
  9793. fsiOPFLD.MedChrgitmType = "06"
  9794. break
  9795. case 12:
  9796. fsiOPFLD.MedChrgitmType = "12"
  9797. break
  9798. case 13:
  9799. fsiOPFLD.MedChrgitmType = "01"
  9800. break
  9801. case 14:
  9802. fsiOPFLD.MedChrgitmType = "04"
  9803. break
  9804. case 15:
  9805. fsiOPFLD.MedChrgitmType = "14"
  9806. break
  9807. }
  9808. memo["hosp_appr_flag"] = "1"
  9809. memo["invoice_no"] = fapiao_code
  9810. memo["memo"] = "自费"
  9811. bytesData, _ := json.Marshal(memo)
  9812. fsiOPFLD.Memo = string(bytesData)
  9813. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9814. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9815. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9816. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9817. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9818. fsiOPFLD.BilgDeptName = department.Name
  9819. fsiOPFLD.BilgDeptCodg = department.Number
  9820. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9821. fsiOPFLD.BilgDrName = doctor.UserName
  9822. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9823. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9824. fsiOPFLD.MedChrgitmType = "08"
  9825. memo["hosp_appr_flag"] = "1"
  9826. memo["invoice_no"] = fapiao_code
  9827. memo["memo"] = "自费"
  9828. bytesData, _ := json.Marshal(memo)
  9829. fsiOPFLD.Memo = string(bytesData)
  9830. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9831. }
  9832. }
  9833. }
  9834. fmt.Println(fsiOPFLDs)
  9835. struct4201A.Fopfd = fsiOPFLDs
  9836. fmt.Println(struct4201A.Fopfd)
  9837. var struct4202 models.Struct4202
  9838. timeLayout := "2006-01-02 15:04:05"
  9839. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9840. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9841. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9842. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9843. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9844. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9845. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9846. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9847. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9848. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9849. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9850. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9851. var config []*models.HisXtDiagnoseConfig
  9852. for _, item := range diagnosis_ids {
  9853. id, _ := strconv.ParseInt(item, 10, 64)
  9854. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9855. config = append(config, &diagnosisConfig)
  9856. }
  9857. var tempDiaginfos []models.OwnPayPatnDiagListD
  9858. for index, item := range config {
  9859. if index == 0 {
  9860. var tempDiaginfo models.OwnPayPatnDiagListD
  9861. tempDiaginfo.InoutDiagType = "1"
  9862. tempDiaginfo.DiagCode = item.CountryCode
  9863. tempDiaginfo.DiagName = item.CountryContentName
  9864. tempDiaginfo.DiagType = "1"
  9865. tempDiaginfo.DiagSrtNo = "1"
  9866. tempDiaginfo.MaindiagFlag = "1"
  9867. tempDiaginfo.ValiFlag = "1"
  9868. tempDiaginfo.DiagDrName = doctor.UserName
  9869. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9870. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9871. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9872. } else {
  9873. var tempDiaginfo models.OwnPayPatnDiagListD
  9874. tempDiaginfo.DiagCode = item.CountryCode
  9875. tempDiaginfo.DiagName = item.CountryContentName
  9876. tempDiaginfo.DiagType = "2"
  9877. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9878. tempDiaginfo.MaindiagFlag = "0"
  9879. tempDiaginfo.ValiFlag = "1"
  9880. tempDiaginfo.DiagDrName = doctor.UserName
  9881. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9882. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9883. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9884. }
  9885. }
  9886. struct4202.ODiagListD = tempDiaginfos
  9887. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9888. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9889. var res2 ResultSix
  9890. var respJSON2 map[string]interface{}
  9891. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9894. return
  9895. }
  9896. userJSONBytes2, _ := json.Marshal(respJSON2)
  9897. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9898. utils.ErrorLog("解析失败:%v", err)
  9899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9900. return
  9901. }
  9902. if res2.Infcode != 0 {
  9903. c.ServeSuccessJSON(map[string]interface{}{
  9904. "failed_code": -10,
  9905. "msg": res2.ErrMsg,
  9906. })
  9907. return
  9908. } else {
  9909. order.IsUploadDiagnose = 1
  9910. order.IsUploadOrderInfo = 1
  9911. service.UpdateOrderTwo(order)
  9912. c.ServeSuccessJSON(map[string]interface{}{
  9913. "msg": "上传成功",
  9914. })
  9915. }
  9916. }
  9917. func (c *HisApiController) Get4207() {
  9918. admin_user_id, _ := c.GetInt64("admin_user_id")
  9919. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9920. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9921. order_id, _ := c.GetInt64("order_id")
  9922. order, _ := service.GetHisOrderByIDTwo(order_id)
  9923. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9924. var struct4207 models.Struct4207
  9925. struct4207.PageNum = "1"
  9926. struct4207.PageSize = "1000"
  9927. struct4207.FixmedinsCode = miConfig.Code
  9928. struct4207.FixmedinsMdtrtID = order.Number
  9929. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9930. saveLog(result, requestLog, "4207", "查询")
  9931. var res2 ResultSix
  9932. var respJSON2 map[string]interface{}
  9933. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9936. return
  9937. }
  9938. userJSONBytes2, _ := json.Marshal(respJSON2)
  9939. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9940. utils.ErrorLog("解析失败:%v", err)
  9941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9942. return
  9943. }
  9944. if res2.Infcode != 0 {
  9945. c.ServeSuccessJSON(map[string]interface{}{
  9946. "failed_code": -10,
  9947. "msg": res2.ErrMsg,
  9948. })
  9949. return
  9950. } else {
  9951. c.ServeSuccessJSON(map[string]interface{}{
  9952. "msg": "查询成功",
  9953. })
  9954. }
  9955. }
  9956. func (c *HisApiController) Get4208() {
  9957. admin_user_id, _ := c.GetInt64("admin_user_id")
  9958. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9959. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9960. order_id, _ := c.GetInt64("order_id")
  9961. order, _ := service.GetHisOrderByIDTwo(order_id)
  9962. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9963. var struct4208 models.Struct4208
  9964. struct4208.PageNum = "1"
  9965. struct4208.PageSize = "1000"
  9966. struct4208.PsnCertType = "01"
  9967. struct4208.Certno = his.Certno
  9968. struct4208.MedType = order.MedType
  9969. struct4208.PsnName = his.Name
  9970. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9971. saveLog(result, requestLog, "4208", "查询")
  9972. var res2 ResultSix
  9973. var respJSON2 map[string]interface{}
  9974. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9977. return
  9978. }
  9979. userJSONBytes2, _ := json.Marshal(respJSON2)
  9980. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9981. utils.ErrorLog("解析失败:%v", err)
  9982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9983. return
  9984. }
  9985. if res2.Infcode != 0 {
  9986. c.ServeSuccessJSON(map[string]interface{}{
  9987. "failed_code": -10,
  9988. "msg": res2.ErrMsg,
  9989. })
  9990. return
  9991. } else {
  9992. c.ServeSuccessJSON(map[string]interface{}{
  9993. "msg": "查询成功",
  9994. })
  9995. }
  9996. }
  9997. func (c *HisApiController) Get4209() {
  9998. admin_user_id, _ := c.GetInt64("admin_user_id")
  9999. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10000. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10001. order_id, _ := c.GetInt64("order_id")
  10002. order, _ := service.GetHisOrderByIDTwo(order_id)
  10003. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10004. var struct4209 models.Struct4209
  10005. struct4209.FixmedinsMdtrtID = order.Number
  10006. struct4209.FixmedinsCode = miConfig.Code
  10007. struct4209.PageSize = "1000"
  10008. struct4209.PageNum = "1"
  10009. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  10010. saveLog(result, requestLog, "4209", "查询")
  10011. var res2 ResultSix
  10012. var respJSON2 map[string]interface{}
  10013. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10016. return
  10017. }
  10018. userJSONBytes2, _ := json.Marshal(respJSON2)
  10019. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10020. utils.ErrorLog("解析失败:%v", err)
  10021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10022. return
  10023. }
  10024. if res2.Infcode != 0 {
  10025. c.ServeSuccessJSON(map[string]interface{}{
  10026. "failed_code": -10,
  10027. "msg": res2.ErrMsg,
  10028. })
  10029. return
  10030. } else {
  10031. c.ServeSuccessJSON(map[string]interface{}{
  10032. "msg": "查询成功",
  10033. })
  10034. }
  10035. }
  10036. type Result3101 struct {
  10037. Infcode string `json:"infcode"`
  10038. InfRefmsgid string `json:"inf_refmsgid"`
  10039. RefmsgTime string `json:"refmsg_time"`
  10040. RespondTime string `json:"respond_time"`
  10041. Enctype string `json:"enctype"`
  10042. Signtype string `json:"signtype"`
  10043. ErrMsg string `json:"err_msg"`
  10044. Output struct {
  10045. Result []struct {
  10046. JudgeResultDetailDtos []struct {
  10047. VolaItemType string `json:"vola_item_type"`
  10048. MdtrtID string `json:"mdtrt_id"`
  10049. JrdID string `json:"jrd_id"`
  10050. PatnID string `json:"patn_id"`
  10051. RxID string `json:"rx_id"`
  10052. VolaAmt interface{} `json:"vola_amt"`
  10053. } `json:"judge_result_detail_dtos"`
  10054. RuleID string `json:"rule_id"`
  10055. VolaEvid string `json:"vola_evid"`
  10056. MdtrtID string `json:"mdtrt_id"`
  10057. RuleName string `json:"rule_name"`
  10058. VolaAmtStas string `json:"vola_amt_stas"`
  10059. JrID string `json:"jr_id"`
  10060. PatnID string `json:"patn_id"`
  10061. SevDeg string `json:"sev_deg"`
  10062. VolaAmt float64 `json:"vola_amt"`
  10063. VolaBhvrType string `json:"vola_bhvr_type"`
  10064. VolaCont string `json:"vola_cont"`
  10065. } `json:"result"`
  10066. } `json:"output"`
  10067. }
  10068. type Resultgd3101 struct {
  10069. Infcode int64 `json:"infcode"`
  10070. InfRefmsgid string `json:"inf_refmsgid"`
  10071. RefmsgTime string `json:"refmsg_time"`
  10072. RespondTime string `json:"respond_time"`
  10073. Enctype string `json:"enctype"`
  10074. Signtype string `json:"signtype"`
  10075. ErrMsg string `json:"err_msg"`
  10076. Output struct {
  10077. Result []struct {
  10078. JudgeResultDetailDtos []struct {
  10079. VolaItemType string `json:"vola_item_type"`
  10080. MdtrtID string `json:"mdtrt_id"`
  10081. JrdID string `json:"jrd_id"`
  10082. PatnID string `json:"patn_id"`
  10083. RxID string `json:"rx_id"`
  10084. VolaAmt interface{} `json:"vola_amt"`
  10085. } `json:"judge_result_detail_dtos"`
  10086. RuleID string `json:"rule_id"`
  10087. VolaEvid string `json:"vola_evid"`
  10088. MdtrtID string `json:"mdtrt_id"`
  10089. RuleName string `json:"rule_name"`
  10090. VolaAmtStas string `json:"vola_amt_stas"`
  10091. JrID string `json:"jr_id"`
  10092. PatnID string `json:"patn_id"`
  10093. SevDeg string `json:"sev_deg"`
  10094. VolaAmt float64 `json:"vola_amt"`
  10095. VolaBhvrType string `json:"vola_bhvr_type"`
  10096. VolaCont string `json:"vola_cont"`
  10097. } `json:"result"`
  10098. } `json:"output"`
  10099. }
  10100. func (c *HisApiController) ReadEleToken() {
  10101. admin_user_id, _ := c.GetInt64("admin_user_id")
  10102. his_patient_id, _ := c.GetInt64("his_patient_id")
  10103. adminUser := c.GetAdminUserInfo()
  10104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10105. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10106. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10107. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10108. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10109. if len(tokens) > 0 {
  10110. c.ServeSuccessJSON(map[string]interface{}{
  10111. "msg": "读取成功",
  10112. })
  10113. } else {
  10114. c.ServeSuccessJSON(map[string]interface{}{
  10115. "failed_code": -10,
  10116. "msg": "读取失败",
  10117. })
  10118. }
  10119. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10120. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10121. if len(tokens) > 0 {
  10122. c.ServeSuccessJSON(map[string]interface{}{
  10123. "msg": "读取成功",
  10124. })
  10125. } else {
  10126. c.ServeSuccessJSON(map[string]interface{}{
  10127. "failed_code": -10,
  10128. "msg": "读取失败",
  10129. })
  10130. }
  10131. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10132. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10133. if len(tokens) > 0 {
  10134. c.ServeSuccessJSON(map[string]interface{}{
  10135. "msg": "读取成功",
  10136. })
  10137. } else {
  10138. c.ServeSuccessJSON(map[string]interface{}{
  10139. "failed_code": -10,
  10140. "msg": "读取失败",
  10141. })
  10142. }
  10143. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10144. var api string
  10145. 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 +
  10146. "&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"
  10147. resp, requestErr := http.Get(api)
  10148. if requestErr != nil {
  10149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10150. }
  10151. body, ioErr := ioutil.ReadAll(resp.Body)
  10152. if ioErr != nil {
  10153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10155. }
  10156. var respJSON map[string]interface{}
  10157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10160. return
  10161. }
  10162. var status string
  10163. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10164. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10165. var token string
  10166. var res ResultTwo //1101结果
  10167. var res10265 ResultTwo10265 //1101结果
  10168. if status == "0" { //读卡成功
  10169. var card_info string //卡信息
  10170. var busi_card_info string
  10171. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10172. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10173. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10174. fmt.Println(card_info)
  10175. fmt.Println(busi_card_info)
  10176. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10177. result, _ := json.Marshal(respJSON)
  10178. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10179. utils.ErrorLog("解析失败:%v", err)
  10180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10181. return
  10182. }
  10183. res.ErrMsg = res10265.ErrMsg
  10184. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10185. res.Infcode = infocode
  10186. res.Output = res10265.Output
  10187. res.InfRefmsgid = res10265.InfRefmsgid
  10188. if res.Infcode == 0 {
  10189. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10190. if err == gorm.ErrRecordNotFound {
  10191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10192. return
  10193. } else if err != nil {
  10194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10195. return
  10196. } else {
  10197. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10198. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10199. infoStr := string(Iinfos)
  10200. idetinfoStr := string(Idetinfos)
  10201. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  10202. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10203. psn := &models.HisPsn{
  10204. PsnNo: res.Output.Baseinfo.PsnNo,
  10205. PatientId: patient.ID,
  10206. Certno: res.Output.Baseinfo.Certno,
  10207. Gend: res.Output.Baseinfo.Gend,
  10208. Naty: res.Output.Baseinfo.Naty,
  10209. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10210. PsnName: res.Output.Baseinfo.PsnName,
  10211. Age: float64(age),
  10212. Brdy: b,
  10213. Idetinfo: idetinfoStr,
  10214. Insuinfo: infoStr,
  10215. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10216. CardInfo: card_info,
  10217. VerifyNumber: token,
  10218. IdCardType: 4,
  10219. }
  10220. var rf []*ResultFive
  10221. json.Unmarshal([]byte(infoStr), &rf)
  10222. var insutypes []*ResultFive
  10223. var insutype string
  10224. var is390 int = 0
  10225. var is310 int = 0
  10226. for _, item := range rf {
  10227. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10228. insutypes = append(insutypes, item)
  10229. }
  10230. }
  10231. if len(insutypes) == 1 {
  10232. insutype = insutypes[0].Insutype
  10233. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10234. } else {
  10235. for _, i := range insutypes {
  10236. if i.Insutype == "390" {
  10237. is390 = 1
  10238. }
  10239. if i.Insutype == "310" {
  10240. is310 = 1
  10241. }
  10242. }
  10243. }
  10244. if is390 == 1 {
  10245. insutype = "390"
  10246. }
  10247. if is310 == 1 {
  10248. insutype = "310"
  10249. }
  10250. if len(insutypes) == 0 {
  10251. insutype = "310"
  10252. }
  10253. service.CreateHisPsn(psn)
  10254. c.ServeSuccessJSON(map[string]interface{}{
  10255. "patient": patient,
  10256. "number": token,
  10257. "insutype": insutype,
  10258. })
  10259. }
  10260. } else {
  10261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10262. return
  10263. }
  10264. } else { //读卡失败
  10265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10266. return
  10267. }
  10268. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10269. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  10270. if len(errMsg) == 0 {
  10271. type ELeData struct {
  10272. Data struct {
  10273. IdNo string `json:"idNo"`
  10274. IdType string `json:"idType"`
  10275. UserName string `json:"userName"`
  10276. EcToken string `json:"ecToken"`
  10277. InsuOrg string `json:"insuOrg"`
  10278. Gender string `json:"gender"`
  10279. Birthday string `json:"birthday"`
  10280. Nationality string `json:"nationality"`
  10281. Email string `json:"email"`
  10282. Extra string `json:"extra"`
  10283. } `json:"data"`
  10284. Code int `json:"code"`
  10285. Message string `json:"message"`
  10286. }
  10287. var ele ELeData
  10288. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10289. if err != nil {
  10290. utils.ErrorLog("解析失败:%v", err)
  10291. }
  10292. token := ele.Data.EcToken
  10293. if len(token) > 0 {
  10294. psn := &models.HisPsn{
  10295. PsnNo: his.PsnNo,
  10296. Age: 0,
  10297. PatientId: his.PatientId,
  10298. Certno: his.Certno,
  10299. Brdy: his.Brdy,
  10300. Gend: his.Gend,
  10301. Naty: his.Naty,
  10302. PsnCertType: his.PsnCertType,
  10303. PsnName: his.PsnName,
  10304. Idetinfo: his.Idetinfo,
  10305. Insuinfo: his.Iinfo,
  10306. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10307. CardInfo: outPutInfo,
  10308. VerifyNumber: token,
  10309. }
  10310. service.CreateHisPsn(psn)
  10311. }
  10312. if len(token) > 0 {
  10313. c.ServeSuccessJSON(map[string]interface{}{
  10314. "msg": "读取成功",
  10315. })
  10316. } else {
  10317. c.ServeSuccessJSON(map[string]interface{}{
  10318. "failed_code": -10,
  10319. "msg": "读取失败",
  10320. })
  10321. }
  10322. }
  10323. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10324. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10325. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10326. type ELeData struct {
  10327. Data struct {
  10328. IdNo string `json:"idNo"`
  10329. IdType string `json:"idType"`
  10330. UserName string `json:"userName"`
  10331. EcToken string `json:"ecToken"`
  10332. InsuOrg string `json:"insuOrg"`
  10333. Gender string `json:"gender"`
  10334. Birthday string `json:"birthday"`
  10335. Nationality string `json:"nationality"`
  10336. Email string `json:"email"`
  10337. Extra string `json:"extra"`
  10338. } `json:"data"`
  10339. Code int `json:"code"`
  10340. Message string `json:"message"`
  10341. }
  10342. var ele ELeData
  10343. err := json.Unmarshal([]byte(result), &ele)
  10344. if err != nil {
  10345. utils.ErrorLog("解析失败:%v", err)
  10346. }
  10347. token := ele.Data.EcToken
  10348. token = Remove0000(token)
  10349. fmt.Println(ele.Data.UserName)
  10350. 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)
  10351. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10352. var res ResultTwo
  10353. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10354. utils.ErrorLog("解析失败:%v", err)
  10355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10356. return
  10357. }
  10358. if res.Infcode == 0 {
  10359. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10360. if err == gorm.ErrRecordNotFound {
  10361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10362. return
  10363. } else if err != nil {
  10364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10365. return
  10366. } else {
  10367. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10368. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10369. infoStr := string(Iinfos)
  10370. idetinfoStr := string(Idetinfos)
  10371. psn := &models.HisPsn{
  10372. PsnNo: res.Output.Baseinfo.PsnNo,
  10373. PatientId: patient.ID,
  10374. Certno: res.Output.Baseinfo.Certno,
  10375. Gend: res.Output.Baseinfo.Gend,
  10376. Naty: res.Output.Baseinfo.Naty,
  10377. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10378. PsnName: res.Output.Baseinfo.PsnName,
  10379. Idetinfo: idetinfoStr,
  10380. Insuinfo: infoStr,
  10381. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10382. CardInfo: "",
  10383. VerifyNumber: token,
  10384. }
  10385. service.CreateHisPsn(psn)
  10386. c.ServeSuccessJSON(map[string]interface{}{
  10387. "patient": patient,
  10388. "number": token,
  10389. })
  10390. }
  10391. } else {
  10392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10393. return
  10394. }
  10395. } else if miConfig.MdtrtareaAdmvs == "361025" {
  10396. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10397. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10398. type ELeData struct {
  10399. Data struct {
  10400. IdNo string `json:"idNo"`
  10401. IdType string `json:"idType"`
  10402. UserName string `json:"userName"`
  10403. EcToken string `json:"ecToken"`
  10404. InsuOrg string `json:"insuOrg"`
  10405. Gender string `json:"gender"`
  10406. Birthday string `json:"birthday"`
  10407. Nationality string `json:"nationality"`
  10408. Email string `json:"email"`
  10409. Extra string `json:"extra"`
  10410. } `json:"data"`
  10411. Code int `json:"code"`
  10412. Message string `json:"message"`
  10413. }
  10414. var ele ELeData
  10415. err := json.Unmarshal([]byte(result), &ele)
  10416. if err != nil {
  10417. utils.ErrorLog("解析失败:%v", err)
  10418. }
  10419. token := ele.Data.EcToken
  10420. token = Remove0000(token)
  10421. fmt.Println(ele.Data.UserName)
  10422. 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)
  10423. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10424. var res ResultTwo
  10425. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10426. utils.ErrorLog("解析失败:%v", err)
  10427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10428. return
  10429. }
  10430. if res.Infcode == 0 {
  10431. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10432. if err == gorm.ErrRecordNotFound {
  10433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10434. return
  10435. } else if err != nil {
  10436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10437. return
  10438. } else {
  10439. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10440. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10441. infoStr := string(Iinfos)
  10442. idetinfoStr := string(Idetinfos)
  10443. psn := &models.HisPsn{
  10444. PsnNo: res.Output.Baseinfo.PsnNo,
  10445. PatientId: patient.ID,
  10446. Certno: res.Output.Baseinfo.Certno,
  10447. Gend: res.Output.Baseinfo.Gend,
  10448. Naty: res.Output.Baseinfo.Naty,
  10449. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10450. PsnName: res.Output.Baseinfo.PsnName,
  10451. Idetinfo: idetinfoStr,
  10452. Insuinfo: infoStr,
  10453. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10454. CardInfo: "",
  10455. VerifyNumber: token,
  10456. }
  10457. service.CreateHisPsn(psn)
  10458. c.ServeSuccessJSON(map[string]interface{}{
  10459. "patient": patient,
  10460. "number": token,
  10461. })
  10462. }
  10463. } else {
  10464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10465. return
  10466. }
  10467. } else if miConfig.MdtrtareaAdmvs == "360100" {
  10468. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10469. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10470. type ELeData struct {
  10471. Data struct {
  10472. IdNo string `json:"idNo"`
  10473. IdType string `json:"idType"`
  10474. UserName string `json:"userName"`
  10475. EcToken string `json:"ecToken"`
  10476. InsuOrg string `json:"insuOrg"`
  10477. Gender string `json:"gender"`
  10478. Birthday string `json:"birthday"`
  10479. Nationality string `json:"nationality"`
  10480. Email string `json:"email"`
  10481. Extra string `json:"extra"`
  10482. } `json:"data"`
  10483. Code int `json:"code"`
  10484. Message string `json:"message"`
  10485. }
  10486. var ele ELeData
  10487. err := json.Unmarshal([]byte(result), &ele)
  10488. if err != nil {
  10489. utils.ErrorLog("解析失败:%v", err)
  10490. }
  10491. token := ele.Data.EcToken
  10492. token = Remove0000(token)
  10493. fmt.Println(ele.Data.UserName)
  10494. 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)
  10495. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10496. var res ResultTwo
  10497. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10498. utils.ErrorLog("解析失败:%v", err)
  10499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10500. return
  10501. }
  10502. if res.Infcode == 0 {
  10503. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10504. if err == gorm.ErrRecordNotFound {
  10505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10506. return
  10507. } else if err != nil {
  10508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10509. return
  10510. } else {
  10511. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10512. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10513. infoStr := string(Iinfos)
  10514. idetinfoStr := string(Idetinfos)
  10515. psn := &models.HisPsn{
  10516. PsnNo: res.Output.Baseinfo.PsnNo,
  10517. PatientId: patient.ID,
  10518. Certno: res.Output.Baseinfo.Certno,
  10519. Gend: res.Output.Baseinfo.Gend,
  10520. Naty: res.Output.Baseinfo.Naty,
  10521. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10522. PsnName: res.Output.Baseinfo.PsnName,
  10523. Idetinfo: idetinfoStr,
  10524. Insuinfo: infoStr,
  10525. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10526. CardInfo: "",
  10527. VerifyNumber: token,
  10528. }
  10529. service.CreateHisPsn(psn)
  10530. c.ServeSuccessJSON(map[string]interface{}{
  10531. "patient": patient,
  10532. "number": token,
  10533. })
  10534. }
  10535. } else {
  10536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10537. return
  10538. }
  10539. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10540. //if initFlag == 0 {
  10541. //c.TestGetJiangXiBasBaseInit()
  10542. //}
  10543. //if initEleFlag == 0 {
  10544. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10545. //}
  10546. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10547. utils.ErrorLog("解析失败:%v", json_result)
  10548. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10549. type ELeData struct {
  10550. Data struct {
  10551. IdNo string `json:"idNo"`
  10552. IdType string `json:"idType"`
  10553. UserName string `json:"userName"`
  10554. EcToken string `json:"ecToken"`
  10555. InsuOrg string `json:"insuOrg"`
  10556. Gender string `json:"gender"`
  10557. Birthday string `json:"birthday"`
  10558. Nationality string `json:"nationality"`
  10559. Email string `json:"email"`
  10560. Extra string `json:"extra"`
  10561. } `json:"data"`
  10562. Code int `json:"code"`
  10563. Message string `json:"message"`
  10564. }
  10565. var ele ELeData
  10566. err := json.Unmarshal([]byte(json_result), &ele)
  10567. if err != nil {
  10568. utils.ErrorLog("解析失败:%v", err)
  10569. }
  10570. token := ele.Data.EcToken
  10571. token = Remove0000(token)
  10572. //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)
  10573. 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)
  10574. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10575. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10576. var res ResultTwo
  10577. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10578. utils.ErrorLog("解析失败:%v", err)
  10579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10580. return
  10581. }
  10582. if res.Infcode == 0 {
  10583. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10584. if err == gorm.ErrRecordNotFound {
  10585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10586. return
  10587. } else if err != nil {
  10588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10589. return
  10590. } else {
  10591. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10592. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10593. infoStr := string(Iinfos)
  10594. idetinfoStr := string(Idetinfos)
  10595. psn := &models.HisPsn{
  10596. PsnNo: res.Output.Baseinfo.PsnNo,
  10597. PatientId: patient.ID,
  10598. Certno: res.Output.Baseinfo.Certno,
  10599. Gend: res.Output.Baseinfo.Gend,
  10600. Naty: res.Output.Baseinfo.Naty,
  10601. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10602. PsnName: res.Output.Baseinfo.PsnName,
  10603. Idetinfo: idetinfoStr,
  10604. Insuinfo: infoStr,
  10605. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10606. CardInfo: "",
  10607. VerifyNumber: token,
  10608. InsuplcAdmdvs: ele.Data.InsuOrg,
  10609. }
  10610. service.CreateHisPsn(psn)
  10611. c.ServeSuccessJSON(map[string]interface{}{
  10612. "patient": patient,
  10613. "number": token,
  10614. })
  10615. }
  10616. } else {
  10617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10618. return
  10619. }
  10620. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10621. res := c.GetoleInfo()
  10622. if res.Infcode == 0 {
  10623. var result string
  10624. if res.Output.MdtrtCertType == "01" {
  10625. 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)
  10626. } else if res.Output.MdtrtCertType == "02" {
  10627. 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)
  10628. } else if res.Output.MdtrtCertType == "03" {
  10629. 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)
  10630. }
  10631. var dat map[string]interface{}
  10632. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10633. fmt.Println(dat)
  10634. } else {
  10635. fmt.Println(err)
  10636. }
  10637. userJSONBytes, _ := json.Marshal(dat)
  10638. var res2 ResultTwo
  10639. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10640. utils.ErrorLog("解析失败:%v", err)
  10641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10642. return
  10643. }
  10644. if res2.Infcode == 0 {
  10645. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10646. if err == gorm.ErrRecordNotFound {
  10647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10648. return
  10649. } else if err != nil {
  10650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10651. return
  10652. } else {
  10653. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10654. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10655. infoStr := string(Iinfos)
  10656. idetinfoStr := string(Idetinfos)
  10657. var rf []*ResultFive
  10658. json.Unmarshal([]byte(infoStr), &rf)
  10659. var insutypes []*ResultFive
  10660. var insutype string
  10661. var is390 int = 0
  10662. var is310 int = 0
  10663. //var insuplc_admdvs string
  10664. for _, item := range rf {
  10665. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10666. insutypes = append(insutypes, item)
  10667. }
  10668. }
  10669. if len(insutypes) == 1 {
  10670. insutype = insutypes[0].Insutype
  10671. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10672. } else {
  10673. for _, i := range insutypes {
  10674. if i.Insutype == "390" {
  10675. is390 = 1
  10676. }
  10677. if i.Insutype == "310" {
  10678. is310 = 1
  10679. }
  10680. }
  10681. }
  10682. if is390 == 1 {
  10683. insutype = "390"
  10684. }
  10685. if is310 == 1 {
  10686. insutype = "310"
  10687. }
  10688. if len(insutypes) == 0 {
  10689. insutype = "310"
  10690. }
  10691. psn := &models.HisPsn{
  10692. PsnNo: res2.Output.Baseinfo.PsnNo,
  10693. PatientId: patient.ID,
  10694. Certno: res2.Output.Baseinfo.Certno,
  10695. Gend: res2.Output.Baseinfo.Gend,
  10696. Naty: res2.Output.Baseinfo.Naty,
  10697. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10698. PsnName: res2.Output.Baseinfo.PsnName,
  10699. Idetinfo: idetinfoStr,
  10700. Insuinfo: infoStr,
  10701. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10702. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10703. VerifyNumber: res.Output.EcToken,
  10704. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10705. }
  10706. service.CreateHisPsn(psn)
  10707. c.ServeSuccessJSON(map[string]interface{}{
  10708. "patient": patient,
  10709. "number": res.Output.CardNo,
  10710. "insutype": insutype,
  10711. })
  10712. }
  10713. } else {
  10714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10715. return
  10716. }
  10717. } else {
  10718. c.ServeSuccessJSON(map[string]interface{}{
  10719. "failed_code": -10,
  10720. "msg": res.ErrMsg,
  10721. })
  10722. }
  10723. } else {
  10724. //if initFlag == 0 {
  10725. // c.TestGetBasBaseInit()
  10726. //}
  10727. //token := c.GetEleBaseInfo()
  10728. //token = Remove0000(token)
  10729. type ELeData struct {
  10730. Code string `json:"code"`
  10731. Data struct {
  10732. Aac002 string `json:"aac002"`
  10733. Aaz500 string `json:"aaz500"`
  10734. ActCardNo string `json:"actCardNo"`
  10735. Bab520 string `json:"bab520"`
  10736. Bkz543 string `json:"bkz543"`
  10737. BusinessType string `json:"businessType"`
  10738. CertfCodg string `json:"certfCodg"`
  10739. EcIndexNo string `json:"ecIndexNo"`
  10740. EcToken string `json:"ecToken"`
  10741. ID0000 string `json:"id0000"`
  10742. IDNo string `json:"idNo"`
  10743. IDType string `json:"idType"`
  10744. Idcode string `json:"idcode"`
  10745. IdentityToken string `json:"identity_token"`
  10746. InsuOrg string `json:"insuOrg"`
  10747. OfficeID string `json:"officeId"`
  10748. OfficeName string `json:"officeName"`
  10749. OperatorID string `json:"operatorId"`
  10750. OperatorName string `json:"operatorName"`
  10751. OrgID string `json:"orgId"`
  10752. UserName string `json:"userName"`
  10753. } `json:"data"`
  10754. Infno interface{} `json:"infno"`
  10755. Message string `json:"message"`
  10756. OrgID string `json:"orgId"`
  10757. TransType string `json:"transType"`
  10758. }
  10759. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10760. fmt.Println(result)
  10761. outPutInfo := Remove0000(result)
  10762. fmt.Println(outPutInfo)
  10763. var ele ELeData
  10764. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10765. if err != nil {
  10766. utils.ErrorLog("解析失败:%v", err)
  10767. }
  10768. token := ele.Data.EcToken
  10769. var result2 string
  10770. var requestLog2 string
  10771. if len(token) > 0 {
  10772. if strings.Contains(ele.Data.IDNo, "HKG") {
  10773. 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)
  10774. } else {
  10775. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10776. }
  10777. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10778. var res ResultTwo
  10779. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10780. utils.ErrorLog("解析失败:%v", err)
  10781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10782. return
  10783. }
  10784. if res.Infcode == 0 {
  10785. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10786. if err == gorm.ErrRecordNotFound {
  10787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10788. return
  10789. } else if err != nil {
  10790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10791. return
  10792. } else {
  10793. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10794. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10795. infoStr := string(Iinfos)
  10796. idetinfoStr := string(Idetinfos)
  10797. psn := &models.HisPsn{
  10798. PsnNo: res.Output.Baseinfo.PsnNo,
  10799. PatientId: patient.ID,
  10800. Certno: res.Output.Baseinfo.Certno,
  10801. Gend: res.Output.Baseinfo.Gend,
  10802. Naty: res.Output.Baseinfo.Naty,
  10803. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10804. PsnName: res.Output.Baseinfo.PsnName,
  10805. Idetinfo: idetinfoStr,
  10806. Insuinfo: infoStr,
  10807. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10808. CardInfo: "",
  10809. VerifyNumber: token,
  10810. }
  10811. service.CreateHisPsn(psn)
  10812. c.ServeSuccessJSON(map[string]interface{}{
  10813. "msg": "读取成功",
  10814. })
  10815. }
  10816. } else {
  10817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10818. return
  10819. }
  10820. } else {
  10821. c.ServeSuccessJSON(map[string]interface{}{
  10822. "failed_code": -10,
  10823. "msg": "读取失败",
  10824. })
  10825. }
  10826. }
  10827. }
  10828. func (c *HisApiController) ReadEleFace() {
  10829. admin_user_id, _ := c.GetInt64("admin_user_id")
  10830. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10831. adminUser := c.GetAdminUserInfo()
  10832. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10833. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10834. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10835. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10836. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10837. if len(tokens) > 0 {
  10838. c.ServeSuccessJSON(map[string]interface{}{
  10839. "msg": "读取成功",
  10840. })
  10841. } else {
  10842. c.ServeSuccessJSON(map[string]interface{}{
  10843. "failed_code": -10,
  10844. "msg": "读取失败",
  10845. })
  10846. }
  10847. }
  10848. }
  10849. func timestampToBirthdayString(timestamp int64) string {
  10850. // 将时间戳转换为 time.Time
  10851. t := time.Unix(timestamp, 0)
  10852. // 格式化时间为生日字符串,例如 "2006-01-02"
  10853. birthday := t.Format("2006-01-02")
  10854. return birthday
  10855. }
  10856. func (c *HisApiController) Get9001() {
  10857. adminUser := c.GetAdminUserInfo()
  10858. admin_user_id, _ := c.GetInt64("admin_user_id")
  10859. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10860. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10861. if miConfig.MdtrtareaAdmvs == "350500" {
  10862. service.GetFjAuthorizationInfo(miConfig.Code)
  10863. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10864. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10865. var dat map[string]interface{}
  10866. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10867. fmt.Println(dat)
  10868. } else {
  10869. fmt.Println(err)
  10870. }
  10871. userJSONBytes, _ := json.Marshal(dat)
  10872. var res models.Result9001
  10873. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10874. utils.ErrorLog("解析失败:%v", err)
  10875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10876. return
  10877. }
  10878. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10879. fmt.Println(miConfig.SecretKey)
  10880. var res models.Result9001Two
  10881. 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 +
  10882. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10883. resp, requestErr := http.Get(api)
  10884. if requestErr != nil {
  10885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10886. return
  10887. }
  10888. body, ioErr := ioutil.ReadAll(resp.Body)
  10889. if ioErr != nil {
  10890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10892. return
  10893. }
  10894. var respJSON map[string]interface{}
  10895. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10898. return
  10899. }
  10900. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10901. if status == "0" {
  10902. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10903. c.ServeSuccessJSON(map[string]interface{}{
  10904. "failed_code": -10,
  10905. "msg": err_msg,
  10906. })
  10907. return
  10908. }
  10909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10910. result, _ := json.Marshal(respJSON)
  10911. fmt.Println("log")
  10912. fmt.Println(string(result))
  10913. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10914. utils.ErrorLog("解析失败:%v", err)
  10915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10916. return
  10917. }
  10918. if res.Infcode == 0 {
  10919. sign := models.HisSignIn{
  10920. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10921. SignNo: res.Output.Signinoutb.SignNo,
  10922. SignTime: "",
  10923. Ctime: time.Now().Unix(),
  10924. Mtime: time.Now().Unix(),
  10925. Status: 1,
  10926. InputLog: "",
  10927. OutputLog: "",
  10928. FixmedinsCode: miConfig.Code,
  10929. }
  10930. err := service.CreateSignIn(&sign)
  10931. if err == nil {
  10932. c.ServeSuccessJSON(map[string]interface{}{
  10933. "msg": "签到成功",
  10934. })
  10935. }
  10936. } else {
  10937. c.ServeSuccessJSON(map[string]interface{}{
  10938. "failed_code": -10,
  10939. "msg": res.ErrMsg,
  10940. })
  10941. return
  10942. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10943. //return
  10944. }
  10945. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10946. fmt.Println(miConfig.SecretKey)
  10947. var res models.Result9001Two
  10948. 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 +
  10949. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10950. resp, requestErr := http.Get(api)
  10951. if requestErr != nil {
  10952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10953. return
  10954. }
  10955. body, ioErr := ioutil.ReadAll(resp.Body)
  10956. if ioErr != nil {
  10957. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10959. return
  10960. }
  10961. var respJSON map[string]interface{}
  10962. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10965. return
  10966. }
  10967. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10968. if status == "0" {
  10969. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10970. c.ServeSuccessJSON(map[string]interface{}{
  10971. "failed_code": -10,
  10972. "msg": err_msg,
  10973. })
  10974. return
  10975. }
  10976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10977. result, _ := json.Marshal(respJSON)
  10978. fmt.Println("log")
  10979. fmt.Println(string(result))
  10980. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10981. utils.ErrorLog("解析失败:%v", err)
  10982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10983. return
  10984. }
  10985. if res.Infcode == 0 {
  10986. sign := models.HisSignIn{
  10987. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10988. SignNo: res.Output.Signinoutb.SignNo,
  10989. SignTime: "",
  10990. Ctime: time.Now().Unix(),
  10991. Mtime: time.Now().Unix(),
  10992. Status: 1,
  10993. InputLog: "",
  10994. OutputLog: "",
  10995. FixmedinsCode: miConfig.Code,
  10996. }
  10997. err := service.CreateSignIn(&sign)
  10998. if err == nil {
  10999. c.ServeSuccessJSON(map[string]interface{}{
  11000. "msg": "签到成功",
  11001. })
  11002. }
  11003. } else {
  11004. c.ServeSuccessJSON(map[string]interface{}{
  11005. "failed_code": -10,
  11006. "msg": res.ErrMsg,
  11007. })
  11008. return
  11009. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11010. //return
  11011. }
  11012. } else {
  11013. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11014. var dat map[string]interface{}
  11015. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11016. fmt.Println(dat)
  11017. } else {
  11018. fmt.Println(err)
  11019. }
  11020. userJSONBytes, _ := json.Marshal(dat)
  11021. var res models.Result9001
  11022. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11023. utils.ErrorLog("解析失败:%v", err)
  11024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11025. return
  11026. }
  11027. if res.Infcode == 0 {
  11028. sign := models.HisSignIn{
  11029. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11030. SignNo: res.Output.Signinoutb.SignNo,
  11031. SignTime: res.Output.Signinoutb.SignTime,
  11032. Ctime: time.Now().Unix(),
  11033. Mtime: time.Now().Unix(),
  11034. Status: 1,
  11035. InputLog: "",
  11036. OutputLog: "",
  11037. FixmedinsCode: miConfig.Code,
  11038. }
  11039. err := service.CreateSignIn(&sign)
  11040. if err == nil {
  11041. c.ServeSuccessJSON(map[string]interface{}{
  11042. "msg": "签到成功",
  11043. })
  11044. }
  11045. }
  11046. }
  11047. }
  11048. 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) {
  11049. var res Result3101
  11050. adminUser := c.GetAdminUserInfo()
  11051. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11052. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11053. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11054. //record_time := c.GetString("record_time")
  11055. //trig_scen := c.GetString("trig_scen")
  11056. timeLayout := "2006-01-02"
  11057. loc, _ := time.LoadLocation("Local")
  11058. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11059. if err != nil {
  11060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11061. return res
  11062. }
  11063. recordDateTime := theTime.Unix()
  11064. var patientPrescription models.HisPrescriptionInfo
  11065. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11066. //if patientPrescription.ID == 0 {
  11067. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11068. //}
  11069. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11070. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11071. //
  11072. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11073. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11074. var pp models.PublicParams
  11075. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11076. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11077. pp.FixmedinsName = miConfig.OrgName
  11078. pp.FixmedinsCode = miConfig.Code
  11079. pp.RequestUrl = miConfig.Url
  11080. pp.Cainfo = miConfig.Cainfo
  11081. pp.SecretKey = miConfig.SecretKey
  11082. pp.AccessKey = miConfig.AccessKey
  11083. pp.OpterName = roles.UserName
  11084. var config []*models.HisXtDiagnoseConfig
  11085. for _, item := range diagnosis_ids {
  11086. id, _ := strconv.ParseInt(item, 10, 64)
  11087. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11088. config = append(config, &diagnosisConfig)
  11089. }
  11090. var pd models.PatientDtos
  11091. pd.PatnID = his.PsnNo
  11092. pd.PatnName = his.Name
  11093. pd.Gend = his.Gend
  11094. pd.Brdy = his.Brdy
  11095. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11096. pd.CurrMdtrtID = his.Number
  11097. var fed models.FsiEncounterDtos
  11098. fed.MdtrtID = his.Number
  11099. fed.MedinsID = miConfig.Code
  11100. fed.MedinsName = miConfig.OrgName
  11101. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11102. fed.MedMdtrtType = "1"
  11103. fed.MedinsType = "1"
  11104. fed.MedinsLv = "11"
  11105. tm := time.Unix(his.RecordDate, 0)
  11106. s_tm := tm.Format("2006-01-02 15:04:05")
  11107. fed.AdmDate = s_tm
  11108. fed.DscgDate = s_tm
  11109. fed.DscgMainDiseCodg = config[0].CountryCode
  11110. fed.DscgMainDiseName = config[0].CountryContentName
  11111. //诊断信息
  11112. var fdds []*models.FsiDiagnoseDtos
  11113. for index, item := range config {
  11114. if index == 0 {
  11115. var fdd models.FsiDiagnoseDtos
  11116. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11117. fdd.InoutDiseType = "1"
  11118. fdd.MaindiseFlag = "1"
  11119. fdd.DiseDate = s_tm
  11120. fdd.DiasSrtNo = "1"
  11121. fdd.DiseName = item.CountryContentName
  11122. fdd.DiseCodg = item.CountryCode
  11123. fdds = append(fdds, &fdd)
  11124. } else {
  11125. var fdd models.FsiDiagnoseDtos
  11126. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11127. fdd.InoutDiseType = "1"
  11128. fdd.MaindiseFlag = "1"
  11129. fdd.DiseDate = s_tm
  11130. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11131. fdd.DiseName = item.CountryContentName
  11132. fdd.DiseCodg = item.CountryCode
  11133. fdds = append(fdds, &fdd)
  11134. }
  11135. }
  11136. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11137. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11138. fed.AdmDeptName = de.Name
  11139. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11140. fed.DscgDeptName = de.Name
  11141. fed.MedMdtrtType = "1"
  11142. fed.MedType = "11"
  11143. //if his.Insutype == "390" {
  11144. // fed.MedType = "1402"
  11145. //} else {
  11146. // fed.MedType = "9933"
  11147. //}
  11148. var orders []*models.FsiOrderDtos
  11149. if trig_scen == "2" {
  11150. //处方医嘱信息
  11151. for _, item := range prescriptions {
  11152. for _, subItem := range item.HisDoctorAdviceInfo {
  11153. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11154. var order models.FsiOrderDtos
  11155. order.RxID = strconv.FormatInt(item.ID, 10)
  11156. order.Rxno = strconv.FormatInt(item.ID, 10)
  11157. order.LongDrordFlag = "0"
  11158. order.HilistType = "1"
  11159. order.ChrgType = "1"
  11160. order.DrordBhvr = "-"
  11161. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11162. order.HosplistName = subItem.BaseDrugLib.DrugName
  11163. order.HilistLv = "1"
  11164. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11165. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11166. order.HosplistName = subItem.BaseDrugLib.DrugName
  11167. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11168. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11169. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11170. order.OwnpayAmt = ""
  11171. order.SelfpayAmt = ""
  11172. order.Spec = ""
  11173. order.SpecUnt = ""
  11174. order.DrordBegnDate = s_tm
  11175. order.DrordStopDate = ""
  11176. order.DrordDrCodg = doctor_info.DoctorNumber
  11177. order.DrordDeptName = department.Name
  11178. order.DrordDeptCodg = department.Number
  11179. order.DrordDrName = doctor_info.UserName
  11180. order.DrordDrProfttl = "234"
  11181. order.CurrDrordFlag = "1"
  11182. orders = append(orders, &order)
  11183. }
  11184. }
  11185. for _, subItem := range item.HisPrescriptionProject {
  11186. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11187. var order models.FsiOrderDtos
  11188. order.RxID = strconv.FormatInt(item.ID, 10)
  11189. order.Rxno = strconv.FormatInt(item.ID, 10)
  11190. order.LongDrordFlag = "0"
  11191. order.HilistType = "1"
  11192. order.ChrgType = "1"
  11193. order.DrordBhvr = "-"
  11194. order.HilistCode = subItem.HisProject.MedicalCode
  11195. order.HosplistName = subItem.HisProject.ProjectName
  11196. order.HilistLv = "1"
  11197. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11198. order.HosplistCode = subItem.HisProject.MedicalCode
  11199. order.HosplistName = subItem.HisProject.ProjectName
  11200. order.Cnt = subItem.Count
  11201. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11202. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11203. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11204. order.OwnpayAmt = ""
  11205. order.SelfpayAmt = ""
  11206. order.Spec = ""
  11207. order.SpecUnt = ""
  11208. order.DrordBegnDate = s_tm
  11209. order.DrordStopDate = ""
  11210. order.DrordDrCodg = doctor_info.DoctorNumber
  11211. order.DrordDeptName = department.Name
  11212. order.DrordDeptCodg = department.Number
  11213. order.DrordDrName = doctor_info.UserName
  11214. order.DrordDrProfttl = "234"
  11215. order.CurrDrordFlag = "1"
  11216. orders = append(orders, &order)
  11217. }
  11218. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11219. var order models.FsiOrderDtos
  11220. order.RxID = strconv.FormatInt(item.ID, 10)
  11221. order.Rxno = strconv.FormatInt(item.ID, 10)
  11222. order.LongDrordFlag = "0"
  11223. order.HilistType = "1"
  11224. order.ChrgType = "1"
  11225. order.DrordBhvr = "-"
  11226. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11227. order.HosplistName = subItem.GoodInfo.GoodName
  11228. order.HilistLv = "1"
  11229. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11230. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11231. order.HosplistName = subItem.GoodInfo.GoodName
  11232. order.Cnt = subItem.Count
  11233. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11234. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11235. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11236. order.OwnpayAmt = ""
  11237. order.SelfpayAmt = ""
  11238. order.Spec = ""
  11239. order.SpecUnt = ""
  11240. order.DrordBegnDate = s_tm
  11241. order.DrordStopDate = ""
  11242. order.DrordDrCodg = doctor_info.DoctorNumber
  11243. order.DrordDeptName = department.Name
  11244. order.DrordDeptCodg = department.Number
  11245. order.DrordDrName = doctor_info.UserName
  11246. order.DrordDrProfttl = "234"
  11247. order.CurrDrordFlag = "1"
  11248. orders = append(orders, &order)
  11249. }
  11250. }
  11251. }
  11252. //处方医嘱信息
  11253. }
  11254. fed.MatnStas = "0"
  11255. fed.MedfeeSumamt = "0"
  11256. fed.OwnpayAmt = "0"
  11257. fed.SelfpayAmt = "0"
  11258. fed.AcctPayamt = "0"
  11259. fed.MaAmt = "0"
  11260. fed.HifpPayamt = "0"
  11261. fed.SetlTotlnum = "1"
  11262. fed.Insutype = his.Insutype
  11263. fed.ReimFlag = "0"
  11264. fed.OutSetlFlag = "0"
  11265. var fopd []*models.FsiOperationDtosData
  11266. data := make(map[string]interface{})
  11267. data["fed"] = fed
  11268. data["fdd"] = fdds
  11269. data["fod"] = orders
  11270. data["pd"] = pd
  11271. data["pp"] = pp
  11272. data["fopd"] = fopd
  11273. data["trig_scen"] = trig_scen
  11274. fmt.Println(data)
  11275. fmt.Println(fed)
  11276. fmt.Println(fdds)
  11277. fmt.Println(orders)
  11278. fmt.Println(pd)
  11279. fmt.Println(pp)
  11280. fmt.Println(fopd)
  11281. client := &http.Client{}
  11282. bytesData, _ := json.Marshal(data)
  11283. var req *http.Request
  11284. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11285. if miConfig.MdtrtareaAdmvs == "320830" {
  11286. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11287. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11288. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11289. } else {
  11290. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11291. }
  11292. resp, _ := client.Do(req)
  11293. defer resp.Body.Close()
  11294. body, ioErr := ioutil.ReadAll(resp.Body)
  11295. if ioErr != nil {
  11296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11298. return res
  11299. }
  11300. var respJSON map[string]interface{}
  11301. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11304. return res
  11305. }
  11306. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11307. fmt.Println(respJSON)
  11308. result, _ := json.Marshal(respJSON)
  11309. fmt.Println(result)
  11310. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11311. utils.ErrorLog("解析失败:%v", err)
  11312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11313. return res
  11314. }
  11315. return res
  11316. } else {
  11317. //if miConfig.MdtrtareaAdmvs == "441202" {
  11318. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11319. saveLog(output, input, "3101", "事前")
  11320. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11321. utils.ErrorLog("解析失败:%v", err)
  11322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11323. return
  11324. }
  11325. return res
  11326. //}
  11327. }
  11328. }
  11329. 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) {
  11330. adminUser := c.GetAdminUserInfo()
  11331. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11332. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11333. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11334. //record_time := c.GetString("record_time")
  11335. //trig_scen := c.GetString("trig_scen")
  11336. timeLayout := "2006-01-02"
  11337. loc, _ := time.LoadLocation("Local")
  11338. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11339. if err != nil {
  11340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11341. return res
  11342. }
  11343. recordDateTime := theTime.Unix()
  11344. var patientPrescription models.HisPrescriptionInfo
  11345. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11346. if patientPrescription.ID == 0 {
  11347. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11348. }
  11349. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11350. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11351. //
  11352. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11353. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11354. var pp models.PublicParams
  11355. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11356. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11357. pp.FixmedinsName = miConfig.OrgName
  11358. pp.FixmedinsCode = miConfig.Code
  11359. pp.RequestUrl = miConfig.Url
  11360. pp.Cainfo = miConfig.Cainfo
  11361. pp.SecretKey = miConfig.SecretKey
  11362. pp.AccessKey = miConfig.AccessKey
  11363. pp.OpterName = roles.UserName
  11364. var config []*models.HisXtDiagnoseConfig
  11365. for _, item := range diagnosis_ids {
  11366. id, _ := strconv.ParseInt(item, 10, 64)
  11367. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11368. config = append(config, &diagnosisConfig)
  11369. }
  11370. var pd models.PatientDtos
  11371. pd.PatnID = his.PsnNo
  11372. pd.PatnName = his.Name
  11373. pd.Gend = his.Gend
  11374. pd.Brdy = his.Brdy
  11375. pd.Poolarea = his.InsuplcAdmdvs
  11376. pd.CurrMdtrtID = his.Number
  11377. var fed models.FsiEncounterDtos
  11378. fed.MdtrtID = his.Number
  11379. fed.MedinsID = miConfig.Code
  11380. fed.MedinsName = miConfig.OrgName
  11381. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11382. fed.MedMdtrtType = "1"
  11383. fed.MedinsType = "1"
  11384. fed.MedinsLv = "11"
  11385. tm := time.Unix(his.RecordDate, 0)
  11386. s_tm := tm.Format("2006-01-02 15:04:05")
  11387. fed.AdmDate = s_tm
  11388. fed.DscgDate = s_tm
  11389. fed.DscgMainDiseCodg = config[0].CountryCode
  11390. fed.DscgMainDiseName = config[0].CountryContentName
  11391. //诊断信息
  11392. var fdds []*models.FsiDiagnoseDtos
  11393. for index, item := range config {
  11394. if index == 0 {
  11395. var fdd models.FsiDiagnoseDtos
  11396. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11397. fdd.InoutDiseType = "1"
  11398. fdd.MaindiseFlag = "1"
  11399. fdd.DiseDate = s_tm
  11400. fdd.DiasSrtNo = "1"
  11401. fdd.DiseName = item.CountryContentName
  11402. fdd.DiseCodg = item.CountryCode
  11403. fdds = append(fdds, &fdd)
  11404. } else {
  11405. var fdd models.FsiDiagnoseDtos
  11406. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11407. fdd.InoutDiseType = "1"
  11408. fdd.MaindiseFlag = "1"
  11409. fdd.DiseDate = s_tm
  11410. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11411. fdd.DiseName = item.CountryContentName
  11412. fdd.DiseCodg = item.CountryCode
  11413. fdds = append(fdds, &fdd)
  11414. }
  11415. }
  11416. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11417. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11418. fed.AdmDeptName = department.Name
  11419. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11420. fed.DscgDeptName = department.Name
  11421. fed.MedMdtrtType = "1"
  11422. fed.MedType = "11"
  11423. //if his.Insutype == "390" {
  11424. // fed.MedType = "1402"
  11425. //} else {
  11426. // fed.MedType = "9933"
  11427. //}
  11428. var orders []*models.FsiOrderDtos
  11429. if trig_scen == "2" {
  11430. //处方医嘱信息
  11431. for _, item := range prescriptions {
  11432. for _, subItem := range item.HisDoctorAdviceInfo {
  11433. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11434. var order models.FsiOrderDtos
  11435. order.RxID = strconv.FormatInt(item.ID, 10)
  11436. order.Rxno = strconv.FormatInt(item.ID, 10)
  11437. order.LongDrordFlag = "0"
  11438. order.HilistType = "1"
  11439. order.ChrgType = "1"
  11440. order.DrordBhvr = "-"
  11441. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11442. order.HosplistName = subItem.BaseDrugLib.DrugName
  11443. order.HilistLv = "1"
  11444. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11445. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11446. order.HosplistName = subItem.BaseDrugLib.DrugName
  11447. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11448. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11449. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11450. order.OwnpayAmt = ""
  11451. order.SelfpayAmt = ""
  11452. order.Spec = ""
  11453. order.SpecUnt = ""
  11454. order.DrordBegnDate = s_tm
  11455. order.DrordStopDate = ""
  11456. order.DrordDrCodg = doctor_info.DoctorNumber
  11457. order.DrordDeptName = department.Name
  11458. order.DrordDeptCodg = department.Number
  11459. order.DrordDrName = doctor_info.UserName
  11460. order.DrordDrProfttl = "234"
  11461. order.CurrDrordFlag = "1"
  11462. orders = append(orders, &order)
  11463. }
  11464. }
  11465. for _, subItem := range item.HisPrescriptionProject {
  11466. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11467. var order models.FsiOrderDtos
  11468. order.RxID = strconv.FormatInt(item.ID, 10)
  11469. order.Rxno = strconv.FormatInt(item.ID, 10)
  11470. order.LongDrordFlag = "0"
  11471. order.HilistType = "1"
  11472. order.ChrgType = "1"
  11473. order.DrordBhvr = "-"
  11474. order.HilistCode = subItem.HisProject.MedicalCode
  11475. order.HosplistName = subItem.HisProject.ProjectName
  11476. order.HilistLv = "1"
  11477. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11478. order.HosplistCode = subItem.HisProject.MedicalCode
  11479. order.HosplistName = subItem.HisProject.ProjectName
  11480. order.Cnt = subItem.Count
  11481. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11482. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11483. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11484. order.OwnpayAmt = ""
  11485. order.SelfpayAmt = ""
  11486. order.Spec = ""
  11487. order.SpecUnt = ""
  11488. order.DrordBegnDate = s_tm
  11489. order.DrordStopDate = ""
  11490. order.DrordDrCodg = doctor_info.DoctorNumber
  11491. order.DrordDeptName = department.Name
  11492. order.DrordDeptCodg = department.Number
  11493. order.DrordDrName = doctor_info.UserName
  11494. order.DrordDrProfttl = "234"
  11495. order.CurrDrordFlag = "1"
  11496. orders = append(orders, &order)
  11497. }
  11498. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11499. var order models.FsiOrderDtos
  11500. order.RxID = strconv.FormatInt(item.ID, 10)
  11501. order.Rxno = strconv.FormatInt(item.ID, 10)
  11502. order.LongDrordFlag = "0"
  11503. order.HilistType = "1"
  11504. order.ChrgType = "1"
  11505. order.DrordBhvr = "-"
  11506. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11507. order.HosplistName = subItem.GoodInfo.GoodName
  11508. order.HilistLv = "1"
  11509. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11510. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11511. order.HosplistName = subItem.GoodInfo.GoodName
  11512. order.Cnt = subItem.Count
  11513. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11514. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11515. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11516. order.OwnpayAmt = ""
  11517. order.SelfpayAmt = ""
  11518. order.Spec = ""
  11519. order.SpecUnt = ""
  11520. order.DrordBegnDate = s_tm
  11521. order.DrordStopDate = ""
  11522. order.DrordDrCodg = doctor_info.DoctorNumber
  11523. order.DrordDeptName = department.Name
  11524. order.DrordDeptCodg = department.Number
  11525. order.DrordDrName = doctor_info.UserName
  11526. order.DrordDrProfttl = "234"
  11527. order.CurrDrordFlag = "1"
  11528. orders = append(orders, &order)
  11529. }
  11530. }
  11531. }
  11532. //处方医嘱信息
  11533. }
  11534. fed.MatnStas = "0"
  11535. fed.MedfeeSumamt = "0"
  11536. fed.OwnpayAmt = "0"
  11537. fed.SelfpayAmt = "0"
  11538. fed.AcctPayamt = "0"
  11539. fed.MaAmt = "0"
  11540. fed.HifpPayamt = "0"
  11541. fed.SetlTotlnum = "1"
  11542. fed.Insutype = his.Insutype
  11543. fed.ReimFlag = "0"
  11544. fed.OutSetlFlag = "0"
  11545. var fopd []*models.FsiOperationDtosData
  11546. data := make(map[string]interface{})
  11547. data["fed"] = fed
  11548. data["fdd"] = fdds
  11549. data["fod"] = orders
  11550. data["pd"] = pd
  11551. data["pp"] = pp
  11552. data["fopd"] = fopd
  11553. data["trig_scen"] = trig_scen
  11554. fmt.Println(data)
  11555. fmt.Println(fed)
  11556. fmt.Println(fdds)
  11557. fmt.Println(orders)
  11558. fmt.Println(pd)
  11559. fmt.Println(pp)
  11560. fmt.Println(fopd)
  11561. client := &http.Client{}
  11562. bytesData, _ := json.Marshal(data)
  11563. var req *http.Request
  11564. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11565. if miConfig.MdtrtareaAdmvs == "320830" {
  11566. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11567. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11568. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11569. } else {
  11570. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11571. }
  11572. resp, _ := client.Do(req)
  11573. defer resp.Body.Close()
  11574. body, ioErr := ioutil.ReadAll(resp.Body)
  11575. if ioErr != nil {
  11576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11578. return res
  11579. }
  11580. var respJSON map[string]interface{}
  11581. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11584. return res
  11585. }
  11586. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11587. fmt.Println(respJSON)
  11588. result, _ := json.Marshal(respJSON)
  11589. fmt.Println(result)
  11590. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11591. utils.ErrorLog("解析失败:%v", err)
  11592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11593. return res
  11594. }
  11595. return res
  11596. } else {
  11597. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11598. saveLog(output, input, "3101", "事前")
  11599. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11600. utils.ErrorLog("解析失败:%v", err)
  11601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11602. return
  11603. }
  11604. return res
  11605. }
  11606. return res
  11607. }
  11608. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11609. ////patient_id, _ := c.GetInt64("patient_id")
  11610. //order_id, _ := c.GetInt64("order_id")
  11611. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11612. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11613. //trig_scen := c.GetString("trig_scen")
  11614. adminUser := c.GetAdminUserInfo()
  11615. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11616. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11617. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11618. record_time := c.GetString("record_time")
  11619. order, _ := service.GetHisOrderByID(order_id)
  11620. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11621. timeLayout := "2006-01-02"
  11622. loc, _ := time.LoadLocation("Local")
  11623. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11624. if err != nil {
  11625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11626. return
  11627. }
  11628. recordDateTime := theTime.Unix()
  11629. var patientPrescription models.HisPrescriptionInfo
  11630. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11631. if patientPrescription.ID == 0 {
  11632. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11633. }
  11634. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11635. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11636. //
  11637. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11638. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11639. var pp models.PublicParams
  11640. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11641. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11642. pp.FixmedinsName = miConfig.OrgName
  11643. pp.FixmedinsCode = miConfig.Code
  11644. pp.RequestUrl = miConfig.Url
  11645. pp.Cainfo = miConfig.Cainfo
  11646. pp.SecretKey = miConfig.SecretKey
  11647. pp.AccessKey = miConfig.AccessKey
  11648. pp.OpterName = roles.UserName
  11649. var config []*models.HisXtDiagnoseConfig
  11650. for _, item := range diagnosis_ids {
  11651. id, _ := strconv.ParseInt(item, 10, 64)
  11652. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11653. config = append(config, &diagnosisConfig)
  11654. }
  11655. var pd models.PatientDtos
  11656. pd.PatnID = his.PsnNo
  11657. pd.PatnName = his.Name
  11658. pd.Gend = his.Gend
  11659. pd.Brdy = psn_info.Brdy
  11660. pd.Poolarea = his.InsuplcAdmdvs
  11661. pd.CurrMdtrtID = his.Number
  11662. var fed models.FsiEncounterDtos
  11663. fed.MdtrtID = his.Number
  11664. fed.MedinsID = miConfig.Code
  11665. fed.MedinsName = miConfig.OrgName
  11666. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11667. fed.MedMdtrtType = "1"
  11668. fed.MedinsType = "1"
  11669. fed.MedinsLv = "11"
  11670. tm := time.Unix(his.RecordDate, 0)
  11671. s_tm := tm.Format("2006-01-02 15:04:05")
  11672. fed.AdmDate = s_tm
  11673. fed.DscgDate = s_tm
  11674. fed.DscgMainDiseCodg = config[0].CountryCode
  11675. fed.DscgMainDiseName = config[0].CountryContentName
  11676. //诊断信息
  11677. var fdds []*models.FsiDiagnoseDtos
  11678. for index, item := range config {
  11679. if index == 0 {
  11680. var fdd models.FsiDiagnoseDtos
  11681. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11682. fdd.InoutDiseType = "1"
  11683. fdd.MaindiseFlag = "1"
  11684. fdd.DiseDate = s_tm
  11685. fdd.DiasSrtNo = "1"
  11686. fdd.DiseName = item.CountryContentName
  11687. fdd.DiseCodg = item.CountryCode
  11688. fdds = append(fdds, &fdd)
  11689. } else {
  11690. var fdd models.FsiDiagnoseDtos
  11691. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11692. fdd.InoutDiseType = "1"
  11693. fdd.MaindiseFlag = "1"
  11694. fdd.DiseDate = s_tm
  11695. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11696. fdd.DiseName = item.CountryContentName
  11697. fdd.DiseCodg = item.CountryCode
  11698. fdds = append(fdds, &fdd)
  11699. }
  11700. }
  11701. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11702. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11703. fed.AdmDeptName = department.Name
  11704. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11705. fed.DscgDeptName = department.Name
  11706. fed.MedType = order.MedType
  11707. //处方医嘱信息
  11708. var orders []*models.FsiOrderDtos
  11709. //for _, item := range prescriptions {
  11710. // for _, subItem := range item.HisDoctorAdviceInfo {
  11711. // var order models.FsiOrderDtos
  11712. // order.RxID = strconv.FormatInt(item.ID, 10)
  11713. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11714. // order.LongDrordFlag = "0"
  11715. // order.HilistType = "1"
  11716. // order.ChrgType = "1"
  11717. // order.DrordBhvr = "-"
  11718. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11719. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11720. // order.HilistLv = "1"
  11721. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11722. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11723. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11724. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11725. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11726. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11727. // order.OwnpayAmt = ""
  11728. // order.SelfpayAmt = ""
  11729. // order.Spec = ""
  11730. // order.SpecUnt = ""
  11731. // order.DrordBegnDate = s_tm
  11732. // order.DrordStopDate = ""
  11733. // order.DrordDrCodg = "1"
  11734. // order.DrordDeptName = department.Name
  11735. // order.DrordDrCodg = "1"
  11736. // order.DrordDrName = doctor_info.UserName
  11737. // order.DrordDrProfttl = ""
  11738. // order.CurrDrordFlag = "1"
  11739. // orders = append(orders, &order)
  11740. // }
  11741. // for _, subItem := range item.HisPrescriptionProject {
  11742. // if subItem.Type == 2 {
  11743. // var order models.FsiOrderDtos
  11744. // order.RxID = strconv.FormatInt(item.ID, 10)
  11745. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11746. // order.LongDrordFlag = "0"
  11747. // order.HilistType = "1"
  11748. // order.ChrgType = "1"
  11749. // order.DrordBhvr = "-"
  11750. // order.HilistCode = subItem.HisProject.MedicalCode
  11751. // order.HosplistName = subItem.HisProject.ProjectName
  11752. // order.HilistLv = "1"
  11753. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11754. // order.HosplistCode = subItem.HisProject.MedicalCode
  11755. // order.HosplistName = subItem.HisProject.ProjectName
  11756. // order.Cnt = subItem.Count
  11757. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11758. //
  11759. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11760. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11761. // order.OwnpayAmt = ""
  11762. // order.SelfpayAmt = ""
  11763. // order.Spec = ""
  11764. // order.SpecUnt = ""
  11765. // order.DrordBegnDate = s_tm
  11766. // order.DrordStopDate = ""
  11767. // order.DrordDrCodg = "1"
  11768. // order.DrordDeptName = department.Name
  11769. // order.DrordDrCodg = "1"
  11770. // order.DrordDrName = doctor_info.UserName
  11771. // order.DrordDrProfttl = ""
  11772. // order.CurrDrordFlag = "1"
  11773. // orders = append(orders, &order)
  11774. //
  11775. // }
  11776. // if subItem.Type == 3 {
  11777. //
  11778. // var order models.FsiOrderDtos
  11779. // order.RxID = strconv.FormatInt(item.ID, 10)
  11780. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11781. // order.LongDrordFlag = "0"
  11782. // order.HilistType = "1"
  11783. // order.ChrgType = "1"
  11784. // order.DrordBhvr = "-"
  11785. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11786. // order.HosplistName = subItem.GoodInfo.GoodName
  11787. // order.HilistLv = "1"
  11788. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11789. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11790. // order.HosplistName = subItem.GoodInfo.GoodName
  11791. // order.Cnt = subItem.Count
  11792. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11793. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11794. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11795. // order.OwnpayAmt = ""
  11796. // order.SelfpayAmt = ""
  11797. // order.Spec = ""
  11798. // order.SpecUnt = ""
  11799. // order.DrordBegnDate = s_tm
  11800. // order.DrordStopDate = ""
  11801. // order.DrordDrCodg = "1"
  11802. // order.DrordDeptName = department.Name
  11803. // order.DrordDrCodg = "1"
  11804. // order.DrordDrName = doctor_info.UserName
  11805. // order.DrordDrProfttl = ""
  11806. // order.CurrDrordFlag = "1"
  11807. // orders = append(orders, &order)
  11808. //
  11809. // }
  11810. // }
  11811. //}
  11812. for _, item := range prescriptions {
  11813. for _, subItem := range item.HisDoctorAdviceInfo {
  11814. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11815. var order models.FsiOrderDtos
  11816. order.RxID = strconv.FormatInt(item.ID, 10)
  11817. order.Rxno = strconv.FormatInt(item.ID, 10)
  11818. order.LongDrordFlag = "0"
  11819. order.HilistType = "101"
  11820. order.ChrgType = "1"
  11821. order.DrordBhvr = "-"
  11822. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11823. order.HosplistName = subItem.BaseDrugLib.DrugName
  11824. order.HilistLv = "1"
  11825. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11826. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11827. order.HosplistName = subItem.BaseDrugLib.DrugName
  11828. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11829. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11830. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11831. order.OwnpayAmt = ""
  11832. order.SelfpayAmt = ""
  11833. order.Spec = ""
  11834. order.SpecUnt = ""
  11835. order.DrordBegnDate = s_tm
  11836. order.DrordStopDate = ""
  11837. order.DrordDrCodg = doctor_info.DoctorNumber
  11838. order.DrordDeptName = department.Name
  11839. order.DrordDeptCodg = department.Number
  11840. order.DrordDrName = doctor_info.UserName
  11841. order.DrordDrProfttl = "234"
  11842. order.CurrDrordFlag = "1"
  11843. orders = append(orders, &order)
  11844. }
  11845. }
  11846. for _, subItem := range item.HisPrescriptionProject {
  11847. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11848. var order models.FsiOrderDtos
  11849. order.RxID = strconv.FormatInt(item.ID, 10)
  11850. order.Rxno = strconv.FormatInt(item.ID, 10)
  11851. order.LongDrordFlag = "0"
  11852. order.HilistType = "201"
  11853. order.ChrgType = "1"
  11854. order.DrordBhvr = "-"
  11855. order.HilistCode = subItem.HisProject.MedicalCode
  11856. order.HosplistName = subItem.HisProject.ProjectName
  11857. order.HilistLv = "1"
  11858. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11859. order.HosplistCode = subItem.HisProject.MedicalCode
  11860. order.HosplistName = subItem.HisProject.ProjectName
  11861. order.Cnt = subItem.Count
  11862. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11863. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11864. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11865. order.OwnpayAmt = ""
  11866. order.SelfpayAmt = ""
  11867. order.Spec = ""
  11868. order.SpecUnt = ""
  11869. order.DrordBegnDate = s_tm
  11870. order.DrordStopDate = ""
  11871. order.DrordDrCodg = doctor_info.DoctorNumber
  11872. order.DrordDeptName = department.Name
  11873. order.DrordDeptCodg = department.Number
  11874. order.DrordDrName = doctor_info.UserName
  11875. order.DrordDrProfttl = "234"
  11876. order.CurrDrordFlag = "1"
  11877. orders = append(orders, &order)
  11878. }
  11879. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11880. var order models.FsiOrderDtos
  11881. order.RxID = strconv.FormatInt(item.ID, 10)
  11882. order.Rxno = strconv.FormatInt(item.ID, 10)
  11883. order.LongDrordFlag = "0"
  11884. order.HilistType = "301"
  11885. order.ChrgType = "1"
  11886. order.DrordBhvr = "0"
  11887. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11888. order.HosplistName = subItem.GoodInfo.GoodName
  11889. order.HilistLv = "1"
  11890. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11891. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11892. order.HosplistName = subItem.GoodInfo.GoodName
  11893. order.Cnt = subItem.Count
  11894. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11895. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11896. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11897. order.OwnpayAmt = ""
  11898. order.SelfpayAmt = ""
  11899. order.Spec = ""
  11900. order.SpecUnt = ""
  11901. order.DrordBegnDate = s_tm
  11902. order.DrordStopDate = ""
  11903. order.DrordDrCodg = doctor_info.DoctorNumber
  11904. order.DrordDeptName = department.Name
  11905. order.DrordDeptCodg = department.Number
  11906. order.DrordDrName = doctor_info.UserName
  11907. order.DrordDrProfttl = "234"
  11908. order.CurrDrordFlag = "1"
  11909. orders = append(orders, &order)
  11910. }
  11911. }
  11912. }
  11913. //处方医嘱信息
  11914. fed.MatnStas = "0"
  11915. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11916. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11917. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11918. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11919. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11920. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11921. fed.SetlTotlnum = "1"
  11922. fed.Insutype = his.Insutype
  11923. fed.ReimFlag = "0"
  11924. fed.OutSetlFlag = "0"
  11925. var fopd []*models.FsiOperationDtosData
  11926. data := make(map[string]interface{})
  11927. data["fed"] = fed
  11928. data["fdd"] = fdds
  11929. data["fod"] = orders
  11930. data["pd"] = pd
  11931. data["pp"] = pp
  11932. data["fopd"] = fopd
  11933. data["trig_scen"] = trig_scen
  11934. client := &http.Client{}
  11935. bytesData, _ := json.Marshal(data)
  11936. var req *http.Request
  11937. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11938. if miConfig.MdtrtareaAdmvs == "320830" {
  11939. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  11940. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11941. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11942. } else {
  11943. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11944. }
  11945. resp, _ := client.Do(req)
  11946. defer resp.Body.Close()
  11947. body, ioErr := ioutil.ReadAll(resp.Body)
  11948. if ioErr != nil {
  11949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11951. return res
  11952. }
  11953. var respJSON map[string]interface{}
  11954. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11957. return res
  11958. }
  11959. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11960. result, _ := json.Marshal(respJSON)
  11961. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11962. utils.ErrorLog("解析失败:%v", err)
  11963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11964. return res
  11965. }
  11966. return res
  11967. } else {
  11968. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11969. saveLog(output, input, "3102", "事中")
  11970. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11971. utils.ErrorLog("解析失败:%v", err)
  11972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11973. return
  11974. }
  11975. return res
  11976. }
  11977. return res
  11978. }
  11979. 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) {
  11980. var res Resultgd3101
  11981. adminUser := c.GetAdminUserInfo()
  11982. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11983. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11984. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11985. //record_time := c.GetString("record_time")
  11986. //trig_scen := c.GetString("trig_scen")
  11987. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11988. //psn_info, _ := service.GetPatientId(patient_id)
  11989. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11990. timeLayout := "2006-01-02"
  11991. loc, _ := time.LoadLocation("Local")
  11992. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11993. if err != nil {
  11994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11995. return res
  11996. }
  11997. recordDateTime := theTime.Unix()
  11998. var patientPrescription models.HisPrescriptionInfo
  11999. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12000. //if patientPrescription.ID == 0 {
  12001. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12002. //}
  12003. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12004. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12005. //
  12006. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12007. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12008. var str string
  12009. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12010. str = timestampToBirthdayString(patient.Birthday)
  12011. } else {
  12012. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12013. }
  12014. var pp models.PublicParams
  12015. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12016. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12017. pp.FixmedinsName = miConfig.OrgName
  12018. pp.FixmedinsCode = miConfig.Code
  12019. pp.RequestUrl = miConfig.Url
  12020. pp.Cainfo = miConfig.Cainfo
  12021. pp.SecretKey = miConfig.SecretKey
  12022. pp.AccessKey = miConfig.AccessKey
  12023. pp.OpterName = roles.UserName
  12024. var config []*models.HisXtDiagnoseConfig
  12025. for _, item := range diagnosis_ids {
  12026. id, _ := strconv.ParseInt(item, 10, 64)
  12027. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12028. config = append(config, &diagnosisConfig)
  12029. }
  12030. var pd models.PatientDtos
  12031. pd.PatnID = his.PsnNo
  12032. pd.PatnName = his.Name
  12033. pd.Gend = his.Gend
  12034. pd.Brdy = str
  12035. pd.Poolarea = miConfig.MdtrtareaAdmvs
  12036. pd.CurrMdtrtID = his.Number
  12037. var fed models.FsiEncounterDtos
  12038. fed.MdtrtID = his.Number
  12039. fed.MedinsID = miConfig.Code
  12040. fed.MedinsName = miConfig.OrgName
  12041. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12042. fed.MedMdtrtType = "1"
  12043. fed.MedinsType = "1"
  12044. fed.MedinsLv = "11"
  12045. tm := time.Unix(his.RecordDate, 0)
  12046. s_tm := tm.Format("2006-01-02 15:04:05")
  12047. fed.AdmDate = s_tm
  12048. fed.DscgDate = s_tm
  12049. fed.DscgMainDiseCodg = config[0].CountryCode
  12050. fed.DscgMainDiseName = config[0].CountryContentName
  12051. //诊断信息
  12052. var fdds []*models.FsiDiagnoseDtos
  12053. for index, item := range config {
  12054. if index == 0 {
  12055. var fdd models.FsiDiagnoseDtos
  12056. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12057. fdd.InoutDiseType = "1"
  12058. fdd.MaindiseFlag = "1"
  12059. fdd.DiseDate = s_tm
  12060. fdd.DiasSrtNo = "1"
  12061. fdd.DiseName = item.CountryContentName
  12062. fdd.DiseCodg = item.CountryCode
  12063. fdds = append(fdds, &fdd)
  12064. } else {
  12065. var fdd models.FsiDiagnoseDtos
  12066. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12067. fdd.InoutDiseType = "1"
  12068. fdd.MaindiseFlag = "1"
  12069. fdd.DiseDate = s_tm
  12070. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12071. fdd.DiseName = item.CountryContentName
  12072. fdd.DiseCodg = item.CountryCode
  12073. fdds = append(fdds, &fdd)
  12074. }
  12075. }
  12076. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12077. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  12078. fed.AdmDeptName = de.Name
  12079. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  12080. fed.DscgDeptName = de.Name
  12081. fed.MedMdtrtType = "1"
  12082. fed.MedType = "11"
  12083. //if his.Insutype == "390" {
  12084. // fed.MedType = "1402"
  12085. //} else {
  12086. // fed.MedType = "9933"
  12087. //}
  12088. var orders []*models.FsiOrderDtos
  12089. if trig_scen == "2" {
  12090. //处方医嘱信息
  12091. for _, item := range prescriptions {
  12092. for _, subItem := range item.HisDoctorAdviceInfo {
  12093. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12094. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12095. var order models.FsiOrderDtos
  12096. order.RxID = strconv.FormatInt(item.ID, 10)
  12097. order.Rxno = strconv.FormatInt(item.ID, 10)
  12098. order.LongDrordFlag = "0"
  12099. order.HilistType = "101"
  12100. order.ChrgType = "1"
  12101. order.DrordBhvr = "0"
  12102. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12103. order.HosplistName = subItem.BaseDrugLib.DrugName
  12104. order.HilistLv = "1"
  12105. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12106. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12107. order.HosplistName = subItem.BaseDrugLib.DrugName
  12108. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12109. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12110. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12111. order.OwnpayAmt = ""
  12112. order.SelfpayAmt = ""
  12113. order.Spec = spec
  12114. order.SpecUnt = subItem.PrescribingNumberUnit
  12115. order.DrordBegnDate = s_tm
  12116. order.DrordStopDate = ""
  12117. order.DrordDrCodg = doctor_info.DoctorNumber
  12118. order.DrordDeptName = department.Name
  12119. order.DrordDeptCodg = department.Number
  12120. order.DrordDrName = doctor_info.UserName
  12121. order.DrordDrProfttl = "234"
  12122. order.CurrDrordFlag = "1"
  12123. orders = append(orders, &order)
  12124. }
  12125. }
  12126. for _, subItem := range item.HisPrescriptionProject {
  12127. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12128. var order models.FsiOrderDtos
  12129. order.RxID = strconv.FormatInt(item.ID, 10)
  12130. order.Rxno = strconv.FormatInt(item.ID, 10)
  12131. order.LongDrordFlag = "0"
  12132. order.HilistType = "201"
  12133. order.ChrgType = "1"
  12134. order.DrordBhvr = "0"
  12135. order.HilistCode = subItem.HisProject.MedicalCode
  12136. order.HosplistName = subItem.HisProject.ProjectName
  12137. order.HilistLv = "1"
  12138. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12139. order.HosplistCode = subItem.HisProject.MedicalCode
  12140. order.HosplistName = subItem.HisProject.ProjectName
  12141. order.Cnt = subItem.Count
  12142. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12143. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12144. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12145. order.OwnpayAmt = ""
  12146. order.SelfpayAmt = ""
  12147. order.Spec = subItem.Unit
  12148. order.SpecUnt = subItem.Unit
  12149. order.DrordBegnDate = s_tm
  12150. order.DrordStopDate = ""
  12151. order.DrordDrCodg = doctor_info.DoctorNumber
  12152. order.DrordDeptName = department.Name
  12153. order.DrordDeptCodg = department.Number
  12154. order.DrordDrName = doctor_info.UserName
  12155. order.DrordDrProfttl = "234"
  12156. order.CurrDrordFlag = "1"
  12157. orders = append(orders, &order)
  12158. }
  12159. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12160. var order models.FsiOrderDtos
  12161. order.RxID = strconv.FormatInt(item.ID, 10)
  12162. order.Rxno = strconv.FormatInt(item.ID, 10)
  12163. order.LongDrordFlag = "0"
  12164. order.HilistType = "301"
  12165. order.ChrgType = "1"
  12166. order.DrordBhvr = "0"
  12167. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12168. order.HosplistName = subItem.GoodInfo.GoodName
  12169. order.HilistLv = "1"
  12170. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12171. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12172. order.HosplistName = subItem.GoodInfo.GoodName
  12173. order.Cnt = subItem.Count
  12174. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12175. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12176. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12177. order.OwnpayAmt = ""
  12178. order.SelfpayAmt = ""
  12179. order.Spec = subItem.GoodInfo.SpecificationName
  12180. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12181. order.DrordBegnDate = s_tm
  12182. order.DrordStopDate = ""
  12183. order.DrordDrCodg = doctor_info.DoctorNumber
  12184. order.DrordDeptName = department.Name
  12185. order.DrordDeptCodg = department.Number
  12186. order.DrordDrName = doctor_info.UserName
  12187. order.DrordDrProfttl = "234"
  12188. order.CurrDrordFlag = "1"
  12189. orders = append(orders, &order)
  12190. }
  12191. }
  12192. }
  12193. //处方医嘱信息
  12194. }
  12195. fed.MatnStas = "0"
  12196. fed.MedfeeSumamt = "0"
  12197. fed.OwnpayAmt = "0"
  12198. fed.SelfpayAmt = "0"
  12199. fed.AcctPayamt = "0"
  12200. fed.MaAmt = "0"
  12201. fed.HifpPayamt = "0"
  12202. fed.SetlTotlnum = "1"
  12203. fed.Insutype = his.Insutype
  12204. fed.ReimFlag = "0"
  12205. fed.OutSetlFlag = "0"
  12206. var fopd []*models.FsiOperationDtosData
  12207. data := make(map[string]interface{})
  12208. data["fed"] = fed
  12209. data["fdd"] = fdds
  12210. data["fod"] = orders
  12211. data["pd"] = pd
  12212. data["pp"] = pp
  12213. data["fopd"] = fopd
  12214. data["trig_scen"] = trig_scen
  12215. fmt.Println(data)
  12216. fmt.Println(fed)
  12217. fmt.Println(fdds)
  12218. fmt.Println(orders)
  12219. fmt.Println(pd)
  12220. fmt.Println(pp)
  12221. fmt.Println(fopd)
  12222. client := &http.Client{}
  12223. bytesData, _ := json.Marshal(data)
  12224. var req *http.Request
  12225. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12226. if miConfig.MdtrtareaAdmvs == "320830" {
  12227. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12228. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12229. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12230. } else {
  12231. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12232. }
  12233. resp, _ := client.Do(req)
  12234. defer resp.Body.Close()
  12235. body, ioErr := ioutil.ReadAll(resp.Body)
  12236. if ioErr != nil {
  12237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12239. return res
  12240. }
  12241. var respJSON map[string]interface{}
  12242. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12245. return res
  12246. }
  12247. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12248. fmt.Println(respJSON)
  12249. result, _ := json.Marshal(respJSON)
  12250. fmt.Println(result)
  12251. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12252. utils.ErrorLog("解析失败:%v", err)
  12253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12254. return res
  12255. }
  12256. return res
  12257. } else {
  12258. //if miConfig.MdtrtareaAdmvs == "441202" {
  12259. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12260. saveLog(output, input, "3101", "事前")
  12261. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12262. utils.ErrorLog("解析失败:%v", err)
  12263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12264. return
  12265. }
  12266. return res
  12267. //}
  12268. }
  12269. }
  12270. 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) {
  12271. adminUser := c.GetAdminUserInfo()
  12272. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12273. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12274. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12275. //record_time := c.GetString("record_time")
  12276. //trig_scen := c.GetString("trig_scen")
  12277. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12278. timeLayout := "2006-01-02"
  12279. loc, _ := time.LoadLocation("Local")
  12280. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12281. if err != nil {
  12282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12283. return res
  12284. }
  12285. recordDateTime := theTime.Unix()
  12286. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12287. var patientPrescription models.HisPrescriptionInfo
  12288. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12289. if patientPrescription.ID == 0 {
  12290. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12291. }
  12292. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12293. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12294. //
  12295. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12296. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12297. var pp models.PublicParams
  12298. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12299. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12300. pp.FixmedinsName = miConfig.OrgName
  12301. pp.FixmedinsCode = miConfig.Code
  12302. pp.RequestUrl = miConfig.Url
  12303. pp.Cainfo = miConfig.Cainfo
  12304. pp.SecretKey = miConfig.SecretKey
  12305. pp.AccessKey = miConfig.AccessKey
  12306. pp.OpterName = roles.UserName
  12307. var config []*models.HisXtDiagnoseConfig
  12308. for _, item := range diagnosis_ids {
  12309. id, _ := strconv.ParseInt(item, 10, 64)
  12310. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12311. config = append(config, &diagnosisConfig)
  12312. }
  12313. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12314. var str string
  12315. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12316. str = timestampToBirthdayString(patient.Birthday)
  12317. } else {
  12318. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12319. }
  12320. var pd models.PatientDtos
  12321. pd.PatnID = his.PsnNo
  12322. pd.PatnName = his.Name
  12323. pd.Gend = his.Gend
  12324. pd.Brdy = str
  12325. pd.Poolarea = his.InsuplcAdmdvs
  12326. pd.CurrMdtrtID = his.Number
  12327. var fed models.FsiEncounterDtos
  12328. fed.MdtrtID = his.Number
  12329. fed.MedinsID = miConfig.Code
  12330. fed.MedinsName = miConfig.OrgName
  12331. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12332. fed.MedMdtrtType = "1"
  12333. fed.MedinsType = "1"
  12334. fed.MedinsLv = "11"
  12335. tm := time.Unix(his.RecordDate, 0)
  12336. s_tm := tm.Format("2006-01-02 15:04:05")
  12337. fed.AdmDate = s_tm
  12338. fed.DscgDate = s_tm
  12339. fed.DscgMainDiseCodg = config[0].CountryCode
  12340. fed.DscgMainDiseName = config[0].CountryContentName
  12341. //诊断信息
  12342. var fdds []*models.FsiDiagnoseDtos
  12343. for index, item := range config {
  12344. if index == 0 {
  12345. var fdd models.FsiDiagnoseDtos
  12346. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12347. fdd.InoutDiseType = "1"
  12348. fdd.MaindiseFlag = "1"
  12349. fdd.DiseDate = s_tm
  12350. fdd.DiasSrtNo = "1"
  12351. fdd.DiseName = item.CountryContentName
  12352. fdd.DiseCodg = item.CountryCode
  12353. fdds = append(fdds, &fdd)
  12354. } else {
  12355. var fdd models.FsiDiagnoseDtos
  12356. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12357. fdd.InoutDiseType = "1"
  12358. fdd.MaindiseFlag = "1"
  12359. fdd.DiseDate = s_tm
  12360. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12361. fdd.DiseName = item.CountryContentName
  12362. fdd.DiseCodg = item.CountryCode
  12363. fdds = append(fdds, &fdd)
  12364. }
  12365. }
  12366. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12367. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12368. fed.AdmDeptName = department.Name
  12369. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12370. fed.DscgDeptName = department.Name
  12371. fed.MedMdtrtType = "1"
  12372. fed.MedType = "11"
  12373. //if his.Insutype == "390" {
  12374. // fed.MedType = "1402"
  12375. //} else {
  12376. // fed.MedType = "9933"
  12377. //}
  12378. var orders []*models.FsiOrderDtos
  12379. if trig_scen == "2" {
  12380. //处方医嘱信息
  12381. for _, item := range prescriptions {
  12382. for _, subItem := range item.HisDoctorAdviceInfo {
  12383. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12384. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12385. var order models.FsiOrderDtos
  12386. order.RxID = strconv.FormatInt(item.ID, 10)
  12387. order.Rxno = strconv.FormatInt(item.ID, 10)
  12388. order.LongDrordFlag = "0"
  12389. order.HilistType = "101"
  12390. order.ChrgType = "1"
  12391. order.DrordBhvr = "0"
  12392. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12393. order.HosplistName = subItem.BaseDrugLib.DrugName
  12394. order.HilistLv = "1"
  12395. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12396. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12397. order.HosplistName = subItem.BaseDrugLib.DrugName
  12398. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12399. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12400. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12401. order.OwnpayAmt = ""
  12402. order.SelfpayAmt = ""
  12403. order.Spec = spec
  12404. order.SpecUnt = subItem.PrescribingNumberUnit
  12405. order.DrordBegnDate = s_tm
  12406. order.DrordStopDate = ""
  12407. order.DrordDrCodg = doctor_info.DoctorNumber
  12408. order.DrordDeptName = department.Name
  12409. order.DrordDeptCodg = department.Number
  12410. order.DrordDrName = doctor_info.UserName
  12411. order.DrordDrProfttl = "234"
  12412. order.CurrDrordFlag = "1"
  12413. orders = append(orders, &order)
  12414. }
  12415. }
  12416. for _, subItem := range item.HisPrescriptionProject {
  12417. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12418. var order models.FsiOrderDtos
  12419. order.RxID = strconv.FormatInt(item.ID, 10)
  12420. order.Rxno = strconv.FormatInt(item.ID, 10)
  12421. order.LongDrordFlag = "0"
  12422. order.HilistType = "201"
  12423. order.ChrgType = "1"
  12424. order.DrordBhvr = "0"
  12425. order.HilistCode = subItem.HisProject.MedicalCode
  12426. order.HosplistName = subItem.HisProject.ProjectName
  12427. order.HilistLv = "1"
  12428. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12429. order.HosplistCode = subItem.HisProject.MedicalCode
  12430. order.HosplistName = subItem.HisProject.ProjectName
  12431. order.Cnt = subItem.Count
  12432. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12433. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12434. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12435. order.OwnpayAmt = ""
  12436. order.SelfpayAmt = ""
  12437. order.Spec = subItem.Unit
  12438. order.SpecUnt = subItem.Unit
  12439. order.DrordBegnDate = s_tm
  12440. order.DrordStopDate = ""
  12441. order.DrordDrCodg = doctor_info.DoctorNumber
  12442. order.DrordDeptName = department.Name
  12443. order.DrordDeptCodg = department.Number
  12444. order.DrordDrName = doctor_info.UserName
  12445. order.DrordDrProfttl = "234"
  12446. order.CurrDrordFlag = "1"
  12447. orders = append(orders, &order)
  12448. }
  12449. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12450. var order models.FsiOrderDtos
  12451. order.RxID = strconv.FormatInt(item.ID, 10)
  12452. order.Rxno = strconv.FormatInt(item.ID, 10)
  12453. order.LongDrordFlag = "0"
  12454. order.HilistType = "301"
  12455. order.ChrgType = "1"
  12456. order.DrordBhvr = "0"
  12457. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12458. order.HosplistName = subItem.GoodInfo.GoodName
  12459. order.HilistLv = "1"
  12460. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12461. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12462. order.HosplistName = subItem.GoodInfo.GoodName
  12463. order.Cnt = subItem.Count
  12464. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12465. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12466. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12467. order.OwnpayAmt = ""
  12468. order.SelfpayAmt = ""
  12469. order.Spec = subItem.GoodInfo.SpecificationName
  12470. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12471. order.DrordBegnDate = s_tm
  12472. order.DrordStopDate = ""
  12473. order.DrordDrCodg = doctor_info.DoctorNumber
  12474. order.DrordDeptName = department.Name
  12475. order.DrordDeptCodg = department.Number
  12476. order.DrordDrName = doctor_info.UserName
  12477. order.DrordDrProfttl = "234"
  12478. order.CurrDrordFlag = "1"
  12479. orders = append(orders, &order)
  12480. }
  12481. }
  12482. }
  12483. //处方医嘱信息
  12484. }
  12485. fed.MatnStas = "0"
  12486. fed.MedfeeSumamt = "0"
  12487. fed.OwnpayAmt = "0"
  12488. fed.SelfpayAmt = "0"
  12489. fed.AcctPayamt = "0"
  12490. fed.MaAmt = "0"
  12491. fed.HifpPayamt = "0"
  12492. fed.SetlTotlnum = "1"
  12493. fed.Insutype = his.Insutype
  12494. fed.ReimFlag = "0"
  12495. fed.OutSetlFlag = "0"
  12496. var fopd []*models.FsiOperationDtosData
  12497. data := make(map[string]interface{})
  12498. data["fed"] = fed
  12499. data["fdd"] = fdds
  12500. data["fod"] = orders
  12501. data["pd"] = pd
  12502. data["pp"] = pp
  12503. data["fopd"] = fopd
  12504. data["trig_scen"] = trig_scen
  12505. fmt.Println(data)
  12506. fmt.Println(fed)
  12507. fmt.Println(fdds)
  12508. fmt.Println(orders)
  12509. fmt.Println(pd)
  12510. fmt.Println(pp)
  12511. fmt.Println(fopd)
  12512. client := &http.Client{}
  12513. bytesData, _ := json.Marshal(data)
  12514. var req *http.Request
  12515. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12516. if miConfig.MdtrtareaAdmvs == "320830" {
  12517. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12518. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12519. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12520. } else {
  12521. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12522. }
  12523. resp, _ := client.Do(req)
  12524. defer resp.Body.Close()
  12525. body, ioErr := ioutil.ReadAll(resp.Body)
  12526. if ioErr != nil {
  12527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12529. return res
  12530. }
  12531. var respJSON map[string]interface{}
  12532. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12535. return res
  12536. }
  12537. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12538. fmt.Println(respJSON)
  12539. result, _ := json.Marshal(respJSON)
  12540. fmt.Println(result)
  12541. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12542. utils.ErrorLog("解析失败:%v", err)
  12543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12544. return res
  12545. }
  12546. return res
  12547. } else {
  12548. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12549. saveLog(output, input, "3101", "事前")
  12550. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12551. utils.ErrorLog("解析失败:%v", err)
  12552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12553. return
  12554. }
  12555. return res
  12556. }
  12557. return res
  12558. }
  12559. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12560. adminUser := c.GetAdminUserInfo()
  12561. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12562. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12563. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12564. record_time := c.GetString("record_time")
  12565. order, _ := service.GetHisOrderByID(order_id)
  12566. timeLayout := "2006-01-02"
  12567. loc, _ := time.LoadLocation("Local")
  12568. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12569. if err != nil {
  12570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12571. return
  12572. }
  12573. recordDateTime := theTime.Unix()
  12574. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12575. var patientPrescription models.HisPrescriptionInfo
  12576. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12577. if patientPrescription.ID == 0 {
  12578. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12579. }
  12580. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12581. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12582. //
  12583. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12584. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12585. var pp models.PublicParams
  12586. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12587. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12588. pp.FixmedinsName = miConfig.OrgName
  12589. pp.FixmedinsCode = miConfig.Code
  12590. pp.RequestUrl = miConfig.Url
  12591. pp.Cainfo = miConfig.Cainfo
  12592. pp.SecretKey = miConfig.SecretKey
  12593. pp.AccessKey = miConfig.AccessKey
  12594. pp.OpterName = roles.UserName
  12595. var config []*models.HisXtDiagnoseConfig
  12596. for _, item := range diagnosis_ids {
  12597. id, _ := strconv.ParseInt(item, 10, 64)
  12598. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12599. config = append(config, &diagnosisConfig)
  12600. }
  12601. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12602. var str string
  12603. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12604. str = timestampToBirthdayString(patient.Birthday)
  12605. } else {
  12606. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12607. }
  12608. var pd models.PatientDtos
  12609. pd.PatnID = his.PsnNo
  12610. pd.PatnName = his.Name
  12611. pd.Gend = his.Gend
  12612. pd.Brdy = str
  12613. pd.Poolarea = his.InsuplcAdmdvs
  12614. pd.CurrMdtrtID = his.Number
  12615. var fed models.FsiEncounterDtos
  12616. fed.MdtrtID = his.Number
  12617. fed.MedinsID = miConfig.Code
  12618. fed.MedinsName = miConfig.OrgName
  12619. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12620. fed.MedMdtrtType = "1"
  12621. fed.MedinsType = "1"
  12622. fed.MedinsLv = "11"
  12623. tm := time.Unix(his.RecordDate, 0)
  12624. s_tm := tm.Format("2006-01-02 15:04:05")
  12625. fed.AdmDate = s_tm
  12626. fed.DscgDate = s_tm
  12627. fed.DscgMainDiseCodg = config[0].CountryCode
  12628. fed.DscgMainDiseName = config[0].CountryContentName
  12629. //诊断信息
  12630. var fdds []*models.FsiDiagnoseDtos
  12631. for index, item := range config {
  12632. if index == 0 {
  12633. var fdd models.FsiDiagnoseDtos
  12634. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12635. fdd.InoutDiseType = "1"
  12636. fdd.MaindiseFlag = "1"
  12637. fdd.DiseDate = s_tm
  12638. fdd.DiasSrtNo = "1"
  12639. fdd.DiseName = item.CountryContentName
  12640. fdd.DiseCodg = item.CountryCode
  12641. fdds = append(fdds, &fdd)
  12642. } else {
  12643. var fdd models.FsiDiagnoseDtos
  12644. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12645. fdd.InoutDiseType = "1"
  12646. fdd.MaindiseFlag = "1"
  12647. fdd.DiseDate = s_tm
  12648. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12649. fdd.DiseName = item.CountryContentName
  12650. fdd.DiseCodg = item.CountryCode
  12651. fdds = append(fdds, &fdd)
  12652. }
  12653. }
  12654. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12655. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12656. fed.AdmDeptName = department.Name
  12657. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12658. fed.DscgDeptName = department.Name
  12659. fed.MedType = order.MedType
  12660. //处方医嘱信息
  12661. var orders []*models.FsiOrderDtos
  12662. //for _, item := range prescriptions {
  12663. // for _, subItem := range item.HisDoctorAdviceInfo {
  12664. // var order models.FsiOrderDtos
  12665. // order.RxID = strconv.FormatInt(item.ID, 10)
  12666. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12667. // order.LongDrordFlag = "0"
  12668. // order.HilistType = "1"
  12669. // order.ChrgType = "1"
  12670. // order.DrordBhvr = "-"
  12671. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12672. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12673. // order.HilistLv = "1"
  12674. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12675. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12676. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12677. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12678. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12679. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12680. // order.OwnpayAmt = ""
  12681. // order.SelfpayAmt = ""
  12682. // order.Spec = ""
  12683. // order.SpecUnt = ""
  12684. // order.DrordBegnDate = s_tm
  12685. // order.DrordStopDate = ""
  12686. // order.DrordDrCodg = "1"
  12687. // order.DrordDeptName = department.Name
  12688. // order.DrordDrCodg = "1"
  12689. // order.DrordDrName = doctor_info.UserName
  12690. // order.DrordDrProfttl = ""
  12691. // order.CurrDrordFlag = "1"
  12692. // orders = append(orders, &order)
  12693. // }
  12694. // for _, subItem := range item.HisPrescriptionProject {
  12695. // if subItem.Type == 2 {
  12696. // var order models.FsiOrderDtos
  12697. // order.RxID = strconv.FormatInt(item.ID, 10)
  12698. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12699. // order.LongDrordFlag = "0"
  12700. // order.HilistType = "1"
  12701. // order.ChrgType = "1"
  12702. // order.DrordBhvr = "-"
  12703. // order.HilistCode = subItem.HisProject.MedicalCode
  12704. // order.HosplistName = subItem.HisProject.ProjectName
  12705. // order.HilistLv = "1"
  12706. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12707. // order.HosplistCode = subItem.HisProject.MedicalCode
  12708. // order.HosplistName = subItem.HisProject.ProjectName
  12709. // order.Cnt = subItem.Count
  12710. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12711. //
  12712. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12713. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12714. // order.OwnpayAmt = ""
  12715. // order.SelfpayAmt = ""
  12716. // order.Spec = ""
  12717. // order.SpecUnt = ""
  12718. // order.DrordBegnDate = s_tm
  12719. // order.DrordStopDate = ""
  12720. // order.DrordDrCodg = "1"
  12721. // order.DrordDeptName = department.Name
  12722. // order.DrordDrCodg = "1"
  12723. // order.DrordDrName = doctor_info.UserName
  12724. // order.DrordDrProfttl = ""
  12725. // order.CurrDrordFlag = "1"
  12726. // orders = append(orders, &order)
  12727. //
  12728. // }
  12729. // if subItem.Type == 3 {
  12730. //
  12731. // var order models.FsiOrderDtos
  12732. // order.RxID = strconv.FormatInt(item.ID, 10)
  12733. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12734. // order.LongDrordFlag = "0"
  12735. // order.HilistType = "1"
  12736. // order.ChrgType = "1"
  12737. // order.DrordBhvr = "-"
  12738. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12739. // order.HosplistName = subItem.GoodInfo.GoodName
  12740. // order.HilistLv = "1"
  12741. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12742. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12743. // order.HosplistName = subItem.GoodInfo.GoodName
  12744. // order.Cnt = subItem.Count
  12745. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12746. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12747. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12748. // order.OwnpayAmt = ""
  12749. // order.SelfpayAmt = ""
  12750. // order.Spec = ""
  12751. // order.SpecUnt = ""
  12752. // order.DrordBegnDate = s_tm
  12753. // order.DrordStopDate = ""
  12754. // order.DrordDrCodg = "1"
  12755. // order.DrordDeptName = department.Name
  12756. // order.DrordDrCodg = "1"
  12757. // order.DrordDrName = doctor_info.UserName
  12758. // order.DrordDrProfttl = ""
  12759. // order.CurrDrordFlag = "1"
  12760. // orders = append(orders, &order)
  12761. //
  12762. // }
  12763. // }
  12764. //}
  12765. for _, item := range prescriptions {
  12766. for _, subItem := range item.HisDoctorAdviceInfo {
  12767. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12768. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12769. var order models.FsiOrderDtos
  12770. order.RxID = strconv.FormatInt(item.ID, 10)
  12771. order.Rxno = strconv.FormatInt(item.ID, 10)
  12772. order.LongDrordFlag = "0"
  12773. order.HilistType = "101"
  12774. order.ChrgType = "01"
  12775. order.DrordBhvr = "0"
  12776. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12777. order.HosplistName = subItem.BaseDrugLib.DrugName
  12778. order.HilistLv = "1"
  12779. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12780. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12781. order.HosplistName = subItem.BaseDrugLib.DrugName
  12782. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12783. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12784. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12785. order.OwnpayAmt = ""
  12786. order.SelfpayAmt = ""
  12787. order.Spec = spec
  12788. order.SpecUnt = subItem.PrescribingNumberUnit
  12789. order.DrordBegnDate = s_tm
  12790. order.DrordStopDate = ""
  12791. order.DrordDrCodg = doctor_info.DoctorNumber
  12792. order.DrordDeptName = department.Name
  12793. order.DrordDeptCodg = department.Number
  12794. order.DrordDrName = doctor_info.UserName
  12795. order.DrordDrProfttl = "234"
  12796. order.CurrDrordFlag = "1"
  12797. orders = append(orders, &order)
  12798. }
  12799. }
  12800. for _, subItem := range item.HisPrescriptionProject {
  12801. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12802. var order models.FsiOrderDtos
  12803. order.RxID = strconv.FormatInt(item.ID, 10)
  12804. order.Rxno = strconv.FormatInt(item.ID, 10)
  12805. order.LongDrordFlag = "0"
  12806. order.HilistType = "201"
  12807. order.ChrgType = "05"
  12808. order.DrordBhvr = "0"
  12809. order.HilistCode = subItem.HisProject.MedicalCode
  12810. order.HosplistName = subItem.HisProject.ProjectName
  12811. order.HilistLv = "1"
  12812. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12813. order.HosplistCode = subItem.HisProject.MedicalCode
  12814. order.HosplistName = subItem.HisProject.ProjectName
  12815. order.Cnt = subItem.Count
  12816. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12817. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12818. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12819. order.OwnpayAmt = ""
  12820. order.SelfpayAmt = ""
  12821. order.Spec = subItem.Unit
  12822. order.SpecUnt = subItem.Unit
  12823. order.DrordBegnDate = s_tm
  12824. order.DrordStopDate = ""
  12825. order.DrordDrCodg = doctor_info.DoctorNumber
  12826. order.DrordDeptName = department.Name
  12827. order.DrordDeptCodg = department.Number
  12828. order.DrordDrName = doctor_info.UserName
  12829. order.DrordDrProfttl = "234"
  12830. order.CurrDrordFlag = "1"
  12831. orders = append(orders, &order)
  12832. }
  12833. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12834. var order models.FsiOrderDtos
  12835. order.RxID = strconv.FormatInt(item.ID, 10)
  12836. order.Rxno = strconv.FormatInt(item.ID, 10)
  12837. order.LongDrordFlag = "0"
  12838. order.HilistType = "301"
  12839. order.ChrgType = "08"
  12840. order.DrordBhvr = "0"
  12841. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12842. order.HosplistName = subItem.GoodInfo.GoodName
  12843. order.HilistLv = "1"
  12844. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12845. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12846. order.HosplistName = subItem.GoodInfo.GoodName
  12847. order.Cnt = subItem.Count
  12848. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12849. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12850. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12851. order.OwnpayAmt = ""
  12852. order.SelfpayAmt = ""
  12853. order.Spec = subItem.GoodInfo.SpecificationName
  12854. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12855. order.DrordBegnDate = s_tm
  12856. order.DrordStopDate = ""
  12857. order.DrordDrCodg = doctor_info.DoctorNumber
  12858. order.DrordDeptName = department.Name
  12859. order.DrordDeptCodg = department.Number
  12860. order.DrordDrName = doctor_info.UserName
  12861. order.DrordDrProfttl = "234"
  12862. order.CurrDrordFlag = "1"
  12863. orders = append(orders, &order)
  12864. }
  12865. }
  12866. }
  12867. //处方医嘱信息
  12868. fed.MatnStas = "0"
  12869. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12870. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12871. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12872. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12873. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12874. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12875. fed.SetlTotlnum = "1"
  12876. fed.Insutype = his.Insutype
  12877. fed.ReimFlag = "0"
  12878. fed.OutSetlFlag = "0"
  12879. var fopd []*models.FsiOperationDtosData
  12880. data := make(map[string]interface{})
  12881. data["fed"] = fed
  12882. data["fdd"] = fdds
  12883. data["fod"] = orders
  12884. data["pd"] = pd
  12885. data["pp"] = pp
  12886. data["fopd"] = fopd
  12887. data["trig_scen"] = trig_scen
  12888. client := &http.Client{}
  12889. bytesData, _ := json.Marshal(data)
  12890. var req *http.Request
  12891. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12892. if miConfig.MdtrtareaAdmvs == "320830" {
  12893. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  12894. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12895. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12896. } else {
  12897. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12898. }
  12899. resp, _ := client.Do(req)
  12900. defer resp.Body.Close()
  12901. body, ioErr := ioutil.ReadAll(resp.Body)
  12902. if ioErr != nil {
  12903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12905. return res
  12906. }
  12907. var respJSON map[string]interface{}
  12908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12911. return res
  12912. }
  12913. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12914. result, _ := json.Marshal(respJSON)
  12915. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12916. utils.ErrorLog("解析失败:%v", err)
  12917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12918. return res
  12919. }
  12920. return res
  12921. } else {
  12922. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12923. saveLog(output, input, "3102", "事中")
  12924. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12925. utils.ErrorLog("解析失败:%v", err)
  12926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12927. return
  12928. }
  12929. return res
  12930. }
  12931. return res
  12932. }
  12933. func (c *HisApiController) Check() {
  12934. psn_no := c.GetString("psn_no")
  12935. in := c.GetString("in")
  12936. mt := c.GetString("mt")
  12937. baseParams := models.BaseParams{
  12938. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12939. FixmedinsCode: "H15049901371",
  12940. InsuplcAdmdvs: "150499",
  12941. MdtrtareaAdmvs: "150499",
  12942. OrgName: "赤峰费森血液透析中心",
  12943. Doctor: "1111",
  12944. }
  12945. service.Gdyb2001(baseParams, psn_no, in, mt)
  12946. }
  12947. func (c *HisApiController) GetPsnNcdsInfo() {
  12948. admin_user_id, _ := c.GetInt64("admin_user_id")
  12949. patient_id, _ := c.GetInt64("patient_id")
  12950. //id, _ := c.GetInt64("id")
  12951. adminUser := c.GetAdminUserInfo()
  12952. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12953. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12954. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12955. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12956. //psn_record, _ := service.GetP(id)
  12957. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12958. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12959. //
  12960. //if psn_record.ID == 0 {
  12961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12962. // return
  12963. //}
  12964. var res Result5301
  12965. var res10265 Result5301For10265
  12966. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12967. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12968. var api string
  12969. if miConfig.MdtrtareaAdmvs == "320830" {
  12970. api = miConfig.AppSecret + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12971. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12972. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12973. 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 +
  12974. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12975. } else {
  12976. 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 +
  12977. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12978. }
  12979. resp, requestErr := http.Get(api)
  12980. if requestErr != nil {
  12981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12982. return
  12983. }
  12984. body, ioErr := ioutil.ReadAll(resp.Body)
  12985. if ioErr != nil {
  12986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12988. return
  12989. }
  12990. var respJSON map[string]interface{}
  12991. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12994. return
  12995. }
  12996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12997. result, _ := json.Marshal(respJSON)
  12998. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12999. utils.ErrorLog("解析失败:%v", err)
  13000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13001. return
  13002. }
  13003. res.ErrMsg = res10265.ErrMsg
  13004. res.Output = res10265.Output
  13005. res.InfRefmsgid = res10265.InfRefmsgid
  13006. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13007. res.Infcode = infocode
  13008. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13009. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13010. var api string
  13011. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13012. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13013. resp, requestErr := http.Get(api)
  13014. if requestErr != nil {
  13015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13016. return
  13017. }
  13018. body, ioErr := ioutil.ReadAll(resp.Body)
  13019. if ioErr != nil {
  13020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13022. return
  13023. }
  13024. var respJSON map[string]interface{}
  13025. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13028. return
  13029. }
  13030. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13031. if status == "0" {
  13032. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13033. c.ServeSuccessJSON(map[string]interface{}{
  13034. "failed_code": -10,
  13035. "msg": err_msg,
  13036. })
  13037. return
  13038. }
  13039. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13040. result, _ := json.Marshal(respJSON)
  13041. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13042. utils.ErrorLog("解析失败:%v", err)
  13043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13044. return
  13045. }
  13046. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13047. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  13048. var api string
  13049. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13050. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13051. resp, requestErr := http.Get(api)
  13052. if requestErr != nil {
  13053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13054. return
  13055. }
  13056. body, ioErr := ioutil.ReadAll(resp.Body)
  13057. if ioErr != nil {
  13058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13060. return
  13061. }
  13062. var respJSON map[string]interface{}
  13063. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13066. return
  13067. }
  13068. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13069. if status == "0" {
  13070. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13071. c.ServeSuccessJSON(map[string]interface{}{
  13072. "failed_code": -10,
  13073. "msg": err_msg,
  13074. })
  13075. return
  13076. }
  13077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13078. result, _ := json.Marshal(respJSON)
  13079. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13080. utils.ErrorLog("解析失败:%v", err)
  13081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13082. return
  13083. }
  13084. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13085. p, _ := service.GetHisPatientById(patient_id)
  13086. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13087. var dat map[string]interface{}
  13088. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13089. fmt.Println(dat)
  13090. } else {
  13091. fmt.Println(err)
  13092. }
  13093. userJSONBytes, _ := json.Marshal(dat)
  13094. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13095. utils.ErrorLog("解析失败:%v", err)
  13096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13097. return
  13098. }
  13099. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13100. p, _ := service.GetHisPatientById(patient_id)
  13101. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13102. var dat map[string]interface{}
  13103. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13104. fmt.Println(dat)
  13105. } else {
  13106. fmt.Println(err)
  13107. }
  13108. userJSONBytes, _ := json.Marshal(dat)
  13109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13110. utils.ErrorLog("解析失败:%v", err)
  13111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13112. return
  13113. }
  13114. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13115. p, _ := service.GetHisPatientById(patient_id)
  13116. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13117. var dat map[string]interface{}
  13118. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13119. fmt.Println(dat)
  13120. } else {
  13121. fmt.Println(err)
  13122. }
  13123. userJSONBytes, _ := json.Marshal(dat)
  13124. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13125. utils.ErrorLog("解析失败:%v", err)
  13126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13127. return
  13128. }
  13129. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13130. p, _ := service.GetHisPatientById(patient_id)
  13131. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13132. var dat map[string]interface{}
  13133. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13134. fmt.Println(dat)
  13135. } else {
  13136. fmt.Println(err)
  13137. }
  13138. userJSONBytes, _ := json.Marshal(dat)
  13139. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13140. utils.ErrorLog("解析失败:%v", err)
  13141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13142. return
  13143. }
  13144. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13145. p, _ := service.GetHisPatientById(patient_id)
  13146. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13147. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13148. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13149. resp, requestErr := http.Get(api)
  13150. if requestErr != nil {
  13151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13152. return
  13153. }
  13154. body, ioErr := ioutil.ReadAll(resp.Body)
  13155. if ioErr != nil {
  13156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13158. return
  13159. }
  13160. var respJSON map[string]interface{}
  13161. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13164. return
  13165. }
  13166. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13167. result, _ := json.Marshal(respJSON)
  13168. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13169. utils.ErrorLog("解析失败:%v", err)
  13170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13171. return
  13172. }
  13173. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13174. p, _ := service.GetHisPatientById(patient_id)
  13175. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  13176. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13177. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13178. resp, requestErr := http.Get(api)
  13179. if requestErr != nil {
  13180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13181. return
  13182. }
  13183. body, ioErr := ioutil.ReadAll(resp.Body)
  13184. if ioErr != nil {
  13185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13187. return
  13188. }
  13189. var respJSON map[string]interface{}
  13190. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13193. return
  13194. }
  13195. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13196. result, _ := json.Marshal(respJSON)
  13197. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13198. utils.ErrorLog("解析失败:%v", err)
  13199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13200. return
  13201. }
  13202. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13203. p, _ := service.GetHisPatientById(patient_id)
  13204. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13205. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13206. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13207. resp, requestErr := http.Get(api)
  13208. if requestErr != nil {
  13209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13210. return
  13211. }
  13212. body, ioErr := ioutil.ReadAll(resp.Body)
  13213. if ioErr != nil {
  13214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13216. return
  13217. }
  13218. var respJSON map[string]interface{}
  13219. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13222. return
  13223. }
  13224. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13225. result, _ := json.Marshal(respJSON)
  13226. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13227. utils.ErrorLog("解析失败:%v", err)
  13228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13229. return
  13230. }
  13231. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13232. p, _ := service.GetHisPatientById(patient_id)
  13233. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13234. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13235. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13236. resp, requestErr := http.Get(api)
  13237. if requestErr != nil {
  13238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13239. return
  13240. }
  13241. body, ioErr := ioutil.ReadAll(resp.Body)
  13242. if ioErr != nil {
  13243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13245. return
  13246. }
  13247. var respJSON map[string]interface{}
  13248. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13251. return
  13252. }
  13253. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13254. result, _ := json.Marshal(respJSON)
  13255. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13256. utils.ErrorLog("解析失败:%v", err)
  13257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13258. return
  13259. }
  13260. } else if miConfig.MdtrtareaAdmvs == "421300" {
  13261. p, _ := service.GetHisPatientById(patient_id)
  13262. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13263. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13264. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13265. resp, requestErr := http.Get(api)
  13266. if requestErr != nil {
  13267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13268. return
  13269. }
  13270. body, ioErr := ioutil.ReadAll(resp.Body)
  13271. if ioErr != nil {
  13272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13274. return
  13275. }
  13276. var respJSON map[string]interface{}
  13277. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13280. return
  13281. }
  13282. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13283. result, _ := json.Marshal(respJSON)
  13284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13285. utils.ErrorLog("解析失败:%v", err)
  13286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13287. return
  13288. }
  13289. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13290. p, _ := service.GetHisPatientById(patient_id)
  13291. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  13292. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13293. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13294. resp, requestErr := http.Get(api)
  13295. if requestErr != nil {
  13296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13297. return
  13298. }
  13299. body, ioErr := ioutil.ReadAll(resp.Body)
  13300. if ioErr != nil {
  13301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13303. return
  13304. }
  13305. var respJSON map[string]interface{}
  13306. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13309. return
  13310. }
  13311. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13312. result, _ := json.Marshal(respJSON)
  13313. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13314. utils.ErrorLog("解析失败:%v", err)
  13315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13316. return
  13317. }
  13318. } else {
  13319. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  13320. var dat map[string]interface{}
  13321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13322. fmt.Println(dat)
  13323. } else {
  13324. fmt.Println(err)
  13325. }
  13326. userJSONBytes, _ := json.Marshal(dat)
  13327. if miConfig.Code == "H15049901371" {
  13328. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13329. utils.ErrorLog("解析失败:%v", err)
  13330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13331. return
  13332. }
  13333. res.InfRefmsgid = res10265.InfRefmsgid
  13334. res.Output = res10265.Output
  13335. res.ErrMsg = res10265.ErrMsg
  13336. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13337. res.Infcode = infocode
  13338. } else {
  13339. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13340. utils.ErrorLog("解析失败:%v", err)
  13341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13342. return
  13343. }
  13344. }
  13345. }
  13346. if res.Infcode == 0 {
  13347. c.ServeSuccessJSON(map[string]interface{}{
  13348. "result": res.Output.Result,
  13349. })
  13350. }
  13351. }
  13352. func (c *HisApiController) CheckInsutype() {
  13353. his_patient_id, _ := c.GetInt64("his_patient_id")
  13354. admin_user_id, _ := c.GetInt64("admin_user_id")
  13355. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13356. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13357. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13358. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13359. var dat map[string]interface{}
  13360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13361. fmt.Println(dat)
  13362. } else {
  13363. fmt.Println(err)
  13364. }
  13365. userJSONBytes, _ := json.Marshal(dat)
  13366. var res Result90100
  13367. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13368. utils.ErrorLog("解析失败:%v", err)
  13369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13370. return
  13371. }
  13372. if res.Infcode != 0 {
  13373. c.ServeSuccessJSON(map[string]interface{}{
  13374. "failed_code": -10,
  13375. "msg": res.ErrMsg,
  13376. })
  13377. return
  13378. } else {
  13379. fmt.Println(res)
  13380. }
  13381. }
  13382. func (c *HisApiController) CheckCardPWD() {
  13383. card_pwd := c.GetString("card_pwd")
  13384. his_patient_id, _ := c.GetInt64("his_patient_id")
  13385. admin_user_id, _ := c.GetInt64("admin_user_id")
  13386. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13387. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13388. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13389. psn, _ := service.GetPsnByPatientId(his.PatientId)
  13390. bas := strings.Split(psn.CardInfo, "|")
  13391. basNumber := bas[2]
  13392. if psn.InsuplcAdmdvs[:4] == "4403" {
  13393. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  13394. var dat map[string]interface{}
  13395. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13396. fmt.Println(dat)
  13397. } else {
  13398. fmt.Println(err)
  13399. }
  13400. userJSONBytes, _ := json.Marshal(dat)
  13401. var res Result90991
  13402. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13403. utils.ErrorLog("解析失败:%v", err)
  13404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13405. return
  13406. }
  13407. if res.Infcode != 0 {
  13408. c.ServeSuccessJSON(map[string]interface{}{
  13409. "failed_code": -10,
  13410. "msg": res.ErrMsg,
  13411. })
  13412. return
  13413. } else {
  13414. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  13415. var msg string
  13416. switch res.Output.Result.CardStat {
  13417. case "00":
  13418. msg = "未激活"
  13419. break
  13420. case "10":
  13421. msg = "激活"
  13422. break
  13423. case "20":
  13424. msg = "窗口挂失"
  13425. break
  13426. case "21":
  13427. msg = "电话挂失"
  13428. break
  13429. case "22":
  13430. msg = "单位网上申报挂失"
  13431. break
  13432. case "23":
  13433. msg = "保健办挂失"
  13434. break
  13435. case "24":
  13436. msg = "个人网上挂失"
  13437. break
  13438. case "25":
  13439. msg = "网上服务大厅挂失"
  13440. break
  13441. case "30":
  13442. msg = "注销"
  13443. break
  13444. case "40":
  13445. msg = "回收"
  13446. break
  13447. case "99":
  13448. msg = "制卡中(无效卡)"
  13449. break
  13450. }
  13451. c.ServeSuccessJSON(map[string]interface{}{
  13452. "failed_code": -10,
  13453. "msg": msg,
  13454. })
  13455. return
  13456. } else {
  13457. c.ServeSuccessJSON(map[string]interface{}{
  13458. "msg": "校验成功",
  13459. })
  13460. return
  13461. }
  13462. }
  13463. } else {
  13464. c.ServeSuccessJSON(map[string]interface{}{
  13465. "msg": "校验成功",
  13466. })
  13467. return
  13468. }
  13469. }
  13470. func (c *HisApiController) CheckCardPWDTwo() {
  13471. //card_pwd := c.GetString("card_pwd")
  13472. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13473. admin_user_id, _ := c.GetInt64("admin_user_id")
  13474. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13475. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13476. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  13477. var dat map[string]interface{}
  13478. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13479. fmt.Println(dat)
  13480. } else {
  13481. fmt.Println(err)
  13482. }
  13483. userJSONBytes, _ := json.Marshal(dat)
  13484. var res Result90991
  13485. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13486. utils.ErrorLog("解析失败:%v", err)
  13487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13488. return
  13489. }
  13490. if res.Infcode != 0 {
  13491. c.ServeSuccessJSON(map[string]interface{}{
  13492. "failed_code": -10,
  13493. "msg": res.ErrMsg,
  13494. })
  13495. return
  13496. } else {
  13497. if res.Output.Result.SscnoCheckStat == "0" {
  13498. var msg string
  13499. switch res.Output.Result.CardStat {
  13500. case "00":
  13501. msg = "未激活"
  13502. break
  13503. case "10":
  13504. msg = "激活"
  13505. break
  13506. case "20":
  13507. msg = "窗口挂失"
  13508. break
  13509. case "21":
  13510. msg = "电话挂失"
  13511. break
  13512. case "22":
  13513. msg = "单位网上申报挂失"
  13514. break
  13515. case "23":
  13516. msg = "保健办挂失"
  13517. break
  13518. case "24":
  13519. msg = "个人网上挂失"
  13520. break
  13521. case "25":
  13522. msg = "网上服务大厅挂失"
  13523. break
  13524. case "30":
  13525. msg = "注销"
  13526. break
  13527. case "40":
  13528. msg = "回收"
  13529. break
  13530. case "99":
  13531. msg = "制卡中(无效卡)"
  13532. break
  13533. }
  13534. c.ServeSuccessJSON(map[string]interface{}{
  13535. "failed_code": -10,
  13536. "msg": msg,
  13537. })
  13538. return
  13539. } else {
  13540. c.ServeSuccessJSON(map[string]interface{}{
  13541. "msg": "校验成功",
  13542. })
  13543. return
  13544. }
  13545. }
  13546. }
  13547. type ELeCertData struct {
  13548. Data struct {
  13549. Extra string `json:"extra"`
  13550. IDNo string `json:"idNo"`
  13551. IDType string `json:"idType"`
  13552. EcToken string `json:"ecToken"`
  13553. InsuOrg string `json:"insuOrg"`
  13554. UserName string `json:"userName"`
  13555. EcIndexNo string `json:"ecIndexNo"`
  13556. Gender string `json:"gender"`
  13557. Birthday string `json:"birthday"`
  13558. Nationality string `json:"nationality"`
  13559. Email string `json:"email"`
  13560. } `json:"OutData"`
  13561. }
  13562. func (c *HisApiController) ReadCard() {
  13563. id_card_type, _ := c.GetInt64("id_card_type")
  13564. admin_user_id, _ := c.GetInt64("admin_user_id")
  13565. certificates, _ := c.GetInt64("certificates")
  13566. //
  13567. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13568. id_card_no := c.GetString("id_card_no")
  13569. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13570. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13571. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13572. switch id_card_type {
  13573. case 1:
  13574. if miConfig.MdtrtareaAdmvs == "421300" {
  13575. var res ResultTwo
  13576. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13577. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13578. "&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)
  13579. resp, requestErr := http.Get(api)
  13580. if requestErr != nil {
  13581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13582. return
  13583. }
  13584. body, ioErr := ioutil.ReadAll(resp.Body)
  13585. if ioErr != nil {
  13586. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13588. return
  13589. }
  13590. var respJSON map[string]interface{}
  13591. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13594. return
  13595. }
  13596. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13597. result, _ := json.Marshal(respJSON)
  13598. fmt.Println("log")
  13599. fmt.Println(string(result))
  13600. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13601. utils.ErrorLog("解析失败:%v", err)
  13602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13603. return
  13604. }
  13605. if res.Infcode == 0 {
  13606. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13607. if err == gorm.ErrRecordNotFound {
  13608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13609. return
  13610. } else if err != nil {
  13611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13612. return
  13613. } else {
  13614. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13615. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13616. infoStr := string(Iinfos)
  13617. idetinfoStr := string(Idetinfos)
  13618. var rf []*ResultFive
  13619. json.Unmarshal([]byte(infoStr), &rf)
  13620. var insutypes []*ResultFive
  13621. var insutype string
  13622. var is390 int = 0
  13623. var is310 int = 0
  13624. for _, item := range rf {
  13625. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13626. insutypes = append(insutypes, item)
  13627. }
  13628. }
  13629. if len(insutypes) == 1 {
  13630. insutype = insutypes[0].Insutype
  13631. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13632. } else {
  13633. for _, i := range insutypes {
  13634. if i.Insutype == "390" {
  13635. is390 = 1
  13636. }
  13637. if i.Insutype == "310" {
  13638. is310 = 1
  13639. }
  13640. }
  13641. }
  13642. if is390 == 1 {
  13643. insutype = "390"
  13644. }
  13645. if is310 == 1 {
  13646. insutype = "310"
  13647. }
  13648. if len(insutypes) == 0 {
  13649. insutype = "390"
  13650. }
  13651. var insuplc_admdvs string
  13652. for _, item := range rf {
  13653. if item.Insutype == insutype {
  13654. insuplc_admdvs = item.InsuplcAdmdvs
  13655. }
  13656. }
  13657. if strings.Contains(insuplc_admdvs, "4213") {
  13658. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13659. }
  13660. psn := &models.HisPsn{
  13661. PsnNo: res.Output.Baseinfo.PsnNo,
  13662. PatientId: patient.ID,
  13663. Certno: res.Output.Baseinfo.Certno,
  13664. Gend: res.Output.Baseinfo.Gend,
  13665. Naty: res.Output.Baseinfo.Naty,
  13666. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13667. PsnName: res.Output.Baseinfo.PsnName,
  13668. Idetinfo: idetinfoStr,
  13669. Insuinfo: infoStr,
  13670. InsuplcAdmdvs: insuplc_admdvs,
  13671. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13672. }
  13673. service.CreateHisPsn(psn)
  13674. c.ServeSuccessJSON(map[string]interface{}{
  13675. "patient": patient,
  13676. "number": res.Output.Baseinfo.Certno,
  13677. })
  13678. }
  13679. } else {
  13680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13681. return
  13682. }
  13683. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13684. var res ResultTwo
  13685. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13686. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13687. "&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)
  13688. resp, requestErr := http.Get(api)
  13689. if requestErr != nil {
  13690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13691. return
  13692. }
  13693. body, ioErr := ioutil.ReadAll(resp.Body)
  13694. if ioErr != nil {
  13695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13697. return
  13698. }
  13699. var respJSON map[string]interface{}
  13700. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13703. return
  13704. }
  13705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13706. result, _ := json.Marshal(respJSON)
  13707. fmt.Println("log")
  13708. fmt.Println(string(result))
  13709. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13710. utils.ErrorLog("解析失败:%v", err)
  13711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13712. return
  13713. }
  13714. if res.Infcode == 0 {
  13715. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13716. if err == gorm.ErrRecordNotFound {
  13717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13718. return
  13719. } else if err != nil {
  13720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13721. return
  13722. } else {
  13723. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13724. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13725. infoStr := string(Iinfos)
  13726. idetinfoStr := string(Idetinfos)
  13727. psn := &models.HisPsn{
  13728. PsnNo: res.Output.Baseinfo.PsnNo,
  13729. PatientId: patient.ID,
  13730. Certno: res.Output.Baseinfo.Certno,
  13731. Gend: res.Output.Baseinfo.Gend,
  13732. Naty: res.Output.Baseinfo.Naty,
  13733. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13734. PsnName: res.Output.Baseinfo.PsnName,
  13735. Idetinfo: idetinfoStr,
  13736. Insuinfo: infoStr,
  13737. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13738. }
  13739. service.CreateHisPsn(psn)
  13740. var rf []*ResultFive
  13741. json.Unmarshal([]byte(infoStr), &rf)
  13742. var insutypes []*ResultFive
  13743. var insutype string
  13744. var is390 int = 0
  13745. var is310 int = 0
  13746. for _, item := range rf {
  13747. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13748. insutypes = append(insutypes, item)
  13749. }
  13750. }
  13751. if len(insutypes) == 1 {
  13752. insutype = insutypes[0].Insutype
  13753. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13754. } else {
  13755. for _, i := range insutypes {
  13756. if i.Insutype == "390" {
  13757. is390 = 1
  13758. }
  13759. if i.Insutype == "310" {
  13760. is310 = 1
  13761. }
  13762. }
  13763. }
  13764. if is390 == 1 {
  13765. insutype = "390"
  13766. }
  13767. if is310 == 1 {
  13768. insutype = "310"
  13769. }
  13770. if len(insutypes) == 0 {
  13771. insutype = "310"
  13772. }
  13773. c.ServeSuccessJSON(map[string]interface{}{
  13774. "patient": patient,
  13775. "number": res.Output.Baseinfo.Certno,
  13776. "insutype": insutype,
  13777. })
  13778. }
  13779. } else {
  13780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13781. return
  13782. }
  13783. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13784. var res ResultTwo
  13785. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13786. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13787. "&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)
  13788. resp, requestErr := http.Get(api)
  13789. if requestErr != nil {
  13790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13791. return
  13792. }
  13793. body, ioErr := ioutil.ReadAll(resp.Body)
  13794. if ioErr != nil {
  13795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13797. return
  13798. }
  13799. var respJSON map[string]interface{}
  13800. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13803. return
  13804. }
  13805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13806. result, _ := json.Marshal(respJSON)
  13807. fmt.Println("log")
  13808. fmt.Println(string(result))
  13809. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13810. utils.ErrorLog("解析失败:%v", err)
  13811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13812. return
  13813. }
  13814. if res.Infcode == 0 {
  13815. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13816. if err == gorm.ErrRecordNotFound {
  13817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13818. return
  13819. } else if err != nil {
  13820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13821. return
  13822. } else {
  13823. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13824. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13825. infoStr := string(Iinfos)
  13826. idetinfoStr := string(Idetinfos)
  13827. var rf []*ResultFive
  13828. json.Unmarshal([]byte(infoStr), &rf)
  13829. var insutypes []*ResultFive
  13830. var insutype string
  13831. var is390 int = 0
  13832. var is310 int = 0
  13833. for _, item := range rf {
  13834. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13835. insutypes = append(insutypes, item)
  13836. }
  13837. }
  13838. if len(insutypes) == 1 {
  13839. insutype = insutypes[0].Insutype
  13840. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13841. } else {
  13842. for _, i := range insutypes {
  13843. if i.Insutype == "390" {
  13844. is390 = 1
  13845. }
  13846. if i.Insutype == "310" {
  13847. is310 = 1
  13848. }
  13849. }
  13850. }
  13851. if is390 == 1 {
  13852. insutype = "390"
  13853. }
  13854. if is310 == 1 {
  13855. insutype = "310"
  13856. }
  13857. if len(insutypes) == 0 {
  13858. insutype = "390"
  13859. }
  13860. var insuplc_admdvs string
  13861. for _, item := range rf {
  13862. if item.Insutype == insutype {
  13863. insuplc_admdvs = item.InsuplcAdmdvs
  13864. }
  13865. }
  13866. psn := &models.HisPsn{
  13867. PsnNo: res.Output.Baseinfo.PsnNo,
  13868. PatientId: patient.ID,
  13869. Certno: res.Output.Baseinfo.Certno,
  13870. Gend: res.Output.Baseinfo.Gend,
  13871. Naty: res.Output.Baseinfo.Naty,
  13872. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13873. PsnName: res.Output.Baseinfo.PsnName,
  13874. Idetinfo: idetinfoStr,
  13875. Insuinfo: infoStr,
  13876. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13877. InsuplcAdmdvs: insuplc_admdvs,
  13878. }
  13879. service.CreateHisPsn(psn)
  13880. for _, item := range rf {
  13881. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13882. insutypes = append(insutypes, item)
  13883. }
  13884. }
  13885. if len(insutypes) == 1 {
  13886. insutype = insutypes[0].Insutype
  13887. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13888. } else {
  13889. for _, i := range insutypes {
  13890. if i.Insutype == "390" {
  13891. is390 = 1
  13892. }
  13893. if i.Insutype == "310" {
  13894. is310 = 1
  13895. }
  13896. }
  13897. }
  13898. if is390 == 1 {
  13899. insutype = "390"
  13900. }
  13901. if is310 == 1 {
  13902. insutype = "310"
  13903. }
  13904. if len(insutypes) == 0 {
  13905. insutype = "310"
  13906. }
  13907. c.ServeSuccessJSON(map[string]interface{}{
  13908. "patient": patient,
  13909. "number": res.Output.Baseinfo.Certno,
  13910. "insutype": insutype,
  13911. })
  13912. }
  13913. } else {
  13914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13915. return
  13916. }
  13917. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13918. var res ResultTwo
  13919. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13920. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13921. "&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)
  13922. resp, requestErr := http.Get(api)
  13923. if requestErr != nil {
  13924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13925. return
  13926. }
  13927. body, ioErr := ioutil.ReadAll(resp.Body)
  13928. if ioErr != nil {
  13929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13931. return
  13932. }
  13933. var respJSON map[string]interface{}
  13934. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13937. return
  13938. }
  13939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13940. result, _ := json.Marshal(respJSON)
  13941. fmt.Println("log")
  13942. fmt.Println(string(result))
  13943. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13944. utils.ErrorLog("解析失败:%v", err)
  13945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13946. return
  13947. }
  13948. if res.Infcode == 0 {
  13949. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13950. if err == gorm.ErrRecordNotFound {
  13951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13952. return
  13953. } else if err != nil {
  13954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13955. return
  13956. } else {
  13957. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13958. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13959. infoStr := string(Iinfos)
  13960. idetinfoStr := string(Idetinfos)
  13961. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13962. psn := &models.HisPsn{
  13963. PsnNo: res.Output.Baseinfo.PsnNo,
  13964. PatientId: patient.ID,
  13965. Certno: res.Output.Baseinfo.Certno,
  13966. Brdy: b,
  13967. Age: float64(age),
  13968. Gend: res.Output.Baseinfo.Gend,
  13969. Naty: res.Output.Baseinfo.Naty,
  13970. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13971. PsnName: res.Output.Baseinfo.PsnName,
  13972. Idetinfo: idetinfoStr,
  13973. Insuinfo: infoStr,
  13974. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13975. }
  13976. service.CreateHisPsn(psn)
  13977. var rf []*ResultFive
  13978. json.Unmarshal([]byte(infoStr), &rf)
  13979. var insutypes []*ResultFive
  13980. var insutype string
  13981. var is390 int = 0
  13982. var is310 int = 0
  13983. for _, item := range rf {
  13984. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13985. insutypes = append(insutypes, item)
  13986. }
  13987. }
  13988. if len(insutypes) == 1 {
  13989. insutype = insutypes[0].Insutype
  13990. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13991. } else {
  13992. for _, i := range insutypes {
  13993. if i.Insutype == "390" {
  13994. is390 = 1
  13995. }
  13996. if i.Insutype == "310" {
  13997. is310 = 1
  13998. }
  13999. }
  14000. }
  14001. if is390 == 1 {
  14002. insutype = "390"
  14003. }
  14004. if is310 == 1 {
  14005. insutype = "310"
  14006. }
  14007. if len(insutypes) == 0 {
  14008. insutype = "310"
  14009. }
  14010. c.ServeSuccessJSON(map[string]interface{}{
  14011. "patient": patient,
  14012. "number": res.Output.Baseinfo.Certno,
  14013. "insutype": insutype,
  14014. })
  14015. }
  14016. } else {
  14017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14018. return
  14019. }
  14020. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  14021. var api string
  14022. if miConfig.MdtrtareaAdmvs == "320830" {
  14023. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14024. "&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
  14025. fmt.Println(api)
  14026. } else if miConfig.MdtrtareaAdmvs == "320921" {
  14027. 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 +
  14028. "&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
  14029. fmt.Println(api)
  14030. } else {
  14031. 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 +
  14032. "&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)
  14033. }
  14034. resp, requestErr := http.Get(api)
  14035. if requestErr != nil {
  14036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14037. return
  14038. }
  14039. body, ioErr := ioutil.ReadAll(resp.Body)
  14040. if ioErr != nil {
  14041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14043. return
  14044. }
  14045. var respJSON map[string]interface{}
  14046. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14049. return
  14050. }
  14051. var status string
  14052. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14053. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14054. //console.log()
  14055. fmt.Println("type===")
  14056. fmt.Println(card_type)
  14057. var token string
  14058. var res ResultTwo //1101结果
  14059. var res10265 ResultTwo10265 //1101结果
  14060. var card_info string //卡信息
  14061. var busi_card_info string
  14062. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14063. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14064. if status == "0" { //读卡成功
  14065. if card_type == "1" {
  14066. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14067. result, _ := json.Marshal(respJSON)
  14068. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14069. utils.ErrorLog("解析失败:%v", err)
  14070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14071. return
  14072. }
  14073. res.ErrMsg = res10265.ErrMsg
  14074. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14075. res.Infcode = infocode
  14076. res.Output = res10265.Output
  14077. res.InfRefmsgid = res10265.InfRefmsgid
  14078. } else {
  14079. //var card_info string //卡信息
  14080. //var busi_card_info string
  14081. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14082. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14083. //fmt.Println(card_info)
  14084. //fmt.Println(busi_card_info)
  14085. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14086. result, _ := json.Marshal(respJSON)
  14087. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14088. utils.ErrorLog("解析失败:%v", err)
  14089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14090. return
  14091. }
  14092. res.ErrMsg = res10265.ErrMsg
  14093. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14094. res.Infcode = infocode
  14095. res.Output = res10265.Output
  14096. res.InfRefmsgid = res10265.InfRefmsgid
  14097. }
  14098. if res.Infcode == 0 {
  14099. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14100. if err == gorm.ErrRecordNotFound {
  14101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14102. return
  14103. } else if err != nil {
  14104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14105. return
  14106. } else {
  14107. if card_type == "1" {
  14108. bas := strings.Split(card_info, "|")
  14109. basNumber := bas[2]
  14110. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14111. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14112. infoStr := string(Iinfos)
  14113. idetinfoStr := string(Idetinfos)
  14114. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14115. psn := &models.HisPsn{
  14116. PsnNo: res.Output.Baseinfo.PsnNo,
  14117. PatientId: patient.ID,
  14118. Certno: res.Output.Baseinfo.Certno,
  14119. Brdy: b,
  14120. Age: float64(age),
  14121. Gend: res.Output.Baseinfo.Gend,
  14122. Naty: res.Output.Baseinfo.Naty,
  14123. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14124. PsnName: res.Output.Baseinfo.PsnName,
  14125. Idetinfo: idetinfoStr,
  14126. Insuinfo: infoStr,
  14127. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14128. CardInfo: card_info,
  14129. VerifyNumber: busi_card_info,
  14130. }
  14131. service.CreateHisPsn(psn)
  14132. var rf []*ResultFive
  14133. json.Unmarshal([]byte(infoStr), &rf)
  14134. var insutypes []*ResultFive
  14135. var insutype string
  14136. var is390 int = 0
  14137. var is310 int = 0
  14138. for _, item := range rf {
  14139. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14140. insutypes = append(insutypes, item)
  14141. }
  14142. }
  14143. if len(insutypes) == 1 {
  14144. insutype = insutypes[0].Insutype
  14145. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14146. } else {
  14147. for _, i := range insutypes {
  14148. if i.Insutype == "390" {
  14149. is390 = 1
  14150. }
  14151. if i.Insutype == "310" {
  14152. is310 = 1
  14153. }
  14154. }
  14155. }
  14156. if is390 == 1 {
  14157. insutype = "390"
  14158. }
  14159. if is310 == 1 {
  14160. insutype = "310"
  14161. }
  14162. if len(insutypes) == 0 {
  14163. insutype = "310"
  14164. }
  14165. c.ServeSuccessJSON(map[string]interface{}{
  14166. "patient": patient,
  14167. "number": basNumber,
  14168. "insutype": insutype,
  14169. })
  14170. } else {
  14171. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14172. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14173. infoStr := string(Iinfos)
  14174. idetinfoStr := string(Idetinfos)
  14175. psn := &models.HisPsn{
  14176. PsnNo: res.Output.Baseinfo.PsnNo,
  14177. PatientId: patient.ID,
  14178. Certno: res.Output.Baseinfo.Certno,
  14179. Gend: res.Output.Baseinfo.Gend,
  14180. Naty: res.Output.Baseinfo.Naty,
  14181. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14182. PsnName: res.Output.Baseinfo.PsnName,
  14183. Idetinfo: idetinfoStr,
  14184. Insuinfo: infoStr,
  14185. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14186. CardInfo: card_info,
  14187. VerifyNumber: token,
  14188. }
  14189. service.CreateHisPsn(psn)
  14190. c.ServeSuccessJSON(map[string]interface{}{
  14191. "patient": patient,
  14192. "number": token,
  14193. })
  14194. }
  14195. }
  14196. } else {
  14197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14198. return
  14199. }
  14200. } else { //读卡失败
  14201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14202. return
  14203. }
  14204. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14205. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  14206. cardnum = DeleteExtraSpaceTwo(cardnum)
  14207. cardCode = DeleteExtraSpaceTwo(cardCode)
  14208. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  14209. name = DeleteExtraSpaceTwo(name)
  14210. errmsg = DeleteExtraSpaceTwo(errmsg)
  14211. cardnum = Remove0000(cardnum)
  14212. cardCode = Remove0000(cardCode)
  14213. id_card_no = Remove0000(id_card_no)
  14214. name = Remove0000(name)
  14215. errmsg = Remove0000(errmsg)
  14216. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  14217. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  14218. //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)
  14219. //fmt.Println(result2)
  14220. //fmt.Println(requestLog2)
  14221. //fmt.Println(errMsgLog2)
  14222. 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)
  14223. saveLog(result, requestLog, "1101", "获取人员信息")
  14224. fmt.Println(errMsgLog)
  14225. if len(errMsgLog) > 0 {
  14226. } else {
  14227. var dat map[string]interface{}
  14228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14229. fmt.Println(dat)
  14230. } else {
  14231. fmt.Println(err)
  14232. }
  14233. userJSONBytes, _ := json.Marshal(dat)
  14234. var res ResultTwo
  14235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14236. utils.ErrorLog("解析失败:%v", err)
  14237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14238. return
  14239. }
  14240. res.ErrMsg = errMsgLog
  14241. if res.Infcode == 0 {
  14242. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14243. if err == gorm.ErrRecordNotFound {
  14244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14245. return
  14246. } else if err != nil {
  14247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14248. return
  14249. } else {
  14250. fmt.Println(res)
  14251. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14252. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14253. infoStr := string(Iinfos)
  14254. idetinfoStr := string(Idetinfos)
  14255. var rf []*ResultFive
  14256. json.Unmarshal([]byte(infoStr), &rf)
  14257. var insutypes []*ResultFive
  14258. var insutype string
  14259. var is390 int = 0
  14260. var is310 int = 0
  14261. for _, item := range rf {
  14262. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14263. insutypes = append(insutypes, item)
  14264. }
  14265. }
  14266. if len(insutypes) == 1 {
  14267. insutype = insutypes[0].Insutype
  14268. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14269. } else {
  14270. for _, i := range insutypes {
  14271. if i.Insutype == "390" {
  14272. is390 = 1
  14273. }
  14274. if i.Insutype == "310" {
  14275. is310 = 1
  14276. }
  14277. }
  14278. }
  14279. if is390 == 1 {
  14280. insutype = "390"
  14281. }
  14282. if is310 == 1 {
  14283. insutype = "310"
  14284. }
  14285. if len(insutypes) == 0 {
  14286. insutype = "390"
  14287. }
  14288. var insuplc_admdvs string
  14289. for _, item := range rf {
  14290. if item.Insutype == insutype {
  14291. insuplc_admdvs = item.InsuplcAdmdvs
  14292. }
  14293. }
  14294. psn := &models.HisPsn{
  14295. PsnNo: res.Output.Baseinfo.PsnNo,
  14296. PatientId: patient.ID,
  14297. Certno: res.Output.Baseinfo.Certno,
  14298. Gend: res.Output.Baseinfo.Gend,
  14299. Naty: res.Output.Baseinfo.Naty,
  14300. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14301. PsnName: res.Output.Baseinfo.PsnName,
  14302. Idetinfo: idetinfoStr,
  14303. Insuinfo: infoStr,
  14304. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14305. CardInfo: basStr,
  14306. VerifyNumber: "",
  14307. InsuplcAdmdvs: insuplc_admdvs,
  14308. }
  14309. service.CreateHisPsn(psn)
  14310. c.ServeSuccessJSON(map[string]interface{}{
  14311. "patient": patient,
  14312. "number": cardnum,
  14313. "insutype": insutype,
  14314. })
  14315. }
  14316. } else {
  14317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14318. return
  14319. }
  14320. }
  14321. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14322. fmt.Println(initFlag)
  14323. fmt.Println("initFlag")
  14324. if initFlag == 0 {
  14325. c.TestGetJiangXiBasBaseInit()
  14326. }
  14327. basStr := c.GetBasBaseInfo()
  14328. if len(basStr) == 0 {
  14329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14330. return
  14331. }
  14332. fmt.Println(basStr)
  14333. bas := strings.Split(basStr, "|")
  14334. basNumber := bas[1]
  14335. fmt.Println(basNumber)
  14336. card := bas[2]
  14337. card_sn := bas[3]
  14338. fmt.Println(card_sn)
  14339. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14340. 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)
  14341. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14342. var dat map[string]interface{}
  14343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14344. fmt.Println(dat)
  14345. } else {
  14346. fmt.Println(err)
  14347. }
  14348. userJSONBytes, _ := json.Marshal(dat)
  14349. var res ResultTwo
  14350. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14351. utils.ErrorLog("解析失败:%v", err)
  14352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14353. return
  14354. }
  14355. if res.Infcode == 0 {
  14356. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14357. if err == gorm.ErrRecordNotFound {
  14358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14359. return
  14360. } else if err != nil {
  14361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14362. return
  14363. } else {
  14364. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14365. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14366. infoStr := string(Iinfos)
  14367. idetinfoStr := string(Idetinfos)
  14368. var rf []*ResultFive
  14369. json.Unmarshal([]byte(infoStr), &rf)
  14370. var insutypes []*ResultFive
  14371. var insutype string
  14372. var is390 int = 0
  14373. var is310 int = 0
  14374. var insuplc_admdvs string
  14375. for _, item := range rf {
  14376. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14377. insutypes = append(insutypes, item)
  14378. }
  14379. }
  14380. if len(insutypes) == 1 {
  14381. insutype = insutypes[0].Insutype
  14382. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14383. } else {
  14384. for _, i := range insutypes {
  14385. if i.Insutype == "390" {
  14386. is390 = 1
  14387. }
  14388. if i.Insutype == "310" {
  14389. is310 = 1
  14390. }
  14391. }
  14392. }
  14393. if is390 == 1 {
  14394. insutype = "390"
  14395. }
  14396. if is310 == 1 {
  14397. insutype = "310"
  14398. }
  14399. if len(insutypes) == 0 {
  14400. insutype = "310"
  14401. }
  14402. for _, item := range rf {
  14403. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14404. insuplc_admdvs = item.InsuplcAdmdvs
  14405. }
  14406. }
  14407. psn := &models.HisPsn{
  14408. PsnNo: res.Output.Baseinfo.PsnNo,
  14409. PatientId: patient.ID,
  14410. Certno: res.Output.Baseinfo.Certno,
  14411. Gend: res.Output.Baseinfo.Gend,
  14412. Naty: res.Output.Baseinfo.Naty,
  14413. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14414. PsnName: res.Output.Baseinfo.PsnName,
  14415. Idetinfo: idetinfoStr,
  14416. Insuinfo: infoStr,
  14417. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14418. CardInfo: basStr,
  14419. InsuplcAdmdvs: insuplc_admdvs,
  14420. VerifyNumber: "",
  14421. }
  14422. service.CreateHisPsn(psn)
  14423. c.ServeSuccessJSON(map[string]interface{}{
  14424. "patient": patient,
  14425. "number": basNumber,
  14426. "insutype": insutype,
  14427. })
  14428. }
  14429. } else {
  14430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14431. return
  14432. }
  14433. } else if miConfig.MdtrtareaAdmvs == "361025" {
  14434. basStr := c.GetBasBaseInfo22222()
  14435. fmt.Println(basStr)
  14436. if len(basStr) == 0 {
  14437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14438. return
  14439. }
  14440. fmt.Println(basStr)
  14441. bas := strings.Split(basStr, "|")
  14442. basNumber := bas[2] //卡号
  14443. card_sn := bas[3] //
  14444. id_card_No := bas[1] //卡号
  14445. fmt.Println(basNumber)
  14446. fmt.Println(card_sn)
  14447. fmt.Println(id_card_No)
  14448. var patient service.Patients
  14449. if len(id_card_No) == 0 {
  14450. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14451. } else {
  14452. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14453. }
  14454. 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)
  14455. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14456. var dat map[string]interface{}
  14457. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14458. fmt.Println(dat)
  14459. } else {
  14460. fmt.Println(err)
  14461. }
  14462. userJSONBytes, _ := json.Marshal(dat)
  14463. var res ResultTwo
  14464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14465. utils.ErrorLog("解析失败:%v", err)
  14466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14467. return
  14468. }
  14469. if res.Infcode == 0 {
  14470. var pateint2 service.Patients
  14471. var err error
  14472. if len(id_card_No) == 0 {
  14473. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14474. } else {
  14475. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14476. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14477. }
  14478. if err == gorm.ErrRecordNotFound {
  14479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14480. return
  14481. } else if err != nil {
  14482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14483. return
  14484. } else {
  14485. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14486. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14487. infoStr := string(Iinfos)
  14488. idetinfoStr := string(Idetinfos)
  14489. var rf []*ResultFive
  14490. json.Unmarshal([]byte(infoStr), &rf)
  14491. var insutypes []*ResultFive
  14492. var insutype string
  14493. var is390 int = 0
  14494. var is310 int = 0
  14495. var insuplc_admdvs string
  14496. for _, item := range rf {
  14497. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14498. insutypes = append(insutypes, item)
  14499. }
  14500. }
  14501. if len(insutypes) == 1 {
  14502. insutype = insutypes[0].Insutype
  14503. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14504. } else {
  14505. for _, i := range insutypes {
  14506. if i.Insutype == "390" {
  14507. is390 = 1
  14508. }
  14509. if i.Insutype == "310" {
  14510. is310 = 1
  14511. }
  14512. }
  14513. }
  14514. if is390 == 1 {
  14515. insutype = "390"
  14516. }
  14517. if is310 == 1 {
  14518. insutype = "310"
  14519. }
  14520. if len(insutypes) == 0 {
  14521. insutype = "310"
  14522. }
  14523. for _, item := range rf {
  14524. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14525. insuplc_admdvs = item.InsuplcAdmdvs
  14526. }
  14527. }
  14528. psn := &models.HisPsn{
  14529. PsnNo: res.Output.Baseinfo.PsnNo,
  14530. PatientId: pateint2.ID,
  14531. Certno: res.Output.Baseinfo.Certno,
  14532. Gend: res.Output.Baseinfo.Gend,
  14533. Naty: res.Output.Baseinfo.Naty,
  14534. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14535. PsnName: res.Output.Baseinfo.PsnName,
  14536. Idetinfo: idetinfoStr,
  14537. Insuinfo: infoStr,
  14538. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14539. CardInfo: basStr,
  14540. InsuplcAdmdvs: insuplc_admdvs,
  14541. VerifyNumber: "",
  14542. }
  14543. service.CreateHisPsn(psn)
  14544. c.ServeSuccessJSON(map[string]interface{}{
  14545. "patient": patient,
  14546. "number": basNumber,
  14547. "insutype": insutype,
  14548. })
  14549. }
  14550. } else {
  14551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14552. return
  14553. }
  14554. } else if miConfig.MdtrtareaAdmvs == "360100" {
  14555. fmt.Println(initFlag)
  14556. fmt.Println("initFlag")
  14557. if initFlag == 0 {
  14558. c.TestGetJiangXiBasBaseInittwo()
  14559. }
  14560. basStr := c.GetBasBaseInfo()
  14561. if len(basStr) == 0 {
  14562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14563. return
  14564. }
  14565. fmt.Println(basStr)
  14566. bas := strings.Split(basStr, "|")
  14567. basNumber := bas[1]
  14568. fmt.Println(basNumber)
  14569. card_sn := bas[3]
  14570. fmt.Println(card_sn)
  14571. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14572. 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)
  14573. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14574. var dat map[string]interface{}
  14575. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14576. fmt.Println(dat)
  14577. } else {
  14578. fmt.Println(err)
  14579. }
  14580. userJSONBytes, _ := json.Marshal(dat)
  14581. var res ResultTwo
  14582. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14583. utils.ErrorLog("解析失败:%v", err)
  14584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14585. return
  14586. }
  14587. if res.Infcode == 0 {
  14588. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14589. if err == gorm.ErrRecordNotFound {
  14590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14591. return
  14592. } else if err != nil {
  14593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14594. return
  14595. } else {
  14596. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14597. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14598. infoStr := string(Iinfos)
  14599. idetinfoStr := string(Idetinfos)
  14600. var rf []*ResultFive
  14601. json.Unmarshal([]byte(infoStr), &rf)
  14602. var insutypes []*ResultFive
  14603. var insutype string
  14604. var is390 int = 0
  14605. var is310 int = 0
  14606. var insuplc_admdvs string
  14607. for _, item := range rf {
  14608. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14609. insutypes = append(insutypes, item)
  14610. }
  14611. }
  14612. if len(insutypes) == 1 {
  14613. insutype = insutypes[0].Insutype
  14614. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14615. } else {
  14616. for _, i := range insutypes {
  14617. if i.Insutype == "390" {
  14618. is390 = 1
  14619. }
  14620. if i.Insutype == "310" {
  14621. is310 = 1
  14622. }
  14623. }
  14624. }
  14625. if is390 == 1 {
  14626. insutype = "390"
  14627. }
  14628. if is310 == 1 {
  14629. insutype = "310"
  14630. }
  14631. if len(insutypes) == 0 {
  14632. insutype = "310"
  14633. }
  14634. for _, item := range rf {
  14635. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14636. insuplc_admdvs = item.InsuplcAdmdvs
  14637. }
  14638. }
  14639. psn := &models.HisPsn{
  14640. PsnNo: res.Output.Baseinfo.PsnNo,
  14641. PatientId: patient.ID,
  14642. Certno: res.Output.Baseinfo.Certno,
  14643. Gend: res.Output.Baseinfo.Gend,
  14644. Naty: res.Output.Baseinfo.Naty,
  14645. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14646. PsnName: res.Output.Baseinfo.PsnName,
  14647. Idetinfo: idetinfoStr,
  14648. Insuinfo: infoStr,
  14649. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14650. CardInfo: basStr,
  14651. InsuplcAdmdvs: insuplc_admdvs,
  14652. VerifyNumber: "",
  14653. }
  14654. service.CreateHisPsn(psn)
  14655. c.ServeSuccessJSON(map[string]interface{}{
  14656. "patient": patient,
  14657. "number": basNumber,
  14658. "insutype": insutype,
  14659. })
  14660. }
  14661. } else {
  14662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14663. return
  14664. }
  14665. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14666. fmt.Println(initFlag)
  14667. fmt.Println("initFlag")
  14668. if initFlag == 0 {
  14669. c.TestGetHnBasBaseInit()
  14670. }
  14671. basStr := c.GetBasBaseInfo()
  14672. if len(basStr) == 0 {
  14673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14674. return
  14675. }
  14676. fmt.Println(basStr)
  14677. bas := strings.Split(basStr, "|")
  14678. basNumber := bas[1]
  14679. fmt.Println(basNumber)
  14680. card_sn := bas[3]
  14681. card_no := bas[2]
  14682. fmt.Println(card_sn)
  14683. name := bas[4]
  14684. name = ConvertToString(name, "gbk", "utf-8")
  14685. 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)
  14686. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14687. var dat map[string]interface{}
  14688. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14689. fmt.Println(dat)
  14690. } else {
  14691. fmt.Println(err)
  14692. }
  14693. userJSONBytes, _ := json.Marshal(dat)
  14694. var res ResultTwo
  14695. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14696. utils.ErrorLog("解析失败:%v", err)
  14697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14698. return
  14699. }
  14700. if res.Infcode == 0 {
  14701. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14702. if err == gorm.ErrRecordNotFound {
  14703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14704. return
  14705. } else if err != nil {
  14706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14707. return
  14708. } else {
  14709. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14710. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14711. infoStr := string(Iinfos)
  14712. idetinfoStr := string(Idetinfos)
  14713. psn := &models.HisPsn{
  14714. PsnNo: res.Output.Baseinfo.PsnNo,
  14715. PatientId: patient.ID,
  14716. Certno: res.Output.Baseinfo.Certno,
  14717. Gend: res.Output.Baseinfo.Gend,
  14718. Naty: res.Output.Baseinfo.Naty,
  14719. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14720. PsnName: res.Output.Baseinfo.PsnName,
  14721. Idetinfo: idetinfoStr,
  14722. Insuinfo: infoStr,
  14723. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14724. CardInfo: basStr,
  14725. VerifyNumber: "",
  14726. }
  14727. service.CreateHisPsn(psn)
  14728. var rf []*ResultFive
  14729. json.Unmarshal([]byte(infoStr), &rf)
  14730. var insutypes []*ResultFive
  14731. var insutype string
  14732. var is390 int = 0
  14733. var is310 int = 0
  14734. for _, item := range rf {
  14735. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14736. insutypes = append(insutypes, item)
  14737. }
  14738. }
  14739. if len(insutypes) == 1 {
  14740. insutype = insutypes[0].Insutype
  14741. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14742. } else {
  14743. for _, i := range insutypes {
  14744. if i.Insutype == "390" {
  14745. is390 = 1
  14746. }
  14747. if i.Insutype == "310" {
  14748. is310 = 1
  14749. }
  14750. }
  14751. }
  14752. if is390 == 1 {
  14753. insutype = "390"
  14754. }
  14755. if is310 == 1 {
  14756. insutype = "310"
  14757. }
  14758. if len(insutypes) == 0 {
  14759. insutype = "310"
  14760. }
  14761. c.ServeSuccessJSON(map[string]interface{}{
  14762. "patient": patient,
  14763. "number": basNumber,
  14764. "insutype": insutype,
  14765. })
  14766. }
  14767. } else {
  14768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14769. return
  14770. }
  14771. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14772. var api string
  14773. 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 +
  14774. "&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
  14775. fmt.Println(api)
  14776. resp, requestErr := http.Get(api)
  14777. if requestErr != nil {
  14778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14779. return
  14780. }
  14781. body, ioErr := ioutil.ReadAll(resp.Body)
  14782. if ioErr != nil {
  14783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14785. return
  14786. }
  14787. var respJSON map[string]interface{}
  14788. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14791. return
  14792. }
  14793. var res ResultTwo //1101结果
  14794. var res10265 ResultTwo10265 //1101结果
  14795. var card_info string //卡信息
  14796. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14797. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14798. result, _ := json.Marshal(respJSON)
  14799. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14800. utils.ErrorLog("解析失败:%v", err)
  14801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14802. return
  14803. }
  14804. res.ErrMsg = res10265.ErrMsg
  14805. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14806. res.Infcode = infocode
  14807. res.Output = res10265.Output
  14808. res.InfRefmsgid = res10265.InfRefmsgid
  14809. if res.Infcode == 0 {
  14810. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14811. if err == gorm.ErrRecordNotFound {
  14812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14813. return
  14814. } else if err != nil {
  14815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14816. return
  14817. } else {
  14818. bas := strings.Split(card_info, "|")
  14819. basNumber := bas[2]
  14820. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14821. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14822. infoStr := string(Iinfos)
  14823. idetinfoStr := string(Idetinfos)
  14824. psn := &models.HisPsn{
  14825. PsnNo: res.Output.Baseinfo.PsnNo,
  14826. PatientId: patient.ID,
  14827. Certno: res.Output.Baseinfo.Certno,
  14828. Gend: res.Output.Baseinfo.Gend,
  14829. Naty: res.Output.Baseinfo.Naty,
  14830. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14831. PsnName: res.Output.Baseinfo.PsnName,
  14832. Idetinfo: idetinfoStr,
  14833. Insuinfo: infoStr,
  14834. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14835. CardInfo: card_info,
  14836. VerifyNumber: token,
  14837. }
  14838. service.CreateHisPsn(psn)
  14839. var rf []*ResultFive
  14840. json.Unmarshal([]byte(infoStr), &rf)
  14841. var insutypes []*ResultFive
  14842. var insutype string
  14843. var is390 int = 0
  14844. var is310 int = 0
  14845. for _, item := range rf {
  14846. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14847. insutypes = append(insutypes, item)
  14848. }
  14849. }
  14850. if len(insutypes) == 1 {
  14851. insutype = insutypes[0].Insutype
  14852. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14853. } else {
  14854. for _, i := range insutypes {
  14855. if i.Insutype == "390" {
  14856. is390 = 1
  14857. }
  14858. if i.Insutype == "310" {
  14859. is310 = 1
  14860. }
  14861. }
  14862. }
  14863. if is390 == 1 {
  14864. insutype = "390"
  14865. }
  14866. if is310 == 1 {
  14867. insutype = "310"
  14868. }
  14869. if len(insutypes) == 0 {
  14870. insutype = "310"
  14871. }
  14872. c.ServeSuccessJSON(map[string]interface{}{
  14873. "patient": patient,
  14874. "number": basNumber,
  14875. "insutype": insutype,
  14876. })
  14877. }
  14878. } else {
  14879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14880. return
  14881. }
  14882. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14883. res := c.GetoleInfo()
  14884. if res.Infcode == 0 {
  14885. var result string
  14886. if res.Output.MdtrtCertType == "01" {
  14887. 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)
  14888. } else if res.Output.MdtrtCertType == "02" {
  14889. 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)
  14890. } else if res.Output.MdtrtCertType == "03" {
  14891. 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)
  14892. }
  14893. var dat map[string]interface{}
  14894. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14895. fmt.Println(dat)
  14896. } else {
  14897. fmt.Println(err)
  14898. }
  14899. userJSONBytes, _ := json.Marshal(dat)
  14900. var res2 ResultTwo
  14901. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14902. utils.ErrorLog("解析失败:%v", err)
  14903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14904. return
  14905. }
  14906. if res2.Infcode == 0 {
  14907. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14908. if err == gorm.ErrRecordNotFound {
  14909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14910. return
  14911. } else if err != nil {
  14912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14913. return
  14914. } else {
  14915. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14916. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14917. infoStr := string(Iinfos)
  14918. idetinfoStr := string(Idetinfos)
  14919. var rf []*ResultFive
  14920. json.Unmarshal([]byte(infoStr), &rf)
  14921. var insutypes []*ResultFive
  14922. var insutype string
  14923. var is390 int = 0
  14924. var is310 int = 0
  14925. //var insuplc_admdvs string
  14926. for _, item := range rf {
  14927. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14928. insutypes = append(insutypes, item)
  14929. }
  14930. }
  14931. if len(insutypes) == 1 {
  14932. insutype = insutypes[0].Insutype
  14933. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14934. } else {
  14935. for _, i := range insutypes {
  14936. if i.Insutype == "390" {
  14937. is390 = 1
  14938. }
  14939. if i.Insutype == "310" {
  14940. is310 = 1
  14941. }
  14942. }
  14943. }
  14944. if is390 == 1 {
  14945. insutype = "390"
  14946. }
  14947. if is310 == 1 {
  14948. insutype = "310"
  14949. }
  14950. if len(insutypes) == 0 {
  14951. insutype = "310"
  14952. }
  14953. psn := &models.HisPsn{
  14954. PsnNo: res2.Output.Baseinfo.PsnNo,
  14955. PatientId: patient.ID,
  14956. Certno: res2.Output.Baseinfo.Certno,
  14957. Gend: res2.Output.Baseinfo.Gend,
  14958. Naty: res2.Output.Baseinfo.Naty,
  14959. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14960. PsnName: res2.Output.Baseinfo.PsnName,
  14961. Idetinfo: idetinfoStr,
  14962. Insuinfo: infoStr,
  14963. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14964. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14965. VerifyNumber: res.Output.EcToken,
  14966. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14967. }
  14968. if res.Output.MdtrtCertType == "01" {
  14969. psn.VerifyNumber = res.Output.EcToken
  14970. //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)
  14971. } else if res.Output.MdtrtCertType == "02" {
  14972. psn.VerifyNumber = res.Output.MdtrtCertNo
  14973. //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)
  14974. } else if res.Output.MdtrtCertType == "03" {
  14975. psn.VerifyNumber = res.Output.MdtrtCertNo
  14976. //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)
  14977. }
  14978. var balc float64
  14979. for _, item := range rf {
  14980. if item.Insutype == insutype {
  14981. balc = item.Balc
  14982. }
  14983. }
  14984. service.CreateHisPsn(psn)
  14985. c.ServeSuccessJSON(map[string]interface{}{
  14986. "patient": patient,
  14987. "number": res.Output.CardNo,
  14988. "insutype": insutype,
  14989. "blac": balc,
  14990. "desc": idetinfoStr,
  14991. })
  14992. }
  14993. } else {
  14994. c.ServeSuccessJSON(map[string]interface{}{
  14995. "failed_code": -10,
  14996. "msg": res2.ErrMsg,
  14997. })
  14998. }
  14999. } else {
  15000. c.ServeSuccessJSON(map[string]interface{}{
  15001. "failed_code": -10,
  15002. "msg": res.ErrMsg,
  15003. })
  15004. }
  15005. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15006. var api string
  15007. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15008. "&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
  15009. fmt.Println(api)
  15010. resp, requestErr := http.Get(api)
  15011. if requestErr != nil {
  15012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15013. return
  15014. }
  15015. body, ioErr := ioutil.ReadAll(resp.Body)
  15016. if ioErr != nil {
  15017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15019. return
  15020. }
  15021. var respJSON map[string]interface{}
  15022. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15025. return
  15026. }
  15027. var status string
  15028. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15029. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15030. //console.log()
  15031. fmt.Println("type===")
  15032. fmt.Println(card_type)
  15033. var token string
  15034. var res ResultTwo //1101结果
  15035. //var res10265 ResultTwoesultTwo10265 //1101结果
  15036. var card_info string //卡信息
  15037. var busi_card_info string
  15038. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15039. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15040. if status == "0" { //读卡成功
  15041. if card_type == "1" {
  15042. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15043. result, _ := json.Marshal(respJSON)
  15044. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15045. utils.ErrorLog("解析失败:%v", err)
  15046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15047. return
  15048. }
  15049. } else {
  15050. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15051. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15052. result, _ := json.Marshal(respJSON)
  15053. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15054. utils.ErrorLog("解析失败:%v", err)
  15055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15056. return
  15057. }
  15058. }
  15059. if res.Infcode == 0 {
  15060. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15061. if err == gorm.ErrRecordNotFound {
  15062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15063. return
  15064. } else if err != nil {
  15065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15066. return
  15067. } else {
  15068. if card_type == "1" {
  15069. bas := strings.Split(card_info, "|")
  15070. basNumber := bas[2]
  15071. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15072. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15073. infoStr := string(Iinfos)
  15074. idetinfoStr := string(Idetinfos)
  15075. psn := &models.HisPsn{
  15076. PsnNo: res.Output.Baseinfo.PsnNo,
  15077. PatientId: patient.ID,
  15078. Certno: res.Output.Baseinfo.Certno,
  15079. Gend: res.Output.Baseinfo.Gend,
  15080. Naty: res.Output.Baseinfo.Naty,
  15081. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15082. PsnName: res.Output.Baseinfo.PsnName,
  15083. Idetinfo: idetinfoStr,
  15084. Insuinfo: infoStr,
  15085. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15086. CardInfo: card_info,
  15087. VerifyNumber: busi_card_info,
  15088. }
  15089. service.CreateHisPsn(psn)
  15090. var rf []*ResultFive
  15091. json.Unmarshal([]byte(infoStr), &rf)
  15092. var insutypes []*ResultFive
  15093. var insutype string
  15094. var is390 int = 0
  15095. var is310 int = 0
  15096. for _, item := range rf {
  15097. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15098. insutypes = append(insutypes, item)
  15099. }
  15100. }
  15101. if len(insutypes) == 1 {
  15102. insutype = insutypes[0].Insutype
  15103. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15104. } else {
  15105. for _, i := range insutypes {
  15106. if i.Insutype == "390" {
  15107. is390 = 1
  15108. }
  15109. if i.Insutype == "310" {
  15110. is310 = 1
  15111. }
  15112. }
  15113. }
  15114. if is390 == 1 {
  15115. insutype = "390"
  15116. }
  15117. if is310 == 1 {
  15118. insutype = "310"
  15119. }
  15120. if len(insutypes) == 0 {
  15121. insutype = "310"
  15122. }
  15123. c.ServeSuccessJSON(map[string]interface{}{
  15124. "patient": patient,
  15125. "number": basNumber,
  15126. "insutype": insutype,
  15127. })
  15128. } else {
  15129. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15130. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15131. infoStr := string(Iinfos)
  15132. idetinfoStr := string(Idetinfos)
  15133. psn := &models.HisPsn{
  15134. PsnNo: res.Output.Baseinfo.PsnNo,
  15135. PatientId: patient.ID,
  15136. Certno: res.Output.Baseinfo.Certno,
  15137. Gend: res.Output.Baseinfo.Gend,
  15138. Naty: res.Output.Baseinfo.Naty,
  15139. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15140. PsnName: res.Output.Baseinfo.PsnName,
  15141. Idetinfo: idetinfoStr,
  15142. Insuinfo: infoStr,
  15143. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15144. CardInfo: card_info,
  15145. VerifyNumber: token,
  15146. }
  15147. service.CreateHisPsn(psn)
  15148. c.ServeSuccessJSON(map[string]interface{}{
  15149. "patient": patient,
  15150. "number": token,
  15151. })
  15152. }
  15153. }
  15154. } else {
  15155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15156. return
  15157. }
  15158. } else { //读卡失败
  15159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15160. return
  15161. }
  15162. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15163. var api string
  15164. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15165. "&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
  15166. fmt.Println(api)
  15167. resp, requestErr := http.Get(api)
  15168. if requestErr != nil {
  15169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15170. return
  15171. }
  15172. body, ioErr := ioutil.ReadAll(resp.Body)
  15173. if ioErr != nil {
  15174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15176. return
  15177. }
  15178. var respJSON map[string]interface{}
  15179. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15182. return
  15183. }
  15184. var status string
  15185. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15186. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15187. //console.log()
  15188. fmt.Println("type===")
  15189. fmt.Println(card_type)
  15190. var token string
  15191. var res ResultTwo //1101结果
  15192. //var res10265 ResultTwoesultTwo10265 //1101结果
  15193. var card_info string //卡信息
  15194. //var busi_card_info string
  15195. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15196. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15197. if status == "0" { //读卡成功
  15198. if card_type == "1" {
  15199. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15200. result, _ := json.Marshal(respJSON)
  15201. fmt.Println(result)
  15202. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15203. utils.ErrorLog("解析失败:%v", err)
  15204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15205. return
  15206. }
  15207. fmt.Println(res)
  15208. } else {
  15209. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15210. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15211. result, _ := json.Marshal(respJSON)
  15212. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15213. utils.ErrorLog("解析失败:%v", err)
  15214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15215. return
  15216. }
  15217. }
  15218. if res.Infcode == 0 {
  15219. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15220. if err == gorm.ErrRecordNotFound {
  15221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15222. return
  15223. } else if err != nil {
  15224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15225. return
  15226. } else {
  15227. if card_type == "1" {
  15228. bas := strings.Split(card_info, "|")
  15229. basNumber := bas[2]
  15230. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15231. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15232. infoStr := string(Iinfos)
  15233. idetinfoStr := string(Idetinfos)
  15234. psn := &models.HisPsn{
  15235. PsnNo: res.Output.Baseinfo.PsnNo,
  15236. PatientId: patient.ID,
  15237. Certno: res.Output.Baseinfo.Certno,
  15238. Gend: res.Output.Baseinfo.Gend,
  15239. Naty: res.Output.Baseinfo.Naty,
  15240. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15241. PsnName: res.Output.Baseinfo.PsnName,
  15242. Idetinfo: idetinfoStr,
  15243. Insuinfo: infoStr,
  15244. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15245. CardInfo: card_info,
  15246. //VerifyNumber: busi_card_info,
  15247. }
  15248. service.CreateHisPsn(psn)
  15249. var rf []*ResultFive
  15250. json.Unmarshal([]byte(infoStr), &rf)
  15251. var insutypes []*ResultFive
  15252. var insutype string
  15253. var is390 int = 0
  15254. var is310 int = 0
  15255. for _, item := range rf {
  15256. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15257. insutypes = append(insutypes, item)
  15258. }
  15259. }
  15260. if len(insutypes) == 1 {
  15261. insutype = insutypes[0].Insutype
  15262. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15263. } else {
  15264. for _, i := range insutypes {
  15265. if i.Insutype == "390" {
  15266. is390 = 1
  15267. }
  15268. if i.Insutype == "310" {
  15269. is310 = 1
  15270. }
  15271. }
  15272. }
  15273. if is390 == 1 {
  15274. insutype = "390"
  15275. }
  15276. if is310 == 1 {
  15277. insutype = "310"
  15278. }
  15279. if len(insutypes) == 0 {
  15280. insutype = "310"
  15281. }
  15282. c.ServeSuccessJSON(map[string]interface{}{
  15283. "patient": patient,
  15284. "number": basNumber,
  15285. "insutype": insutype,
  15286. })
  15287. } else {
  15288. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15289. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15290. infoStr := string(Iinfos)
  15291. idetinfoStr := string(Idetinfos)
  15292. psn := &models.HisPsn{
  15293. PsnNo: res.Output.Baseinfo.PsnNo,
  15294. PatientId: patient.ID,
  15295. Certno: res.Output.Baseinfo.Certno,
  15296. Gend: res.Output.Baseinfo.Gend,
  15297. Naty: res.Output.Baseinfo.Naty,
  15298. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15299. PsnName: res.Output.Baseinfo.PsnName,
  15300. Idetinfo: idetinfoStr,
  15301. Insuinfo: infoStr,
  15302. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15303. CardInfo: card_info,
  15304. VerifyNumber: token,
  15305. }
  15306. service.CreateHisPsn(psn)
  15307. c.ServeSuccessJSON(map[string]interface{}{
  15308. "patient": patient,
  15309. "number": token,
  15310. })
  15311. }
  15312. }
  15313. } else {
  15314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15315. return
  15316. }
  15317. } else { //读卡失败
  15318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15319. return
  15320. }
  15321. } else {
  15322. if initFlag == 0 {
  15323. c.TestGetBasBaseInit()
  15324. }
  15325. basStr := c.GetBasBaseInfo()
  15326. if len(basStr) == 0 {
  15327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15328. return
  15329. }
  15330. fmt.Println(basStr)
  15331. bas := strings.Split(basStr, "|")
  15332. basNumber := bas[1]
  15333. fmt.Println(basNumber)
  15334. card_sn := bas[3]
  15335. fmt.Println(card_sn)
  15336. cardNumber := bas[2]
  15337. fmt.Println(cardNumber)
  15338. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  15339. var result string
  15340. if bas[0][:2] == "44" {
  15341. 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)
  15342. } else {
  15343. 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)
  15344. }
  15345. var dat map[string]interface{}
  15346. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15347. fmt.Println(dat)
  15348. } else {
  15349. fmt.Println(err)
  15350. }
  15351. userJSONBytes, _ := json.Marshal(dat)
  15352. var res ResultTwo
  15353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15354. utils.ErrorLog("解析失败:%v", err)
  15355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15356. return
  15357. }
  15358. if res.Infcode == 0 {
  15359. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15360. if err == gorm.ErrRecordNotFound {
  15361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15362. return
  15363. } else if err != nil {
  15364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15365. return
  15366. } else {
  15367. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15368. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15369. infoStr := string(Iinfos)
  15370. idetinfoStr := string(Idetinfos)
  15371. var rf []*ResultFive
  15372. json.Unmarshal([]byte(infoStr), &rf)
  15373. var insutypes []*ResultFive
  15374. var insutype string
  15375. var is390 int = 0
  15376. var is310 int = 0
  15377. var insuplc_admdvs string
  15378. for _, item := range rf {
  15379. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15380. insutypes = append(insutypes, item)
  15381. }
  15382. }
  15383. if len(insutypes) == 1 {
  15384. insutype = insutypes[0].Insutype
  15385. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15386. } else {
  15387. for _, i := range insutypes {
  15388. if i.Insutype == "390" {
  15389. is390 = 1
  15390. }
  15391. if i.Insutype == "310" {
  15392. is310 = 1
  15393. }
  15394. }
  15395. }
  15396. if is390 == 1 {
  15397. insutype = "390"
  15398. }
  15399. if is310 == 1 {
  15400. insutype = "310"
  15401. }
  15402. if len(insutypes) == 0 {
  15403. insutype = "310"
  15404. }
  15405. for _, item := range rf {
  15406. if item.Insutype == insutype {
  15407. insuplc_admdvs = item.InsuplcAdmdvs
  15408. }
  15409. }
  15410. psn := &models.HisPsn{
  15411. PsnNo: res.Output.Baseinfo.PsnNo,
  15412. PatientId: patient.ID,
  15413. Certno: res.Output.Baseinfo.Certno,
  15414. Gend: res.Output.Baseinfo.Gend,
  15415. Naty: res.Output.Baseinfo.Naty,
  15416. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15417. PsnName: res.Output.Baseinfo.PsnName,
  15418. Idetinfo: idetinfoStr,
  15419. Insuinfo: infoStr,
  15420. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15421. CardInfo: basStr,
  15422. VerifyNumber: "",
  15423. InsuplcAdmdvs: insuplc_admdvs,
  15424. }
  15425. service.CreateHisPsn(psn)
  15426. c.ServeSuccessJSON(map[string]interface{}{
  15427. "patient": patient,
  15428. "insutype": insutype,
  15429. "number": basNumber,
  15430. })
  15431. }
  15432. } else {
  15433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15434. return
  15435. }
  15436. break
  15437. }
  15438. case 2:
  15439. if miConfig.MdtrtareaAdmvs == "430800" {
  15440. if initFlag == 0 {
  15441. c.TestGetHnBasBaseInit()
  15442. }
  15443. SFZStr := c.GetSFZBaseInfo()
  15444. if len(SFZStr) == 0 {
  15445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15446. return
  15447. }
  15448. fmt.Println(SFZStr)
  15449. id_card_str := strings.Split(SFZStr, "^")
  15450. card_no := id_card_str[0]
  15451. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15452. //name := id_card_str[1]
  15453. //name = ConvertToString(name, "gbk", "utf-8")
  15454. 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)
  15455. var dat map[string]interface{}
  15456. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15457. fmt.Println(dat)
  15458. } else {
  15459. fmt.Println(err)
  15460. }
  15461. userJSONBytes, _ := json.Marshal(dat)
  15462. var res ResultTwo
  15463. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15464. utils.ErrorLog("解析失败:%v", err)
  15465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15466. return
  15467. }
  15468. if res.Infcode == 0 {
  15469. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15470. if err == gorm.ErrRecordNotFound {
  15471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15472. return
  15473. } else if err != nil {
  15474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15475. return
  15476. } else {
  15477. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15478. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15479. infoStr := string(Iinfos)
  15480. idetinfoStr := string(Idetinfos)
  15481. var rf []*ResultFive
  15482. json.Unmarshal([]byte(infoStr), &rf)
  15483. var insutypes []*ResultFive
  15484. var insutype string
  15485. var is390 int = 0
  15486. var is310 int = 0
  15487. for _, item := range rf {
  15488. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15489. insutypes = append(insutypes, item)
  15490. }
  15491. }
  15492. if len(insutypes) == 1 {
  15493. insutype = insutypes[0].Insutype
  15494. } else {
  15495. for _, i := range insutypes {
  15496. if i.Insutype == "390" {
  15497. is390 = 1
  15498. }
  15499. if i.Insutype == "310" {
  15500. is310 = 1
  15501. }
  15502. }
  15503. }
  15504. if is390 == 1 {
  15505. insutype = "390"
  15506. }
  15507. if is310 == 1 {
  15508. insutype = "310"
  15509. }
  15510. if len(insutypes) == 0 {
  15511. insutype = "310"
  15512. }
  15513. var InsuplcAdmdvs string
  15514. for _, item := range rf {
  15515. if item.Insutype == insutype {
  15516. InsuplcAdmdvs = item.InsuplcAdmdvs
  15517. }
  15518. }
  15519. psn := &models.HisPsn{
  15520. PsnNo: res.Output.Baseinfo.PsnNo,
  15521. PatientId: patient.ID,
  15522. Certno: res.Output.Baseinfo.Certno,
  15523. Gend: res.Output.Baseinfo.Gend,
  15524. Naty: res.Output.Baseinfo.Naty,
  15525. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15526. PsnName: res.Output.Baseinfo.PsnName,
  15527. Idetinfo: idetinfoStr,
  15528. Insuinfo: infoStr,
  15529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15530. CardInfo: SFZStr,
  15531. VerifyNumber: "",
  15532. InsuplcAdmdvs: InsuplcAdmdvs,
  15533. }
  15534. service.CreateHisPsn(psn)
  15535. c.ServeSuccessJSON(map[string]interface{}{
  15536. "patient": patient,
  15537. "number": card_no,
  15538. "insutype": insutype,
  15539. })
  15540. }
  15541. } else {
  15542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15543. return
  15544. }
  15545. } else if miConfig.MdtrtareaAdmvs == "420200" {
  15546. var res ResultTwo
  15547. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  15548. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15549. "&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)
  15550. resp, requestErr := http.Get(api)
  15551. if requestErr != nil {
  15552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15553. return
  15554. }
  15555. body, ioErr := ioutil.ReadAll(resp.Body)
  15556. if ioErr != nil {
  15557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15559. return
  15560. }
  15561. var respJSON map[string]interface{}
  15562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15565. return
  15566. }
  15567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15568. result, _ := json.Marshal(respJSON)
  15569. fmt.Println("log")
  15570. fmt.Println(string(result))
  15571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15572. utils.ErrorLog("解析失败:%v", err)
  15573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15574. return
  15575. }
  15576. if res.Infcode == 0 {
  15577. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15578. if err == gorm.ErrRecordNotFound {
  15579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15580. return
  15581. } else if err != nil {
  15582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15583. return
  15584. } else {
  15585. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15586. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15587. infoStr := string(Iinfos)
  15588. idetinfoStr := string(Idetinfos)
  15589. psn := &models.HisPsn{
  15590. PsnNo: res.Output.Baseinfo.PsnNo,
  15591. PatientId: patient.ID,
  15592. Certno: res.Output.Baseinfo.Certno,
  15593. Gend: res.Output.Baseinfo.Gend,
  15594. Naty: res.Output.Baseinfo.Naty,
  15595. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15596. PsnName: res.Output.Baseinfo.PsnName,
  15597. Idetinfo: idetinfoStr,
  15598. Insuinfo: infoStr,
  15599. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15600. }
  15601. service.CreateHisPsn(psn)
  15602. c.ServeSuccessJSON(map[string]interface{}{
  15603. "patient": patient,
  15604. "number": res.Output.Baseinfo.Certno,
  15605. })
  15606. }
  15607. } else {
  15608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15609. return
  15610. }
  15611. } else if miConfig.MdtrtareaAdmvs == "421182" {
  15612. var res ResultTwo
  15613. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15614. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15615. "&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)
  15616. resp, requestErr := http.Get(api)
  15617. if requestErr != nil {
  15618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15619. return
  15620. }
  15621. body, ioErr := ioutil.ReadAll(resp.Body)
  15622. if ioErr != nil {
  15623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15625. return
  15626. }
  15627. var respJSON map[string]interface{}
  15628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15631. return
  15632. }
  15633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15634. result, _ := json.Marshal(respJSON)
  15635. fmt.Println("log")
  15636. fmt.Println(string(result))
  15637. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15638. utils.ErrorLog("解析失败:%v", err)
  15639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15640. return
  15641. }
  15642. if res.Infcode == 0 {
  15643. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15644. if err == gorm.ErrRecordNotFound {
  15645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15646. return
  15647. } else if err != nil {
  15648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15649. return
  15650. } else {
  15651. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15652. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15653. infoStr := string(Iinfos)
  15654. idetinfoStr := string(Idetinfos)
  15655. psn := &models.HisPsn{
  15656. PsnNo: res.Output.Baseinfo.PsnNo,
  15657. PatientId: patient.ID,
  15658. Certno: res.Output.Baseinfo.Certno,
  15659. Gend: res.Output.Baseinfo.Gend,
  15660. Naty: res.Output.Baseinfo.Naty,
  15661. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15662. PsnName: res.Output.Baseinfo.PsnName,
  15663. Idetinfo: idetinfoStr,
  15664. Insuinfo: infoStr,
  15665. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15666. }
  15667. service.CreateHisPsn(psn)
  15668. c.ServeSuccessJSON(map[string]interface{}{
  15669. "patient": patient,
  15670. "number": res.Output.Baseinfo.Certno,
  15671. })
  15672. }
  15673. } else {
  15674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15675. return
  15676. }
  15677. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15678. var res ResultTwo
  15679. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15680. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15681. "&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)
  15682. resp, requestErr := http.Get(api)
  15683. if requestErr != nil {
  15684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15685. return
  15686. }
  15687. body, ioErr := ioutil.ReadAll(resp.Body)
  15688. if ioErr != nil {
  15689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15691. return
  15692. }
  15693. var respJSON map[string]interface{}
  15694. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15697. return
  15698. }
  15699. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15700. result, _ := json.Marshal(respJSON)
  15701. fmt.Println("log")
  15702. fmt.Println(string(result))
  15703. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15704. utils.ErrorLog("解析失败:%v", err)
  15705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15706. return
  15707. }
  15708. if res.Infcode == 0 {
  15709. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15710. if err == gorm.ErrRecordNotFound {
  15711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15712. return
  15713. } else if err != nil {
  15714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15715. return
  15716. } else {
  15717. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15718. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15719. infoStr := string(Iinfos)
  15720. idetinfoStr := string(Idetinfos)
  15721. var rf []*ResultFive
  15722. json.Unmarshal([]byte(infoStr), &rf)
  15723. var insutypes []*ResultFive
  15724. var insutype string
  15725. var is390 int = 0
  15726. var is310 int = 0
  15727. for _, item := range rf {
  15728. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15729. insutypes = append(insutypes, item)
  15730. }
  15731. }
  15732. if len(insutypes) == 1 {
  15733. insutype = insutypes[0].Insutype
  15734. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15735. } else {
  15736. for _, i := range insutypes {
  15737. if i.Insutype == "390" {
  15738. is390 = 1
  15739. }
  15740. if i.Insutype == "310" {
  15741. is310 = 1
  15742. }
  15743. }
  15744. }
  15745. if is390 == 1 {
  15746. insutype = "390"
  15747. }
  15748. if is310 == 1 {
  15749. insutype = "310"
  15750. }
  15751. if len(insutypes) == 0 {
  15752. insutype = "390"
  15753. }
  15754. var insuplc_admdvs string
  15755. for _, item := range rf {
  15756. if item.Insutype == insutype {
  15757. insuplc_admdvs = item.InsuplcAdmdvs
  15758. }
  15759. }
  15760. psn := &models.HisPsn{
  15761. PsnNo: res.Output.Baseinfo.PsnNo,
  15762. PatientId: patient.ID,
  15763. Certno: res.Output.Baseinfo.Certno,
  15764. Gend: res.Output.Baseinfo.Gend,
  15765. Naty: res.Output.Baseinfo.Naty,
  15766. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15767. PsnName: res.Output.Baseinfo.PsnName,
  15768. Idetinfo: idetinfoStr,
  15769. Insuinfo: infoStr,
  15770. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15771. InsuplcAdmdvs: insuplc_admdvs,
  15772. }
  15773. service.CreateHisPsn(psn)
  15774. c.ServeSuccessJSON(map[string]interface{}{
  15775. "patient": patient,
  15776. "number": res.Output.Baseinfo.Certno,
  15777. })
  15778. }
  15779. } else {
  15780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15781. return
  15782. }
  15783. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15784. res := c.GetoleInfo()
  15785. if res.Infcode == 0 {
  15786. var result string
  15787. if res.Output.MdtrtCertType == "01" {
  15788. 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)
  15789. } else if res.Output.MdtrtCertType == "02" {
  15790. 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)
  15791. } else if res.Output.MdtrtCertType == "03" {
  15792. 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)
  15793. }
  15794. var dat map[string]interface{}
  15795. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15796. fmt.Println(dat)
  15797. } else {
  15798. fmt.Println(err)
  15799. }
  15800. userJSONBytes, _ := json.Marshal(dat)
  15801. var res2 ResultTwo
  15802. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15803. utils.ErrorLog("解析失败:%v", err)
  15804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15805. return
  15806. }
  15807. if res2.Infcode == 0 {
  15808. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15809. if err == gorm.ErrRecordNotFound {
  15810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15811. return
  15812. } else if err != nil {
  15813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15814. return
  15815. } else {
  15816. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15817. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15818. infoStr := string(Iinfos)
  15819. idetinfoStr := string(Idetinfos)
  15820. var rf []*ResultFive
  15821. json.Unmarshal([]byte(infoStr), &rf)
  15822. var insutypes []*ResultFive
  15823. var insutype string
  15824. var is390 int = 0
  15825. var is310 int = 0
  15826. //var insuplc_admdvs string
  15827. for _, item := range rf {
  15828. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15829. insutypes = append(insutypes, item)
  15830. }
  15831. }
  15832. if len(insutypes) == 1 {
  15833. insutype = insutypes[0].Insutype
  15834. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15835. } else {
  15836. for _, i := range insutypes {
  15837. if i.Insutype == "390" {
  15838. is390 = 1
  15839. }
  15840. if i.Insutype == "310" {
  15841. is310 = 1
  15842. }
  15843. }
  15844. }
  15845. if is390 == 1 {
  15846. insutype = "390"
  15847. }
  15848. if is310 == 1 {
  15849. insutype = "310"
  15850. }
  15851. if len(insutypes) == 0 {
  15852. insutype = "310"
  15853. }
  15854. psn := &models.HisPsn{
  15855. PsnNo: res2.Output.Baseinfo.PsnNo,
  15856. PatientId: patient.ID,
  15857. //Brdy: res2.Output.Baseinfo.Brdy,
  15858. Certno: res2.Output.Baseinfo.Certno,
  15859. Gend: res2.Output.Baseinfo.Gend,
  15860. Naty: res2.Output.Baseinfo.Naty,
  15861. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15862. PsnName: res2.Output.Baseinfo.PsnName,
  15863. Idetinfo: idetinfoStr,
  15864. Insuinfo: infoStr,
  15865. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15866. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15867. VerifyNumber: res.Output.EcToken,
  15868. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15869. }
  15870. service.CreateHisPsn(psn)
  15871. var balc float64
  15872. for _, item := range rf {
  15873. if item.Insutype == insutype {
  15874. balc = item.Balc
  15875. }
  15876. }
  15877. c.ServeSuccessJSON(map[string]interface{}{
  15878. "patient": patient,
  15879. "number": res.Output.CardNo,
  15880. "insutype": insutype,
  15881. "blac": balc,
  15882. "desc": idetinfoStr,
  15883. })
  15884. }
  15885. } else {
  15886. c.ServeSuccessJSON(map[string]interface{}{
  15887. "failed_code": -10,
  15888. "msg": res2.ErrMsg,
  15889. })
  15890. }
  15891. } else {
  15892. c.ServeSuccessJSON(map[string]interface{}{
  15893. "failed_code": -10,
  15894. "msg": res.ErrMsg,
  15895. })
  15896. }
  15897. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15898. var insuplc_admdvs string
  15899. if len(patient.InsuplcAdmdvs) > 0 {
  15900. insuplc_admdvs = patient.InsuplcAdmdvs
  15901. } else {
  15902. if len(insuplc_admdvs_str) > 0 {
  15903. insuplc_admdvs = insuplc_admdvs_str
  15904. } else {
  15905. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15906. }
  15907. }
  15908. //请求内网数据
  15909. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15910. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15911. "&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=" + ""
  15912. resp, requestErr := http.Get(api)
  15913. if requestErr != nil {
  15914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15915. return
  15916. }
  15917. body, ioErr := ioutil.ReadAll(resp.Body)
  15918. if ioErr != nil {
  15919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15921. return
  15922. }
  15923. var respJSON map[string]interface{}
  15924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15927. return
  15928. }
  15929. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15930. if status == "0" {
  15931. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15932. c.ServeSuccessJSON(map[string]interface{}{
  15933. "failed_code": -10,
  15934. "msg": err_msg,
  15935. })
  15936. return
  15937. }
  15938. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15939. var res ResultTwo
  15940. result, _ := json.Marshal(respJSON)
  15941. fmt.Println("log")
  15942. fmt.Println(string(result))
  15943. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15944. utils.ErrorLog("解析失败:%v", err)
  15945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15946. return
  15947. }
  15948. if res.Infcode == 0 {
  15949. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15950. if err == gorm.ErrRecordNotFound {
  15951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15952. return
  15953. } else if err != nil {
  15954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15955. return
  15956. } else {
  15957. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15958. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15959. infoStr := string(Iinfos)
  15960. idetinfoStr := string(Idetinfos)
  15961. psn := &models.HisPsn{
  15962. PsnNo: res.Output.Baseinfo.PsnNo,
  15963. PatientId: patient.ID,
  15964. Certno: res.Output.Baseinfo.Certno,
  15965. Gend: res.Output.Baseinfo.Gend,
  15966. Naty: res.Output.Baseinfo.Naty,
  15967. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15968. PsnName: res.Output.Baseinfo.PsnName,
  15969. Idetinfo: idetinfoStr,
  15970. Insuinfo: infoStr,
  15971. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15972. }
  15973. service.CreateHisPsn(psn)
  15974. var rf []*ResultFive
  15975. json.Unmarshal([]byte(infoStr), &rf)
  15976. var insutypes []*ResultFive
  15977. var is390 int = 0
  15978. var is310 int = 0
  15979. var insutype string
  15980. for _, item := range rf {
  15981. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15982. insutypes = append(insutypes, item)
  15983. }
  15984. }
  15985. if len(insutypes) == 1 {
  15986. insutype = insutypes[0].Insutype
  15987. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15988. } else {
  15989. for _, i := range insutypes {
  15990. if i.Insutype == "390" {
  15991. is390 = 1
  15992. }
  15993. if i.Insutype == "310" {
  15994. is310 = 1
  15995. }
  15996. }
  15997. }
  15998. if is390 == 1 {
  15999. insutype = "390"
  16000. }
  16001. if is310 == 1 {
  16002. insutype = "310"
  16003. }
  16004. if len(insutypes) == 0 {
  16005. insutype = "390"
  16006. }
  16007. c.ServeSuccessJSON(map[string]interface{}{
  16008. "patient": patient,
  16009. "insutype": insutype,
  16010. "number": res.Output.Baseinfo.Certno,
  16011. "info": res,
  16012. })
  16013. }
  16014. } else {
  16015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16016. return
  16017. }
  16018. } else {
  16019. SFZStr := c.GetSFZBaseInfo()
  16020. id_card_str := strings.Split(SFZStr, "^")
  16021. id_card_number := id_card_str[0]
  16022. card_sn := ""
  16023. 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)
  16024. var dat map[string]interface{}
  16025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16026. fmt.Println(dat)
  16027. } else {
  16028. fmt.Println(err)
  16029. }
  16030. userJSONBytes, _ := json.Marshal(dat)
  16031. var res ResultTwo
  16032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16033. utils.ErrorLog("解析失败:%v", err)
  16034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16035. return
  16036. }
  16037. if res.Infcode == 0 {
  16038. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  16039. if err == gorm.ErrRecordNotFound {
  16040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16041. return
  16042. } else if err != nil {
  16043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16044. return
  16045. } else {
  16046. c.ServeSuccessJSON(map[string]interface{}{
  16047. "patient": patient,
  16048. "number": id_card_number,
  16049. })
  16050. }
  16051. } else {
  16052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16053. return
  16054. }
  16055. }
  16056. break
  16057. case 3:
  16058. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16059. var api string
  16060. if miConfig.MdtrtareaAdmvs == "320830" {
  16061. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16062. "&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
  16063. fmt.Println(api)
  16064. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16065. 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 +
  16066. "&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
  16067. fmt.Println(api)
  16068. } else {
  16069. 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 +
  16070. "&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)
  16071. }
  16072. resp, requestErr := http.Get(api)
  16073. if requestErr != nil {
  16074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16075. return
  16076. }
  16077. body, ioErr := ioutil.ReadAll(resp.Body)
  16078. if ioErr != nil {
  16079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16081. return
  16082. }
  16083. var respJSON map[string]interface{}
  16084. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16087. return
  16088. }
  16089. var status string
  16090. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16091. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16092. var token string
  16093. var res ResultTwo //1101结果
  16094. var res10265 ResultTwo10265 //1101结果
  16095. var card_info string //卡信息
  16096. var busi_card_info string
  16097. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16098. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16099. if status == "0" { //读卡成功
  16100. if card_type == "1" {
  16101. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16102. result, _ := json.Marshal(respJSON)
  16103. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16104. utils.ErrorLog("解析失败:%v", err)
  16105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16106. return
  16107. }
  16108. res.ErrMsg = res10265.ErrMsg
  16109. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16110. res.Infcode = infocode
  16111. res.Output = res10265.Output
  16112. res.InfRefmsgid = res10265.InfRefmsgid
  16113. } else {
  16114. //var card_info string //卡信息
  16115. //var busi_card_info string
  16116. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16117. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16118. //fmt.Println(card_info)
  16119. //fmt.Println(busi_card_info)
  16120. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16121. result, _ := json.Marshal(respJSON)
  16122. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16123. utils.ErrorLog("解析失败:%v", err)
  16124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16125. return
  16126. }
  16127. res.ErrMsg = res10265.ErrMsg
  16128. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16129. res.Infcode = infocode
  16130. res.Output = res10265.Output
  16131. res.InfRefmsgid = res10265.InfRefmsgid
  16132. }
  16133. if res.Infcode == 0 {
  16134. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16135. if err == gorm.ErrRecordNotFound {
  16136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16137. return
  16138. } else if err != nil {
  16139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16140. return
  16141. } else {
  16142. if card_type == "1" {
  16143. bas := strings.Split(card_info, "|")
  16144. basNumber := bas[2]
  16145. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16146. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16147. infoStr := string(Iinfos)
  16148. idetinfoStr := string(Idetinfos)
  16149. psn := &models.HisPsn{
  16150. PsnNo: res.Output.Baseinfo.PsnNo,
  16151. PatientId: patient.ID,
  16152. Certno: res.Output.Baseinfo.Certno,
  16153. //Brdy: res.Output.Baseinfo.Brdy,
  16154. Gend: res.Output.Baseinfo.Gend,
  16155. Naty: res.Output.Baseinfo.Naty,
  16156. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16157. PsnName: res.Output.Baseinfo.PsnName,
  16158. Idetinfo: idetinfoStr,
  16159. Insuinfo: infoStr,
  16160. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16161. CardInfo: card_info,
  16162. VerifyNumber: busi_card_info,
  16163. }
  16164. service.CreateHisPsn(psn)
  16165. c.ServeSuccessJSON(map[string]interface{}{
  16166. "patient": patient,
  16167. "number": basNumber,
  16168. })
  16169. } else {
  16170. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16171. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16172. infoStr := string(Iinfos)
  16173. idetinfoStr := string(Idetinfos)
  16174. psn := &models.HisPsn{
  16175. PsnNo: res.Output.Baseinfo.PsnNo,
  16176. PatientId: patient.ID,
  16177. Certno: res.Output.Baseinfo.Certno,
  16178. Gend: res.Output.Baseinfo.Gend,
  16179. Naty: res.Output.Baseinfo.Naty,
  16180. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16181. PsnName: res.Output.Baseinfo.PsnName,
  16182. Idetinfo: idetinfoStr,
  16183. Insuinfo: infoStr,
  16184. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16185. CardInfo: card_info,
  16186. VerifyNumber: token,
  16187. }
  16188. service.CreateHisPsn(psn)
  16189. var rf []*ResultFive
  16190. json.Unmarshal([]byte(infoStr), &rf)
  16191. var insutypes []*ResultFive
  16192. var insutype string
  16193. var is390 int = 0
  16194. var is310 int = 0
  16195. for _, item := range rf {
  16196. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16197. insutypes = append(insutypes, item)
  16198. }
  16199. }
  16200. if len(insutypes) == 1 {
  16201. insutype = insutypes[0].Insutype
  16202. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16203. } else {
  16204. for _, i := range insutypes {
  16205. if i.Insutype == "390" {
  16206. is390 = 1
  16207. }
  16208. if i.Insutype == "310" {
  16209. is310 = 1
  16210. }
  16211. }
  16212. }
  16213. if is390 == 1 {
  16214. insutype = "390"
  16215. }
  16216. if is310 == 1 {
  16217. insutype = "310"
  16218. }
  16219. if len(insutypes) == 0 {
  16220. insutype = "310"
  16221. }
  16222. c.ServeSuccessJSON(map[string]interface{}{
  16223. "patient": patient,
  16224. "number": token,
  16225. "insutype": insutype,
  16226. })
  16227. }
  16228. }
  16229. } else {
  16230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16231. return
  16232. }
  16233. } else { //读卡失败
  16234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16235. return
  16236. }
  16237. }
  16238. break
  16239. case 4:
  16240. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16241. var api string
  16242. if miConfig.MdtrtareaAdmvs == "320830" {
  16243. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16244. "&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
  16245. fmt.Println(api)
  16246. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16247. 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 +
  16248. "&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
  16249. fmt.Println(api)
  16250. } else {
  16251. 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 +
  16252. "&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)
  16253. }
  16254. resp, requestErr := http.Get(api)
  16255. if requestErr != nil {
  16256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16257. return
  16258. }
  16259. body, ioErr := ioutil.ReadAll(resp.Body)
  16260. if ioErr != nil {
  16261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16263. return
  16264. }
  16265. var respJSON map[string]interface{}
  16266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16269. return
  16270. }
  16271. var status string
  16272. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16273. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16274. var token string
  16275. var res ResultTwo //1101结果
  16276. var res10265 ResultTwo10265 //1101结果
  16277. if status == "0" { //读卡成功
  16278. var card_info string //卡信息
  16279. var busi_card_info string
  16280. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16281. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16282. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16283. fmt.Println(card_info)
  16284. fmt.Println(busi_card_info)
  16285. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16286. result, _ := json.Marshal(respJSON)
  16287. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16288. utils.ErrorLog("解析失败:%v", err)
  16289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16290. return
  16291. }
  16292. res.ErrMsg = res10265.ErrMsg
  16293. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16294. res.Infcode = infocode
  16295. res.Output = res10265.Output
  16296. res.InfRefmsgid = res10265.InfRefmsgid
  16297. if res.Infcode == 0 {
  16298. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16299. if err == gorm.ErrRecordNotFound {
  16300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16301. return
  16302. } else if err != nil {
  16303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16304. return
  16305. } else {
  16306. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16307. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16308. infoStr := string(Iinfos)
  16309. idetinfoStr := string(Idetinfos)
  16310. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16311. psn := &models.HisPsn{
  16312. PsnNo: res.Output.Baseinfo.PsnNo,
  16313. PatientId: patient.ID,
  16314. Certno: res.Output.Baseinfo.Certno,
  16315. Brdy: b,
  16316. Age: float64(age),
  16317. //Brdy: res.Output.Baseinfo.Brdy,
  16318. Gend: res.Output.Baseinfo.Gend,
  16319. Naty: res.Output.Baseinfo.Naty,
  16320. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16321. PsnName: res.Output.Baseinfo.PsnName,
  16322. Idetinfo: idetinfoStr,
  16323. Insuinfo: infoStr,
  16324. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16325. CardInfo: card_info,
  16326. VerifyNumber: token,
  16327. }
  16328. var rf []*ResultFive
  16329. json.Unmarshal([]byte(infoStr), &rf)
  16330. var insutypes []*ResultFive
  16331. var insutype string
  16332. var is390 int = 0
  16333. var is310 int = 0
  16334. for _, item := range rf {
  16335. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16336. insutypes = append(insutypes, item)
  16337. }
  16338. }
  16339. if len(insutypes) == 1 {
  16340. insutype = insutypes[0].Insutype
  16341. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16342. } else {
  16343. for _, i := range insutypes {
  16344. if i.Insutype == "390" {
  16345. is390 = 1
  16346. }
  16347. if i.Insutype == "310" {
  16348. is310 = 1
  16349. }
  16350. }
  16351. }
  16352. if is390 == 1 {
  16353. insutype = "390"
  16354. }
  16355. if is310 == 1 {
  16356. insutype = "310"
  16357. }
  16358. if len(insutypes) == 0 {
  16359. insutype = "310"
  16360. }
  16361. service.CreateHisPsn(psn)
  16362. c.ServeSuccessJSON(map[string]interface{}{
  16363. "patient": patient,
  16364. "number": token,
  16365. "insutype": insutype,
  16366. })
  16367. }
  16368. } else {
  16369. c.ServeSuccessJSON(map[string]interface{}{
  16370. "failed_code": -10,
  16371. "msg": res.ErrMsg,
  16372. })
  16373. }
  16374. } else { //读卡失败
  16375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16376. return
  16377. }
  16378. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16379. var api string
  16380. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16381. "&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
  16382. resp, requestErr := http.Get(api)
  16383. if requestErr != nil {
  16384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16385. return
  16386. }
  16387. body, ioErr := ioutil.ReadAll(resp.Body)
  16388. if ioErr != nil {
  16389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16391. return
  16392. }
  16393. var respJSON map[string]interface{}
  16394. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16397. return
  16398. }
  16399. var status string
  16400. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16401. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16402. var token string
  16403. var res ResultTwo //1101结果
  16404. if status == "1" { //读卡成功
  16405. var card_info string //卡信息
  16406. var busi_card_info string
  16407. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16408. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16409. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16410. fmt.Println(card_info)
  16411. fmt.Println(busi_card_info)
  16412. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16413. result, _ := json.Marshal(respJSON)
  16414. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16415. utils.ErrorLog("解析失败:%v", err)
  16416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16417. return
  16418. }
  16419. if res.Infcode == 0 {
  16420. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16421. if err == gorm.ErrRecordNotFound {
  16422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16423. return
  16424. } else if err != nil {
  16425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16426. return
  16427. } else {
  16428. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16429. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16430. infoStr := string(Iinfos)
  16431. idetinfoStr := string(Idetinfos)
  16432. psn := &models.HisPsn{
  16433. PsnNo: res.Output.Baseinfo.PsnNo,
  16434. PatientId: patient.ID,
  16435. Certno: res.Output.Baseinfo.Certno,
  16436. Gend: res.Output.Baseinfo.Gend,
  16437. Naty: res.Output.Baseinfo.Naty,
  16438. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16439. PsnName: res.Output.Baseinfo.PsnName,
  16440. Idetinfo: idetinfoStr,
  16441. Insuinfo: infoStr,
  16442. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16443. CardInfo: card_info,
  16444. VerifyNumber: token,
  16445. }
  16446. var rf []*ResultFive
  16447. json.Unmarshal([]byte(infoStr), &rf)
  16448. var insutypes []*ResultFive
  16449. var insutype string
  16450. var is390 int = 0
  16451. var is310 int = 0
  16452. for _, item := range rf {
  16453. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16454. insutypes = append(insutypes, item)
  16455. }
  16456. }
  16457. if len(insutypes) == 1 {
  16458. insutype = insutypes[0].Insutype
  16459. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16460. } else {
  16461. for _, i := range insutypes {
  16462. if i.Insutype == "390" {
  16463. is390 = 1
  16464. }
  16465. if i.Insutype == "310" {
  16466. is310 = 1
  16467. }
  16468. }
  16469. }
  16470. if is390 == 1 {
  16471. insutype = "390"
  16472. }
  16473. if is310 == 1 {
  16474. insutype = "310"
  16475. }
  16476. if len(insutypes) == 0 {
  16477. insutype = "310"
  16478. }
  16479. service.CreateHisPsn(psn)
  16480. c.ServeSuccessJSON(map[string]interface{}{
  16481. "patient": patient,
  16482. "number": token,
  16483. "insutype": insutype,
  16484. })
  16485. }
  16486. } else {
  16487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16488. return
  16489. }
  16490. } else { //读卡失败
  16491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16492. return
  16493. }
  16494. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16495. var api string
  16496. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16497. "&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
  16498. resp, requestErr := http.Get(api)
  16499. if requestErr != nil {
  16500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16501. return
  16502. }
  16503. body, ioErr := ioutil.ReadAll(resp.Body)
  16504. if ioErr != nil {
  16505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16507. return
  16508. }
  16509. var respJSON map[string]interface{}
  16510. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16513. return
  16514. }
  16515. var status string
  16516. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16517. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16518. var token string
  16519. var res ResultTwo //1101结果
  16520. if status == "1" { //读卡成功
  16521. var card_info string //卡信息
  16522. var busi_card_info string
  16523. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16524. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16525. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16526. fmt.Println(card_info)
  16527. fmt.Println(busi_card_info)
  16528. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16529. result, _ := json.Marshal(respJSON)
  16530. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16531. utils.ErrorLog("解析失败:%v", err)
  16532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16533. return
  16534. }
  16535. if res.Infcode == 0 {
  16536. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16537. if err == gorm.ErrRecordNotFound {
  16538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16539. return
  16540. } else if err != nil {
  16541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16542. return
  16543. } else {
  16544. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16545. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16546. infoStr := string(Iinfos)
  16547. idetinfoStr := string(Idetinfos)
  16548. psn := &models.HisPsn{
  16549. PsnNo: res.Output.Baseinfo.PsnNo,
  16550. PatientId: patient.ID,
  16551. Certno: res.Output.Baseinfo.Certno,
  16552. Gend: res.Output.Baseinfo.Gend,
  16553. Naty: res.Output.Baseinfo.Naty,
  16554. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16555. PsnName: res.Output.Baseinfo.PsnName,
  16556. Idetinfo: idetinfoStr,
  16557. Insuinfo: infoStr,
  16558. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16559. CardInfo: card_info,
  16560. VerifyNumber: token,
  16561. }
  16562. var rf []*ResultFive
  16563. json.Unmarshal([]byte(infoStr), &rf)
  16564. var insutypes []*ResultFive
  16565. var insutype string
  16566. var is390 int = 0
  16567. var is310 int = 0
  16568. for _, item := range rf {
  16569. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16570. insutypes = append(insutypes, item)
  16571. }
  16572. }
  16573. if len(insutypes) == 1 {
  16574. insutype = insutypes[0].Insutype
  16575. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16576. } else {
  16577. for _, i := range insutypes {
  16578. if i.Insutype == "390" {
  16579. is390 = 1
  16580. }
  16581. if i.Insutype == "310" {
  16582. is310 = 1
  16583. }
  16584. }
  16585. }
  16586. if is390 == 1 {
  16587. insutype = "390"
  16588. }
  16589. if is310 == 1 {
  16590. insutype = "310"
  16591. }
  16592. if len(insutypes) == 0 {
  16593. insutype = "390"
  16594. }
  16595. service.CreateHisPsn(psn)
  16596. c.ServeSuccessJSON(map[string]interface{}{
  16597. "patient": patient,
  16598. "number": token,
  16599. "insutype": insutype,
  16600. })
  16601. }
  16602. } else {
  16603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16604. return
  16605. }
  16606. } else { //读卡失败
  16607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16608. return
  16609. }
  16610. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16611. //idNo := c.GetString("idNo")
  16612. //userName := c.GetString("userName")
  16613. //ecToken := c.GetString("ecToken")
  16614. //insuOrg := c.GetString("insuOrg")
  16615. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  16616. utils.ErrorLog("解析失败:%v", json_result)
  16617. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16618. type ELeData struct {
  16619. Data struct {
  16620. IdNo string `json:"idNo"`
  16621. IdType string `json:"idType"`
  16622. UserName string `json:"userName"`
  16623. EcToken string `json:"ecToken"`
  16624. InsuOrg string `json:"insuOrg"`
  16625. Gender string `json:"gender"`
  16626. Birthday string `json:"birthday"`
  16627. Nationality string `json:"nationality"`
  16628. Email string `json:"email"`
  16629. Extra string `json:"extra"`
  16630. } `json:"data"`
  16631. Code int `json:"code"`
  16632. Message string `json:"message"`
  16633. }
  16634. var ele ELeData
  16635. err := json.Unmarshal([]byte(json_result), &ele)
  16636. if err != nil {
  16637. utils.ErrorLog("解析失败:%v", err)
  16638. }
  16639. token := ele.Data.EcToken
  16640. token = Remove0000(token)
  16641. 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)
  16642. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16643. var res ResultTwo
  16644. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16645. utils.ErrorLog("解析失败:%v", err)
  16646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16647. return
  16648. }
  16649. if res.Infcode == 0 {
  16650. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16651. if err == gorm.ErrRecordNotFound {
  16652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16653. return
  16654. } else if err != nil {
  16655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16656. return
  16657. } else {
  16658. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16659. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16660. infoStr := string(Iinfos)
  16661. idetinfoStr := string(Idetinfos)
  16662. psn := &models.HisPsn{
  16663. PsnNo: res.Output.Baseinfo.PsnNo,
  16664. PatientId: patient.ID,
  16665. Certno: res.Output.Baseinfo.Certno,
  16666. Gend: res.Output.Baseinfo.Gend,
  16667. Naty: res.Output.Baseinfo.Naty,
  16668. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16669. PsnName: res.Output.Baseinfo.PsnName,
  16670. Idetinfo: idetinfoStr,
  16671. Insuinfo: infoStr,
  16672. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16673. CardInfo: "",
  16674. Stage: "1",
  16675. VerifyNumber: token,
  16676. InsuplcAdmdvs: ele.Data.InsuOrg,
  16677. }
  16678. service.CreateHisPsn(psn)
  16679. var rf []*ResultFive
  16680. json.Unmarshal([]byte(infoStr), &rf)
  16681. var insutypes []*ResultFive
  16682. var insutype string
  16683. var is390 int = 0
  16684. var is310 int = 0
  16685. for _, item := range rf {
  16686. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16687. insutypes = append(insutypes, item)
  16688. }
  16689. }
  16690. if len(insutypes) == 1 {
  16691. insutype = insutypes[0].Insutype
  16692. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16693. } else {
  16694. for _, i := range insutypes {
  16695. if i.Insutype == "390" {
  16696. is390 = 1
  16697. }
  16698. if i.Insutype == "310" {
  16699. is310 = 1
  16700. }
  16701. }
  16702. }
  16703. if is390 == 1 {
  16704. insutype = "390"
  16705. }
  16706. if is310 == 1 {
  16707. insutype = "310"
  16708. }
  16709. if len(insutypes) == 0 {
  16710. insutype = "310"
  16711. }
  16712. c.ServeSuccessJSON(map[string]interface{}{
  16713. "patient": patient,
  16714. "number": token,
  16715. "insutype": insutype,
  16716. })
  16717. }
  16718. } else {
  16719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16720. return
  16721. }
  16722. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16723. //if initFlag == 0 {
  16724. //c.TestGetJiangXiBasBaseInit()
  16725. //}
  16726. //if initEleFlag == 0 {
  16727. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16728. //}
  16729. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16730. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16731. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16732. type ELeData struct {
  16733. Data struct {
  16734. IdNo string `json:"idNo"`
  16735. IdType string `json:"idType"`
  16736. UserName string `json:"userName"`
  16737. EcToken string `json:"ecToken"`
  16738. InsuOrg string `json:"insuOrg"`
  16739. Gender string `json:"gender"`
  16740. Birthday string `json:"birthday"`
  16741. Nationality string `json:"nationality"`
  16742. Email string `json:"email"`
  16743. Extra string `json:"extra"`
  16744. } `json:"data"`
  16745. Code int `json:"code"`
  16746. Message string `json:"message"`
  16747. }
  16748. var ele ELeData
  16749. err := json.Unmarshal([]byte(result), &ele)
  16750. if err != nil {
  16751. utils.ErrorLog("解析失败:%v", err)
  16752. }
  16753. token := ele.Data.EcToken
  16754. token = Remove0000(token)
  16755. 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)
  16756. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16757. var res ResultTwo
  16758. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16759. utils.ErrorLog("解析失败:%v", err)
  16760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16761. return
  16762. }
  16763. if res.Infcode == 0 {
  16764. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16765. if err == gorm.ErrRecordNotFound {
  16766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16767. return
  16768. } else if err != nil {
  16769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16770. return
  16771. } else {
  16772. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16773. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16774. infoStr := string(Iinfos)
  16775. idetinfoStr := string(Idetinfos)
  16776. psn := &models.HisPsn{
  16777. PsnNo: res.Output.Baseinfo.PsnNo,
  16778. PatientId: patient.ID,
  16779. Certno: res.Output.Baseinfo.Certno,
  16780. Gend: res.Output.Baseinfo.Gend,
  16781. Naty: res.Output.Baseinfo.Naty,
  16782. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16783. PsnName: res.Output.Baseinfo.PsnName,
  16784. Idetinfo: idetinfoStr,
  16785. Insuinfo: infoStr,
  16786. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16787. CardInfo: "",
  16788. VerifyNumber: token,
  16789. InsuplcAdmdvs: ele.Data.InsuOrg,
  16790. }
  16791. service.CreateHisPsn(psn)
  16792. var rf []*ResultFive
  16793. json.Unmarshal([]byte(infoStr), &rf)
  16794. var insutypes []*ResultFive
  16795. var insutype string
  16796. var is390 int = 0
  16797. var is310 int = 0
  16798. for _, item := range rf {
  16799. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16800. insutypes = append(insutypes, item)
  16801. }
  16802. }
  16803. if len(insutypes) == 1 {
  16804. insutype = insutypes[0].Insutype
  16805. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16806. } else {
  16807. for _, i := range insutypes {
  16808. if i.Insutype == "390" {
  16809. is390 = 1
  16810. }
  16811. if i.Insutype == "310" {
  16812. is310 = 1
  16813. }
  16814. }
  16815. }
  16816. if is390 == 1 {
  16817. insutype = "390"
  16818. }
  16819. if is310 == 1 {
  16820. insutype = "310"
  16821. }
  16822. if len(insutypes) == 0 {
  16823. insutype = "310"
  16824. }
  16825. c.ServeSuccessJSON(map[string]interface{}{
  16826. "patient": patient,
  16827. "number": token,
  16828. "insutype": insutype,
  16829. })
  16830. }
  16831. } else {
  16832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16833. return
  16834. }
  16835. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16836. //if initFlag == 0 {
  16837. //c.TestGetJiangXiBasBaseInit()
  16838. //}
  16839. //if initEleFlag == 0 {
  16840. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16841. //}
  16842. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16843. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16844. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16845. type ELeData struct {
  16846. Data struct {
  16847. IdNo string `json:"idNo"`
  16848. IdType string `json:"idType"`
  16849. UserName string `json:"userName"`
  16850. EcToken string `json:"ecToken"`
  16851. InsuOrg string `json:"insuOrg"`
  16852. Gender string `json:"gender"`
  16853. Birthday string `json:"birthday"`
  16854. Nationality string `json:"nationality"`
  16855. Email string `json:"email"`
  16856. Extra string `json:"extra"`
  16857. } `json:"data"`
  16858. Code int `json:"code"`
  16859. Message string `json:"message"`
  16860. }
  16861. var ele ELeData
  16862. err := json.Unmarshal([]byte(result), &ele)
  16863. if err != nil {
  16864. utils.ErrorLog("解析失败:%v", err)
  16865. }
  16866. token := ele.Data.EcToken
  16867. token = Remove0000(token)
  16868. 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)
  16869. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16870. var res ResultTwo
  16871. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16872. utils.ErrorLog("解析失败:%v", err)
  16873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16874. return
  16875. }
  16876. if res.Infcode == 0 {
  16877. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16878. if err == gorm.ErrRecordNotFound {
  16879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16880. return
  16881. } else if err != nil {
  16882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16883. return
  16884. } else {
  16885. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16886. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16887. infoStr := string(Iinfos)
  16888. idetinfoStr := string(Idetinfos)
  16889. psn := &models.HisPsn{
  16890. PsnNo: res.Output.Baseinfo.PsnNo,
  16891. PatientId: patient.ID,
  16892. Certno: res.Output.Baseinfo.Certno,
  16893. Gend: res.Output.Baseinfo.Gend,
  16894. Naty: res.Output.Baseinfo.Naty,
  16895. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16896. PsnName: res.Output.Baseinfo.PsnName,
  16897. Idetinfo: idetinfoStr,
  16898. Insuinfo: infoStr,
  16899. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16900. CardInfo: "",
  16901. VerifyNumber: token,
  16902. InsuplcAdmdvs: ele.Data.InsuOrg,
  16903. }
  16904. service.CreateHisPsn(psn)
  16905. var rf []*ResultFive
  16906. json.Unmarshal([]byte(infoStr), &rf)
  16907. var insutypes []*ResultFive
  16908. var insutype string
  16909. var is390 int = 0
  16910. var is310 int = 0
  16911. for _, item := range rf {
  16912. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16913. insutypes = append(insutypes, item)
  16914. }
  16915. }
  16916. if len(insutypes) == 1 {
  16917. insutype = insutypes[0].Insutype
  16918. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16919. } else {
  16920. for _, i := range insutypes {
  16921. if i.Insutype == "390" {
  16922. is390 = 1
  16923. }
  16924. if i.Insutype == "310" {
  16925. is310 = 1
  16926. }
  16927. }
  16928. }
  16929. if is390 == 1 {
  16930. insutype = "390"
  16931. }
  16932. if is310 == 1 {
  16933. insutype = "310"
  16934. }
  16935. if len(insutypes) == 0 {
  16936. insutype = "310"
  16937. }
  16938. c.ServeSuccessJSON(map[string]interface{}{
  16939. "patient": patient,
  16940. "number": token,
  16941. "insutype": insutype,
  16942. })
  16943. }
  16944. } else {
  16945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16946. return
  16947. }
  16948. } else if miConfig.MdtrtareaAdmvs == "360100" {
  16949. //if initFlag == 0 {
  16950. //c.TestGetJiangXiBasBaseInit()
  16951. //}
  16952. //if initEleFlag == 0 {
  16953. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16954. //}
  16955. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16956. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16957. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16958. type ELeData struct {
  16959. Data struct {
  16960. IdNo string `json:"idNo"`
  16961. IdType string `json:"idType"`
  16962. UserName string `json:"userName"`
  16963. EcToken string `json:"ecToken"`
  16964. InsuOrg string `json:"insuOrg"`
  16965. Gender string `json:"gender"`
  16966. Birthday string `json:"birthday"`
  16967. Nationality string `json:"nationality"`
  16968. Email string `json:"email"`
  16969. Extra string `json:"extra"`
  16970. } `json:"data"`
  16971. Code int `json:"code"`
  16972. Message string `json:"message"`
  16973. }
  16974. var ele ELeData
  16975. err := json.Unmarshal([]byte(result), &ele)
  16976. if err != nil {
  16977. utils.ErrorLog("解析失败:%v", err)
  16978. }
  16979. token := ele.Data.EcToken
  16980. token = Remove0000(token)
  16981. 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)
  16982. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16983. var res ResultTwo
  16984. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16985. utils.ErrorLog("解析失败:%v", err)
  16986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16987. return
  16988. }
  16989. if res.Infcode == 0 {
  16990. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16991. if err == gorm.ErrRecordNotFound {
  16992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16993. return
  16994. } else if err != nil {
  16995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16996. return
  16997. } else {
  16998. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16999. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17000. infoStr := string(Iinfos)
  17001. idetinfoStr := string(Idetinfos)
  17002. psn := &models.HisPsn{
  17003. PsnNo: res.Output.Baseinfo.PsnNo,
  17004. PatientId: patient.ID,
  17005. Certno: res.Output.Baseinfo.Certno,
  17006. Gend: res.Output.Baseinfo.Gend,
  17007. Naty: res.Output.Baseinfo.Naty,
  17008. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17009. PsnName: res.Output.Baseinfo.PsnName,
  17010. Idetinfo: idetinfoStr,
  17011. Insuinfo: infoStr,
  17012. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17013. CardInfo: "",
  17014. VerifyNumber: token,
  17015. InsuplcAdmdvs: ele.Data.InsuOrg,
  17016. }
  17017. service.CreateHisPsn(psn)
  17018. var rf []*ResultFive
  17019. json.Unmarshal([]byte(infoStr), &rf)
  17020. var insutypes []*ResultFive
  17021. var insutype string
  17022. var is390 int = 0
  17023. var is310 int = 0
  17024. for _, item := range rf {
  17025. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17026. insutypes = append(insutypes, item)
  17027. }
  17028. }
  17029. if len(insutypes) == 1 {
  17030. insutype = insutypes[0].Insutype
  17031. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17032. } else {
  17033. for _, i := range insutypes {
  17034. if i.Insutype == "390" {
  17035. is390 = 1
  17036. }
  17037. if i.Insutype == "310" {
  17038. is310 = 1
  17039. }
  17040. }
  17041. }
  17042. if is390 == 1 {
  17043. insutype = "390"
  17044. }
  17045. if is310 == 1 {
  17046. insutype = "310"
  17047. }
  17048. if len(insutypes) == 0 {
  17049. insutype = "310"
  17050. }
  17051. c.ServeSuccessJSON(map[string]interface{}{
  17052. "patient": patient,
  17053. "number": token,
  17054. "insutype": insutype,
  17055. })
  17056. }
  17057. } else {
  17058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17059. return
  17060. }
  17061. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17062. //if initFlag == 0 {
  17063. c.TestGetJiangXiBasBaseInit()
  17064. //}
  17065. //if initEleFlag == 0 {
  17066. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17067. //}
  17068. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17069. type ELeData struct {
  17070. Data struct {
  17071. IdNo string `json:"idNo"`
  17072. IdType string `json:"idType"`
  17073. UserName string `json:"userName"`
  17074. EcToken string `json:"ecToken"`
  17075. InsuOrg string `json:"insuOrg"`
  17076. Gender string `json:"gender"`
  17077. Birthday string `json:"birthday"`
  17078. Nationality string `json:"nationality"`
  17079. Email string `json:"email"`
  17080. Extra string `json:"extra"`
  17081. } `json:"data"`
  17082. Code int `json:"code"`
  17083. Message string `json:"message"`
  17084. }
  17085. var ele ELeData
  17086. err := json.Unmarshal([]byte(json_result), &ele)
  17087. if err != nil {
  17088. utils.ErrorLog("解析失败:%v", err)
  17089. }
  17090. token := ele.Data.EcToken
  17091. token = Remove0000(token)
  17092. 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)
  17093. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17094. var res ResultTwo
  17095. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17096. utils.ErrorLog("解析失败:%v", err)
  17097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17098. return
  17099. }
  17100. if res.Infcode == 0 {
  17101. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17102. if err == gorm.ErrRecordNotFound {
  17103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17104. return
  17105. } else if err != nil {
  17106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17107. return
  17108. } else {
  17109. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17110. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17111. infoStr := string(Iinfos)
  17112. idetinfoStr := string(Idetinfos)
  17113. psn := &models.HisPsn{
  17114. PsnNo: res.Output.Baseinfo.PsnNo,
  17115. PatientId: patient.ID,
  17116. Certno: res.Output.Baseinfo.Certno,
  17117. Gend: res.Output.Baseinfo.Gend,
  17118. Naty: res.Output.Baseinfo.Naty,
  17119. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17120. PsnName: res.Output.Baseinfo.PsnName,
  17121. Idetinfo: idetinfoStr,
  17122. Insuinfo: infoStr,
  17123. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17124. CardInfo: "",
  17125. VerifyNumber: token,
  17126. }
  17127. service.CreateHisPsn(psn)
  17128. var rf []*ResultFive
  17129. json.Unmarshal([]byte(infoStr), &rf)
  17130. var insutypes []*ResultFive
  17131. var insutype string
  17132. var is390 int = 0
  17133. var is310 int = 0
  17134. for _, item := range rf {
  17135. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17136. insutypes = append(insutypes, item)
  17137. }
  17138. }
  17139. if len(insutypes) == 1 {
  17140. insutype = insutypes[0].Insutype
  17141. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17142. } else {
  17143. for _, i := range insutypes {
  17144. if i.Insutype == "390" {
  17145. is390 = 1
  17146. }
  17147. if i.Insutype == "310" {
  17148. is310 = 1
  17149. }
  17150. }
  17151. }
  17152. if is390 == 1 {
  17153. insutype = "390"
  17154. }
  17155. if is310 == 1 {
  17156. insutype = "310"
  17157. }
  17158. if len(insutypes) == 0 {
  17159. insutype = "310"
  17160. }
  17161. c.ServeSuccessJSON(map[string]interface{}{
  17162. "patient": patient,
  17163. "number": token,
  17164. "insutype": insutype,
  17165. })
  17166. }
  17167. } else {
  17168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17169. return
  17170. }
  17171. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17172. type ELeData struct {
  17173. Code string `json:"code"`
  17174. Data struct {
  17175. Aac002 string `json:"aac002"`
  17176. Aaz500 string `json:"aaz500"`
  17177. ActCardNo string `json:"actCardNo"`
  17178. Bab520 string `json:"bab520"`
  17179. Bkz543 string `json:"bkz543"`
  17180. BusinessType string `json:"businessType"`
  17181. CertfCodg string `json:"certfCodg"`
  17182. EcIndexNo string `json:"ecIndexNo"`
  17183. EcToken string `json:"ecToken"`
  17184. ID0000 string `json:"id0000"`
  17185. IDNo string `json:"idNo"`
  17186. IDType string `json:"idType"`
  17187. Idcode string `json:"idcode"`
  17188. IdentityToken string `json:"identity_token"`
  17189. InsuOrg string `json:"insuOrg"`
  17190. OfficeID string `json:"officeId"`
  17191. OfficeName string `json:"officeName"`
  17192. OperatorID string `json:"operatorId"`
  17193. OperatorName string `json:"operatorName"`
  17194. OrgID string `json:"orgId"`
  17195. UserName string `json:"userName"`
  17196. } `json:"data"`
  17197. Infno interface{} `json:"infno"`
  17198. Message string `json:"message"`
  17199. OrgID string `json:"orgId"`
  17200. TransType string `json:"transType"`
  17201. }
  17202. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  17203. outPutInfo = Remove0000(outPutInfo)
  17204. if len(outPutInfo) > 0 {
  17205. var ele ELeData
  17206. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17207. if err != nil {
  17208. utils.ErrorLog("解析失败:%v", err)
  17209. }
  17210. token := ele.Data.EcToken
  17211. fmt.Println(inputInfo)
  17212. fmt.Println(outPutInfo)
  17213. 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)
  17214. saveLog(result, requestLog, "1101", "获取人员信息")
  17215. var dat map[string]interface{}
  17216. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17217. fmt.Println(dat)
  17218. } else {
  17219. fmt.Println(err)
  17220. }
  17221. userJSONBytes, _ := json.Marshal(dat)
  17222. var res ResultTwo
  17223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17224. utils.ErrorLog("解析失败:%v", err)
  17225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17226. return
  17227. }
  17228. res.ErrMsg = errMsgLog
  17229. if res.Infcode == 0 {
  17230. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17231. if err == gorm.ErrRecordNotFound {
  17232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17233. return
  17234. } else if err != nil {
  17235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17236. return
  17237. } else {
  17238. fmt.Println(res)
  17239. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17240. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17241. infoStr := string(Iinfos)
  17242. idetinfoStr := string(Idetinfos)
  17243. psn := &models.HisPsn{
  17244. PsnNo: res.Output.Baseinfo.PsnNo,
  17245. PatientId: patient.ID,
  17246. Certno: res.Output.Baseinfo.Certno,
  17247. Gend: res.Output.Baseinfo.Gend,
  17248. Naty: res.Output.Baseinfo.Naty,
  17249. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17250. PsnName: res.Output.Baseinfo.PsnName,
  17251. Idetinfo: idetinfoStr,
  17252. Insuinfo: infoStr,
  17253. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17254. CardInfo: outPutInfo,
  17255. VerifyNumber: token,
  17256. InsuplcAdmdvs: ele.Data.InsuOrg,
  17257. }
  17258. service.CreateHisPsn(psn)
  17259. var rf []*ResultFive
  17260. json.Unmarshal([]byte(infoStr), &rf)
  17261. var insutypes []*ResultFive
  17262. var insutype string
  17263. var is390 int = 0
  17264. var is310 int = 0
  17265. for _, item := range rf {
  17266. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17267. insutypes = append(insutypes, item)
  17268. }
  17269. }
  17270. if len(insutypes) == 1 {
  17271. insutype = insutypes[0].Insutype
  17272. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17273. } else {
  17274. for _, i := range insutypes {
  17275. if i.Insutype == "390" {
  17276. is390 = 1
  17277. }
  17278. if i.Insutype == "310" {
  17279. is310 = 1
  17280. }
  17281. }
  17282. }
  17283. if is390 == 1 {
  17284. insutype = "390"
  17285. }
  17286. if is310 == 1 {
  17287. insutype = "310"
  17288. }
  17289. if len(insutypes) == 0 {
  17290. insutype = "310"
  17291. }
  17292. c.ServeSuccessJSON(map[string]interface{}{
  17293. "patient": patient,
  17294. "number": token,
  17295. "insutype": insutype,
  17296. })
  17297. }
  17298. } else {
  17299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17300. return
  17301. }
  17302. }
  17303. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17304. var api string
  17305. 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 +
  17306. "&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
  17307. resp, requestErr := http.Get(api)
  17308. if requestErr != nil {
  17309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17310. return
  17311. }
  17312. body, ioErr := ioutil.ReadAll(resp.Body)
  17313. if ioErr != nil {
  17314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17316. return
  17317. }
  17318. var respJSON map[string]interface{}
  17319. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17322. return
  17323. }
  17324. var status string
  17325. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17326. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17327. var token string
  17328. var res ResultTwo //1101结果
  17329. var res10265 ResultTwo10265 //1101结果
  17330. if status == "0" { //读卡成功
  17331. var card_info string //卡信息
  17332. var busi_card_info string
  17333. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17334. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17335. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17336. fmt.Println(card_info)
  17337. fmt.Println(busi_card_info)
  17338. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17339. result, _ := json.Marshal(respJSON)
  17340. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17341. utils.ErrorLog("解析失败:%v", err)
  17342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17343. return
  17344. }
  17345. res.ErrMsg = res10265.ErrMsg
  17346. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17347. res.Infcode = infocode
  17348. res.Output = res10265.Output
  17349. res.InfRefmsgid = res10265.InfRefmsgid
  17350. if res.Infcode == 0 {
  17351. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17352. if err == gorm.ErrRecordNotFound {
  17353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17354. return
  17355. } else if err != nil {
  17356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17357. return
  17358. } else {
  17359. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17360. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17361. infoStr := string(Iinfos)
  17362. idetinfoStr := string(Idetinfos)
  17363. psn := &models.HisPsn{
  17364. PsnNo: res.Output.Baseinfo.PsnNo,
  17365. PatientId: patient.ID,
  17366. Certno: res.Output.Baseinfo.Certno,
  17367. Gend: res.Output.Baseinfo.Gend,
  17368. Naty: res.Output.Baseinfo.Naty,
  17369. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17370. PsnName: res.Output.Baseinfo.PsnName,
  17371. Idetinfo: idetinfoStr,
  17372. Insuinfo: infoStr,
  17373. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17374. CardInfo: card_info,
  17375. VerifyNumber: token,
  17376. }
  17377. var rf []*ResultFive
  17378. json.Unmarshal([]byte(infoStr), &rf)
  17379. var insutypes []*ResultFive
  17380. var insutype string
  17381. var is390 int = 0
  17382. var is310 int = 0
  17383. for _, item := range rf {
  17384. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17385. insutypes = append(insutypes, item)
  17386. }
  17387. }
  17388. if len(insutypes) == 1 {
  17389. insutype = insutypes[0].Insutype
  17390. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17391. } else {
  17392. for _, i := range insutypes {
  17393. if i.Insutype == "390" {
  17394. is390 = 1
  17395. }
  17396. if i.Insutype == "310" {
  17397. is310 = 1
  17398. }
  17399. }
  17400. }
  17401. if is390 == 1 {
  17402. insutype = "390"
  17403. }
  17404. if is310 == 1 {
  17405. insutype = "310"
  17406. }
  17407. if len(insutypes) == 0 {
  17408. insutype = "310"
  17409. }
  17410. service.CreateHisPsn(psn)
  17411. c.ServeSuccessJSON(map[string]interface{}{
  17412. "patient": patient,
  17413. "number": token,
  17414. "insutype": insutype,
  17415. })
  17416. }
  17417. } else {
  17418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17419. return
  17420. }
  17421. } else { //读卡失败
  17422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17423. return
  17424. }
  17425. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17426. res := c.GetoleInfo()
  17427. if res.Infcode == 0 {
  17428. var result string
  17429. if res.Output.MdtrtCertType == "01" {
  17430. 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)
  17431. } else if res.Output.MdtrtCertType == "02" {
  17432. 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)
  17433. } else if res.Output.MdtrtCertType == "03" {
  17434. 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)
  17435. }
  17436. var dat map[string]interface{}
  17437. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17438. fmt.Println(dat)
  17439. } else {
  17440. fmt.Println(err)
  17441. }
  17442. userJSONBytes, _ := json.Marshal(dat)
  17443. var res2 ResultTwo
  17444. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17445. utils.ErrorLog("解析失败:%v", err)
  17446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17447. return
  17448. }
  17449. if res2.Infcode == 0 {
  17450. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  17451. if err == gorm.ErrRecordNotFound {
  17452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17453. return
  17454. } else if err != nil {
  17455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17456. return
  17457. } else {
  17458. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  17459. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  17460. infoStr := string(Iinfos)
  17461. idetinfoStr := string(Idetinfos)
  17462. var rf []*ResultFive
  17463. json.Unmarshal([]byte(infoStr), &rf)
  17464. var insutypes []*ResultFive
  17465. var insutype string
  17466. var is390 int = 0
  17467. var is310 int = 0
  17468. //var insuplc_admdvs string
  17469. for _, item := range rf {
  17470. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17471. insutypes = append(insutypes, item)
  17472. }
  17473. }
  17474. if len(insutypes) == 1 {
  17475. insutype = insutypes[0].Insutype
  17476. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17477. } else {
  17478. for _, i := range insutypes {
  17479. if i.Insutype == "390" {
  17480. is390 = 1
  17481. }
  17482. if i.Insutype == "310" {
  17483. is310 = 1
  17484. }
  17485. }
  17486. }
  17487. if is390 == 1 {
  17488. insutype = "390"
  17489. }
  17490. if is310 == 1 {
  17491. insutype = "310"
  17492. }
  17493. if len(insutypes) == 0 {
  17494. insutype = "310"
  17495. }
  17496. psn := &models.HisPsn{
  17497. PsnNo: res2.Output.Baseinfo.PsnNo,
  17498. PatientId: patient.ID,
  17499. Certno: res2.Output.Baseinfo.Certno,
  17500. Gend: res2.Output.Baseinfo.Gend,
  17501. Naty: res2.Output.Baseinfo.Naty,
  17502. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  17503. PsnName: res2.Output.Baseinfo.PsnName,
  17504. Idetinfo: idetinfoStr,
  17505. Insuinfo: infoStr,
  17506. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17507. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  17508. VerifyNumber: res.Output.EcToken,
  17509. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  17510. }
  17511. if res.Output.MdtrtCertType == "01" {
  17512. psn.VerifyNumber = res.Output.EcToken
  17513. //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)
  17514. } else if res.Output.MdtrtCertType == "02" {
  17515. psn.VerifyNumber = res.Output.CardNo
  17516. //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)
  17517. } else if res.Output.MdtrtCertType == "03" {
  17518. psn.VerifyNumber = res.Output.MdtrtCertNo
  17519. //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)
  17520. }
  17521. service.CreateHisPsn(psn)
  17522. var balc float64
  17523. for _, item := range rf {
  17524. if item.Insutype == insutype {
  17525. balc = item.Balc
  17526. }
  17527. }
  17528. c.ServeSuccessJSON(map[string]interface{}{
  17529. "patient": patient,
  17530. "number": res.Output.CardNo,
  17531. "insutype": insutype,
  17532. "blac": balc,
  17533. "desc": idetinfoStr,
  17534. })
  17535. }
  17536. } else {
  17537. c.ServeSuccessJSON(map[string]interface{}{
  17538. "failed_code": -10,
  17539. "msg": res2.ErrMsg,
  17540. })
  17541. }
  17542. } else {
  17543. c.ServeSuccessJSON(map[string]interface{}{
  17544. "failed_code": -10,
  17545. "msg": res.ErrMsg,
  17546. })
  17547. }
  17548. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17549. var res ResultTwo
  17550. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  17551. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17552. "&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)
  17553. resp, requestErr := http.Get(api)
  17554. if requestErr != nil {
  17555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17556. return
  17557. }
  17558. body, ioErr := ioutil.ReadAll(resp.Body)
  17559. if ioErr != nil {
  17560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17562. return
  17563. }
  17564. var respJSON map[string]interface{}
  17565. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17568. return
  17569. }
  17570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17571. result, _ := json.Marshal(respJSON)
  17572. fmt.Println("log")
  17573. fmt.Println(string(result))
  17574. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17575. utils.ErrorLog("解析失败:%v", err)
  17576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17577. return
  17578. }
  17579. if res.Infcode == 0 {
  17580. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17581. if err == gorm.ErrRecordNotFound {
  17582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17583. return
  17584. } else if err != nil {
  17585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17586. return
  17587. } else {
  17588. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17589. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17590. infoStr := string(Iinfos)
  17591. idetinfoStr := string(Idetinfos)
  17592. var rf []*ResultFive
  17593. json.Unmarshal([]byte(infoStr), &rf)
  17594. var insutypes []*ResultFive
  17595. var insutype string
  17596. var is390 int = 0
  17597. var is310 int = 0
  17598. for _, item := range rf {
  17599. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17600. insutypes = append(insutypes, item)
  17601. }
  17602. }
  17603. if len(insutypes) == 1 {
  17604. insutype = insutypes[0].Insutype
  17605. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17606. } else {
  17607. for _, i := range insutypes {
  17608. if i.Insutype == "390" {
  17609. is390 = 1
  17610. }
  17611. if i.Insutype == "310" {
  17612. is310 = 1
  17613. }
  17614. }
  17615. }
  17616. if is390 == 1 {
  17617. insutype = "390"
  17618. }
  17619. if is310 == 1 {
  17620. insutype = "310"
  17621. }
  17622. if len(insutypes) == 0 {
  17623. insutype = "390"
  17624. }
  17625. var insuplc_admdvs string
  17626. for _, item := range rf {
  17627. if item.Insutype == insutype {
  17628. insuplc_admdvs = item.InsuplcAdmdvs
  17629. }
  17630. }
  17631. psn := &models.HisPsn{
  17632. PsnNo: res.Output.Baseinfo.PsnNo,
  17633. PatientId: patient.ID,
  17634. Certno: res.Output.Baseinfo.Certno,
  17635. Gend: res.Output.Baseinfo.Gend,
  17636. Naty: res.Output.Baseinfo.Naty,
  17637. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17638. PsnName: res.Output.Baseinfo.PsnName,
  17639. Idetinfo: idetinfoStr,
  17640. Insuinfo: infoStr,
  17641. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17642. InsuplcAdmdvs: insuplc_admdvs,
  17643. }
  17644. service.CreateHisPsn(psn)
  17645. c.ServeSuccessJSON(map[string]interface{}{
  17646. "patient": patient,
  17647. "number": res.Output.Baseinfo.Certno,
  17648. })
  17649. }
  17650. } else {
  17651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17652. return
  17653. }
  17654. } else {
  17655. type ELeData struct {
  17656. Code string `json:"code"`
  17657. Data struct {
  17658. Aac002 string `json:"aac002"`
  17659. Aaz500 string `json:"aaz500"`
  17660. ActCardNo string `json:"actCardNo"`
  17661. Bab520 string `json:"bab520"`
  17662. Bkz543 string `json:"bkz543"`
  17663. BusinessType string `json:"businessType"`
  17664. CertfCodg string `json:"certfCodg"`
  17665. EcIndexNo string `json:"ecIndexNo"`
  17666. EcToken string `json:"ecToken"`
  17667. ID0000 string `json:"id0000"`
  17668. IDNo string `json:"idNo"`
  17669. IDType string `json:"idType"`
  17670. Idcode string `json:"idcode"`
  17671. IdentityToken string `json:"identity_token"`
  17672. InsuOrg string `json:"insuOrg"`
  17673. OfficeID string `json:"officeId"`
  17674. OfficeName string `json:"officeName"`
  17675. OperatorID string `json:"operatorId"`
  17676. OperatorName string `json:"operatorName"`
  17677. OrgID string `json:"orgId"`
  17678. UserName string `json:"userName"`
  17679. } `json:"data"`
  17680. Infno interface{} `json:"infno"`
  17681. Message string `json:"message"`
  17682. OrgID string `json:"orgId"`
  17683. TransType string `json:"transType"`
  17684. }
  17685. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17686. fmt.Println(result)
  17687. outPutInfo := Remove0000(result)
  17688. fmt.Println(outPutInfo)
  17689. if len(outPutInfo) > 0 {
  17690. var ele ELeData
  17691. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17692. if err != nil {
  17693. utils.ErrorLog("解析失败:%v", err)
  17694. }
  17695. token := ele.Data.EcToken
  17696. fmt.Println(outPutInfo)
  17697. 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)
  17698. saveLog(result, requestLog, "1101", "获取人员信息")
  17699. var dat map[string]interface{}
  17700. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17701. fmt.Println(dat)
  17702. } else {
  17703. fmt.Println(err)
  17704. }
  17705. userJSONBytes, _ := json.Marshal(dat)
  17706. var res ResultTwo
  17707. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17708. utils.ErrorLog("解析失败:%v", err)
  17709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17710. return
  17711. }
  17712. if res.Infcode == 0 {
  17713. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17714. if err == gorm.ErrRecordNotFound {
  17715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17716. return
  17717. } else if err != nil {
  17718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17719. return
  17720. } else {
  17721. fmt.Println(res)
  17722. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17723. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17724. infoStr := string(Iinfos)
  17725. idetinfoStr := string(Idetinfos)
  17726. psn := &models.HisPsn{
  17727. PsnNo: res.Output.Baseinfo.PsnNo,
  17728. PatientId: patient.ID,
  17729. Certno: res.Output.Baseinfo.Certno,
  17730. Gend: res.Output.Baseinfo.Gend,
  17731. Naty: res.Output.Baseinfo.Naty,
  17732. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17733. PsnName: res.Output.Baseinfo.PsnName,
  17734. Idetinfo: idetinfoStr,
  17735. Insuinfo: infoStr,
  17736. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17737. CardInfo: outPutInfo,
  17738. VerifyNumber: token,
  17739. InsuplcAdmdvs: ele.Data.InsuOrg,
  17740. }
  17741. service.CreateHisPsn(psn)
  17742. var rf []*ResultFive
  17743. json.Unmarshal([]byte(infoStr), &rf)
  17744. var insutypes []*ResultFive
  17745. var insutype string
  17746. var is390 int = 0
  17747. var is310 int = 0
  17748. for _, item := range rf {
  17749. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17750. insutypes = append(insutypes, item)
  17751. }
  17752. }
  17753. if len(insutypes) == 1 {
  17754. insutype = insutypes[0].Insutype
  17755. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17756. } else {
  17757. for _, i := range insutypes {
  17758. if i.Insutype == "390" {
  17759. is390 = 1
  17760. }
  17761. if i.Insutype == "310" {
  17762. is310 = 1
  17763. }
  17764. }
  17765. }
  17766. if is390 == 1 {
  17767. insutype = "390"
  17768. }
  17769. if is310 == 1 {
  17770. insutype = "310"
  17771. }
  17772. if len(insutypes) == 0 {
  17773. insutype = "310"
  17774. }
  17775. c.ServeSuccessJSON(map[string]interface{}{
  17776. "patient": patient,
  17777. "number": token,
  17778. "insutype": insutype,
  17779. })
  17780. }
  17781. } else {
  17782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17783. return
  17784. }
  17785. }
  17786. //fmt.Println(result)
  17787. //
  17788. //if initFlag == 0 {
  17789. // c.TestGetBasBaseInit()
  17790. //}
  17791. //token := c.GetEleBaseInfo()
  17792. //
  17793. //token = Remove0000(token)
  17794. //
  17795. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17796. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17797. ////
  17798. //var res ResultTwo
  17799. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17800. // utils.ErrorLog("解析失败:%v", err)
  17801. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17802. // return
  17803. //}
  17804. //
  17805. //if res.Infcode == 0 {
  17806. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17807. // if err == gorm.ErrRecordNotFound {
  17808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17809. // return
  17810. // } else if err != nil {
  17811. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17812. // return
  17813. //
  17814. // } else {
  17815. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17816. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17817. // infoStr := string(Iinfos)
  17818. // idetinfoStr := string(Idetinfos)
  17819. //
  17820. //
  17821. //
  17822. //
  17823. // var rf []*ResultFive
  17824. // json.Unmarshal([]byte(infoStr), &rf)
  17825. //
  17826. // var insutypes []*ResultFive
  17827. // var insutype string
  17828. // var is390 int = 0
  17829. // var is310 int = 0
  17830. // var insuplc_admdvs string
  17831. //
  17832. // for _, item := range rf {
  17833. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17834. // insutypes = append(insutypes, item)
  17835. // }
  17836. // }
  17837. //
  17838. // if len(insutypes) == 1 {
  17839. // insutype = insutypes[0].Insutype
  17840. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17841. // } else {
  17842. // for _, i := range insutypes {
  17843. // if i.Insutype == "390" {
  17844. // is390 = 1
  17845. // }
  17846. //
  17847. // if i.Insutype == "310" {
  17848. // is310 = 1
  17849. // }
  17850. // }
  17851. // }
  17852. // if is390 == 1 {
  17853. // insutype = "390"
  17854. // }
  17855. //
  17856. // if is310 == 1 {
  17857. // insutype = "310"
  17858. // }
  17859. // if len(insutypes) == 0 {
  17860. // insutype = "310"
  17861. // }
  17862. // for _, item := range rf {
  17863. // if item.Insutype == insutype {
  17864. // insuplc_admdvs = item.InsuplcAdmdvs
  17865. // }
  17866. // }
  17867. // psn := &models.HisPsn{
  17868. // PsnNo: res.Output.Baseinfo.PsnNo,
  17869. // Age: res.Output.Baseinfo.Age,
  17870. // PatientId: patient.ID,
  17871. // Certno: res.Output.Baseinfo.Certno,
  17872. // Brdy: res.Output.Baseinfo.Brdy,
  17873. // Gend: res.Output.Baseinfo.Gend,
  17874. // Naty: res.Output.Baseinfo.Naty,
  17875. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17876. // PsnName: res.Output.Baseinfo.PsnName,
  17877. // Idetinfo: idetinfoStr,
  17878. // Insuinfo: infoStr,
  17879. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17880. // CardInfo: "",
  17881. // VerifyNumber: token,
  17882. // InsuplcAdmdvs: insuplc_admdvs,
  17883. // }
  17884. // service.CreateHisPsn(psn)
  17885. //
  17886. // c.ServeSuccessJSON(map[string]interface{}{
  17887. // "patient": patient,
  17888. // "number": token,
  17889. // })
  17890. // }
  17891. //} else {
  17892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17893. // return
  17894. //}
  17895. }
  17896. break
  17897. case 5:
  17898. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  17899. var api string
  17900. if miConfig.MdtrtareaAdmvs == "320830" {
  17901. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  17902. "&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
  17903. fmt.Println(api)
  17904. } else if miConfig.MdtrtareaAdmvs == "320921" {
  17905. 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 +
  17906. "&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
  17907. fmt.Println(api)
  17908. } else {
  17909. 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 +
  17910. "&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)
  17911. }
  17912. resp, requestErr := http.Get(api)
  17913. if requestErr != nil {
  17914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17915. return
  17916. }
  17917. body, ioErr := ioutil.ReadAll(resp.Body)
  17918. if ioErr != nil {
  17919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17921. return
  17922. }
  17923. var respJSON map[string]interface{}
  17924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17927. return
  17928. }
  17929. var status string
  17930. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17931. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17932. var token string
  17933. var res ResultTwo //1101结果
  17934. var res10265 ResultTwo10265 //1101结果
  17935. if status == "0" { //读卡成功
  17936. var card_info string //卡信息
  17937. //var busi_card_info string
  17938. var auth_info string
  17939. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17940. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17941. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17942. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17943. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17944. result, _ := json.Marshal(respJSON)
  17945. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17946. utils.ErrorLog("解析失败:%v", err)
  17947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17948. return
  17949. }
  17950. res.ErrMsg = res10265.ErrMsg
  17951. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17952. res.Infcode = infocode
  17953. res.Output = res10265.Output
  17954. res.InfRefmsgid = res10265.InfRefmsgid
  17955. if res.Infcode == 0 {
  17956. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17957. if err == gorm.ErrRecordNotFound {
  17958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17959. return
  17960. } else if err != nil {
  17961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17962. return
  17963. } else {
  17964. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17965. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17966. infoStr := string(Iinfos)
  17967. idetinfoStr := string(Idetinfos)
  17968. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  17969. psn := &models.HisPsn{
  17970. PsnNo: res.Output.Baseinfo.PsnNo,
  17971. PatientId: patient.ID,
  17972. Certno: res.Output.Baseinfo.Certno,
  17973. Gend: res.Output.Baseinfo.Gend,
  17974. Brdy: b,
  17975. Age: float64(age),
  17976. Naty: res.Output.Baseinfo.Naty,
  17977. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17978. PsnName: res.Output.Baseinfo.PsnName,
  17979. Idetinfo: idetinfoStr,
  17980. Insuinfo: infoStr,
  17981. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17982. CardInfo: card_info,
  17983. VerifyNumber: token,
  17984. AuthInfo: auth_info,
  17985. }
  17986. var rf []*ResultFive
  17987. json.Unmarshal([]byte(infoStr), &rf)
  17988. var insutypes []*ResultFive
  17989. var insutype string
  17990. var is390 int = 0
  17991. var is310 int = 0
  17992. for _, item := range rf {
  17993. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17994. insutypes = append(insutypes, item)
  17995. }
  17996. }
  17997. if len(insutypes) == 1 {
  17998. insutype = insutypes[0].Insutype
  17999. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18000. } else {
  18001. for _, i := range insutypes {
  18002. if i.Insutype == "390" {
  18003. is390 = 1
  18004. }
  18005. if i.Insutype == "310" {
  18006. is310 = 1
  18007. }
  18008. }
  18009. }
  18010. if is390 == 1 {
  18011. insutype = "390"
  18012. }
  18013. if is310 == 1 {
  18014. insutype = "310"
  18015. }
  18016. if len(insutypes) == 0 {
  18017. insutype = "310"
  18018. }
  18019. service.CreateHisPsn(psn)
  18020. c.ServeSuccessJSON(map[string]interface{}{
  18021. "patient": patient,
  18022. "number": token,
  18023. "insutype": insutype,
  18024. })
  18025. }
  18026. } else {
  18027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18028. return
  18029. }
  18030. } else { //读卡失败
  18031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18032. return
  18033. }
  18034. }
  18035. break
  18036. }
  18037. }
  18038. var initFlag int64 = 0
  18039. var initEleFlag int64 = 0
  18040. func (c *HisApiController) TestGetBasBaseInit() {
  18041. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18042. Iinit := DllDef.MustFindProc("Init")
  18043. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18044. url := ""
  18045. if miConfig.InsuplcAdmdvs[:4] == "4403" {
  18046. url = "http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"
  18047. } else if miConfig.InsuplcAdmdvs[:4] == "4401" {
  18048. url = ""
  18049. } else {
  18050. url = "http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"
  18051. }
  18052. fmt.Println("SSCard的报错原因:", url)
  18053. fmt.Println("SSCard的报错原因:", miConfig.InsuplcAdmdvs)
  18054. ret, _, err := Iinit.Call(StrPtr(url), StrPtr(miConfig.InsuplcAdmdvs))
  18055. if ret != 0 {
  18056. fmt.Println("SSCard的报错原因:", err)
  18057. fmt.Println("SSCard的运算结果为:", ret)
  18058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18059. return
  18060. }
  18061. result := int(ret)
  18062. fmt.Println("SSCard的运算结果为1:", result)
  18063. initFlag = 1
  18064. return
  18065. }
  18066. func (c *HisApiController) HandleJiangXiReadCard() {
  18067. fmt.Println("~~~~~~")
  18068. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18069. admin_user_id, _ := c.GetInt64("admin_user_id")
  18070. id_card_type, _ := c.GetInt64("id_card_type")
  18071. //certificates, _ := c.GetInt64("certificates")
  18072. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18073. if initFlag == 0 {
  18074. c.TestGetJiangXiBasBaseInit()
  18075. }
  18076. basStr := c.GetBasBaseInfo()
  18077. if len(basStr) == 0 {
  18078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18079. return
  18080. }
  18081. fmt.Println(basStr)
  18082. bas := strings.Split(basStr, "|")
  18083. basNumber := bas[1]
  18084. fmt.Println(basNumber)
  18085. card_sn := bas[3]
  18086. fmt.Println(card_sn)
  18087. 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, "")
  18088. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  18089. var dat map[string]interface{}
  18090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18091. fmt.Println(dat)
  18092. } else {
  18093. fmt.Println(err)
  18094. }
  18095. userJSONBytes, _ := json.Marshal(dat)
  18096. var res ResultTwo
  18097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18098. utils.ErrorLog("解析失败:%v", err)
  18099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18100. return
  18101. }
  18102. if res.Infcode == 0 {
  18103. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  18104. if err == gorm.ErrRecordNotFound {
  18105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18106. return
  18107. } else if err != nil {
  18108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18109. return
  18110. } else {
  18111. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18112. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18113. infoStr := string(Iinfos)
  18114. idetinfoStr := string(Idetinfos)
  18115. psn := &models.HisPsn{
  18116. PsnNo: res.Output.Baseinfo.PsnNo,
  18117. PatientId: patient.ID,
  18118. Certno: res.Output.Baseinfo.Certno,
  18119. Gend: res.Output.Baseinfo.Gend,
  18120. Naty: res.Output.Baseinfo.Naty,
  18121. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18122. PsnName: res.Output.Baseinfo.PsnName,
  18123. Idetinfo: idetinfoStr,
  18124. Insuinfo: infoStr,
  18125. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18126. CardInfo: basStr,
  18127. VerifyNumber: "",
  18128. }
  18129. service.CreateHisPsn(psn)
  18130. c.ServeSuccessJSON(map[string]interface{}{
  18131. "patient": patient,
  18132. "number": basNumber,
  18133. })
  18134. }
  18135. } else {
  18136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18137. return
  18138. }
  18139. }
  18140. func (c *HisApiController) TestGetHnBasBaseInit() {
  18141. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18142. Iinit := DllDef.MustFindProc("Init")
  18143. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18144. //http://10.77.211.236/CSB/hsa-fsi-1303
  18145. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  18146. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  18147. // 调用 Init 函数
  18148. 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"))))
  18149. //if ret != 0 {
  18150. fmt.Println("SSCard的报错原因:", err)
  18151. fmt.Println("SSCard的运算结果为:", ret)
  18152. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18153. // return
  18154. //}
  18155. result := int(ret)
  18156. fmt.Println("SSCard的运算结果为1:", result)
  18157. initFlag = 1
  18158. return
  18159. }
  18160. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  18161. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18162. Iinit := DllDef.MustFindProc("Init")
  18163. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18164. //http://10.77.211.236/CSB/hsa-fsi-1303
  18165. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  18166. if ret != 0 {
  18167. fmt.Println("SSCard的报错原因:", err)
  18168. fmt.Println("SSCard的运算结果为:", ret)
  18169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18170. return
  18171. }
  18172. result := int(ret)
  18173. fmt.Println("SSCard的运算结果为1:", result)
  18174. initFlag = 1
  18175. return
  18176. }
  18177. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  18178. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18179. Iinit := DllDef.MustFindProc("Init")
  18180. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18181. //http://10.77.211.236/CSB/hsa-fsi-1303
  18182. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  18183. if ret != 0 {
  18184. fmt.Println("SSCard的报错原因:", err)
  18185. fmt.Println("SSCard的运算结果为:", ret)
  18186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18187. return
  18188. }
  18189. result := int(ret)
  18190. fmt.Println("SSCard的运算结果为1:", result)
  18191. initFlag = 1
  18192. return
  18193. }
  18194. func (c *HisApiController) GetSFZBaseInfo() string {
  18195. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18196. readCard := DllDef.MustFindProc("ReadSFZ")
  18197. if readCard == nil {
  18198. fmt.Println("readcard is nil")
  18199. readCard = DllDef.MustFindProc("ReadSFZ")
  18200. }
  18201. str := make([]byte, 8096)
  18202. str1 := make([]byte, 8096)
  18203. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  18204. fmt.Println(r)
  18205. return Remove0000(string(str))
  18206. }
  18207. func (c *HisApiController) GetEleBaseInfo() string {
  18208. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18209. readCard := DllDef.MustFindProc("GetQRBase")
  18210. fmt.Println(readCard)
  18211. if readCard == nil {
  18212. fmt.Println("readcard is nil")
  18213. readCard = DllDef.MustFindProc("GetQRBase")
  18214. }
  18215. str := make([]byte, 1024)
  18216. str1 := make([]byte, 1024)
  18217. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18218. fmt.Println(ret2)
  18219. fmt.Println(string(str1))
  18220. fmt.Println(string(str))
  18221. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18222. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18223. if ret2 != 0 {
  18224. return ""
  18225. }
  18226. return string(str)
  18227. }
  18228. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18229. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18230. readCard := DllDef.MustFindProc("NationEcTrans")
  18231. fmt.Println(readCard)
  18232. fmt.Println("!!!!!")
  18233. pBusiCardInfo := make([]byte, 2048)
  18234. input := make(map[string]interface{})
  18235. inputData := make(map[string]interface{})
  18236. inputData["orgId"] = code
  18237. inputData["businessType"] = "01101"
  18238. inputData["operatorId"] = "1"
  18239. inputData["operatorName"] = "admin"
  18240. inputData["officeId"] = "001"
  18241. inputData["officeName"] = "血透室"
  18242. inputData["deviceType"] = ""
  18243. input["data"] = inputData
  18244. input["orgId"] = code
  18245. input["transType"] = "ec.query"
  18246. bytesData, _ := json.Marshal(input)
  18247. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18248. fmt.Println(ret2)
  18249. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18250. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18251. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  18252. }
  18253. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18254. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18255. readCard := DllDef.MustFindProc("NationEcTrans")
  18256. fmt.Println(readCard)
  18257. fmt.Println("!!!!!")
  18258. pBusiCardInfo := make([]byte, 2048)
  18259. input := make(map[string]interface{})
  18260. inputData := make(map[string]interface{})
  18261. inputData["orgId"] = code
  18262. inputData["businessType"] = "01101"
  18263. inputData["operatorId"] = "9"
  18264. inputData["operatorName"] = "admin"
  18265. inputData["officeId"] = "001"
  18266. inputData["officeName"] = "血透室"
  18267. inputData["deviceType"] = ""
  18268. input["data"] = inputData
  18269. input["orgId"] = code
  18270. input["transType"] = "ec.query"
  18271. bytesData, _ := json.Marshal(input)
  18272. 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])))
  18273. fmt.Println(ret2)
  18274. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18275. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18276. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18277. }
  18278. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  18279. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18280. readCard := DllDef.MustFindProc("NationEcTrans")
  18281. fmt.Println(readCard)
  18282. fmt.Println("!!!!!")
  18283. pBusiCardInfo := make([]byte, 2048)
  18284. input := make(map[string]interface{})
  18285. inputData := make(map[string]interface{})
  18286. inputData["orgId"] = code
  18287. inputData["businessType"] = "01301"
  18288. inputData["operatorId"] = "9"
  18289. inputData["operatorName"] = "admin"
  18290. inputData["officeId"] = "001"
  18291. inputData["officeName"] = "血透室"
  18292. inputData["deviceType"] = ""
  18293. input["data"] = inputData
  18294. input["orgId"] = code
  18295. input["transType"] = "ec.query"
  18296. bytesData, _ := json.Marshal(input)
  18297. 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])))
  18298. fmt.Println(ret2)
  18299. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18300. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18301. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18302. }
  18303. func GetJxEleBaseInfo(org_id int64) string {
  18304. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18305. readCard := DllDef.MustFindProc("NationEcTrans")
  18306. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18307. if readCard == nil {
  18308. fmt.Println("readcard is nil")
  18309. readCard = DllDef.MustFindProc("NationEcTrans")
  18310. }
  18311. str1 := make([]byte, 1024)
  18312. data := make(map[string]interface{})
  18313. inputData := make(map[string]interface{})
  18314. inputData["orgId"] = miConfig.Code
  18315. inputData["businessType"] = "01101"
  18316. inputData["operatorId"] = "test001"
  18317. inputData["operatorName"] = "cn"
  18318. inputData["officeId"] = "32760"
  18319. inputData["officeName"] = "waike"
  18320. inputData["deviceType"] = ""
  18321. data["data"] = inputData
  18322. data["transType"] = "ec.query"
  18323. data["extra "] = ""
  18324. data["orgId"] = miConfig.Code
  18325. bytesData, _ := json.Marshal(data)
  18326. //bytesData, _ := json.Marshal(data)
  18327. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18328. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18329. fmt.Println(ret2)
  18330. fmt.Println(string(str1))
  18331. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18332. if ret2 != 0 {
  18333. return ""
  18334. }
  18335. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18336. }
  18337. //func GetJxEleBaseInfoTWO(org_id int64) string {
  18338. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  18339. // readCard := DllDef.MustFindProc("NationEcTrans")
  18340. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18341. //
  18342. // if readCard == nil {
  18343. // fmt.Println("readcard is nil")
  18344. // readCard = DllDef.MustFindProc("NationEcTrans")
  18345. // }
  18346. // str1 := make([]byte, 1024)
  18347. //
  18348. // data := make(map[string]interface{})
  18349. //
  18350. // inputData := make(map[string]interface{})
  18351. // inputData["orgId"] = miConfig.Code
  18352. // inputData["businessType"] = "01101"
  18353. // inputData["operatorId"] = "test001"
  18354. // inputData["operatorName"] = "cn"
  18355. // inputData["officeId"] = "32760"
  18356. // inputData["officeName"] = "waike"
  18357. // inputData["deviceType"] = ""
  18358. //
  18359. // data["data"] = inputData
  18360. // data["transType"] = "ec.query"
  18361. // data["extra "] = ""
  18362. // data["orgId"] = miConfig.Code
  18363. // bytesData, _ := json.Marshal(data)
  18364. // //bytesData, _ := json.Marshal(data)
  18365. //
  18366. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18367. //
  18368. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18369. // fmt.Println(ret2)
  18370. // fmt.Println(string(str1))
  18371. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18372. //
  18373. // if ret2 != 0 {
  18374. // return ""
  18375. // }
  18376. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18377. //}
  18378. func GetJxEleBaseInitInfo(org_id int64) string {
  18379. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18380. readCard := DllDef.MustFindProc("NationEcTrans")
  18381. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18382. if readCard == nil {
  18383. fmt.Println("readcard is nil")
  18384. readCard = DllDef.MustFindProc("NationEcTrans")
  18385. }
  18386. str1 := make([]byte, 2048)
  18387. data := make(map[string]interface{})
  18388. inputData := make(map[string]interface{})
  18389. inputData["orgId"] = miConfig.Code
  18390. inputData["businessType"] = "01101"
  18391. inputData["operatorId"] = "1"
  18392. inputData["operatorName"] = "huangchuang"
  18393. inputData["officeId"] = "101"
  18394. inputData["officeName"] = "xuetou"
  18395. inputData["deviceType"] = ""
  18396. data["data"] = inputData
  18397. data["transType"] = "ec.query"
  18398. data["orgId"] = miConfig.Code
  18399. bytesData, _ := json.Marshal(data)
  18400. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18401. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18402. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  18403. fmt.Println(ret2)
  18404. fmt.Println(string(str1))
  18405. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18406. if ret2 != 0 {
  18407. return ""
  18408. }
  18409. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  18410. initEleFlag = 1
  18411. }
  18412. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18413. }
  18414. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  18415. // // 构建命令
  18416. // cmd := exec.Command("python", "b.py")
  18417. //
  18418. // // 执行命令并等待完成
  18419. // output, err := cmd.CombinedOutput()
  18420. // if err != nil {
  18421. // fmt.Println("Error executing Python script:", err)
  18422. // return
  18423. // }
  18424. //
  18425. // // 打印Python脚本的输出
  18426. // fmt.Println(string(output))
  18427. //}
  18428. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  18429. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  18430. readCard := DllDef.MustFindProc("gxyb_call")
  18431. if readCard == nil {
  18432. fmt.Println("readcard is nil")
  18433. readCard = DllDef.MustFindProc("gxyb_call")
  18434. }
  18435. str := make([]byte, 1024)
  18436. str1 := make([]byte, 1024)
  18437. //data := make(map[string]interface{})
  18438. currentTime := time.Now()
  18439. // 格式化时间为 "YYYYMMDDHH24MISS"
  18440. formattedTime := currentTime.Format("20060102150405")
  18441. inputData := make(map[string]interface{})
  18442. inputData2 := make(map[string]interface{})
  18443. inputData["transNo"] = "1401"
  18444. inputData["transType"] = "passwordCheck"
  18445. inputData["timestamp"] = formattedTime
  18446. inputData2["fixmedinsCode"] = code
  18447. inputData2["psnNo"] = ""
  18448. inputData["data"] = inputData2
  18449. jsonBytes, err := json.Marshal(inputData)
  18450. if err != nil {
  18451. fmt.Println("Error encoding map to JSON:", err)
  18452. }
  18453. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18454. fmt.Println(string(str1))
  18455. fmt.Println(string(str))
  18456. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18457. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18458. if ret2 != 0 {
  18459. return ""
  18460. }
  18461. return string(str)
  18462. }
  18463. func (c *HisApiController) GetoleInfo() Response {
  18464. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  18465. defer ole.CoUninitialize()
  18466. // Replace with the ProgID or CLSID of your COM object
  18467. progID := "YinHai.XJ.Actual.Interface.New"
  18468. // Create COM object
  18469. unknown, err := oleutil.CreateObject(progID)
  18470. if err != nil {
  18471. fmt.Println("Unable to create COM object:", err)
  18472. }
  18473. defer unknown.Release()
  18474. // Query for the IDispatch interface
  18475. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  18476. if err != nil {
  18477. fmt.Println("Unable to get IDispatch interface:", err)
  18478. }
  18479. defer dispatch.Release()
  18480. // Prepare parameters
  18481. transNo := "1401"
  18482. transType := "passwordCheck"
  18483. timestamp := time.Now().Unix()
  18484. fixmedinsCode := "H45072101171"
  18485. psnNo := ""
  18486. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  18487. result2 := ""
  18488. // Call COM object's method using the IDispatch interface
  18489. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  18490. fmt.Println(resulr)
  18491. fmt.Println(result2)
  18492. if err != nil {
  18493. fmt.Println("调用COM对象方法失败:", err)
  18494. }
  18495. var response Response
  18496. err2 := json.Unmarshal([]byte(result2), &response)
  18497. if err2 != nil {
  18498. fmt.Println("解析JSON失败:", err)
  18499. }
  18500. return response
  18501. }
  18502. func (c *HisApiController) GetBasBaseInfo() string {
  18503. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18504. readCard := DllDef.MustFindProc("ReadCardBas")
  18505. if readCard == nil {
  18506. fmt.Println("readcard is nil")
  18507. readCard = DllDef.MustFindProc("ReadCardBas")
  18508. }
  18509. str := make([]byte, 1024)
  18510. str1 := make([]byte, 1024)
  18511. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18512. fmt.Println(string(str1))
  18513. fmt.Println(string(str))
  18514. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18515. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18516. if ret2 != 0 {
  18517. return ""
  18518. }
  18519. return string(str)
  18520. }
  18521. type Program struct {
  18522. FunctionID string `xml:"function_id"`
  18523. CardInfo string `xml:"cardinfo"`
  18524. User string `xml:"user"`
  18525. }
  18526. func (c *HisApiController) GetBasBaseInfo1111() string {
  18527. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  18528. readCard := DllDef.MustFindProc("ReadSICardInfo")
  18529. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  18530. if readCard == nil {
  18531. fmt.Println("readcard is nil")
  18532. readCard = DllDef.MustFindProc("ReadSICardInfo")
  18533. }
  18534. if readCard2 == nil {
  18535. fmt.Println("readcard is nil")
  18536. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  18537. }
  18538. str := make([]byte, 1024)
  18539. str1 := make([]byte, 1024)
  18540. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18541. str3 := make([]byte, 1024)
  18542. str4 := make([]byte, 1024)
  18543. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  18544. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18545. //if err != nil {
  18546. // fmt.Println("Error opening file:", err)
  18547. //}
  18548. //defer file.Close()
  18549. //
  18550. //var lastProgram Program
  18551. //scanner := bufio.NewScanner(file)
  18552. //inProgram := false
  18553. //
  18554. //for scanner.Scan() {
  18555. // line := scanner.Text()
  18556. // if strings.Contains(line, "<program>") {
  18557. // inProgram = true
  18558. // programXML := "<program>"
  18559. // for scanner.Scan() {
  18560. // line = scanner.Text()
  18561. // programXML += line
  18562. // if strings.Contains(line, "</program>") {
  18563. // programXML += "</program>"
  18564. // break
  18565. // }
  18566. // }
  18567. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18568. // // 解析成功,更新最后的 Program
  18569. // }
  18570. // inProgram = false
  18571. // }
  18572. //}
  18573. //
  18574. // fmt.Println("Error reading file:", inProgram)
  18575. //
  18576. //if err := scanner.Err(); err != nil {
  18577. // fmt.Println("Error reading file:", err)
  18578. //}
  18579. // 输出最后一次的 Program
  18580. //fmt.Printf("最后一次的 <program>:\n")
  18581. //fmt.Printf("<program>\n")
  18582. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18583. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18584. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18585. //fmt.Printf("</program>\n")
  18586. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18587. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18588. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18589. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18590. return ConvertToString(string(str), "gbk", "utf-8")
  18591. }
  18592. func (c *HisApiController) GetBasBaseInfo22222() string {
  18593. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18594. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18595. if readCard == nil {
  18596. fmt.Println("readcard is nil")
  18597. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18598. }
  18599. str := make([]byte, 1024)
  18600. str1 := make([]byte, 1024)
  18601. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  18602. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18603. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18604. //if err != nil {
  18605. // fmt.Println("Error opening file:", err)
  18606. //}
  18607. //defer file.Close()
  18608. //
  18609. //var lastProgram Program
  18610. //scanner := bufio.NewScanner(file)
  18611. //inProgram := false
  18612. //
  18613. //for scanner.Scan() {
  18614. // line := scanner.Text()
  18615. // if strings.Contains(line, "<program>") {
  18616. // inProgram = true
  18617. // programXML := "<program>"
  18618. // for scanner.Scan() {
  18619. // line = scanner.Text()
  18620. // programXML += line
  18621. // if strings.Contains(line, "</program>") {
  18622. // programXML += "</program>"
  18623. // break
  18624. // }
  18625. // }
  18626. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18627. // // 解析成功,更新最后的 Program
  18628. // }
  18629. // inProgram = false
  18630. // }
  18631. //}
  18632. //
  18633. // fmt.Println("Error reading file:", inProgram)
  18634. //
  18635. //if err := scanner.Err(); err != nil {
  18636. // fmt.Println("Error reading file:", err)
  18637. //}
  18638. // 输出最后一次的 Program
  18639. //fmt.Printf("最后一次的 <program>:\n")
  18640. //fmt.Printf("<program>\n")
  18641. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18642. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18643. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18644. //fmt.Printf("</program>\n")
  18645. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18646. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18647. return ConvertToString(string(str1), "gbk", "utf-8")
  18648. }
  18649. func (c *HisApiController) GetahBasBaseInfo() string {
  18650. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18651. readCard := DllDef.MustFindProc("iReadCardBas")
  18652. if readCard == nil {
  18653. fmt.Println("readcard is nil")
  18654. readCard = DllDef.MustFindProc("iReadCardBas")
  18655. }
  18656. //str := make([]byte, 1024)
  18657. str1 := make([]byte, 1024)
  18658. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18659. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18660. //if err != nil {
  18661. // fmt.Println("Error opening file:", err)
  18662. //}
  18663. //defer file.Close()
  18664. //
  18665. //var lastProgram Program
  18666. //scanner := bufio.NewScanner(file)
  18667. //inProgram := false
  18668. //
  18669. //for scanner.Scan() {
  18670. // line := scanner.Text()
  18671. // if strings.Contains(line, "<program>") {
  18672. // inProgram = true
  18673. // programXML := "<program>"
  18674. // for scanner.Scan() {
  18675. // line = scanner.Text()
  18676. // programXML += line
  18677. // if strings.Contains(line, "</program>") {
  18678. // programXML += "</program>"
  18679. // break
  18680. // }
  18681. // }
  18682. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18683. // // 解析成功,更新最后的 Program
  18684. // }
  18685. // inProgram = false
  18686. // }
  18687. //}
  18688. //
  18689. // fmt.Println("Error reading file:", inProgram)
  18690. //
  18691. //if err := scanner.Err(); err != nil {
  18692. // fmt.Println("Error reading file:", err)
  18693. //}
  18694. // 输出最后一次的 Program
  18695. //fmt.Printf("最后一次的 <program>:\n")
  18696. //fmt.Printf("<program>\n")
  18697. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18698. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18699. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18700. //fmt.Printf("</program>\n")
  18701. fmt.Println(string(str1))
  18702. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18703. if ret2 != 0 {
  18704. return ""
  18705. }
  18706. return string(str1)
  18707. }
  18708. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18709. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18710. readCard := DllDef.MustFindProc("read_cardinfo")
  18711. if readCard == nil {
  18712. fmt.Println("readcard is nil")
  18713. readCard = DllDef.MustFindProc("read_cardinfo")
  18714. }
  18715. str := make([]byte, 1024) //卡号
  18716. str1 := make([]byte, 1024) //卡识别码
  18717. str2 := make([]byte, 1024) //身份证号
  18718. str3 := make([]byte, 1024) //姓名
  18719. str4 := make([]byte, 1024) //错误信息
  18720. 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])))
  18721. fmt.Println(string(str1))
  18722. fmt.Println(string(str))
  18723. fmt.Println(string(str2))
  18724. fmt.Println(string(str3))
  18725. fmt.Println(string(str4))
  18726. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18727. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18728. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18729. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18730. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18731. if ret2 != 0 {
  18732. return "", "", "", "", ""
  18733. }
  18734. return string(str), string(str1), string(str2), string(str3), string(str4)
  18735. }
  18736. type CustomFundPay struct {
  18737. FundPayType string `json:"fund_pay_type"`
  18738. FundPayamt float64 `json:"fund_payamt"`
  18739. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18740. }
  18741. //func (c *HisApiController) GetBatchSettleList() {
  18742. // start_time_str := c.GetString("start_time")
  18743. // //end_time_str := c.GetString("end_time")
  18744. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18745. //
  18746. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18747. //
  18748. // for _, item := range orders {
  18749. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18750. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18751. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18752. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18753. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18754. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18755. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18756. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18757. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18758. //
  18759. // if order.ID == 0 {
  18760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18761. // return
  18762. // }
  18763. //
  18764. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18765. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18766. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18767. // //fmt.Println(count)
  18768. // //var zero string
  18769. // //number := count + 1
  18770. // //if number >= 1000 {
  18771. // // zero = "0000" + strconv.FormatInt(number, 10)
  18772. // //} else if number >= 10000 {
  18773. // // zero = "000" + strconv.FormatInt(number, 10)
  18774. // //} else if number >= 100000 {
  18775. // // zero = "00" + strconv.FormatInt(number, 10)
  18776. // //} else if number >= 1000000 {
  18777. // // zero = "0" + strconv.FormatInt(number, 10)
  18778. // //} else {
  18779. // // zero = strconv.FormatInt(number, 10)
  18780. // //}
  18781. // //fmt.Println(zero)
  18782. //
  18783. // struct4101 := service.Struct4101{
  18784. // PsnNo: order.PsnNo,
  18785. // MdtrtId: order.MdtrtId,
  18786. // SetlId: order.SetlId,
  18787. // PsnName: order.PsnName,
  18788. // Gend: order.Gend,
  18789. // Brdy: his.Brdy,
  18790. // Age: his.Age,
  18791. // Naty: order.Naty,
  18792. // PatnCertType: "01",
  18793. // Certno: order.Certno,
  18794. // Prfs: "90",
  18795. // ConerName: roles[0].UserName,
  18796. // PatnRlts: "99",
  18797. // ConerAddr: miConfig.OrgName,
  18798. // ConerTel: admin.Mobile,
  18799. // HiType: order.Insutype,
  18800. // Insuplc: miConfig.InsuplcAdmdvs,
  18801. // MaindiagFlag: "1",
  18802. // BillCode: order.SetlId,
  18803. // BillNo: order.SetlId,
  18804. // BizSn: order.Number,
  18805. // PsnSelfPay: order.PsnPartAmt,
  18806. // PsnOwnPay: order.PsnPartAmt,
  18807. // AcctPay: order.AcctPay,
  18808. // PsnCashpay: order.PsnCashPay,
  18809. // HiPaymtd: "1",
  18810. // Hsorg: miConfig.InsuplcAdmdvs,
  18811. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18812. // MedinsFillPsn: curRoles.UserName,
  18813. // MedinsFillDept: miConfig.OrgName,
  18814. // IptMedType: "2",
  18815. // }
  18816. // struct4101.SetlBegnDate = order.SetlTime
  18817. // struct4101.SetlEndDate = order.SetlTime
  18818. // time_arr := strings.Split(order.SetlTime, " ")
  18819. // struct4101.AdmTime = time_arr[0]
  18820. // struct4101.AdmEndTime = time_arr[0]
  18821. //
  18822. // var rf []CustomFundPay
  18823. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18824. //
  18825. // var tempFunPays []service.CustomStruct
  18826. // for _, item := range rf {
  18827. // var tempFunPay service.CustomStruct
  18828. // tempFunPay.FundPayamt = item.FundPayamt
  18829. // tempFunPay.FundPayType = item.FundPayType
  18830. // tempFunPays = append(tempFunPays, tempFunPay)
  18831. // }
  18832. // struct4101.CustomStruct = tempFunPays
  18833. //
  18834. // var tempDiaginfos []service.DiaginfoStructTwo
  18835. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18836. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18837. //
  18838. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18839. // var config []*models.HisXtDiagnoseConfig
  18840. // for _, item := range diagnosis_ids {
  18841. // id, _ := strconv.ParseInt(item, 10, 64)
  18842. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18843. // config = append(config, &diagnosisConfig)
  18844. // }
  18845. //
  18846. // for index, item := range config {
  18847. // if index == 0 {
  18848. // var tempDiaginfo service.DiaginfoStructTwo
  18849. // tempDiaginfo.DiagCode = item.CountryCode
  18850. // tempDiaginfo.DiagName = item.CountryContentName
  18851. // tempDiaginfo.DiagType = "1"
  18852. // tempDiaginfo.MaindiagFlag = "1"
  18853. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18854. // } else {
  18855. // var tempDiaginfo service.DiaginfoStructTwo
  18856. // tempDiaginfo.DiagCode = item.CountryCode
  18857. // tempDiaginfo.DiagName = item.CountryContentName
  18858. // tempDiaginfo.DiagType = "1"
  18859. // tempDiaginfo.MaindiagFlag = "0"
  18860. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18861. // }
  18862. // }
  18863. // struct4101.Diseinfo = tempDiaginfos
  18864. //
  18865. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18866. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18867. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18868. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18869. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18870. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18871. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18872. //
  18873. // var iteminfo service.IteminfoStruct
  18874. //
  18875. // var bedCostTotal float64 = 0 //床位总费
  18876. // var bedCostSelfTotal float64 = 0 //床位自费
  18877. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18878. //
  18879. // var operationCostTotal float64 = 0 //手术费
  18880. // var operationCostSelfTotal float64 = 0 //手术费
  18881. // var operationCostPartSelfTotal float64 = 0 //手术费
  18882. //
  18883. // var otherCostTotal float64 = 0 //其他费用
  18884. // var otherCostSelfTotal float64 = 0 //其他费用
  18885. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18886. //
  18887. // var materialCostTotal float64 = 0 //材料费
  18888. // var materialCostSelfTotal float64 = 0 //材料费
  18889. // var materialCostPartSelfTotal float64 = 0 //材料费
  18890. //
  18891. // var westernMedicineCostTotal float64 = 0 //西药费
  18892. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18893. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18894. //
  18895. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18896. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18897. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18898. //
  18899. // var checkCostTotal float64 = 0 //检查费
  18900. // var checkCostSelfTotal float64 = 0 //检查费
  18901. // var checkCostPartSelfTotal float64 = 0 //检查费
  18902. //
  18903. // var laboratoryCostTotal float64 = 0 //化验费
  18904. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18905. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18906. //
  18907. // var treatCostTotal float64 = 0 //治疗费用
  18908. // var treatCostSelfTotal float64 = 0 //治疗费用
  18909. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18910. //
  18911. // decimal.DivisionPrecision = 2
  18912. //
  18913. // var bed_fulamt_ownpay_amt float64 = 0
  18914. // var operation_fulamt_ownpay_amt float64 = 0
  18915. // var other_fulamt_ownpay_amt float64 = 0
  18916. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18917. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18918. // var check_fulamt_ownpay_amt float64 = 0
  18919. // var material_fulamt_ownpay_amt float64 = 0
  18920. // var laboratory_fulamt_ownpay_amt float64 = 0
  18921. // var treat_fulamt_ownpay_amt float64 = 0
  18922. //
  18923. // var bed_claa_sunmfee float64 = 0
  18924. // var bed_clab_amt float64 = 0
  18925. // var bed_other_amt float64 = 0
  18926. //
  18927. // var operation_claa_sunmfee float64 = 0
  18928. // var operation_clab_amt float64 = 0
  18929. // var operation_other_amt float64 = 0
  18930. //
  18931. // var other_claa_sunmfee float64 = 0
  18932. // var other_clab_amt float64 = 0
  18933. // var other_other_amt float64 = 0
  18934. //
  18935. // var westernMedicine_claa_sunmfee float64 = 0
  18936. // var westernMedicine_clab_amt float64 = 0
  18937. // var westernMedicine_other_amt float64 = 0
  18938. //
  18939. // var chineseTraditional_claa_sunmfee float64 = 0
  18940. // var chineseTraditional_clab_amt float64 = 0
  18941. // var chineseTraditional_other_amt float64 = 0
  18942. //
  18943. // var check_claa_sunmfee float64 = 0
  18944. // var check_clab_amt float64 = 0
  18945. // var check_other_amt float64 = 0
  18946. //
  18947. // var material_claa_sunmfee float64 = 0
  18948. // var material_clab_amt float64 = 0
  18949. // var material_other_amt float64 = 0
  18950. //
  18951. // var laboratory_claa_sunmfee float64 = 0
  18952. // var laboratory_clab_amt float64 = 0
  18953. // var laboratory_other_amt float64 = 0
  18954. //
  18955. // var treat_claa_sunmfee float64 = 0
  18956. // var treat_clab_amt float64 = 0
  18957. // var treat_other_amt float64 = 0
  18958. //
  18959. // for _, item := range order.HisOrderInfo {
  18960. // if item.MedChrgitmType == "01" { //床位费
  18961. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18962. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18963. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18964. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18965. // if item.ChrgitmLv == "1" {
  18966. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18967. // }
  18968. // if item.ChrgitmLv == "2" {
  18969. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18970. //
  18971. // }
  18972. // if item.ChrgitmLv == "3" {
  18973. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18974. // }
  18975. //
  18976. // }
  18977. //
  18978. // if item.MedChrgitmType == "03" { //检查费
  18979. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18980. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18981. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18982. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18983. // if item.ChrgitmLv == "1" {
  18984. //
  18985. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18986. //
  18987. // }
  18988. // if item.ChrgitmLv == "2" {
  18989. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18990. //
  18991. // }
  18992. // if item.ChrgitmLv == "3" {
  18993. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18994. // }
  18995. // }
  18996. //
  18997. // if item.MedChrgitmType == "04" { //化验费
  18998. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18999. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19000. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19001. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19002. // if item.ChrgitmLv == "1" {
  19003. //
  19004. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19005. //
  19006. // }
  19007. // if item.ChrgitmLv == "2" {
  19008. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19009. //
  19010. // }
  19011. // if item.ChrgitmLv == "3" {
  19012. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19013. // }
  19014. // }
  19015. //
  19016. // if item.MedChrgitmType == "05" { //治疗费
  19017. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19018. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19019. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19020. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19021. // if item.ChrgitmLv == "1" {
  19022. //
  19023. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19024. //
  19025. // }
  19026. // if item.ChrgitmLv == "2" {
  19027. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19028. //
  19029. // }
  19030. // if item.ChrgitmLv == "3" {
  19031. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19032. // }
  19033. // }
  19034. //
  19035. // if item.MedChrgitmType == "06" { //手术费
  19036. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19037. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19038. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19039. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19040. //
  19041. // if item.ChrgitmLv == "1" {
  19042. //
  19043. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19044. //
  19045. // }
  19046. // if item.ChrgitmLv == "2" {
  19047. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19048. //
  19049. // }
  19050. // if item.ChrgitmLv == "3" {
  19051. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19052. // }
  19053. // }
  19054. //
  19055. // if item.MedChrgitmType == "08" { //材料费
  19056. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19057. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19058. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19059. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19060. // if item.ChrgitmLv == "1" {
  19061. //
  19062. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19063. //
  19064. // }
  19065. // if item.ChrgitmLv == "2" {
  19066. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19067. //
  19068. // }
  19069. // if item.ChrgitmLv == "3" {
  19070. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19071. // }
  19072. // }
  19073. //
  19074. // if item.MedChrgitmType == "09" { //西药费
  19075. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19076. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19077. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19078. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19079. // if item.ChrgitmLv == "1" {
  19080. //
  19081. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19082. //
  19083. // }
  19084. // if item.ChrgitmLv == "2" {
  19085. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19086. //
  19087. // }
  19088. // if item.ChrgitmLv == "3" {
  19089. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19090. // }
  19091. // }
  19092. //
  19093. // if item.MedChrgitmType == "11" { //中成费
  19094. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19095. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19096. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19097. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19098. // if item.ChrgitmLv == "1" {
  19099. //
  19100. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19101. //
  19102. // }
  19103. // if item.ChrgitmLv == "2" {
  19104. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19105. //
  19106. // }
  19107. // if item.ChrgitmLv == "3" {
  19108. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19109. // }
  19110. // }
  19111. //
  19112. // if item.MedChrgitmType == "14" { //其他费
  19113. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19114. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19115. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19116. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19117. // if item.ChrgitmLv == "1" {
  19118. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19119. //
  19120. // }
  19121. // if item.ChrgitmLv == "2" {
  19122. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19123. //
  19124. // }
  19125. // if item.ChrgitmLv == "3" {
  19126. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19127. // }
  19128. // }
  19129. //
  19130. // }
  19131. //
  19132. // var iteminfoStructs []service.IteminfoStruct
  19133. //
  19134. // if bedCostTotal != 0 {
  19135. // iteminfo.MedChrgitm = "01"
  19136. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19137. // iteminfo.Amt = bedCostTotal
  19138. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19139. // iteminfo.ClabAmt = bed_clab_amt
  19140. // iteminfo.OthAmt = bed_other_amt
  19141. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19142. // }
  19143. //
  19144. // if checkCostTotal != 0 {
  19145. // iteminfo.MedChrgitm = "03"
  19146. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19147. // iteminfo.Amt = checkCostTotal
  19148. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19149. // iteminfo.ClabAmt = check_clab_amt
  19150. // iteminfo.OthAmt = check_other_amt
  19151. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19152. //
  19153. // }
  19154. //
  19155. // if laboratoryCostTotal != 0 {
  19156. // iteminfo.MedChrgitm = "04"
  19157. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19158. // iteminfo.Amt = laboratoryCostTotal
  19159. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19160. // iteminfo.ClabAmt = laboratory_clab_amt
  19161. // iteminfo.OthAmt = laboratory_other_amt
  19162. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19163. //
  19164. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19165. //
  19166. // }
  19167. //
  19168. // if treatCostTotal != 0 {
  19169. // iteminfo.MedChrgitm = "05"
  19170. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19171. // iteminfo.Amt = treatCostTotal
  19172. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19173. // iteminfo.ClabAmt = treat_clab_amt
  19174. // iteminfo.OthAmt = treat_other_amt
  19175. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19176. // //(struct4101.IteminfoStruct, iteminfo)
  19177. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19178. // }
  19179. //
  19180. // if operationCostTotal != 0 {
  19181. // iteminfo.MedChrgitm = "06"
  19182. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19183. // iteminfo.Amt = operationCostTotal
  19184. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19185. // iteminfo.ClabAmt = operation_clab_amt
  19186. // iteminfo.OthAmt = operation_other_amt
  19187. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19188. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19189. // }
  19190. //
  19191. // if materialCostTotal != 0 {
  19192. // iteminfo.MedChrgitm = "08"
  19193. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19194. // iteminfo.Amt = materialCostTotal
  19195. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19196. // iteminfo.ClabAmt = material_clab_amt
  19197. // iteminfo.OthAmt = material_other_amt
  19198. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19199. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19200. // }
  19201. //
  19202. // if westernMedicineCostTotal != 0 {
  19203. // iteminfo.MedChrgitm = "09"
  19204. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19205. // iteminfo.Amt = westernMedicineCostTotal
  19206. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19207. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19208. // iteminfo.OthAmt = westernMedicine_other_amt
  19209. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19210. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19211. //
  19212. // }
  19213. // if chineseTraditionalMedicineCostTotal != 0 {
  19214. // iteminfo.MedChrgitm = "11"
  19215. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19216. // iteminfo.Amt = westernMedicineCostTotal
  19217. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19218. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19219. // iteminfo.OthAmt = westernMedicine_other_amt
  19220. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19221. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19222. //
  19223. // }
  19224. // if otherCostTotal != 0 {
  19225. // iteminfo.MedChrgitm = "14"
  19226. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19227. // iteminfo.Amt = otherCostTotal
  19228. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19229. // iteminfo.ClabAmt = other_clab_amt
  19230. // iteminfo.OthAmt = other_other_amt
  19231. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19232. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19233. //
  19234. // }
  19235. // struct4101.IteminfoStruct = iteminfoStructs
  19236. // struct4101.Ntly = "中国"
  19237. // struct4101.AdmCaty = "A03.06"
  19238. //
  19239. // struct4101.DoctorName = doctor.UserName
  19240. // struct4101.DoctorCode = doctor.DoctorNumber
  19241. //
  19242. // var res ResultSeventeen
  19243. //
  19244. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19245. // struct4101.BillCode = order.Number
  19246. // struct4101.BillNo = order.SetlId
  19247. // var resOther ResultSeventeenOther
  19248. // var pp models.PublicParams
  19249. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19250. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19251. // pp.FixmedinsName = miConfig.OrgName
  19252. // pp.FixmedinsCode = miConfig.Code
  19253. // pp.RequestUrl = miConfig.Url
  19254. // pp.Cainfo = miConfig.Cainfo
  19255. // pp.SecretKey = miConfig.SecretKey
  19256. // pp.AccessKey = miConfig.AccessKey
  19257. // pp.OpterName = curRoles.UserName
  19258. //
  19259. // client := &http.Client{}
  19260. // var req *http.Request
  19261. // data := make(map[string]interface{})
  19262. // data["struct4101"] = struct4101
  19263. // data["pp"] = pp
  19264. // bytesData, _ := json.Marshal(data)
  19265. // if miConfig.MdtrtareaAdmvs == "320921" {
  19266. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19267. // } else {
  19268. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19269. // }
  19270. // resp, _ := client.Do(req)
  19271. // defer resp.Body.Close()
  19272. // body, ioErr := ioutil.ReadAll(resp.Body)
  19273. // if ioErr != nil {
  19274. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19275. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19276. // return
  19277. // }
  19278. // var respJSON map[string]interface{}
  19279. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19280. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19282. // return
  19283. // }
  19284. //
  19285. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19286. // userJSONBytes, _ := json.Marshal(respJSON)
  19287. // fmt.Println("log")
  19288. // fmt.Println(string(userJSONBytes))
  19289. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19290. // utils.ErrorLog("解析失败:%v", err)
  19291. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19292. // return
  19293. // }
  19294. // res.InfRefmsgid = resOther.InfRefmsgid
  19295. // res.Output = resOther.Output
  19296. // res.ErrMsg = resOther.ErrMsg
  19297. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19298. // res.Infcode = infocode
  19299. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  19300. //
  19301. // var pp models.PublicParams
  19302. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19303. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19304. // pp.FixmedinsName = miConfig.OrgName
  19305. // pp.FixmedinsCode = miConfig.Code
  19306. // pp.RequestUrl = miConfig.Url
  19307. // pp.Cainfo = miConfig.Cainfo
  19308. // pp.SecretKey = miConfig.SecretKey
  19309. // pp.AccessKey = miConfig.AccessKey
  19310. // pp.OpterName = curRoles.UserName
  19311. // result, _ := service.Jxyb4101(struct4101, pp)
  19312. // var dat map[string]interface{}
  19313. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19314. // fmt.Println(dat)
  19315. // } else {
  19316. // fmt.Println(err)
  19317. // }
  19318. // userJSONBytes, _ := json.Marshal(dat)
  19319. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19320. // utils.ErrorLog("解析失败:%v", err)
  19321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19322. // return
  19323. // }
  19324. //
  19325. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  19326. // var pp models.PublicParams
  19327. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19328. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19329. // pp.FixmedinsName = miConfig.OrgName
  19330. // pp.FixmedinsCode = miConfig.Code
  19331. // pp.RequestUrl = miConfig.Url
  19332. // pp.Cainfo = miConfig.Cainfo
  19333. // pp.SecretKey = miConfig.SecretKey
  19334. // pp.AccessKey = miConfig.AccessKey
  19335. // pp.OpterName = curRoles.UserName
  19336. // result, _ := service.Hnyb4101(struct4101, pp)
  19337. // var dat map[string]interface{}
  19338. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19339. // fmt.Println(dat)
  19340. // } else {
  19341. // fmt.Println(err)
  19342. // }
  19343. // userJSONBytes, _ := json.Marshal(dat)
  19344. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19345. // utils.ErrorLog("解析失败:%v", err)
  19346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19347. // return
  19348. // }
  19349. //
  19350. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  19351. // var resOther ResultSeventeenOther
  19352. //
  19353. // var pp models.PublicParams
  19354. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19355. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19356. // pp.FixmedinsName = miConfig.OrgName
  19357. // pp.FixmedinsCode = miConfig.Code
  19358. // pp.RequestUrl = miConfig.Url
  19359. // pp.Cainfo = miConfig.Cainfo
  19360. // pp.SecretKey = miConfig.SecretKey
  19361. // pp.AccessKey = miConfig.AccessKey
  19362. // pp.OpterName = curRoles.UserName
  19363. // client := &http.Client{}
  19364. // var req *http.Request
  19365. // data := make(map[string]interface{})
  19366. // data["struct4101"] = struct4101
  19367. // data["pp"] = pp
  19368. // bytesData, _ := json.Marshal(data)
  19369. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19370. // resp, _ := client.Do(req)
  19371. // defer resp.Body.Close()
  19372. // body, ioErr := ioutil.ReadAll(resp.Body)
  19373. // if ioErr != nil {
  19374. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19375. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19376. // return
  19377. // }
  19378. // var respJSON map[string]interface{}
  19379. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19380. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19382. // return
  19383. // }
  19384. //
  19385. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19386. // userJSONBytes, _ := json.Marshal(respJSON)
  19387. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19388. // utils.ErrorLog("解析失败:%v", err)
  19389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19390. // return
  19391. // }
  19392. // res.InfRefmsgid = resOther.InfRefmsgid
  19393. // res.Output = resOther.Output
  19394. // res.ErrMsg = resOther.ErrMsg
  19395. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19396. // res.Infcode = infocode
  19397. //
  19398. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  19399. // var pp models.PublicParams
  19400. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19401. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19402. // pp.FixmedinsName = miConfig.OrgName
  19403. // pp.FixmedinsCode = miConfig.Code
  19404. // pp.RequestUrl = miConfig.Url
  19405. // pp.Cainfo = miConfig.Cainfo
  19406. // pp.SecretKey = miConfig.SecretKey
  19407. // pp.AccessKey = miConfig.AccessKey
  19408. // pp.OpterName = curRoles.UserName
  19409. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19410. // fmt.Println(requestLog)
  19411. // fmt.Println(errMsgLog)
  19412. //
  19413. // saveLog(result, requestLog, "4101a", "上传清单")
  19414. //
  19415. // var dat map[string]interface{}
  19416. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19417. // fmt.Println(dat)
  19418. // } else {
  19419. // fmt.Println(err)
  19420. // }
  19421. // userJSONBytes, _ := json.Marshal(dat)
  19422. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19423. // utils.ErrorLog("解析失败:%v", err)
  19424. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19425. // return
  19426. // }
  19427. //
  19428. // } else {
  19429. //
  19430. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  19431. // var dat map[string]interface{}
  19432. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19433. // fmt.Println(dat)
  19434. // } else {
  19435. // fmt.Println(err)
  19436. // }
  19437. // userJSONBytes, _ := json.Marshal(dat)
  19438. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19439. // utils.ErrorLog("解析失败:%v", err)
  19440. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19441. // return
  19442. // }
  19443. // }
  19444. //
  19445. // if res.Infcode != 0 {
  19446. // adminUser := c.GetAdminUserInfo()
  19447. // errlog := &models.HisOrderError{
  19448. // UserOrgId: adminUser.CurrentOrgId,
  19449. // Ctime: time.Now().Unix(),
  19450. // Mtime: time.Now().Unix(),
  19451. // ErrMsg: res.ErrMsg,
  19452. // Status: 1,
  19453. // PatientId: order.ID,
  19454. // Stage: 10265,
  19455. // }
  19456. // service.CreateErrMsgLog(errlog)
  19457. // continue
  19458. // } else {
  19459. // //order.FaPiaoNumber = zero
  19460. // //order.FaPiaoCode = last_order.FaPiaoCode
  19461. // //service.UpdateOrder(order)
  19462. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19463. // Number: res.Output.SetlListId,
  19464. // Status: 1,
  19465. // Ctime: time.Now().Unix(),
  19466. // Mtime: time.Now().Unix(),
  19467. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19468. // IsUpload: 1,
  19469. // OrderId: order.ID,
  19470. // }
  19471. // service.CreateUploadRecord(hisFundSettleListResult)
  19472. // c.ServeSuccessJSON(map[string]interface{}{
  19473. // "msg": "上传成功",
  19474. // "result": hisFundSettleListResult,
  19475. // })
  19476. // continue
  19477. // }
  19478. // }
  19479. //}
  19480. func (c *HisApiController) GetbatchSettleList() {
  19481. //order_id, _ := c.GetInt64("order_id")
  19482. admin_user_id, _ := c.GetInt64("admin_user_id")
  19483. orders, _ := service.GetAllHisOrderTwo10485()
  19484. for _, item := range orders {
  19485. order, _ := service.GetHisOrderByIDTwo(item.ID)
  19486. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19487. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19488. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19489. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19490. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19491. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19492. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19493. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19494. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19495. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19496. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19497. //fmt.Println(count)
  19498. //var zero string
  19499. //number := count + 1
  19500. //if number >= 1000 {
  19501. // zero = "0000" + strconv.FormatInt(number, 10)
  19502. //} else if number >= 10000 {
  19503. // zero = "000" + strconv.FormatInt(number, 10)
  19504. //} else if number >= 100000 {
  19505. // zero = "00" + strconv.FormatInt(number, 10)
  19506. //} else if number >= 1000000 {
  19507. // zero = "0" + strconv.FormatInt(number, 10)
  19508. //} else {
  19509. // zero = strconv.FormatInt(number, 10)
  19510. //}
  19511. //fmt.Println(zero)
  19512. struct4101 := service.Struct4101{
  19513. PsnNo: order.PsnNo,
  19514. MdtrtId: order.MdtrtId,
  19515. SetlId: order.SetlId,
  19516. PsnName: order.PsnName,
  19517. Gend: order.Gend,
  19518. Brdy: his.Brdy,
  19519. Age: his.Age,
  19520. Naty: order.Naty,
  19521. PatnCertType: "01",
  19522. Certno: order.Certno,
  19523. Prfs: "90",
  19524. ConerName: roles[0].UserName,
  19525. PatnRlts: "99",
  19526. ConerAddr: miConfig.OrgName,
  19527. ConerTel: admin.Mobile,
  19528. HiType: order.Insutype,
  19529. Insuplc: miConfig.InsuplcAdmdvs,
  19530. MaindiagFlag: "1",
  19531. BillCode: order.SetlId,
  19532. BillNo: order.SetlId,
  19533. BizSn: order.Number,
  19534. PsnSelfPay: order.PsnPartAmt,
  19535. PsnOwnPay: order.PsnPartAmt,
  19536. AcctPay: order.AcctPay,
  19537. PsnCashpay: order.PsnCashPay,
  19538. HiPaymtd: "1",
  19539. Hsorg: miConfig.InsuplcAdmdvs,
  19540. HsorgOpter: miConfig.InsuplcAdmdvs,
  19541. MedinsFillPsn: curRoles.UserName,
  19542. MedinsFillDept: miConfig.OrgName,
  19543. IptMedType: "2",
  19544. }
  19545. struct4101.SetlBegnDate = order.SetlTime
  19546. struct4101.SetlEndDate = order.SetlTime
  19547. time_arr := strings.Split(order.SetlTime, " ")
  19548. struct4101.AdmTime = time_arr[0]
  19549. struct4101.AdmEndTime = time_arr[0]
  19550. //var rf []CustomFundPay
  19551. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19552. //
  19553. //var tempFunPays []service.CustomStruct
  19554. //for _, item := range rf {
  19555. // var tempFunPay service.CustomStruct
  19556. // tempFunPay.FundPayamt = item.FundPayamt
  19557. // tempFunPay.FundPayType = item.FundPayType
  19558. // tempFunPays = append(tempFunPays, tempFunPay)
  19559. //}
  19560. //struct4101.CustomStruct = tempFunPays
  19561. var tempDiaginfos []service.DiaginfoStructTwo
  19562. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19563. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19564. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19565. var config []*models.HisXtDiagnoseConfig
  19566. for _, item := range diagnosis_ids {
  19567. id, _ := strconv.ParseInt(item, 10, 64)
  19568. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19569. config = append(config, &diagnosisConfig)
  19570. }
  19571. for index, item := range config {
  19572. if index == 0 {
  19573. var tempDiaginfo service.DiaginfoStructTwo
  19574. tempDiaginfo.DiagCode = item.CountryCode
  19575. tempDiaginfo.DiagName = item.CountryContentName
  19576. tempDiaginfo.DiagType = "1"
  19577. tempDiaginfo.MaindiagFlag = "1"
  19578. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19579. } else {
  19580. var tempDiaginfo service.DiaginfoStructTwo
  19581. tempDiaginfo.DiagCode = item.CountryCode
  19582. tempDiaginfo.DiagName = item.CountryContentName
  19583. tempDiaginfo.DiagType = "1"
  19584. tempDiaginfo.MaindiagFlag = "0"
  19585. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19586. }
  19587. }
  19588. struct4101.Diseinfo = tempDiaginfos
  19589. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19590. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19591. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19592. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19593. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19594. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19595. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19596. var iteminfo service.IteminfoStruct
  19597. var bedCostTotal float64 = 0 //床位总费
  19598. var bedCostSelfTotal float64 = 0 //床位自费
  19599. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19600. var operationCostTotal float64 = 0 //手术费
  19601. var operationCostSelfTotal float64 = 0 //手术费
  19602. var operationCostPartSelfTotal float64 = 0 //手术费
  19603. var otherCostTotal float64 = 0 //其他费用
  19604. var otherCostSelfTotal float64 = 0 //其他费用
  19605. var otherCostPartSelfTotal float64 = 0 //其他费用
  19606. var materialCostTotal float64 = 0 //材料费
  19607. var materialCostSelfTotal float64 = 0 //材料费
  19608. var materialCostPartSelfTotal float64 = 0 //材料费
  19609. var westernMedicineCostTotal float64 = 0 //西药费
  19610. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19611. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19612. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19613. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19614. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19615. var checkCostTotal float64 = 0 //检查费
  19616. var checkCostSelfTotal float64 = 0 //检查费
  19617. var checkCostPartSelfTotal float64 = 0 //检查费
  19618. var laboratoryCostTotal float64 = 0 //化验费
  19619. var laboratoryCostSelfTotal float64 = 0 //化验费
  19620. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19621. var treatCostTotal float64 = 0 //治疗费用
  19622. var treatCostSelfTotal float64 = 0 //治疗费用
  19623. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19624. decimal.DivisionPrecision = 2
  19625. var bed_fulamt_ownpay_amt float64 = 0
  19626. var operation_fulamt_ownpay_amt float64 = 0
  19627. var other_fulamt_ownpay_amt float64 = 0
  19628. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19629. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19630. var check_fulamt_ownpay_amt float64 = 0
  19631. var material_fulamt_ownpay_amt float64 = 0
  19632. var laboratory_fulamt_ownpay_amt float64 = 0
  19633. var treat_fulamt_ownpay_amt float64 = 0
  19634. var bed_claa_sunmfee float64 = 0
  19635. var bed_clab_amt float64 = 0
  19636. var bed_other_amt float64 = 0
  19637. var operation_claa_sunmfee float64 = 0
  19638. var operation_clab_amt float64 = 0
  19639. var operation_other_amt float64 = 0
  19640. var other_claa_sunmfee float64 = 0
  19641. var other_clab_amt float64 = 0
  19642. var other_other_amt float64 = 0
  19643. var westernMedicine_claa_sunmfee float64 = 0
  19644. var westernMedicine_clab_amt float64 = 0
  19645. var westernMedicine_other_amt float64 = 0
  19646. var chineseTraditional_claa_sunmfee float64 = 0
  19647. var chineseTraditional_clab_amt float64 = 0
  19648. var chineseTraditional_other_amt float64 = 0
  19649. var check_claa_sunmfee float64 = 0
  19650. var check_clab_amt float64 = 0
  19651. var check_other_amt float64 = 0
  19652. var material_claa_sunmfee float64 = 0
  19653. var material_clab_amt float64 = 0
  19654. var material_other_amt float64 = 0
  19655. var laboratory_claa_sunmfee float64 = 0
  19656. var laboratory_clab_amt float64 = 0
  19657. var laboratory_other_amt float64 = 0
  19658. var treat_claa_sunmfee float64 = 0
  19659. var treat_clab_amt float64 = 0
  19660. var treat_other_amt float64 = 0
  19661. for _, item := range order.HisOrderInfo {
  19662. if item.MedChrgitmType == "01" { //床位费
  19663. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19664. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19665. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19666. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19667. if item.ChrgitmLv == "1" {
  19668. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19669. }
  19670. if item.ChrgitmLv == "2" {
  19671. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19672. }
  19673. if item.ChrgitmLv == "3" {
  19674. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19675. }
  19676. }
  19677. if item.MedChrgitmType == "03" { //检查费
  19678. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19679. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19680. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19681. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19682. if item.ChrgitmLv == "1" {
  19683. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19684. }
  19685. if item.ChrgitmLv == "2" {
  19686. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19687. }
  19688. if item.ChrgitmLv == "3" {
  19689. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19690. }
  19691. }
  19692. if item.MedChrgitmType == "04" { //化验费
  19693. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19694. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19695. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19696. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19697. if item.ChrgitmLv == "1" {
  19698. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19699. }
  19700. if item.ChrgitmLv == "2" {
  19701. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19702. }
  19703. if item.ChrgitmLv == "3" {
  19704. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19705. }
  19706. }
  19707. if item.MedChrgitmType == "05" { //治疗费
  19708. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19709. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19710. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19711. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19712. if item.ChrgitmLv == "1" {
  19713. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19714. }
  19715. if item.ChrgitmLv == "2" {
  19716. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19717. }
  19718. if item.ChrgitmLv == "3" {
  19719. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19720. }
  19721. }
  19722. if item.MedChrgitmType == "06" { //手术费
  19723. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19724. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19725. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19726. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19727. if item.ChrgitmLv == "1" {
  19728. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19729. }
  19730. if item.ChrgitmLv == "2" {
  19731. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19732. }
  19733. if item.ChrgitmLv == "3" {
  19734. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19735. }
  19736. }
  19737. if item.MedChrgitmType == "08" { //材料费
  19738. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19739. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19740. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19741. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19742. if item.ChrgitmLv == "1" {
  19743. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19744. }
  19745. if item.ChrgitmLv == "2" {
  19746. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19747. }
  19748. if item.ChrgitmLv == "3" {
  19749. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19750. }
  19751. }
  19752. if item.MedChrgitmType == "09" { //西药费
  19753. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19754. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19755. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19756. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19757. if item.ChrgitmLv == "1" {
  19758. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19759. }
  19760. if item.ChrgitmLv == "2" {
  19761. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19762. }
  19763. if item.ChrgitmLv == "3" {
  19764. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19765. }
  19766. }
  19767. if item.MedChrgitmType == "11" { //中成费
  19768. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19769. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19770. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19771. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19772. if item.ChrgitmLv == "1" {
  19773. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19774. }
  19775. if item.ChrgitmLv == "2" {
  19776. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19777. }
  19778. if item.ChrgitmLv == "3" {
  19779. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19780. }
  19781. }
  19782. if item.MedChrgitmType == "14" { //其他费
  19783. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19784. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19785. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19786. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19787. if item.ChrgitmLv == "1" {
  19788. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19789. }
  19790. if item.ChrgitmLv == "2" {
  19791. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19792. }
  19793. if item.ChrgitmLv == "3" {
  19794. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19795. }
  19796. }
  19797. }
  19798. var iteminfoStructs []service.IteminfoStruct
  19799. if bedCostTotal != 0 {
  19800. iteminfo.MedChrgitm = "01"
  19801. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19802. iteminfo.Amt = bedCostTotal
  19803. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19804. iteminfo.ClabAmt = bed_clab_amt
  19805. iteminfo.OthAmt = bed_other_amt
  19806. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19807. }
  19808. if checkCostTotal != 0 {
  19809. iteminfo.MedChrgitm = "03"
  19810. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19811. iteminfo.Amt = checkCostTotal
  19812. iteminfo.ClaaSumfee = check_claa_sunmfee
  19813. iteminfo.ClabAmt = check_clab_amt
  19814. iteminfo.OthAmt = check_other_amt
  19815. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19816. }
  19817. if laboratoryCostTotal != 0 {
  19818. iteminfo.MedChrgitm = "04"
  19819. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19820. iteminfo.Amt = laboratoryCostTotal
  19821. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19822. iteminfo.ClabAmt = laboratory_clab_amt
  19823. iteminfo.OthAmt = laboratory_other_amt
  19824. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19825. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19826. }
  19827. if treatCostTotal != 0 {
  19828. iteminfo.MedChrgitm = "05"
  19829. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19830. iteminfo.Amt = treatCostTotal
  19831. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19832. iteminfo.ClabAmt = treat_clab_amt
  19833. iteminfo.OthAmt = treat_other_amt
  19834. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19835. //(struct4101.IteminfoStruct, iteminfo)
  19836. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19837. }
  19838. if operationCostTotal != 0 {
  19839. iteminfo.MedChrgitm = "06"
  19840. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19841. iteminfo.Amt = operationCostTotal
  19842. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19843. iteminfo.ClabAmt = operation_clab_amt
  19844. iteminfo.OthAmt = operation_other_amt
  19845. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19846. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19847. }
  19848. if materialCostTotal != 0 {
  19849. iteminfo.MedChrgitm = "08"
  19850. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19851. iteminfo.Amt = materialCostTotal
  19852. iteminfo.ClaaSumfee = material_claa_sunmfee
  19853. iteminfo.ClabAmt = material_clab_amt
  19854. iteminfo.OthAmt = material_other_amt
  19855. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19856. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19857. }
  19858. if westernMedicineCostTotal != 0 {
  19859. iteminfo.MedChrgitm = "09"
  19860. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19861. iteminfo.Amt = westernMedicineCostTotal
  19862. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19863. iteminfo.ClabAmt = westernMedicine_clab_amt
  19864. iteminfo.OthAmt = westernMedicine_other_amt
  19865. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19866. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19867. }
  19868. if chineseTraditionalMedicineCostTotal != 0 {
  19869. iteminfo.MedChrgitm = "11"
  19870. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19871. iteminfo.Amt = westernMedicineCostTotal
  19872. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19873. iteminfo.ClabAmt = westernMedicine_clab_amt
  19874. iteminfo.OthAmt = westernMedicine_other_amt
  19875. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19876. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19877. }
  19878. if otherCostTotal != 0 {
  19879. iteminfo.MedChrgitm = "14"
  19880. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19881. iteminfo.Amt = otherCostTotal
  19882. iteminfo.ClaaSumfee = other_claa_sunmfee
  19883. iteminfo.ClabAmt = other_clab_amt
  19884. iteminfo.OthAmt = other_other_amt
  19885. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19886. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19887. }
  19888. struct4101.IteminfoStruct = iteminfoStructs
  19889. struct4101.Ntly = "中国"
  19890. struct4101.AdmCaty = "A03.06"
  19891. struct4101.DoctorName = doctor.UserName
  19892. struct4101.DoctorCode = doctor.DoctorNumber
  19893. var res ResultSeventeen
  19894. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  19895. struct4101.BillCode = order.Number
  19896. struct4101.BillNo = order.SetlId
  19897. var resOther ResultSeventeenOther
  19898. var pp models.PublicParams
  19899. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19900. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19901. pp.FixmedinsName = miConfig.OrgName
  19902. pp.FixmedinsCode = miConfig.Code
  19903. pp.RequestUrl = miConfig.Url
  19904. pp.Cainfo = miConfig.Cainfo
  19905. pp.SecretKey = miConfig.SecretKey
  19906. pp.AccessKey = miConfig.AccessKey
  19907. pp.OpterName = curRoles.UserName
  19908. client := &http.Client{}
  19909. var req *http.Request
  19910. data := make(map[string]interface{})
  19911. data["struct4101"] = struct4101
  19912. data["pp"] = pp
  19913. bytesData, _ := json.Marshal(data)
  19914. if miConfig.MdtrtareaAdmvs == "320830" {
  19915. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  19916. } else if miConfig.MdtrtareaAdmvs == "320921" {
  19917. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19918. } else {
  19919. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19920. }
  19921. resp, _ := client.Do(req)
  19922. defer resp.Body.Close()
  19923. body, ioErr := ioutil.ReadAll(resp.Body)
  19924. if ioErr != nil {
  19925. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19927. return
  19928. }
  19929. var respJSON map[string]interface{}
  19930. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19933. return
  19934. }
  19935. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19936. userJSONBytes, _ := json.Marshal(respJSON)
  19937. fmt.Println("log")
  19938. fmt.Println(string(userJSONBytes))
  19939. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19940. utils.ErrorLog("解析失败:%v", err)
  19941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19942. return
  19943. }
  19944. res.InfRefmsgid = resOther.InfRefmsgid
  19945. res.Output = resOther.Output
  19946. res.ErrMsg = resOther.ErrMsg
  19947. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19948. res.Infcode = infocode
  19949. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19950. var pp models.PublicParams
  19951. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19952. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19953. pp.FixmedinsName = miConfig.OrgName
  19954. pp.FixmedinsCode = miConfig.Code
  19955. pp.RequestUrl = miConfig.Url
  19956. pp.Cainfo = miConfig.Cainfo
  19957. pp.SecretKey = miConfig.SecretKey
  19958. pp.AccessKey = miConfig.AccessKey
  19959. pp.OpterName = curRoles.UserName
  19960. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19961. result, _ := service.Jxyb4101(struct4101, pp)
  19962. var dat map[string]interface{}
  19963. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19964. fmt.Println(dat)
  19965. } else {
  19966. fmt.Println(err)
  19967. }
  19968. userJSONBytes, _ := json.Marshal(dat)
  19969. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19970. utils.ErrorLog("解析失败:%v", err)
  19971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19972. return
  19973. }
  19974. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19975. var pp models.PublicParams
  19976. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19977. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19978. pp.FixmedinsName = miConfig.OrgName
  19979. pp.FixmedinsCode = miConfig.Code
  19980. pp.RequestUrl = miConfig.Url
  19981. pp.Cainfo = miConfig.Cainfo
  19982. pp.SecretKey = miConfig.SecretKey
  19983. pp.AccessKey = miConfig.AccessKey
  19984. pp.OpterName = curRoles.UserName
  19985. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19986. result, _ := service.Jxyb4101(struct4101, pp)
  19987. var dat map[string]interface{}
  19988. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19989. fmt.Println(dat)
  19990. } else {
  19991. fmt.Println(err)
  19992. }
  19993. userJSONBytes, _ := json.Marshal(dat)
  19994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19995. utils.ErrorLog("解析失败:%v", err)
  19996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19997. return
  19998. }
  19999. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20000. var pp models.PublicParams
  20001. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20002. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20003. pp.FixmedinsName = miConfig.OrgName
  20004. pp.FixmedinsCode = miConfig.Code
  20005. pp.RequestUrl = miConfig.Url
  20006. pp.Cainfo = miConfig.Cainfo
  20007. pp.SecretKey = miConfig.SecretKey
  20008. pp.AccessKey = miConfig.AccessKey
  20009. pp.OpterName = curRoles.UserName
  20010. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20011. result, _ := service.Jxyb4101(struct4101, pp)
  20012. var dat map[string]interface{}
  20013. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20014. fmt.Println(dat)
  20015. } else {
  20016. fmt.Println(err)
  20017. }
  20018. userJSONBytes, _ := json.Marshal(dat)
  20019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20020. utils.ErrorLog("解析失败:%v", err)
  20021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20022. return
  20023. }
  20024. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20025. var pp models.PublicParams
  20026. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20027. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20028. pp.FixmedinsName = miConfig.OrgName
  20029. pp.FixmedinsCode = miConfig.Code
  20030. pp.RequestUrl = miConfig.Url
  20031. pp.Cainfo = miConfig.Cainfo
  20032. pp.SecretKey = miConfig.SecretKey
  20033. pp.AccessKey = miConfig.AccessKey
  20034. pp.OpterName = curRoles.UserName
  20035. result, _ := service.Hnyb4101(struct4101, pp)
  20036. var dat map[string]interface{}
  20037. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20038. fmt.Println(dat)
  20039. } else {
  20040. fmt.Println(err)
  20041. }
  20042. userJSONBytes, _ := json.Marshal(dat)
  20043. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20044. utils.ErrorLog("解析失败:%v", err)
  20045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20046. return
  20047. }
  20048. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20049. var resOther ResultSeventeenOther
  20050. var pp models.PublicParams
  20051. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20052. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20053. pp.FixmedinsName = miConfig.OrgName
  20054. pp.FixmedinsCode = miConfig.Code
  20055. pp.RequestUrl = miConfig.Url
  20056. pp.Cainfo = miConfig.Cainfo
  20057. pp.SecretKey = miConfig.SecretKey
  20058. pp.AccessKey = miConfig.AccessKey
  20059. pp.OpterName = curRoles.UserName
  20060. client := &http.Client{}
  20061. var req *http.Request
  20062. data := make(map[string]interface{})
  20063. data["struct4101"] = struct4101
  20064. data["pp"] = pp
  20065. bytesData, _ := json.Marshal(data)
  20066. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20067. resp, _ := client.Do(req)
  20068. defer resp.Body.Close()
  20069. body, ioErr := ioutil.ReadAll(resp.Body)
  20070. if ioErr != nil {
  20071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20073. return
  20074. }
  20075. var respJSON map[string]interface{}
  20076. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20079. return
  20080. }
  20081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20082. userJSONBytes, _ := json.Marshal(respJSON)
  20083. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20084. utils.ErrorLog("解析失败:%v", err)
  20085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20086. return
  20087. }
  20088. res.InfRefmsgid = resOther.InfRefmsgid
  20089. res.Output = resOther.Output
  20090. res.ErrMsg = resOther.ErrMsg
  20091. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20092. res.Infcode = infocode
  20093. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20094. var pp models.PublicParams
  20095. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20096. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20097. pp.FixmedinsName = miConfig.OrgName
  20098. pp.FixmedinsCode = miConfig.Code
  20099. pp.RequestUrl = miConfig.Url
  20100. pp.Cainfo = miConfig.Cainfo
  20101. pp.SecretKey = miConfig.SecretKey
  20102. pp.AccessKey = miConfig.AccessKey
  20103. pp.OpterName = curRoles.UserName
  20104. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20105. fmt.Println(requestLog)
  20106. fmt.Println(errMsgLog)
  20107. saveLog(result, requestLog, "4101a", "上传清单")
  20108. var dat map[string]interface{}
  20109. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20110. fmt.Println(dat)
  20111. } else {
  20112. fmt.Println(err)
  20113. }
  20114. userJSONBytes, _ := json.Marshal(dat)
  20115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20116. utils.ErrorLog("解析失败:%v", err)
  20117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20118. return
  20119. }
  20120. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20121. var pp models.PublicParams
  20122. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20123. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20124. pp.FixmedinsName = miConfig.OrgName
  20125. pp.FixmedinsCode = miConfig.Code
  20126. pp.RequestUrl = miConfig.Url
  20127. pp.Cainfo = miConfig.Cainfo
  20128. pp.SecretKey = miConfig.SecretKey
  20129. pp.AccessKey = miConfig.AccessKey
  20130. pp.OpterName = curRoles.UserName
  20131. client := &http.Client{}
  20132. var req *http.Request
  20133. data := make(map[string]interface{})
  20134. data["struct4101"] = struct4101
  20135. data["pp"] = pp
  20136. bytesData, _ := json.Marshal(data)
  20137. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20138. resp, _ := client.Do(req)
  20139. defer resp.Body.Close()
  20140. body, ioErr := ioutil.ReadAll(resp.Body)
  20141. if ioErr != nil {
  20142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20144. return
  20145. }
  20146. var respJSON map[string]interface{}
  20147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20150. return
  20151. }
  20152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20153. userJSONBytes, _ := json.Marshal(respJSON)
  20154. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20155. utils.ErrorLog("解析失败:%v", err)
  20156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20157. return
  20158. }
  20159. } else {
  20160. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20161. var dat map[string]interface{}
  20162. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20163. fmt.Println(dat)
  20164. } else {
  20165. fmt.Println(err)
  20166. }
  20167. userJSONBytes, _ := json.Marshal(dat)
  20168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20169. utils.ErrorLog("解析失败:%v", err)
  20170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20171. return
  20172. }
  20173. }
  20174. if res.Infcode != 0 {
  20175. errlog := &models.HisOrderError{
  20176. UserOrgId: order.UserOrgId,
  20177. Ctime: time.Now().Unix(),
  20178. Mtime: time.Now().Unix(),
  20179. ErrMsg: res.ErrMsg + "解析失败",
  20180. Status: 1,
  20181. PatientId: order.ID,
  20182. Stage: 10485,
  20183. }
  20184. service.CreateErrMsgLog(errlog)
  20185. continue
  20186. //c.ServeSuccessJSON(map[string]interface{}{
  20187. // "failed_code": -10,
  20188. // "msg": res.ErrMsg,
  20189. //})
  20190. } else {
  20191. //order.FaPiaoNumber = zero
  20192. //order.FaPiaoCode = last_order.FaPiaoCode
  20193. //service.UpdateOrder(order)
  20194. hisFundSettleListResult := &models.HisFundSettleListResult{
  20195. Number: res.Output.SetlListId,
  20196. Status: 1,
  20197. Ctime: time.Now().Unix(),
  20198. Mtime: time.Now().Unix(),
  20199. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20200. IsUpload: 1,
  20201. OrderId: order.ID,
  20202. }
  20203. service.CreateUploadRecord(hisFundSettleListResult)
  20204. continue
  20205. }
  20206. }
  20207. }
  20208. func (c *HisApiController) GetSettleList() {
  20209. order_id, _ := c.GetInt64("order_id")
  20210. admin_user_id, _ := c.GetInt64("admin_user_id")
  20211. order, _ := service.GetHisOrderByIDTwo(order_id)
  20212. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20213. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20214. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20215. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20216. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20217. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20218. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20219. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20220. if order.ID == 0 {
  20221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20222. return
  20223. }
  20224. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20225. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20226. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20227. //fmt.Println(count)
  20228. //var zero string
  20229. //number := count + 1
  20230. //if number >= 1000 {
  20231. // zero = "0000" + strconv.FormatInt(number, 10)
  20232. //} else if number >= 10000 {
  20233. // zero = "000" + strconv.FormatInt(number, 10)
  20234. //} else if number >= 100000 {
  20235. // zero = "00" + strconv.FormatInt(number, 10)
  20236. //} else if number >= 1000000 {
  20237. // zero = "0" + strconv.FormatInt(number, 10)
  20238. //} else {
  20239. // zero = strconv.FormatInt(number, 10)
  20240. //}
  20241. //fmt.Println(zero)
  20242. struct4101 := service.Struct4101{
  20243. PsnNo: order.PsnNo,
  20244. MdtrtId: order.MdtrtId,
  20245. SetlId: order.SetlId,
  20246. PsnName: order.PsnName,
  20247. Gend: order.Gend,
  20248. Brdy: his.Brdy,
  20249. Age: his.Age,
  20250. Naty: order.Naty,
  20251. PatnCertType: "01",
  20252. Certno: order.Certno,
  20253. Prfs: "90",
  20254. ConerName: roles[0].UserName,
  20255. PatnRlts: "99",
  20256. ConerAddr: miConfig.OrgName,
  20257. ConerTel: admin.Mobile,
  20258. HiType: order.Insutype,
  20259. Insuplc: miConfig.InsuplcAdmdvs,
  20260. MaindiagFlag: "1",
  20261. BillCode: order.SetlId,
  20262. BillNo: order.SetlId,
  20263. BizSn: order.Number,
  20264. PsnSelfPay: order.PsnPartAmt,
  20265. PsnOwnPay: order.PsnPartAmt,
  20266. AcctPay: order.AcctPay,
  20267. PsnCashpay: order.PsnCashPay,
  20268. HiPaymtd: "1",
  20269. Hsorg: miConfig.InsuplcAdmdvs,
  20270. HsorgOpter: miConfig.InsuplcAdmdvs,
  20271. MedinsFillPsn: curRoles.UserName,
  20272. MedinsFillDept: miConfig.OrgName,
  20273. IptMedType: "2",
  20274. }
  20275. struct4101.SetlBegnDate = order.SetlTime
  20276. struct4101.SetlEndDate = order.SetlTime
  20277. time_arr := strings.Split(order.SetlTime, " ")
  20278. struct4101.AdmTime = time_arr[0]
  20279. struct4101.AdmEndTime = time_arr[0]
  20280. //
  20281. //var rf []CustomFundPay
  20282. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20283. //
  20284. //var tempFunPays []service.CustomStruct
  20285. //for _, item := range rf {
  20286. // var tempFunPay service.CustomStruct
  20287. // tempFunPay.FundPayamt = item.FundPayamt
  20288. // tempFunPay.FundPayType = item.FundPayType
  20289. // tempFunPays = append(tempFunPays, tempFunPay)
  20290. //}
  20291. //struct4101.CustomStruct = tempFunPays
  20292. var tempDiaginfos []service.DiaginfoStructTwo
  20293. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20294. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20295. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  20296. var config []*models.HisXtDiagnoseConfig
  20297. for _, item := range diagnosis_ids {
  20298. id, _ := strconv.ParseInt(item, 10, 64)
  20299. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20300. config = append(config, &diagnosisConfig)
  20301. }
  20302. if miConfig.Code == "H15049901371" {
  20303. //for _, item := range config {
  20304. // if item.ID == 138 {
  20305. diagnosisConfig, _ := service.FindDiagnoseById(138)
  20306. var tempDiaginfo service.DiaginfoStructTwo
  20307. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  20308. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  20309. tempDiaginfo.DiagType = "1"
  20310. tempDiaginfo.MaindiagFlag = "1"
  20311. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20312. //}
  20313. //}
  20314. for _, item := range config {
  20315. if item.ID != 138 {
  20316. var tempDiaginfo service.DiaginfoStructTwo
  20317. tempDiaginfo.DiagCode = item.CountryCode
  20318. tempDiaginfo.DiagName = item.CountryContentName
  20319. tempDiaginfo.DiagType = "1"
  20320. tempDiaginfo.MaindiagFlag = "0"
  20321. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20322. }
  20323. }
  20324. } else {
  20325. for index, item := range config {
  20326. if index == 0 {
  20327. var tempDiaginfo service.DiaginfoStructTwo
  20328. tempDiaginfo.DiagCode = item.CountryCode
  20329. tempDiaginfo.DiagName = item.CountryContentName
  20330. tempDiaginfo.DiagType = "1"
  20331. tempDiaginfo.MaindiagFlag = "1"
  20332. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20333. } else {
  20334. var tempDiaginfo service.DiaginfoStructTwo
  20335. tempDiaginfo.DiagCode = item.CountryCode
  20336. tempDiaginfo.DiagName = item.CountryContentName
  20337. tempDiaginfo.DiagType = "1"
  20338. tempDiaginfo.MaindiagFlag = "0"
  20339. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20340. }
  20341. }
  20342. }
  20343. struct4101.Diseinfo = tempDiaginfos
  20344. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20345. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20346. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20347. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  20348. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  20349. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20350. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20351. var iteminfo service.IteminfoStruct
  20352. var bedCostTotal float64 = 0 //床位总费
  20353. var bedCostSelfTotal float64 = 0 //床位自费
  20354. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20355. var operationCostTotal float64 = 0 //手术费
  20356. var operationCostSelfTotal float64 = 0 //手术费
  20357. var operationCostPartSelfTotal float64 = 0 //手术费
  20358. var otherCostTotal float64 = 0 //其他费用
  20359. var otherCostSelfTotal float64 = 0 //其他费用
  20360. var otherCostPartSelfTotal float64 = 0 //其他费用
  20361. var materialCostTotal float64 = 0 //材料费
  20362. var materialCostSelfTotal float64 = 0 //材料费
  20363. var materialCostPartSelfTotal float64 = 0 //材料费
  20364. var westernMedicineCostTotal float64 = 0 //西药费
  20365. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20366. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20367. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20368. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20369. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20370. var checkCostTotal float64 = 0 //检查费
  20371. var checkCostSelfTotal float64 = 0 //检查费
  20372. var checkCostPartSelfTotal float64 = 0 //检查费
  20373. var laboratoryCostTotal float64 = 0 //化验费
  20374. var laboratoryCostSelfTotal float64 = 0 //化验费
  20375. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20376. var treatCostTotal float64 = 0 //治疗费用
  20377. var treatCostSelfTotal float64 = 0 //治疗费用
  20378. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20379. decimal.DivisionPrecision = 2
  20380. var bed_fulamt_ownpay_amt float64 = 0
  20381. var operation_fulamt_ownpay_amt float64 = 0
  20382. var other_fulamt_ownpay_amt float64 = 0
  20383. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20384. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20385. var check_fulamt_ownpay_amt float64 = 0
  20386. var material_fulamt_ownpay_amt float64 = 0
  20387. var laboratory_fulamt_ownpay_amt float64 = 0
  20388. var treat_fulamt_ownpay_amt float64 = 0
  20389. var bed_claa_sunmfee float64 = 0
  20390. var bed_clab_amt float64 = 0
  20391. var bed_other_amt float64 = 0
  20392. var operation_claa_sunmfee float64 = 0
  20393. var operation_clab_amt float64 = 0
  20394. var operation_other_amt float64 = 0
  20395. var other_claa_sunmfee float64 = 0
  20396. var other_clab_amt float64 = 0
  20397. var other_other_amt float64 = 0
  20398. var westernMedicine_claa_sunmfee float64 = 0
  20399. var westernMedicine_clab_amt float64 = 0
  20400. var westernMedicine_other_amt float64 = 0
  20401. var chineseTraditional_claa_sunmfee float64 = 0
  20402. var chineseTraditional_clab_amt float64 = 0
  20403. var chineseTraditional_other_amt float64 = 0
  20404. var check_claa_sunmfee float64 = 0
  20405. var check_clab_amt float64 = 0
  20406. var check_other_amt float64 = 0
  20407. var material_claa_sunmfee float64 = 0
  20408. var material_clab_amt float64 = 0
  20409. var material_other_amt float64 = 0
  20410. var laboratory_claa_sunmfee float64 = 0
  20411. var laboratory_clab_amt float64 = 0
  20412. var laboratory_other_amt float64 = 0
  20413. var treat_claa_sunmfee float64 = 0
  20414. var treat_clab_amt float64 = 0
  20415. var treat_other_amt float64 = 0
  20416. for _, item := range order.HisOrderInfo {
  20417. if item.MedChrgitmType == "01" { //床位费
  20418. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20419. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20420. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20421. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20422. if item.ChrgitmLv == "1" {
  20423. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20424. }
  20425. if item.ChrgitmLv == "2" {
  20426. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20427. }
  20428. if item.ChrgitmLv == "3" {
  20429. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20430. }
  20431. }
  20432. if item.MedChrgitmType == "03" { //检查费
  20433. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20434. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20435. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20436. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20437. if item.ChrgitmLv == "1" {
  20438. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20439. }
  20440. if item.ChrgitmLv == "2" {
  20441. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20442. }
  20443. if item.ChrgitmLv == "3" {
  20444. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20445. }
  20446. }
  20447. if item.MedChrgitmType == "04" { //化验费
  20448. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20449. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20450. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20451. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20452. if item.ChrgitmLv == "1" {
  20453. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20454. }
  20455. if item.ChrgitmLv == "2" {
  20456. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20457. }
  20458. if item.ChrgitmLv == "3" {
  20459. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20460. }
  20461. }
  20462. if item.MedChrgitmType == "05" { //治疗费
  20463. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20464. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20465. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20466. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20467. if item.ChrgitmLv == "1" {
  20468. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20469. }
  20470. if item.ChrgitmLv == "2" {
  20471. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20472. }
  20473. if item.ChrgitmLv == "3" {
  20474. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20475. }
  20476. }
  20477. if item.MedChrgitmType == "06" { //手术费
  20478. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20479. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20480. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20481. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20482. if item.ChrgitmLv == "1" {
  20483. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20484. }
  20485. if item.ChrgitmLv == "2" {
  20486. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20487. }
  20488. if item.ChrgitmLv == "3" {
  20489. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20490. }
  20491. }
  20492. if item.MedChrgitmType == "08" { //材料费
  20493. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20494. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20495. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20496. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20497. if item.ChrgitmLv == "1" {
  20498. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20499. }
  20500. if item.ChrgitmLv == "2" {
  20501. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20502. }
  20503. if item.ChrgitmLv == "3" {
  20504. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20505. }
  20506. }
  20507. if item.MedChrgitmType == "09" { //西药费
  20508. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20509. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20510. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20511. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20512. if item.ChrgitmLv == "1" {
  20513. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20514. }
  20515. if item.ChrgitmLv == "2" {
  20516. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20517. }
  20518. if item.ChrgitmLv == "3" {
  20519. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20520. }
  20521. }
  20522. if item.MedChrgitmType == "11" { //中成费
  20523. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20524. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20525. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20526. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20527. if item.ChrgitmLv == "1" {
  20528. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20529. }
  20530. if item.ChrgitmLv == "2" {
  20531. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20532. }
  20533. if item.ChrgitmLv == "3" {
  20534. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20535. }
  20536. }
  20537. if item.MedChrgitmType == "14" { //其他费
  20538. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20539. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20540. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20541. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20542. if item.ChrgitmLv == "1" {
  20543. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20544. }
  20545. if item.ChrgitmLv == "2" {
  20546. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20547. }
  20548. if item.ChrgitmLv == "3" {
  20549. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20550. }
  20551. }
  20552. }
  20553. var iteminfoStructs []service.IteminfoStruct
  20554. if bedCostTotal != 0 {
  20555. iteminfo.MedChrgitm = "01"
  20556. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20557. iteminfo.Amt = bedCostTotal
  20558. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20559. iteminfo.ClabAmt = bed_clab_amt
  20560. iteminfo.OthAmt = bed_other_amt
  20561. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20562. }
  20563. if checkCostTotal != 0 {
  20564. iteminfo.MedChrgitm = "03"
  20565. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20566. iteminfo.Amt = checkCostTotal
  20567. iteminfo.ClaaSumfee = check_claa_sunmfee
  20568. iteminfo.ClabAmt = check_clab_amt
  20569. iteminfo.OthAmt = check_other_amt
  20570. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20571. }
  20572. if laboratoryCostTotal != 0 {
  20573. iteminfo.MedChrgitm = "04"
  20574. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20575. iteminfo.Amt = laboratoryCostTotal
  20576. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20577. iteminfo.ClabAmt = laboratory_clab_amt
  20578. iteminfo.OthAmt = laboratory_other_amt
  20579. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20580. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20581. }
  20582. if treatCostTotal != 0 {
  20583. iteminfo.MedChrgitm = "05"
  20584. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20585. iteminfo.Amt = treatCostTotal
  20586. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20587. iteminfo.ClabAmt = treat_clab_amt
  20588. iteminfo.OthAmt = treat_other_amt
  20589. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20590. //(struct4101.IteminfoStruct, iteminfo)
  20591. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20592. }
  20593. if operationCostTotal != 0 {
  20594. iteminfo.MedChrgitm = "06"
  20595. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20596. iteminfo.Amt = operationCostTotal
  20597. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20598. iteminfo.ClabAmt = operation_clab_amt
  20599. iteminfo.OthAmt = operation_other_amt
  20600. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20601. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20602. }
  20603. if materialCostTotal != 0 {
  20604. iteminfo.MedChrgitm = "08"
  20605. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20606. iteminfo.Amt = materialCostTotal
  20607. iteminfo.ClaaSumfee = material_claa_sunmfee
  20608. iteminfo.ClabAmt = material_clab_amt
  20609. iteminfo.OthAmt = material_other_amt
  20610. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20611. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20612. }
  20613. if westernMedicineCostTotal != 0 {
  20614. iteminfo.MedChrgitm = "09"
  20615. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20616. iteminfo.Amt = westernMedicineCostTotal
  20617. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20618. iteminfo.ClabAmt = westernMedicine_clab_amt
  20619. iteminfo.OthAmt = westernMedicine_other_amt
  20620. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20621. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20622. }
  20623. if chineseTraditionalMedicineCostTotal != 0 {
  20624. iteminfo.MedChrgitm = "11"
  20625. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20626. iteminfo.Amt = westernMedicineCostTotal
  20627. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20628. iteminfo.ClabAmt = westernMedicine_clab_amt
  20629. iteminfo.OthAmt = westernMedicine_other_amt
  20630. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20631. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20632. }
  20633. if otherCostTotal != 0 {
  20634. iteminfo.MedChrgitm = "14"
  20635. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20636. iteminfo.Amt = otherCostTotal
  20637. iteminfo.ClaaSumfee = other_claa_sunmfee
  20638. iteminfo.ClabAmt = other_clab_amt
  20639. iteminfo.OthAmt = other_other_amt
  20640. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20641. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20642. }
  20643. struct4101.IteminfoStruct = iteminfoStructs
  20644. struct4101.Ntly = "中国"
  20645. struct4101.AdmCaty = "A03.06"
  20646. struct4101.DoctorName = doctor.UserName
  20647. struct4101.DoctorCode = doctor.DoctorNumber
  20648. var res ResultSeventeen
  20649. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20650. struct4101.BillCode = order.Number
  20651. struct4101.BillNo = order.SetlId
  20652. var resOther ResultSeventeenOther
  20653. var pp models.PublicParams
  20654. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20655. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20656. pp.FixmedinsName = miConfig.OrgName
  20657. pp.FixmedinsCode = miConfig.Code
  20658. pp.RequestUrl = miConfig.Url
  20659. pp.Cainfo = miConfig.Cainfo
  20660. pp.SecretKey = miConfig.SecretKey
  20661. pp.AccessKey = miConfig.AccessKey
  20662. pp.OpterName = curRoles.UserName
  20663. client := &http.Client{}
  20664. var req *http.Request
  20665. data := make(map[string]interface{})
  20666. data["struct4101"] = struct4101
  20667. data["pp"] = pp
  20668. bytesData, _ := json.Marshal(data)
  20669. if miConfig.MdtrtareaAdmvs == "320830" {
  20670. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20671. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20672. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20673. } else {
  20674. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20675. }
  20676. resp, _ := client.Do(req)
  20677. defer resp.Body.Close()
  20678. body, ioErr := ioutil.ReadAll(resp.Body)
  20679. if ioErr != nil {
  20680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20682. return
  20683. }
  20684. var respJSON map[string]interface{}
  20685. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20688. return
  20689. }
  20690. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20691. userJSONBytes, _ := json.Marshal(respJSON)
  20692. fmt.Println("log")
  20693. fmt.Println(string(userJSONBytes))
  20694. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20695. utils.ErrorLog("解析失败:%v", err)
  20696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20697. return
  20698. }
  20699. res.InfRefmsgid = resOther.InfRefmsgid
  20700. res.Output = resOther.Output
  20701. res.ErrMsg = resOther.ErrMsg
  20702. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20703. res.Infcode = infocode
  20704. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20705. var pp models.PublicParams
  20706. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20707. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20708. pp.FixmedinsName = miConfig.OrgName
  20709. pp.FixmedinsCode = miConfig.Code
  20710. pp.RequestUrl = miConfig.Url
  20711. pp.Cainfo = miConfig.Cainfo
  20712. pp.SecretKey = miConfig.SecretKey
  20713. pp.AccessKey = miConfig.AccessKey
  20714. pp.OpterName = curRoles.UserName
  20715. result, _ := service.Jxyb4101(struct4101, pp)
  20716. var dat map[string]interface{}
  20717. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20718. fmt.Println(dat)
  20719. } else {
  20720. fmt.Println(err)
  20721. }
  20722. userJSONBytes, _ := json.Marshal(dat)
  20723. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20724. utils.ErrorLog("解析失败:%v", err)
  20725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20726. return
  20727. }
  20728. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20729. var pp models.PublicParams
  20730. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20731. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20732. pp.FixmedinsName = miConfig.OrgName
  20733. pp.FixmedinsCode = miConfig.Code
  20734. pp.RequestUrl = miConfig.Url
  20735. pp.Cainfo = miConfig.Cainfo
  20736. pp.SecretKey = miConfig.SecretKey
  20737. pp.AccessKey = miConfig.AccessKey
  20738. pp.OpterName = curRoles.UserName
  20739. result, _ := service.Jxyb4101(struct4101, pp)
  20740. var dat map[string]interface{}
  20741. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20742. fmt.Println(dat)
  20743. } else {
  20744. fmt.Println(err)
  20745. }
  20746. userJSONBytes, _ := json.Marshal(dat)
  20747. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20748. utils.ErrorLog("解析失败:%v", err)
  20749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20750. return
  20751. }
  20752. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20753. var pp models.PublicParams
  20754. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20755. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20756. pp.FixmedinsName = miConfig.OrgName
  20757. pp.FixmedinsCode = miConfig.Code
  20758. pp.RequestUrl = miConfig.Url
  20759. pp.Cainfo = miConfig.Cainfo
  20760. pp.SecretKey = miConfig.SecretKey
  20761. pp.AccessKey = miConfig.AccessKey
  20762. pp.OpterName = curRoles.UserName
  20763. result, _ := service.Jxyb4101(struct4101, pp)
  20764. var dat map[string]interface{}
  20765. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20766. fmt.Println(dat)
  20767. } else {
  20768. fmt.Println(err)
  20769. }
  20770. userJSONBytes, _ := json.Marshal(dat)
  20771. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20772. utils.ErrorLog("解析失败:%v", err)
  20773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20774. return
  20775. }
  20776. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20777. var pp models.PublicParams
  20778. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20779. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20780. pp.FixmedinsName = miConfig.OrgName
  20781. pp.FixmedinsCode = miConfig.Code
  20782. pp.RequestUrl = miConfig.Url
  20783. pp.Cainfo = miConfig.Cainfo
  20784. pp.SecretKey = miConfig.SecretKey
  20785. pp.AccessKey = miConfig.AccessKey
  20786. pp.OpterName = curRoles.UserName
  20787. result, _ := service.Hnyb4101(struct4101, pp)
  20788. var dat map[string]interface{}
  20789. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20790. fmt.Println(dat)
  20791. } else {
  20792. fmt.Println(err)
  20793. }
  20794. userJSONBytes, _ := json.Marshal(dat)
  20795. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20796. utils.ErrorLog("解析失败:%v", err)
  20797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20798. return
  20799. }
  20800. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20801. var resOther ResultSeventeenOther
  20802. var pp models.PublicParams
  20803. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20804. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20805. pp.FixmedinsName = miConfig.OrgName
  20806. pp.FixmedinsCode = miConfig.Code
  20807. pp.RequestUrl = miConfig.Url
  20808. pp.Cainfo = miConfig.Cainfo
  20809. pp.SecretKey = miConfig.SecretKey
  20810. pp.AccessKey = miConfig.AccessKey
  20811. pp.OpterName = curRoles.UserName
  20812. client := &http.Client{}
  20813. var req *http.Request
  20814. data := make(map[string]interface{})
  20815. data["struct4101"] = struct4101
  20816. data["pp"] = pp
  20817. bytesData, _ := json.Marshal(data)
  20818. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20819. resp, _ := client.Do(req)
  20820. defer resp.Body.Close()
  20821. body, ioErr := ioutil.ReadAll(resp.Body)
  20822. if ioErr != nil {
  20823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20825. return
  20826. }
  20827. var respJSON map[string]interface{}
  20828. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20831. return
  20832. }
  20833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20834. userJSONBytes, _ := json.Marshal(respJSON)
  20835. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20836. utils.ErrorLog("解析失败:%v", err)
  20837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20838. return
  20839. }
  20840. res.InfRefmsgid = resOther.InfRefmsgid
  20841. res.Output = resOther.Output
  20842. res.ErrMsg = resOther.ErrMsg
  20843. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20844. res.Infcode = infocode
  20845. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20846. var pp models.PublicParams
  20847. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20848. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20849. pp.FixmedinsName = miConfig.OrgName
  20850. pp.FixmedinsCode = miConfig.Code
  20851. pp.RequestUrl = miConfig.Url
  20852. pp.Cainfo = miConfig.Cainfo
  20853. pp.SecretKey = miConfig.SecretKey
  20854. pp.AccessKey = miConfig.AccessKey
  20855. pp.OpterName = curRoles.UserName
  20856. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20857. fmt.Println(requestLog)
  20858. fmt.Println(errMsgLog)
  20859. saveLog(result, requestLog, "4101a", "上传清单")
  20860. var dat map[string]interface{}
  20861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20862. fmt.Println(dat)
  20863. } else {
  20864. fmt.Println(err)
  20865. }
  20866. userJSONBytes, _ := json.Marshal(dat)
  20867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20868. utils.ErrorLog("解析失败:%v", err)
  20869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20870. return
  20871. }
  20872. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20873. var pp models.PublicParams
  20874. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20875. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20876. pp.FixmedinsName = miConfig.OrgName
  20877. pp.FixmedinsCode = miConfig.Code
  20878. pp.RequestUrl = miConfig.Url
  20879. pp.Cainfo = miConfig.Cainfo
  20880. pp.SecretKey = miConfig.SecretKey
  20881. pp.AccessKey = miConfig.AccessKey
  20882. pp.OpterName = curRoles.UserName
  20883. client := &http.Client{}
  20884. var req *http.Request
  20885. data := make(map[string]interface{})
  20886. data["struct4101"] = struct4101
  20887. data["pp"] = pp
  20888. bytesData, _ := json.Marshal(data)
  20889. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20890. resp, _ := client.Do(req)
  20891. defer resp.Body.Close()
  20892. body, ioErr := ioutil.ReadAll(resp.Body)
  20893. if ioErr != nil {
  20894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20896. return
  20897. }
  20898. var respJSON map[string]interface{}
  20899. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20902. return
  20903. }
  20904. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20905. userJSONBytes, _ := json.Marshal(respJSON)
  20906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20907. utils.ErrorLog("解析失败:%v", err)
  20908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20909. return
  20910. }
  20911. } else {
  20912. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20913. var dat map[string]interface{}
  20914. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20915. fmt.Println(dat)
  20916. } else {
  20917. fmt.Println(err)
  20918. }
  20919. userJSONBytes, _ := json.Marshal(dat)
  20920. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20921. utils.ErrorLog("解析失败:%v", err)
  20922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20923. return
  20924. }
  20925. }
  20926. if res.Infcode != 0 {
  20927. c.ServeSuccessJSON(map[string]interface{}{
  20928. "failed_code": -10,
  20929. "msg": res.ErrMsg,
  20930. })
  20931. return
  20932. } else {
  20933. //order.FaPiaoNumber = zero
  20934. //order.FaPiaoCode = last_order.FaPiaoCode
  20935. //service.UpdateOrder(order)
  20936. hisFundSettleListResult := &models.HisFundSettleListResult{
  20937. Number: res.Output.SetlListId,
  20938. Status: 1,
  20939. Ctime: time.Now().Unix(),
  20940. Mtime: time.Now().Unix(),
  20941. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20942. IsUpload: 1,
  20943. OrderId: order_id,
  20944. }
  20945. service.CreateUploadRecord(hisFundSettleListResult)
  20946. c.ServeSuccessJSON(map[string]interface{}{
  20947. "msg": "上传成功",
  20948. "result": hisFundSettleListResult,
  20949. })
  20950. return
  20951. }
  20952. }
  20953. func (c *HisApiController) GetSettleListHospital() {
  20954. order_id, _ := c.GetInt64("order_id")
  20955. admin_user_id, _ := c.GetInt64("admin_user_id")
  20956. order, _ := service.GetHisOrderByIDTwo(order_id)
  20957. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20958. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  20959. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20960. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20961. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20962. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20963. if order.ID == 0 {
  20964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20965. return
  20966. }
  20967. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20968. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20969. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20970. fmt.Println(count)
  20971. var zero string
  20972. number := count + 1
  20973. if number >= 1000 {
  20974. zero = "0000" + strconv.FormatInt(number, 10)
  20975. } else if number >= 10000 {
  20976. zero = "000" + strconv.FormatInt(number, 10)
  20977. } else if number >= 100000 {
  20978. zero = "00" + strconv.FormatInt(number, 10)
  20979. } else if number >= 1000000 {
  20980. zero = "0" + strconv.FormatInt(number, 10)
  20981. } else {
  20982. zero = strconv.FormatInt(number, 10)
  20983. }
  20984. fmt.Println(zero)
  20985. struct4101 := service.Struct4101{
  20986. PsnNo: order.PsnNo,
  20987. MdtrtId: order.MdtrtId,
  20988. SetlId: order.SetlId,
  20989. PsnName: order.PsnName,
  20990. Gend: order.Gend,
  20991. Brdy: his.Brdy,
  20992. Age: int64(order.Age),
  20993. Naty: order.Naty,
  20994. PatnCertType: "01",
  20995. Certno: order.Certno,
  20996. Prfs: "90",
  20997. ConerName: roles[0].UserName,
  20998. PatnRlts: "99",
  20999. ConerAddr: miConfig.OrgName,
  21000. ConerTel: admin.Mobile,
  21001. HiType: order.Insutype,
  21002. Insuplc: miConfig.InsuplcAdmdvs,
  21003. MaindiagFlag: "1",
  21004. BillCode: order.SetlId,
  21005. BillNo: order.SetlId,
  21006. BizSn: order.Number,
  21007. PsnSelfPay: order.PsnPartAmt,
  21008. PsnOwnPay: order.PsnPartAmt,
  21009. AcctPay: order.AcctPay,
  21010. PsnCashpay: order.PsnCashPay,
  21011. HiPaymtd: "1",
  21012. Hsorg: miConfig.InsuplcAdmdvs,
  21013. HsorgOpter: miConfig.InsuplcAdmdvs,
  21014. MedinsFillPsn: curRoles.UserName,
  21015. MedinsFillDept: depart.Name,
  21016. IptMedType: "2",
  21017. AdmTime: his.InHosptialTime,
  21018. AdmEndTime: his.OutHosptialTime,
  21019. }
  21020. struct4101.SetlBegnDate = order.SetlTime
  21021. struct4101.SetlEndDate = order.SetlTime
  21022. //var rf []CustomFundPay
  21023. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  21024. //
  21025. //var tempFunPays []service.CustomStruct
  21026. //for _, item := range rf {
  21027. // var tempFunPay service.CustomStruct
  21028. // tempFunPay.FundPayamt = item.FundPayamt
  21029. // tempFunPay.FundPayType = item.FundPayType
  21030. // tempFunPays = append(tempFunPays, tempFunPay)
  21031. //}
  21032. //struct4101.CustomStruct = tempFunPays
  21033. var tempDiaginfos []service.DiaginfoStructTwo
  21034. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21035. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21036. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  21037. //for _, item := range infos {
  21038. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  21039. //}
  21040. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  21041. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  21042. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21043. fmt.Println(diagnosis_ids_arr)
  21044. if order.UserOrgId == 10210 {
  21045. var diagnosis_ids_arr_two []int64
  21046. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  21047. var config []*models.HisXtDiagnoseConfig
  21048. for _, id := range diagnosis_ids_arr_two {
  21049. //id, _ := strconv.ParseInt(item, 10, 64)
  21050. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21051. if diagnosisConfig.ID > 0 {
  21052. config = append(config, &diagnosisConfig)
  21053. }
  21054. }
  21055. for index, item := range config {
  21056. if item.ID > 0 {
  21057. if index == 0 {
  21058. var tempDiaginfo service.DiaginfoStructTwo
  21059. tempDiaginfo.DiagCode = item.CountryCode
  21060. tempDiaginfo.DiagName = item.CountryContentName
  21061. tempDiaginfo.DiagType = "1"
  21062. tempDiaginfo.MaindiagFlag = "1"
  21063. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21064. } else {
  21065. var tempDiaginfo service.DiaginfoStructTwo
  21066. tempDiaginfo.DiagCode = item.CountryCode
  21067. tempDiaginfo.DiagName = item.CountryContentName
  21068. tempDiaginfo.DiagType = "1"
  21069. tempDiaginfo.MaindiagFlag = "0"
  21070. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21071. }
  21072. }
  21073. }
  21074. struct4101.Diseinfo = tempDiaginfos
  21075. } else {
  21076. var config []*models.HisXtDiagnoseConfig
  21077. for _, item := range diagnosis_ids_arr {
  21078. id, _ := strconv.ParseInt(item, 10, 64)
  21079. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21080. if diagnosisConfig.ID > 0 {
  21081. config = append(config, &diagnosisConfig)
  21082. }
  21083. }
  21084. for index, item := range config {
  21085. if item.ID > 0 {
  21086. if index == 0 {
  21087. var tempDiaginfo service.DiaginfoStructTwo
  21088. tempDiaginfo.DiagCode = item.CountryCode
  21089. tempDiaginfo.DiagName = item.CountryContentName
  21090. tempDiaginfo.DiagType = "1"
  21091. tempDiaginfo.MaindiagFlag = "1"
  21092. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21093. } else {
  21094. var tempDiaginfo service.DiaginfoStructTwo
  21095. tempDiaginfo.DiagCode = item.CountryCode
  21096. tempDiaginfo.DiagName = item.CountryContentName
  21097. tempDiaginfo.DiagType = "1"
  21098. tempDiaginfo.MaindiagFlag = "0"
  21099. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21100. }
  21101. }
  21102. }
  21103. struct4101.Diseinfo = tempDiaginfos
  21104. }
  21105. sickConfigTwo, _ := service.FindSickById(his.SickType)
  21106. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21107. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21108. tempOpspdiseinfo2.OprnOprtCode = ""
  21109. tempOpspdiseinfo2.OprnOprtName = ""
  21110. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21111. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21112. var iteminfo service.IteminfoStruct
  21113. var bedCostTotal float64 = 0 //床位总费
  21114. var bedCostSelfTotal float64 = 0 //床位自费
  21115. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21116. var operationCostTotal float64 = 0 //手术费
  21117. var operationCostSelfTotal float64 = 0 //手术费
  21118. var operationCostPartSelfTotal float64 = 0 //手术费
  21119. var otherCostTotal float64 = 0 //其他费用
  21120. var otherCostSelfTotal float64 = 0 //其他费用
  21121. var otherCostPartSelfTotal float64 = 0 //其他费用
  21122. var materialCostTotal float64 = 0 //材料费
  21123. var materialCostSelfTotal float64 = 0 //材料费
  21124. var materialCostPartSelfTotal float64 = 0 //材料费
  21125. var westernMedicineCostTotal float64 = 0 //西药费
  21126. var westernMedicineCostSelfTotal float64 = 0 //西药费
  21127. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21128. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21129. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21130. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21131. var checkCostTotal float64 = 0 //检查费
  21132. var checkCostSelfTotal float64 = 0 //检查费
  21133. var checkCostPartSelfTotal float64 = 0 //检查费
  21134. var laboratoryCostTotal float64 = 0 //化验费
  21135. var laboratoryCostSelfTotal float64 = 0 //化验费
  21136. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21137. var treatCostTotal float64 = 0 //治疗费用
  21138. var treatCostSelfTotal float64 = 0 //治疗费用
  21139. var treatCostPartSelfTotal float64 = 0 //治疗费用
  21140. decimal.DivisionPrecision = 2
  21141. var bed_fulamt_ownpay_amt float64 = 0
  21142. var operation_fulamt_ownpay_amt float64 = 0
  21143. var other_fulamt_ownpay_amt float64 = 0
  21144. var westernMedicine_fulamt_ownpay_amt float64 = 0
  21145. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21146. var check_fulamt_ownpay_amt float64 = 0
  21147. var material_fulamt_ownpay_amt float64 = 0
  21148. var laboratory_fulamt_ownpay_amt float64 = 0
  21149. var treat_fulamt_ownpay_amt float64 = 0
  21150. var bed_claa_sunmfee float64 = 0
  21151. var bed_clab_amt float64 = 0
  21152. var bed_other_amt float64 = 0
  21153. var operation_claa_sunmfee float64 = 0
  21154. var operation_clab_amt float64 = 0
  21155. var operation_other_amt float64 = 0
  21156. var other_claa_sunmfee float64 = 0
  21157. var other_clab_amt float64 = 0
  21158. var other_other_amt float64 = 0
  21159. var westernMedicine_claa_sunmfee float64 = 0
  21160. var westernMedicine_clab_amt float64 = 0
  21161. var westernMedicine_other_amt float64 = 0
  21162. var chineseTraditional_claa_sunmfee float64 = 0
  21163. var chineseTraditional_clab_amt float64 = 0
  21164. var chineseTraditional_other_amt float64 = 0
  21165. var check_claa_sunmfee float64 = 0
  21166. var check_clab_amt float64 = 0
  21167. var check_other_amt float64 = 0
  21168. var material_claa_sunmfee float64 = 0
  21169. var material_clab_amt float64 = 0
  21170. var material_other_amt float64 = 0
  21171. var laboratory_claa_sunmfee float64 = 0
  21172. var laboratory_clab_amt float64 = 0
  21173. var laboratory_other_amt float64 = 0
  21174. var treat_claa_sunmfee float64 = 0
  21175. var treat_clab_amt float64 = 0
  21176. var treat_other_amt float64 = 0
  21177. for _, item := range order.HisOrderInfo {
  21178. if item.MedChrgitmType == "01" { //床位费
  21179. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21180. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21181. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21182. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21183. if item.ChrgitmLv == "1" {
  21184. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21185. }
  21186. if item.ChrgitmLv == "2" {
  21187. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21188. }
  21189. if item.ChrgitmLv == "3" {
  21190. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21191. }
  21192. }
  21193. if item.MedChrgitmType == "03" { //检查费
  21194. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21195. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21196. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21197. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21198. if item.ChrgitmLv == "1" {
  21199. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21200. }
  21201. if item.ChrgitmLv == "2" {
  21202. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21203. }
  21204. if item.ChrgitmLv == "3" {
  21205. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21206. }
  21207. }
  21208. if item.MedChrgitmType == "04" { //化验费
  21209. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21210. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21211. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21212. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21213. if item.ChrgitmLv == "1" {
  21214. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21215. }
  21216. if item.ChrgitmLv == "2" {
  21217. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21218. }
  21219. if item.ChrgitmLv == "3" {
  21220. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21221. }
  21222. }
  21223. if item.MedChrgitmType == "05" { //治疗费
  21224. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21225. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21226. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21227. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21228. if item.ChrgitmLv == "1" {
  21229. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21230. }
  21231. if item.ChrgitmLv == "2" {
  21232. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21233. }
  21234. if item.ChrgitmLv == "3" {
  21235. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21236. }
  21237. }
  21238. if item.MedChrgitmType == "06" { //手术费
  21239. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21240. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21241. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21242. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21243. if item.ChrgitmLv == "1" {
  21244. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21245. }
  21246. if item.ChrgitmLv == "2" {
  21247. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21248. }
  21249. if item.ChrgitmLv == "3" {
  21250. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21251. }
  21252. }
  21253. if item.MedChrgitmType == "08" { //材料费
  21254. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21255. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21256. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21257. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21258. if item.ChrgitmLv == "1" {
  21259. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21260. }
  21261. if item.ChrgitmLv == "2" {
  21262. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21263. }
  21264. if item.ChrgitmLv == "3" {
  21265. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21266. }
  21267. }
  21268. if item.MedChrgitmType == "09" { //西药费
  21269. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21270. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21271. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21272. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21273. if item.ChrgitmLv == "1" {
  21274. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21275. }
  21276. if item.ChrgitmLv == "2" {
  21277. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21278. }
  21279. if item.ChrgitmLv == "3" {
  21280. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21281. }
  21282. }
  21283. if item.MedChrgitmType == "11" { //中成费
  21284. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21285. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21286. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21287. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21288. if item.ChrgitmLv == "1" {
  21289. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21290. }
  21291. if item.ChrgitmLv == "2" {
  21292. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21293. }
  21294. if item.ChrgitmLv == "3" {
  21295. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21296. }
  21297. }
  21298. if item.MedChrgitmType == "14" { //其他费
  21299. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21300. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21301. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21302. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21303. if item.ChrgitmLv == "1" {
  21304. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21305. }
  21306. if item.ChrgitmLv == "2" {
  21307. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21308. }
  21309. if item.ChrgitmLv == "3" {
  21310. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21311. }
  21312. }
  21313. }
  21314. var iteminfoStructs []service.IteminfoStruct
  21315. if bedCostTotal != 0 {
  21316. iteminfo.MedChrgitm = "01"
  21317. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21318. iteminfo.Amt = bedCostTotal
  21319. iteminfo.ClaaSumfee = bed_claa_sunmfee
  21320. iteminfo.ClabAmt = bed_clab_amt
  21321. iteminfo.OthAmt = bed_other_amt
  21322. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21323. }
  21324. if checkCostTotal != 0 {
  21325. iteminfo.MedChrgitm = "03"
  21326. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21327. iteminfo.Amt = checkCostTotal
  21328. iteminfo.ClaaSumfee = check_claa_sunmfee
  21329. iteminfo.ClabAmt = check_clab_amt
  21330. iteminfo.OthAmt = check_other_amt
  21331. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21332. }
  21333. if laboratoryCostTotal != 0 {
  21334. iteminfo.MedChrgitm = "04"
  21335. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21336. iteminfo.Amt = laboratoryCostTotal
  21337. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21338. iteminfo.ClabAmt = laboratory_clab_amt
  21339. iteminfo.OthAmt = laboratory_other_amt
  21340. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21341. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21342. }
  21343. if treatCostTotal != 0 {
  21344. iteminfo.MedChrgitm = "05"
  21345. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21346. iteminfo.Amt = treatCostTotal
  21347. iteminfo.ClaaSumfee = treat_claa_sunmfee
  21348. iteminfo.ClabAmt = treat_clab_amt
  21349. iteminfo.OthAmt = treat_other_amt
  21350. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21351. //(struct4101.IteminfoStruct, iteminfo)
  21352. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21353. }
  21354. if operationCostTotal != 0 {
  21355. iteminfo.MedChrgitm = "06"
  21356. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21357. iteminfo.Amt = operationCostTotal
  21358. iteminfo.ClaaSumfee = operation_claa_sunmfee
  21359. iteminfo.ClabAmt = operation_clab_amt
  21360. iteminfo.OthAmt = operation_other_amt
  21361. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21362. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21363. }
  21364. if materialCostTotal != 0 {
  21365. iteminfo.MedChrgitm = "08"
  21366. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21367. iteminfo.Amt = materialCostTotal
  21368. iteminfo.ClaaSumfee = material_claa_sunmfee
  21369. iteminfo.ClabAmt = material_clab_amt
  21370. iteminfo.OthAmt = material_other_amt
  21371. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21372. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21373. }
  21374. if westernMedicineCostTotal != 0 {
  21375. iteminfo.MedChrgitm = "09"
  21376. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21377. iteminfo.Amt = westernMedicineCostTotal
  21378. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21379. iteminfo.ClabAmt = westernMedicine_clab_amt
  21380. iteminfo.OthAmt = westernMedicine_other_amt
  21381. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21382. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21383. }
  21384. if chineseTraditionalMedicineCostTotal != 0 {
  21385. iteminfo.MedChrgitm = "11"
  21386. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21387. iteminfo.Amt = westernMedicineCostTotal
  21388. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21389. iteminfo.ClabAmt = westernMedicine_clab_amt
  21390. iteminfo.OthAmt = westernMedicine_other_amt
  21391. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21392. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21393. }
  21394. if otherCostTotal != 0 {
  21395. iteminfo.MedChrgitm = "14"
  21396. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21397. iteminfo.Amt = otherCostTotal
  21398. iteminfo.ClaaSumfee = other_claa_sunmfee
  21399. iteminfo.ClabAmt = other_clab_amt
  21400. iteminfo.OthAmt = other_other_amt
  21401. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21402. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21403. }
  21404. struct4101.IteminfoStruct = iteminfoStructs
  21405. struct4101.Ntly = "中国"
  21406. struct4101.AdmCaty = "A03.06"
  21407. var resOther ResultSeventeenOther
  21408. var res ResultSeventeen
  21409. if miConfig.MdtrtareaAdmvs == "150499" {
  21410. var pp models.PublicParams
  21411. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21412. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21413. pp.FixmedinsName = miConfig.OrgName
  21414. pp.FixmedinsCode = miConfig.Code
  21415. pp.RequestUrl = miConfig.Url
  21416. pp.Cainfo = miConfig.Cainfo
  21417. pp.SecretKey = miConfig.SecretKey
  21418. pp.AccessKey = miConfig.AccessKey
  21419. pp.OpterName = curRoles.UserName
  21420. client := &http.Client{}
  21421. var req *http.Request
  21422. data := make(map[string]interface{})
  21423. data["struct4101"] = struct4101
  21424. data["pp"] = pp
  21425. bytesData, _ := json.Marshal(data)
  21426. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  21427. resp, _ := client.Do(req)
  21428. defer resp.Body.Close()
  21429. body, ioErr := ioutil.ReadAll(resp.Body)
  21430. if ioErr != nil {
  21431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21433. return
  21434. }
  21435. var respJSON map[string]interface{}
  21436. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21439. return
  21440. }
  21441. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21442. userJSONBytes, _ := json.Marshal(respJSON)
  21443. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  21444. utils.ErrorLog("解析失败:%v", err)
  21445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21446. return
  21447. }
  21448. res.InfRefmsgid = resOther.InfRefmsgid
  21449. res.Output = resOther.Output
  21450. res.ErrMsg = resOther.ErrMsg
  21451. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  21452. res.Infcode = infocode
  21453. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21454. var pp models.PublicParams
  21455. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21456. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21457. pp.FixmedinsName = miConfig.OrgName
  21458. pp.FixmedinsCode = miConfig.Code
  21459. pp.RequestUrl = miConfig.Url
  21460. pp.Cainfo = miConfig.Cainfo
  21461. pp.SecretKey = miConfig.SecretKey
  21462. pp.AccessKey = miConfig.AccessKey
  21463. pp.OpterName = curRoles.UserName
  21464. result, _ := service.Jxyb4101(struct4101, pp)
  21465. var dat map[string]interface{}
  21466. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21467. fmt.Println(dat)
  21468. } else {
  21469. fmt.Println(err)
  21470. }
  21471. userJSONBytes, _ := json.Marshal(dat)
  21472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21473. utils.ErrorLog("解析失败:%v", err)
  21474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21475. return
  21476. }
  21477. } else if miConfig.MdtrtareaAdmvs == "361025" {
  21478. var pp models.PublicParams
  21479. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21480. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21481. pp.FixmedinsName = miConfig.OrgName
  21482. pp.FixmedinsCode = miConfig.Code
  21483. pp.RequestUrl = miConfig.Url
  21484. pp.Cainfo = miConfig.Cainfo
  21485. pp.SecretKey = miConfig.SecretKey
  21486. pp.AccessKey = miConfig.AccessKey
  21487. pp.OpterName = curRoles.UserName
  21488. result, _ := service.Jxyb4101(struct4101, pp)
  21489. var dat map[string]interface{}
  21490. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21491. fmt.Println(dat)
  21492. } else {
  21493. fmt.Println(err)
  21494. }
  21495. userJSONBytes, _ := json.Marshal(dat)
  21496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21497. utils.ErrorLog("解析失败:%v", err)
  21498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21499. return
  21500. }
  21501. } else if miConfig.MdtrtareaAdmvs == "360100" {
  21502. var pp models.PublicParams
  21503. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21504. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21505. pp.FixmedinsName = miConfig.OrgName
  21506. pp.FixmedinsCode = miConfig.Code
  21507. pp.RequestUrl = miConfig.Url
  21508. pp.Cainfo = miConfig.Cainfo
  21509. pp.SecretKey = miConfig.SecretKey
  21510. pp.AccessKey = miConfig.AccessKey
  21511. pp.OpterName = curRoles.UserName
  21512. result, _ := service.Jxyb4101(struct4101, pp)
  21513. var dat map[string]interface{}
  21514. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21515. fmt.Println(dat)
  21516. } else {
  21517. fmt.Println(err)
  21518. }
  21519. userJSONBytes, _ := json.Marshal(dat)
  21520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21521. utils.ErrorLog("解析失败:%v", err)
  21522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21523. return
  21524. }
  21525. } else {
  21526. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21527. var dat map[string]interface{}
  21528. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21529. fmt.Println(dat)
  21530. } else {
  21531. fmt.Println(err)
  21532. }
  21533. userJSONBytes, _ := json.Marshal(dat)
  21534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21535. utils.ErrorLog("解析失败:%v", err)
  21536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21537. return
  21538. }
  21539. }
  21540. if res.Infcode != 0 {
  21541. c.ServeSuccessJSON(map[string]interface{}{
  21542. "failed_code": -10,
  21543. "msg": res.ErrMsg,
  21544. })
  21545. return
  21546. } else {
  21547. if miConfig.MdtrtareaAdmvs != "150499" {
  21548. order.FaPiaoNumber = zero
  21549. order.FaPiaoCode = last_order.FaPiaoCode
  21550. service.UpdateOrder(order)
  21551. }
  21552. hisFundSettleListResult := &models.HisFundSettleListResult{
  21553. Number: res.Output.SetlListId,
  21554. Status: 1,
  21555. Ctime: time.Now().Unix(),
  21556. Mtime: time.Now().Unix(),
  21557. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21558. IsUpload: 1,
  21559. OrderId: order_id,
  21560. }
  21561. service.CreateUploadRecord(hisFundSettleListResult)
  21562. c.ServeSuccessJSON(map[string]interface{}{
  21563. "msg": "上传成功",
  21564. "result": hisFundSettleListResult,
  21565. })
  21566. return
  21567. }
  21568. }
  21569. //func (c *HisApiController) GetBatchSettleList() {
  21570. // orders, _ := service.GetAllHisOrder(10106)
  21571. // for _, item := range orders {
  21572. // order_id := item.ID
  21573. // order, _ := service.GetHisOrderByIDTwo(order_id)
  21574. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21575. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  21576. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21577. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  21578. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21579. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21580. //
  21581. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  21582. //
  21583. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  21584. //
  21585. // if order.ID == 0 {
  21586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21587. // return
  21588. // }
  21589. // if his.BalanceAccountsType == 2 {
  21590. // continue
  21591. // }
  21592. // struct4101 := service.Struct4101{
  21593. // PsnNo: order.PsnNo,
  21594. // MdtrtId: order.MdtrtId,
  21595. // SetlId: order.SetlId,
  21596. // PsnName: order.PsnName,
  21597. // Gend: order.Gend,
  21598. // Brdy: his.Brdy,
  21599. // Age: his.Age,
  21600. // Naty: order.Naty,
  21601. // PatnCertType: "01",
  21602. // Certno: order.Certno,
  21603. // Prfs: "90",
  21604. // ConerName: roles[0].UserName,
  21605. // PatnRlts: "99",
  21606. // ConerAddr: miConfig.OrgName,
  21607. // ConerTel: admin.Mobile,
  21608. // HiType: order.Insutype,
  21609. // Insuplc: his.InsuplcAdmdvs,
  21610. // MaindiagFlag: "1",
  21611. // BillCode: order.SetlId,
  21612. // BillNo: order.SetlId,
  21613. // BizSn: order.Number,
  21614. // PsnSelfPay: order.PsnPartAmt,
  21615. // PsnOwnPay: order.PsnPartAmt,
  21616. // AcctPay: order.AcctPay,
  21617. // PsnCashpay: order.PsnCashPay,
  21618. // HiPaymtd: "1",
  21619. // Hsorg: his.InsuplcAdmdvs,
  21620. // HsorgOpter: his.InsuplcAdmdvs,
  21621. // MedinsFillPsn: curRoles.UserName,
  21622. // MedinsFillDept: depart.Name,
  21623. // IptMedType: "2",
  21624. // }
  21625. // struct4101.SetlBegnDate = order.SetlTime
  21626. // struct4101.SetlEndDate = order.SetlTime
  21627. // //if order.SettleType == 1 {
  21628. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  21629. // // dateStr := t.Format("2006-01-02")
  21630. // // struct4101.SetlBegnDate = dateStr
  21631. // // struct4101.SetlEndDate = dateStr
  21632. // //} else {
  21633. // // t := time.Unix(int64(order.SettleStartTime), 0)
  21634. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  21635. // // dateStartStr := t.Format("2006-01-02")
  21636. // // dateEndStr := t2.Format("2006-01-02")
  21637. // // struct4101.SetlBegnDate = dateStartStr
  21638. // // struct4101.SetlEndDate = dateEndStr
  21639. // //}
  21640. //
  21641. // var rf []CustomFundPay
  21642. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  21643. //
  21644. // var tempFunPays []service.CustomStruct
  21645. // var tempFunPay610100 service.CustomStruct
  21646. //
  21647. // for _, item := range rf {
  21648. // if item.FundPayType == "610100" {
  21649. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  21650. // tempFunPay610100.FundPayType = item.FundPayType
  21651. // } else {
  21652. // var tempFunPay service.CustomStruct
  21653. // tempFunPay.FundPayamt = item.FundPayamt
  21654. // tempFunPay.FundPayType = item.FundPayType
  21655. // tempFunPays = append(tempFunPays, tempFunPay)
  21656. // }
  21657. // }
  21658. // tempFunPays = append(tempFunPays, tempFunPay610100)
  21659. // struct4101.CustomStruct = tempFunPays
  21660. //
  21661. // var tempDiaginfos []service.DiaginfoStructTwo
  21662. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21663. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21664. //
  21665. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21666. // var config []*models.HisXtDiagnoseConfig
  21667. // for _, item := range diagnosis_ids {
  21668. // id, _ := strconv.ParseInt(item, 10, 64)
  21669. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  21670. // config = append(config, &diagnosisConfig)
  21671. // }
  21672. //
  21673. // for index, item := range config {
  21674. // if index == 0 {
  21675. // var tempDiaginfo service.DiaginfoStructTwo
  21676. // tempDiaginfo.DiagCode = item.CountryCode
  21677. // tempDiaginfo.DiagName = item.CountryContentName
  21678. // tempDiaginfo.DiagType = "1"
  21679. // tempDiaginfo.MaindiagFlag = "1"
  21680. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21681. // } else {
  21682. //
  21683. // var tempDiaginfo service.DiaginfoStructTwo
  21684. // tempDiaginfo.DiagCode = item.CountryCode
  21685. // tempDiaginfo.DiagName = item.CountryContentName
  21686. // tempDiaginfo.DiagType = "2"
  21687. // tempDiaginfo.MaindiagFlag = "0"
  21688. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21689. // }
  21690. // }
  21691. // struct4101.Diseinfo = tempDiaginfos
  21692. //
  21693. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  21694. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21695. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21696. // tempOpspdiseinfo2.OprnOprtCode = ""
  21697. // tempOpspdiseinfo2.OprnOprtName = ""
  21698. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21699. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21700. //
  21701. // var iteminfo service.IteminfoStruct
  21702. //
  21703. // var bedCostTotal float64 = 0 //床位总费
  21704. // var bedCostSelfTotal float64 = 0 //床位自费
  21705. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21706. //
  21707. // var examineCostTotal float64 = 0 //诊查总费
  21708. // var examineCostSelfTotal float64 = 0 //诊查自费
  21709. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21710. //
  21711. // var nursingCostTotal float64 = 0 //护理总费
  21712. // var nursingCostSelfTotal float64 = 0 //护理自费
  21713. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21714. //
  21715. // var chineseMedicineCostTotal float64 = 0 //中成药
  21716. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21717. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21718. //
  21719. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21720. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21721. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21722. //
  21723. // var registerCostTotal float64 = 0 //一般诊疗费
  21724. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21725. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21726. //
  21727. // var operationCostTotal float64 = 0 //手术费
  21728. // var operationCostSelfTotal float64 = 0 //手术费
  21729. // var operationCostPartSelfTotal float64 = 0 //手术费
  21730. //
  21731. // var otherCostTotal float64 = 0 //其他费用
  21732. // var otherCostSelfTotal float64 = 0 //其他费用
  21733. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21734. //
  21735. // var materialCostTotal float64 = 0 //材料费
  21736. // var materialCostSelfTotal float64 = 0 //材料费
  21737. // var materialCostPartSelfTotal float64 = 0 //材料费
  21738. //
  21739. // var westernMedicineCostTotal float64 = 0 //西药费
  21740. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21741. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21742. //
  21743. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21744. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21745. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21746. //
  21747. // var checkCostTotal float64 = 0 //检查费
  21748. // var checkCostSelfTotal float64 = 0 //检查费
  21749. // var checkCostPartSelfTotal float64 = 0 //检查费
  21750. //
  21751. // var laboratoryCostTotal float64 = 0 //化验费
  21752. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21753. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21754. //
  21755. // var treatCostTotal float64 = 0 //治疗费用
  21756. // var treatCostSelfTotal float64 = 0 //治疗费用
  21757. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21758. //
  21759. // decimal.DivisionPrecision = 2
  21760. //
  21761. // var bed_fulamt_ownpay_amt float64 = 0
  21762. //
  21763. // var examine_fulamt_ownpay_amt float64 = 0
  21764. //
  21765. // var nursing_fulamt_ownpay_amt float64 = 0
  21766. //
  21767. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21768. //
  21769. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21770. //
  21771. // var register_fulamt_ownpay_amt float64 = 0
  21772. //
  21773. // var operation_fulamt_ownpay_amt float64 = 0
  21774. // var other_fulamt_ownpay_amt float64 = 0
  21775. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21776. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21777. // var check_fulamt_ownpay_amt float64 = 0
  21778. // var material_fulamt_ownpay_amt float64 = 0
  21779. // var laboratory_fulamt_ownpay_amt float64 = 0
  21780. // var treat_fulamt_ownpay_amt float64 = 0
  21781. //
  21782. // var bed_claa_sunmfee float64 = 0
  21783. // var bed_clab_amt float64 = 0
  21784. // var bed_other_amt float64 = 0
  21785. //
  21786. // var examine_claa_sunmfee float64 = 0
  21787. // var examine_clab_amt float64 = 0
  21788. // var examine_other_amt float64 = 0
  21789. //
  21790. // var nursing_claa_sunmfee float64 = 0
  21791. // var nursing_clab_amt float64 = 0
  21792. // var nursing_other_amt float64 = 0
  21793. //
  21794. // var chinese_medicine_claa_sunmfee float64 = 0
  21795. // var chinese_medicine_clab_amt float64 = 0
  21796. // var chinese_medicine_other_amt float64 = 0
  21797. //
  21798. // var commonly_treatment_claa_sunmfee float64 = 0
  21799. // var commonly_treatment_clab_amt float64 = 0
  21800. // var commonly_treatment_other_amt float64 = 0
  21801. //
  21802. // var operation_claa_sunmfee float64 = 0
  21803. // var operation_clab_amt float64 = 0
  21804. // var operation_other_amt float64 = 0
  21805. //
  21806. // var other_claa_sunmfee float64 = 0
  21807. // var other_clab_amt float64 = 0
  21808. // var other_other_amt float64 = 0
  21809. //
  21810. // var westernMedicine_claa_sunmfee float64 = 0
  21811. // var westernMedicine_clab_amt float64 = 0
  21812. // var westernMedicine_other_amt float64 = 0
  21813. //
  21814. // var chineseTraditional_claa_sunmfee float64 = 0
  21815. // var chineseTraditional_clab_amt float64 = 0
  21816. // var chineseTraditional_other_amt float64 = 0
  21817. //
  21818. // var check_claa_sunmfee float64 = 0
  21819. // var check_clab_amt float64 = 0
  21820. // var check_other_amt float64 = 0
  21821. //
  21822. // var material_claa_sunmfee float64 = 0
  21823. // var material_clab_amt float64 = 0
  21824. // var material_other_amt float64 = 0
  21825. //
  21826. // var laboratory_claa_sunmfee float64 = 0
  21827. // var laboratory_clab_amt float64 = 0
  21828. // var laboratory_other_amt float64 = 0
  21829. //
  21830. // var treat_claa_sunmfee float64 = 0
  21831. // var treat_clab_amt float64 = 0
  21832. // var treat_other_amt float64 = 0
  21833. //
  21834. // var register_claa_sunmfee float64 = 0
  21835. // var register_clab_amt float64 = 0
  21836. // var register_other_amt float64 = 0
  21837. //
  21838. // for _, item := range order.HisOrderInfo {
  21839. // if item.MedChrgitmType == "01" { //床位费
  21840. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21841. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21842. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21843. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21844. // if item.ChrgitmLv == "1" {
  21845. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21846. // }
  21847. // if item.ChrgitmLv == "2" {
  21848. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21849. //
  21850. // }
  21851. // if item.ChrgitmLv == "3" {
  21852. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21853. // }
  21854. //
  21855. // }
  21856. //
  21857. // if item.MedChrgitmType == "02" { //诊查
  21858. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21859. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21860. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21861. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21862. // if item.ChrgitmLv == "1" {
  21863. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21864. // }
  21865. // if item.ChrgitmLv == "2" {
  21866. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21867. //
  21868. // }
  21869. // if item.ChrgitmLv == "3" {
  21870. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21871. // }
  21872. //
  21873. // }
  21874. //
  21875. // if item.MedChrgitmType == "03" { //检查费
  21876. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21877. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21878. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21879. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21880. // if item.ChrgitmLv == "1" {
  21881. //
  21882. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21883. //
  21884. // }
  21885. // if item.ChrgitmLv == "2" {
  21886. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21887. //
  21888. // }
  21889. // if item.ChrgitmLv == "3" {
  21890. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21891. // }
  21892. // }
  21893. //
  21894. // if item.MedChrgitmType == "04" { //化验费
  21895. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21896. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21897. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21898. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21899. // if item.ChrgitmLv == "1" {
  21900. //
  21901. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21902. //
  21903. // }
  21904. // if item.ChrgitmLv == "2" {
  21905. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21906. //
  21907. // }
  21908. // if item.ChrgitmLv == "3" {
  21909. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21910. // }
  21911. // }
  21912. //
  21913. // if item.MedChrgitmType == "05" { //治疗费
  21914. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21915. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21916. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21917. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21918. // if item.ChrgitmLv == "1" {
  21919. //
  21920. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21921. //
  21922. // }
  21923. // if item.ChrgitmLv == "2" {
  21924. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21925. //
  21926. // }
  21927. // if item.ChrgitmLv == "3" {
  21928. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21929. // }
  21930. // }
  21931. //
  21932. // if item.MedChrgitmType == "06" { //手术费
  21933. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21934. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21935. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21936. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21937. //
  21938. // if item.ChrgitmLv == "1" {
  21939. //
  21940. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21941. //
  21942. // }
  21943. // if item.ChrgitmLv == "2" {
  21944. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21945. //
  21946. // }
  21947. // if item.ChrgitmLv == "3" {
  21948. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21949. // }
  21950. // }
  21951. //
  21952. // if item.MedChrgitmType == "07" { //手术费
  21953. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21954. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21955. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21956. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21957. //
  21958. // if item.ChrgitmLv == "1" {
  21959. //
  21960. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21961. //
  21962. // }
  21963. // if item.ChrgitmLv == "2" {
  21964. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21965. //
  21966. // }
  21967. // if item.ChrgitmLv == "3" {
  21968. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21969. // }
  21970. // }
  21971. //
  21972. // if item.MedChrgitmType == "08" { //材料费
  21973. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21974. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21975. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21976. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21977. // if item.ChrgitmLv == "1" {
  21978. //
  21979. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21980. //
  21981. // }
  21982. // if item.ChrgitmLv == "2" {
  21983. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21984. //
  21985. // }
  21986. // if item.ChrgitmLv == "3" {
  21987. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21988. // }
  21989. // }
  21990. // if item.MedChrgitmType == "09" { //西药费
  21991. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21992. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21993. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21994. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21995. // if item.ChrgitmLv == "1" {
  21996. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21997. // }
  21998. // if item.ChrgitmLv == "2" {
  21999. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22000. // }
  22001. // if item.ChrgitmLv == "3" {
  22002. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22003. // }
  22004. // }
  22005. // if item.MedChrgitmType == "10" { //中药饮片
  22006. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22007. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22008. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22009. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22010. // if item.ChrgitmLv == "1" {
  22011. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22012. // }
  22013. // if item.ChrgitmLv == "2" {
  22014. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22015. // }
  22016. // if item.ChrgitmLv == "3" {
  22017. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22018. // }
  22019. // }
  22020. //
  22021. // if item.MedChrgitmType == "11" { //中成费
  22022. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22023. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22024. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22025. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22026. // if item.ChrgitmLv == "1" {
  22027. //
  22028. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22029. //
  22030. // }
  22031. // if item.ChrgitmLv == "2" {
  22032. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22033. //
  22034. // }
  22035. // if item.ChrgitmLv == "3" {
  22036. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22037. // }
  22038. // }
  22039. //
  22040. // if item.MedChrgitmType == "12" { //中成费
  22041. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22042. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22043. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22044. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22045. // if item.ChrgitmLv == "1" {
  22046. //
  22047. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22048. //
  22049. // }
  22050. // if item.ChrgitmLv == "2" {
  22051. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22052. //
  22053. // }
  22054. // if item.ChrgitmLv == "3" {
  22055. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22056. // }
  22057. // }
  22058. //
  22059. // if item.MedChrgitmType == "13" { //中成费
  22060. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22061. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22062. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22063. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22064. // if item.ChrgitmLv == "1" {
  22065. //
  22066. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22067. //
  22068. // }
  22069. // if item.ChrgitmLv == "2" {
  22070. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22071. //
  22072. // }
  22073. // if item.ChrgitmLv == "3" {
  22074. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22075. // }
  22076. // }
  22077. //
  22078. // if item.MedChrgitmType == "14" { //其他费
  22079. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22080. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22081. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22082. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22083. // if item.ChrgitmLv == "1" {
  22084. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22085. //
  22086. // }
  22087. // if item.ChrgitmLv == "2" {
  22088. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22089. //
  22090. // }
  22091. // if item.ChrgitmLv == "3" {
  22092. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22093. // }
  22094. // }
  22095. //
  22096. // }
  22097. //
  22098. // var iteminfoStructs []service.IteminfoStruct
  22099. //
  22100. // if bedCostTotal != 0 {
  22101. // iteminfo.MedChrgitm = "01"
  22102. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22103. // iteminfo.Amt = bedCostTotal
  22104. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  22105. // iteminfo.ClabAmt = bed_clab_amt
  22106. // iteminfo.OthAmt = bed_other_amt
  22107. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22108. // }
  22109. //
  22110. // if examineCostTotal != 0 {
  22111. // iteminfo.MedChrgitm = "02"
  22112. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  22113. // iteminfo.Amt = examineCostTotal
  22114. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  22115. // iteminfo.ClabAmt = examine_clab_amt
  22116. // iteminfo.OthAmt = examine_other_amt
  22117. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22118. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22119. // }
  22120. //
  22121. // if checkCostTotal != 0 {
  22122. // iteminfo.MedChrgitm = "03"
  22123. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  22124. // iteminfo.Amt = checkCostTotal
  22125. // iteminfo.ClaaSumfee = check_claa_sunmfee
  22126. // iteminfo.ClabAmt = check_clab_amt
  22127. // iteminfo.OthAmt = check_other_amt
  22128. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22129. //
  22130. // }
  22131. //
  22132. // if laboratoryCostTotal != 0 {
  22133. // iteminfo.MedChrgitm = "04"
  22134. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  22135. // iteminfo.Amt = laboratoryCostTotal
  22136. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  22137. // iteminfo.ClabAmt = laboratory_clab_amt
  22138. // iteminfo.OthAmt = laboratory_other_amt
  22139. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22140. //
  22141. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22142. //
  22143. // }
  22144. //
  22145. // if treatCostTotal != 0 {
  22146. // iteminfo.MedChrgitm = "05"
  22147. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  22148. // iteminfo.Amt = treatCostTotal
  22149. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  22150. // iteminfo.ClabAmt = treat_clab_amt
  22151. // iteminfo.OthAmt = treat_other_amt
  22152. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22153. // //(struct4101.IteminfoStruct, iteminfo)
  22154. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22155. // }
  22156. //
  22157. // if operationCostTotal != 0 {
  22158. // iteminfo.MedChrgitm = "06"
  22159. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22160. // iteminfo.Amt = operationCostTotal
  22161. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  22162. // iteminfo.ClabAmt = operation_clab_amt
  22163. // iteminfo.OthAmt = operation_other_amt
  22164. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22165. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22166. // }
  22167. //
  22168. // if nursingCostTotal != 0 {
  22169. // iteminfo.MedChrgitm = "07"
  22170. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  22171. // iteminfo.Amt = nursingCostTotal
  22172. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  22173. // iteminfo.ClabAmt = nursing_clab_amt
  22174. // iteminfo.OthAmt = nursing_other_amt
  22175. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22176. // }
  22177. //
  22178. // if materialCostTotal != 0 {
  22179. // iteminfo.MedChrgitm = "08"
  22180. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  22181. // iteminfo.Amt = materialCostTotal
  22182. // iteminfo.ClaaSumfee = material_claa_sunmfee
  22183. // iteminfo.ClabAmt = material_clab_amt
  22184. // iteminfo.OthAmt = material_other_amt
  22185. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22186. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22187. // }
  22188. //
  22189. // if westernMedicineCostTotal != 0 {
  22190. // iteminfo.MedChrgitm = "09"
  22191. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22192. // iteminfo.Amt = westernMedicineCostTotal
  22193. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22194. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22195. // iteminfo.OthAmt = westernMedicine_other_amt
  22196. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22197. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22198. //
  22199. // }
  22200. //
  22201. // if chineseMedicineCostTotal != 0 {
  22202. // iteminfo.MedChrgitm = "10"
  22203. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  22204. // iteminfo.Amt = chineseMedicineCostTotal
  22205. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  22206. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  22207. // iteminfo.OthAmt = chinese_medicine_other_amt
  22208. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22209. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22210. //
  22211. // }
  22212. //
  22213. // if chineseTraditionalMedicineCostTotal != 0 {
  22214. // iteminfo.MedChrgitm = "11"
  22215. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22216. // iteminfo.Amt = westernMedicineCostTotal
  22217. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22218. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22219. // iteminfo.OthAmt = westernMedicine_other_amt
  22220. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22221. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22222. //
  22223. // }
  22224. //
  22225. // if commonlyTreatmentCostTotal != 0 {
  22226. // iteminfo.MedChrgitm = "12"
  22227. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  22228. // iteminfo.Amt = commonlyTreatmentCostTotal
  22229. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  22230. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  22231. // iteminfo.OthAmt = commonly_treatment_other_amt
  22232. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22233. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22234. //
  22235. // }
  22236. //
  22237. // if registerCostTotal != 0 {
  22238. // iteminfo.MedChrgitm = "13"
  22239. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  22240. // iteminfo.Amt = registerCostTotal
  22241. // iteminfo.ClaaSumfee = register_claa_sunmfee
  22242. // iteminfo.ClabAmt = register_clab_amt
  22243. // iteminfo.OthAmt = register_other_amt
  22244. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22245. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22246. //
  22247. // }
  22248. //
  22249. // if otherCostTotal != 0 {
  22250. // iteminfo.MedChrgitm = "14"
  22251. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  22252. // iteminfo.Amt = otherCostTotal
  22253. // iteminfo.ClaaSumfee = other_claa_sunmfee
  22254. // iteminfo.ClabAmt = other_clab_amt
  22255. // iteminfo.OthAmt = other_other_amt
  22256. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22257. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22258. //
  22259. // }
  22260. // struct4101.IteminfoStruct = iteminfoStructs
  22261. // time_arr := strings.Split(order.SetlTime, " ")
  22262. // struct4101.AdmTime = time_arr[0]
  22263. // struct4101.AdmEndTime = time_arr[0]
  22264. //
  22265. // struct4101.DoctorName = doctor.UserName
  22266. // struct4101.DoctorCode = doctor.DoctorNumber
  22267. //
  22268. // struct4101.Ntly = "中国"
  22269. // struct4101.AdmCaty = "A03.06"
  22270. // var res ResultSeventeen
  22271. // if miConfig.MdtrtareaAdmvs == "421300" {
  22272. // data := make(map[string]interface{})
  22273. // data["struct4101"] = struct4101
  22274. // data["secret_key"] = miConfig.SecretKey
  22275. // data["org_name"] = miConfig.OrgName
  22276. // data["opera"] = curRoles.UserName
  22277. // data["code"] = miConfig.Code
  22278. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22279. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22280. //
  22281. // client := &http.Client{}
  22282. // bytesData, _ := json.Marshal(data)
  22283. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22284. // resp, _ := client.Do(req)
  22285. // defer resp.Body.Close()
  22286. // body, ioErr := ioutil.ReadAll(resp.Body)
  22287. // if ioErr != nil {
  22288. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22290. // return
  22291. // }
  22292. // var respJSON map[string]interface{}
  22293. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22294. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22295. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22296. // return
  22297. // }
  22298. //
  22299. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22300. // userJSONBytes, _ := json.Marshal(respJSON)
  22301. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22302. // utils.ErrorLog("解析失败:%v", err)
  22303. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22304. // adminUser := c.GetAdminUserInfo()
  22305. // errlog := &models.HisOrderError{
  22306. // UserOrgId: adminUser.CurrentOrgId,
  22307. // Ctime: time.Now().Unix(),
  22308. // Mtime: time.Now().Unix(),
  22309. // ErrMsg: res.ErrMsg + "解析失败",
  22310. // Status: 1,
  22311. // PatientId: order_id,
  22312. // Stage: 10088,
  22313. // }
  22314. // service.CreateErrMsgLog(errlog)
  22315. // continue
  22316. // }
  22317. //
  22318. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  22319. // data := make(map[string]interface{})
  22320. // data["struct4101"] = struct4101
  22321. // data["secret_key"] = miConfig.SecretKey
  22322. // data["org_name"] = miConfig.OrgName
  22323. // data["opera"] = curRoles.UserName
  22324. // data["code"] = miConfig.Code
  22325. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22326. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22327. //
  22328. // client := &http.Client{}
  22329. // bytesData, _ := json.Marshal(data)
  22330. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22331. // resp, _ := client.Do(req)
  22332. // defer resp.Body.Close()
  22333. // body, ioErr := ioutil.ReadAll(resp.Body)
  22334. // if ioErr != nil {
  22335. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22337. // return
  22338. // }
  22339. // var respJSON map[string]interface{}
  22340. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22341. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22343. // return
  22344. // }
  22345. //
  22346. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22347. // userJSONBytes, _ := json.Marshal(respJSON)
  22348. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22349. // utils.ErrorLog("解析失败:%v", err)
  22350. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22351. // adminUser := c.GetAdminUserInfo()
  22352. // errlog := &models.HisOrderError{
  22353. // UserOrgId: adminUser.CurrentOrgId,
  22354. // Ctime: time.Now().Unix(),
  22355. // Mtime: time.Now().Unix(),
  22356. // ErrMsg: res.ErrMsg + "解析失败",
  22357. // Status: 1,
  22358. // PatientId: order_id,
  22359. // Stage: 10088,
  22360. // }
  22361. // service.CreateErrMsgLog(errlog)
  22362. // continue
  22363. // }
  22364. //
  22365. // } else {
  22366. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  22367. // fmt.Println(result)
  22368. //
  22369. // var dat map[string]interface{}
  22370. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22371. // fmt.Println(dat)
  22372. // } else {
  22373. // fmt.Println(err)
  22374. // }
  22375. // userJSONBytes, _ := json.Marshal(dat)
  22376. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22377. // utils.ErrorLog("解析失败:%v", err)
  22378. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22379. // adminUser := c.GetAdminUserInfo()
  22380. // errlog := &models.HisOrderError{
  22381. // UserOrgId: adminUser.CurrentOrgId,
  22382. // Ctime: time.Now().Unix(),
  22383. // Mtime: time.Now().Unix(),
  22384. // ErrMsg: res.ErrMsg + "解析失败",
  22385. // Status: 1,
  22386. // PatientId: order_id,
  22387. // Stage: 10106,
  22388. // }
  22389. // service.CreateErrMsgLog(errlog)
  22390. // continue
  22391. // }
  22392. // }
  22393. //
  22394. // if res.Infcode != 0 {
  22395. // adminUser := c.GetAdminUserInfo()
  22396. // errlog := &models.HisOrderError{
  22397. // UserOrgId: adminUser.CurrentOrgId,
  22398. // Ctime: time.Now().Unix(),
  22399. // Mtime: time.Now().Unix(),
  22400. // ErrMsg: res.ErrMsg,
  22401. // Status: 1,
  22402. // PatientId: order_id,
  22403. // Stage: 10106,
  22404. // }
  22405. // service.CreateErrMsgLog(errlog)
  22406. // continue
  22407. // } else {
  22408. // hisFundSettleListResult := &models.HisFundSettleListResult{
  22409. // Number: res.Output.SetlListId,
  22410. // Status: 1,
  22411. // Ctime: time.Now().Unix(),
  22412. // Mtime: time.Now().Unix(),
  22413. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  22414. // IsUpload: 1,
  22415. // OrderId: order_id,
  22416. // }
  22417. // service.CreateUploadRecord(hisFundSettleListResult)
  22418. // continue
  22419. // }
  22420. // }
  22421. //}
  22422. func (c *HisApiController) GetOrgInfo() {
  22423. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  22424. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  22425. }
  22426. func (c *HisApiController) GetHisPatientInfo() {
  22427. medical_insurance_card := c.GetString("medical_insurance_card")
  22428. id_card_type, _ := c.GetInt64("id_card_type")
  22429. id_card := c.GetString("id_card")
  22430. adminInfo := c.GetAdminUserInfo()
  22431. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22432. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22433. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  22434. IdCardNo := ""
  22435. if id_card_type == 1 {
  22436. IdCardNo = medical_insurance_card
  22437. } else if id_card_type == 2 {
  22438. IdCardNo = id_card
  22439. }
  22440. if config.IsOpen == 1 {
  22441. 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
  22442. resp, requestErr := http.Get(api)
  22443. if requestErr != nil {
  22444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22445. return
  22446. }
  22447. defer resp.Body.Close()
  22448. body, ioErr := ioutil.ReadAll(resp.Body)
  22449. if ioErr != nil {
  22450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22452. return
  22453. }
  22454. var respJSON map[string]interface{}
  22455. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22458. return
  22459. }
  22460. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22461. userJSONBytes, _ := json.Marshal(userJSON)
  22462. var res ResultTwo
  22463. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22464. utils.ErrorLog("解析失败:%v", err)
  22465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22466. return
  22467. }
  22468. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22469. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22470. infoStr := string(Iinfos)
  22471. idetinfoStr := string(Idetinfos)
  22472. if res.Infcode == 0 {
  22473. his := models.VMHisPatient{
  22474. Status: 1,
  22475. Ctime: time.Now().Unix(),
  22476. Mtime: time.Now().Unix(),
  22477. PsnNo: res.Output.Baseinfo.PsnNo,
  22478. PsnCertType: res.Output.Baseinfo.PsnCertType,
  22479. Certno: res.Output.Baseinfo.Certno,
  22480. PsnName: res.Output.Baseinfo.PsnName,
  22481. Gend: res.Output.Baseinfo.Gend,
  22482. Naty: res.Output.Baseinfo.Naty,
  22483. Iinfo: infoStr,
  22484. Idetinfo: idetinfoStr,
  22485. UserOrgId: adminInfo.CurrentOrgId,
  22486. IsReturn: 1,
  22487. IdCardType: id_card_type,
  22488. }
  22489. c.ServeSuccessJSON(map[string]interface{}{
  22490. "info": his,
  22491. })
  22492. } else {
  22493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  22494. return
  22495. }
  22496. }
  22497. }
  22498. //func GetBasBaseInfo() (jsonStr string, err error) {
  22499. //
  22500. // handle := syscall.NewLazyDLL("SSCard.dll")
  22501. // add := handle.NewProc("ReadCardBas")
  22502. // str := make([]byte, 1024)
  22503. // str1 := make([]byte, 1024)
  22504. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22505. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  22506. //
  22507. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  22508. //
  22509. // fmt.Println("> Add(4,5)的结果为:", ret)
  22510. // handle.Release()
  22511. //
  22512. // return "", nil
  22513. //
  22514. //}
  22515. //func GetQRBaseInfo() (jsonStr string, err error) {
  22516. // handle := syscall.LoadDLL("SSCard.dll")
  22517. // ReadCardBas := handle.FindProc("GetQRBase")
  22518. //
  22519. // str := make([]byte, 256)
  22520. // str1 := make([]byte, 256)
  22521. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22522. //
  22523. // fmt.Println(string(str))
  22524. // fmt.Println(r)
  22525. // return string(str), nil
  22526. //}
  22527. //func CardInit() int {
  22528. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  22529. // add := DllTestDef.MustFindProc("Init")
  22530. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22531. // if err != nil {
  22532. // fmt.Println("SSCard的运算结果为:", ret)
  22533. // }
  22534. // result := int(ret)
  22535. // return result
  22536. //}
  22537. //func CardInit() int {
  22538. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22539. // if err != nil {
  22540. // fmt.Println("SSCard的运算结果为:", ret)
  22541. // }
  22542. // fmt.Println(err)
  22543. // result := int(ret)
  22544. // return result
  22545. //}
  22546. func IntPtr(n int) uintptr {
  22547. return uintptr(n)
  22548. }
  22549. func StrPtr(s string) uintptr {
  22550. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  22551. }
  22552. type Result2001 struct {
  22553. Cainfo interface{} `json:"cainfo"`
  22554. ErrMsg string `json:"err_msg"`
  22555. InfRefmsgid string `json:"inf_refmsgid"`
  22556. Infcode int64 `json:"infcode"`
  22557. Output struct {
  22558. Trtinfo struct {
  22559. PsnNo string `json:"psn_no"`
  22560. TrtChkType string `json:"trt_chk_type"`
  22561. FundPayType string `json:"fund_pay_type"`
  22562. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22563. Begndate string `json:"begndate"`
  22564. Enddate string `json:"enddate"`
  22565. TrtChkRslt string `json:"trt_chk_rslt"`
  22566. } `json:"trtinfo"`
  22567. } `json:"output"`
  22568. RefmsgTime string `json:"refmsg_time"`
  22569. RespondTime string `json:"respond_time"`
  22570. Signtype interface{} `json:"signtype"`
  22571. WarnMsg interface{} `json:"warn_msg"`
  22572. }
  22573. type Result2001Org10265 struct {
  22574. Cainfo interface{} `json:"cainfo"`
  22575. ErrMsg string `json:"err_msg"`
  22576. InfRefmsgid string `json:"inf_refmsgid"`
  22577. Infcode string `json:"infcode"`
  22578. Output struct {
  22579. Trtinfo struct {
  22580. PsnNo string `json:"psn_no"`
  22581. TrtChkType string `json:"trt_chk_type"`
  22582. FundPayType string `json:"fund_pay_type"`
  22583. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22584. Begndate string `json:"begndate"`
  22585. Enddate string `json:"enddate"`
  22586. TrtChkRslt string `json:"trt_chk_rslt"`
  22587. } `json:"trtinfo"`
  22588. } `json:"output"`
  22589. RefmsgTime string `json:"refmsg_time"`
  22590. RespondTime string `json:"respond_time"`
  22591. Signtype interface{} `json:"signtype"`
  22592. WarnMsg interface{} `json:"warn_msg"`
  22593. }
  22594. type ResultTwo struct {
  22595. ErrMsg string `json:"err_msg"`
  22596. InfRefmsgid string `json:"inf_refmsgid"`
  22597. Infcode int64 `json:"infcode"`
  22598. Output struct {
  22599. Baseinfo struct {
  22600. //Brdy string `json:"brdy"`
  22601. Certno string `json:"certno"`
  22602. Gend string `json:"gend"`
  22603. Naty string `json:"naty"`
  22604. PsnCertType string `json:"psn_cert_type"`
  22605. PsnName string `json:"psn_name"`
  22606. PsnNo string `json:"psn_no"`
  22607. } `json:"baseinfo"`
  22608. Idetinfo []interface{} `json:"idetinfo"`
  22609. Iinfo []struct {
  22610. Balc float64 `json:"balc"`
  22611. CvlservFlag string `json:"cvlserv_flag"`
  22612. EmpName string `json:"emp_name"`
  22613. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22614. Insutype string `json:"insutype"`
  22615. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22616. //PausInsuDate string `json:"paus_insu_date"`
  22617. //PsnInsuDate string `json:"psn_insu_date"`
  22618. PsnInsuStas string `json:"psn_insu_stas"`
  22619. PsnType string `json:"psn_type"`
  22620. } `json:"insuinfo"`
  22621. } `json:"output"`
  22622. RefmsgTime string `json:"refmsg_time"`
  22623. RespondTime string `json:"respond_time"`
  22624. Signtype interface{} `json:"signtype"`
  22625. WarnInfo interface{} `json:"warn_info"`
  22626. }
  22627. type ResultTwo10265 struct {
  22628. ErrMsg string `json:"err_msg"`
  22629. InfRefmsgid string `json:"inf_refmsgid"`
  22630. Infcode string `json:"infcode"`
  22631. Output struct {
  22632. Baseinfo struct {
  22633. //Brdy string `json:"brdy"`
  22634. Certno string `json:"certno"`
  22635. Gend string `json:"gend"`
  22636. Naty string `json:"naty"`
  22637. PsnCertType string `json:"psn_cert_type"`
  22638. PsnName string `json:"psn_name"`
  22639. PsnNo string `json:"psn_no"`
  22640. } `json:"baseinfo"`
  22641. Idetinfo []interface{} `json:"idetinfo"`
  22642. Iinfo []struct {
  22643. Balc float64 `json:"balc"`
  22644. CvlservFlag string `json:"cvlserv_flag"`
  22645. EmpName string `json:"emp_name"`
  22646. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22647. Insutype string `json:"insutype"`
  22648. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22649. PsnInsuStas string `json:"psn_insu_stas"`
  22650. PsnType string `json:"psn_type"`
  22651. } `json:"insuinfo"`
  22652. } `json:"output"`
  22653. RefmsgTime string `json:"refmsg_time"`
  22654. RespondTime string `json:"respond_time"`
  22655. Signtype interface{} `json:"signtype"`
  22656. WarnInfo interface{} `json:"warn_info"`
  22657. }
  22658. type ResultThree struct {
  22659. Cainfo interface{} `json:"cainfo"`
  22660. ErrMsg string `json:"err_msg"`
  22661. InfRefmsgid string `json:"inf_refmsgid"`
  22662. Infcode int64 `json:"infcode"`
  22663. Output struct {
  22664. Data struct {
  22665. IptOtpNo string `json:"ipt_otp_no"`
  22666. MdtrtID string `json:"mdtrt_id"`
  22667. PsnNo string `json:"psn_no"`
  22668. } `json:"data"`
  22669. } `json:"output"`
  22670. RefmsgTime string `json:"refmsg_time"`
  22671. RespondTime string `json:"respond_time"`
  22672. Signtype interface{} `json:"signtype"`
  22673. WarnMsg interface{} `json:"warn_msg"`
  22674. }
  22675. type ResultThree10265 struct {
  22676. Cainfo interface{} `json:"cainfo"`
  22677. ErrMsg string `json:"err_msg"`
  22678. InfRefmsgid string `json:"inf_refmsgid"`
  22679. Infcode string `json:"infcode"`
  22680. Output struct {
  22681. Data struct {
  22682. IptOtpNo string `json:"ipt_otp_no"`
  22683. MdtrtID string `json:"mdtrt_id"`
  22684. PsnNo string `json:"psn_no"`
  22685. } `json:"data"`
  22686. } `json:"output"`
  22687. RefmsgTime string `json:"refmsg_time"`
  22688. RespondTime string `json:"respond_time"`
  22689. Signtype interface{} `json:"signtype"`
  22690. WarnMsg interface{} `json:"warn_msg"`
  22691. }
  22692. type ResultFour struct {
  22693. Cainfo string `json:"cainfo"`
  22694. ErrMsg string `json:"err_msg"`
  22695. InfRefmsgid string `json:"inf_refmsgid"`
  22696. Infcode int64 `json:"infcode"`
  22697. Output struct {
  22698. Result []struct {
  22699. BasMednFlag string `json:"bas_medn_flag"`
  22700. ChldMedcFlag string `json:"chld_medc_flag"`
  22701. ChrgitmLv string `json:"chrgitm_lv"`
  22702. Cnt float64 `json:"cnt"`
  22703. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22704. DrtReimFlag string `json:"drt_reim_flag"`
  22705. FeedetlSn string `json:"feedetl_sn"`
  22706. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22707. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22708. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22709. ListSpItemFlag string `json:"list_sp_item_flag"`
  22710. LmtUsedFlag string `json:"lmt_used_flag"`
  22711. MedChrgitmType string `json:"med_chrgitm_type"`
  22712. Memo string `json:"memo"`
  22713. OverlmtAmt float64 `json:"overlmt_amt"`
  22714. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22715. Pric float64 `json:"pric"`
  22716. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22717. SelfpayProp float64 `json:"selfpay_prop"`
  22718. } `json:"result"`
  22719. } `json:"output"`
  22720. RefmsgTime string `json:"refmsg_time"`
  22721. RespondTime string `json:"respond_time"`
  22722. Signtype string `json:"signtype"`
  22723. WarnMsg string `json:"warn_msg"`
  22724. }
  22725. type ResultFour10265 struct {
  22726. Cainfo string `json:"cainfo"`
  22727. ErrMsg string `json:"err_msg"`
  22728. InfRefmsgid string `json:"inf_refmsgid"`
  22729. Infcode string `json:"infcode"`
  22730. Output struct {
  22731. Result []struct {
  22732. BasMednFlag string `json:"bas_medn_flag"`
  22733. ChldMedcFlag string `json:"chld_medc_flag"`
  22734. ChrgitmLv string `json:"chrgitm_lv"`
  22735. Cnt float64 `json:"cnt"`
  22736. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22737. DrtReimFlag string `json:"drt_reim_flag"`
  22738. FeedetlSn string `json:"feedetl_sn"`
  22739. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22740. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22741. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22742. ListSpItemFlag string `json:"list_sp_item_flag"`
  22743. LmtUsedFlag string `json:"lmt_used_flag"`
  22744. MedChrgitmType string `json:"med_chrgitm_type"`
  22745. Memo string `json:"memo"`
  22746. OverlmtAmt float64 `json:"overlmt_amt"`
  22747. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22748. Pric float64 `json:"pric"`
  22749. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22750. SelfpayProp float64 `json:"selfpay_prop"`
  22751. } `json:"result"`
  22752. } `json:"output"`
  22753. RefmsgTime string `json:"refmsg_time"`
  22754. RespondTime string `json:"respond_time"`
  22755. Signtype string `json:"signtype"`
  22756. WarnMsg string `json:"warn_msg"`
  22757. }
  22758. type ResultMemo struct {
  22759. InsuAdmdvs string `json:"insuAdmdvs"`
  22760. }
  22761. // [{"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}]
  22762. type ResultIDInfo struct {
  22763. Begntime string `json:"begntime"`
  22764. Endtime string `json:"endtime"`
  22765. Memo string `json:"memo"`
  22766. }
  22767. type ResultFive struct {
  22768. Balc float64 `json:"balc"`
  22769. CvlservFlag string `json:"cvlserv_flag"`
  22770. EmpName string `json:"emp_name"`
  22771. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22772. Insutype string `json:"insutype"`
  22773. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22774. PausInsuDate string `json:"paus_insu_date"`
  22775. PsnInsuDate string `json:"psn_insu_date"`
  22776. PsnInsuStas string `json:"psn_insu_stas"`
  22777. PsnType string `json:"psn_type"`
  22778. }
  22779. type ResultSix struct {
  22780. Cainfo interface{} `json:"cainfo"`
  22781. ErrMsg string `json:"err_msg"`
  22782. InfRefmsgid string `json:"inf_refmsgid"`
  22783. Infcode int64 `json:"infcode"`
  22784. Output struct {
  22785. } `json:"output"`
  22786. RefmsgTime string `json:"refmsg_time"`
  22787. RespondTime string `json:"respond_time"`
  22788. Signtype interface{} `json:"signtype"`
  22789. WarnMsg interface{} `json:"warn_msg"`
  22790. }
  22791. type ResultSix3103 struct {
  22792. Cainfo interface{} `json:"cainfo"`
  22793. ErrMsg string `json:"err_msg"`
  22794. InfRefmsgid string `json:"inf_refmsgid"`
  22795. Infcode int64 `json:"infcode"`
  22796. RefmsgTime string `json:"refmsg_time"`
  22797. RespondTime string `json:"respond_time"`
  22798. Signtype interface{} `json:"signtype"`
  22799. WarnMsg interface{} `json:"warn_msg"`
  22800. }
  22801. type FJ3507Result struct {
  22802. Cainfo interface{} `json:"cainfo"`
  22803. ErrMsg string `json:"err_msg"`
  22804. InfRefmsgid string `json:"inf_refmsgid"`
  22805. Infcode int64 `json:"infcode"`
  22806. Output struct {
  22807. retRslt string `json:"retRslt"`
  22808. msgRslt string `json:"msgRslt"`
  22809. } `json:"output"`
  22810. RefmsgTime string `json:"refmsg_time"`
  22811. RespondTime string `json:"respond_time"`
  22812. Signtype interface{} `json:"signtype"`
  22813. WarnMsg interface{} `json:"warn_msg"`
  22814. }
  22815. type FJ3507ResultFor10188 struct {
  22816. Cainfo interface{} `json:"cainfo"`
  22817. ErrMsg string `json:"err_msg"`
  22818. InfRefmsgid string `json:"inf_refmsgid"`
  22819. Infcode string `json:"infcode"`
  22820. RefmsgTime string `json:"refmsg_time"`
  22821. RespondTime string `json:"respond_time"`
  22822. Signtype interface{} `json:"signtype"`
  22823. WarnMsg interface{} `json:"warn_msg"`
  22824. }
  22825. type Result2406 struct {
  22826. Cainfo interface{} `json:"cainfo"`
  22827. ErrMsg string `json:"err_msg"`
  22828. InfRefmsgid string `json:"inf_refmsgid"`
  22829. Infcode int64 `json:"infcode"`
  22830. Output struct {
  22831. Result struct {
  22832. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22833. } `json:"result"`
  22834. } `json:"output"`
  22835. RefmsgTime string `json:"refmsg_time"`
  22836. RespondTime string `json:"respond_time"`
  22837. Signtype interface{} `json:"signtype"`
  22838. WarnMsg interface{} `json:"warn_msg"`
  22839. }
  22840. type GZResultSix struct {
  22841. Cainfo interface{} `json:"cainfo"`
  22842. ErrMsg string `json:"err_msg"`
  22843. InfRefmsgid string `json:"inf_refmsgid"`
  22844. Infcode int64 `json:"infcode"`
  22845. Output string `json:"output"`
  22846. RefmsgTime string `json:"refmsg_time"`
  22847. RespondTime string `json:"respond_time"`
  22848. Signtype interface{} `json:"signtype"`
  22849. WarnMsg interface{} `json:"warn_msg"`
  22850. }
  22851. type ResultSix10265 struct {
  22852. Cainfo interface{} `json:"cainfo"`
  22853. ErrMsg string `json:"err_msg"`
  22854. InfRefmsgid string `json:"inf_refmsgid"`
  22855. Infcode string `json:"infcode"`
  22856. Output struct {
  22857. } `json:"output"`
  22858. RefmsgTime string `json:"refmsg_time"`
  22859. RespondTime string `json:"respond_time"`
  22860. Signtype interface{} `json:"signtype"`
  22861. WarnMsg interface{} `json:"warn_msg"`
  22862. }
  22863. type ResultSeven struct {
  22864. Cainfo string `json:"cainfo"`
  22865. ErrMsg string `json:"err_msg"`
  22866. InfRefmsgid string `json:"inf_refmsgid"`
  22867. Infcode int64 `json:"infcode"`
  22868. Output struct {
  22869. Setlinfo struct {
  22870. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22871. AcctPay float64 `json:"acct_pay"`
  22872. ActPayDedc float64 `json:"act_pay_dedc"`
  22873. Age float64 `json:"age"`
  22874. Balc float64 `json:"balc"`
  22875. Certno string `json:"certno"`
  22876. ClrOptins string `json:"clr_optins"`
  22877. ClrType string `json:"clr_type"`
  22878. ClrWay string `json:"clr_way"`
  22879. CvlservFlag string `json:"cvlserv_flag"`
  22880. CvlservPay float64 `json:"cvlserv_pay"`
  22881. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22882. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22883. Gend string `json:"gend"`
  22884. HifesPay float64 `json:"hifes_pay"`
  22885. HifmiPay float64 `json:"hifmi_pay"`
  22886. HifpPay float64 `json:"hifp_pay"`
  22887. HospPartAmt float64 `json:"hosp_part_amt"`
  22888. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22889. Insutype string `json:"insutype"`
  22890. MafPay float64 `json:"maf_pay"`
  22891. MdtrtCertType string `json:"mdtrt_cert_type"`
  22892. HifobPay float64 `json:"hifob_pay"`
  22893. MdtrtID string `json:"mdtrt_id"`
  22894. MedType string `json:"med_type"`
  22895. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22896. MedinsSetlID string `json:"medins_setl_id"`
  22897. Naty string `json:"naty"`
  22898. OthPay float64 `json:"oth_pay"`
  22899. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22900. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22901. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22902. PsnCashPay float64 `json:"psn_cash_pay"`
  22903. PsnCertType string `json:"psn_cert_type"`
  22904. PsnName string `json:"psn_name"`
  22905. PsnNo string `json:"psn_no"`
  22906. PsnPartAmt float64 `json:"psn_part_amt"`
  22907. PsnType string `json:"psn_type"`
  22908. SetlID string `json:"setl_id"`
  22909. SetlTime string `json:"setl_time"`
  22910. } `json:"setlinfo"`
  22911. Setldetail interface{} `json:"setldetail"`
  22912. } `json:"output"`
  22913. RefmsgTime string `json:"refmsg_time"`
  22914. RespondTime string `json:"respond_time"`
  22915. Signtype interface{} `json:"signtype"`
  22916. WarnMsg interface{} `json:"warn_msg"`
  22917. }
  22918. type ResultSevenAH struct {
  22919. Cainfo string `json:"cainfo"`
  22920. ErrMsg string `json:"err_msg"`
  22921. InfRefmsgid string `json:"inf_refmsgid"`
  22922. Infcode int64 `json:"infcode"`
  22923. Output struct {
  22924. Setlinfo struct {
  22925. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22926. AcctPay float64 `json:"acct_pay"`
  22927. ActPayDedc float64 `json:"act_pay_dedc"`
  22928. Age float64 `json:"age"`
  22929. Balc float64 `json:"balc"`
  22930. Certno string `json:"certno"`
  22931. ClrOptins string `json:"clr_optins"`
  22932. ClrType string `json:"clr_type"`
  22933. ClrWay string `json:"clr_way"`
  22934. CvlservFlag string `json:"cvlserv_flag"`
  22935. CvlservPay float64 `json:"cvlserv_pay"`
  22936. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22937. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22938. Gend string `json:"gend"`
  22939. HifesPay float64 `json:"hifes_pay"`
  22940. HifmiPay float64 `json:"hifmi_pay"`
  22941. HifpPay float64 `json:"hifp_pay"`
  22942. HospPartAmt float64 `json:"hosp_part_amt"`
  22943. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22944. Insutype string `json:"insutype"`
  22945. MafPay float64 `json:"maf_pay"`
  22946. MdtrtCertType string `json:"mdtrt_cert_type"`
  22947. HifobPay float64 `json:"hifob_pay"`
  22948. MdtrtID string `json:"mdtrt_id"`
  22949. MedType string `json:"med_type"`
  22950. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22951. MedinsSetlID string `json:"medins_setl_id"`
  22952. Naty string `json:"naty"`
  22953. OthPay float64 `json:"oth_pay"`
  22954. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22955. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22956. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22957. PsnCashPay float64 `json:"psn_cash_pay"`
  22958. PsnCertType string `json:"psn_cert_type"`
  22959. PsnName string `json:"psn_name"`
  22960. PsnNo string `json:"psn_no"`
  22961. PsnPartAmt float64 `json:"psn_part_amt"`
  22962. PsnType string `json:"psn_type"`
  22963. SetlID string `json:"setl_id"`
  22964. SetlTime int64 `json:"setl_time"`
  22965. } `json:"setlinfo"`
  22966. Setldetail interface{} `json:"setldetail"`
  22967. } `json:"output"`
  22968. RefmsgTime string `json:"refmsg_time"`
  22969. RespondTime string `json:"respond_time"`
  22970. Signtype interface{} `json:"signtype"`
  22971. WarnMsg interface{} `json:"warn_msg"`
  22972. }
  22973. type ResultSeven10265 struct {
  22974. Cainfo string `json:"cainfo"`
  22975. ErrMsg string `json:"err_msg"`
  22976. InfRefmsgid string `json:"inf_refmsgid"`
  22977. Infcode string `json:"infcode"`
  22978. Output struct {
  22979. Setlinfo struct {
  22980. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22981. AcctPay float64 `json:"acct_pay"`
  22982. ActPayDedc float64 `json:"act_pay_dedc"`
  22983. Age float64 `json:"age"`
  22984. Balc float64 `json:"balc"`
  22985. Certno string `json:"certno"`
  22986. ClrOptins string `json:"clr_optins"`
  22987. ClrType string `json:"clr_type"`
  22988. ClrWay string `json:"clr_way"`
  22989. CvlservFlag string `json:"cvlserv_flag"`
  22990. CvlservPay float64 `json:"cvlserv_pay"`
  22991. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22992. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22993. Gend string `json:"gend"`
  22994. HifesPay float64 `json:"hifes_pay"`
  22995. HifmiPay float64 `json:"hifmi_pay"`
  22996. HifpPay float64 `json:"hifp_pay"`
  22997. HospPartAmt float64 `json:"hosp_part_amt"`
  22998. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22999. Insutype string `json:"insutype"`
  23000. MafPay float64 `json:"maf_pay"`
  23001. MdtrtCertType string `json:"mdtrt_cert_type"`
  23002. HifobPay float64 `json:"hifob_pay"`
  23003. MdtrtID string `json:"mdtrt_id"`
  23004. MedType string `json:"med_type"`
  23005. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23006. MedinsSetlID string `json:"medins_setl_id"`
  23007. Naty string `json:"naty"`
  23008. OthPay float64 `json:"oth_pay"`
  23009. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23010. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23011. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23012. PsnCashPay float64 `json:"psn_cash_pay"`
  23013. PsnCertType string `json:"psn_cert_type"`
  23014. PsnName string `json:"psn_name"`
  23015. PsnNo string `json:"psn_no"`
  23016. PsnPartAmt float64 `json:"psn_part_amt"`
  23017. PsnType string `json:"psn_type"`
  23018. SetlID string `json:"setl_id"`
  23019. SetlTime string `json:"setl_time"`
  23020. } `json:"setlinfo"`
  23021. Setldetail interface{} `json:"setldetail"`
  23022. } `json:"output"`
  23023. RefmsgTime string `json:"refmsg_time"`
  23024. RespondTime string `json:"respond_time"`
  23025. Signtype interface{} `json:"signtype"`
  23026. WarnMsg interface{} `json:"warn_msg"`
  23027. }
  23028. type ResultSeven10265Two struct {
  23029. Cainfo string `json:"cainfo"`
  23030. ErrMsg string `json:"err_msg"`
  23031. InfRefmsgid string `json:"inf_refmsgid"`
  23032. Infcode string `json:"infcode"`
  23033. Output struct {
  23034. Setlinfo struct {
  23035. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23036. AcctPay float64 `json:"acct_pay"`
  23037. ActPayDedc float64 `json:"act_pay_dedc"`
  23038. Age float64 `json:"age"`
  23039. Balc float64 `json:"balc"`
  23040. Certno string `json:"certno"`
  23041. ClrOptins string `json:"clr_optins"`
  23042. ClrType string `json:"clr_type"`
  23043. ClrWay string `json:"clr_way"`
  23044. CvlservFlag string `json:"cvlserv_flag"`
  23045. CvlservPay float64 `json:"cvlserv_pay"`
  23046. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23047. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23048. Gend string `json:"gend"`
  23049. HifesPay float64 `json:"hifes_pay"`
  23050. HifmiPay float64 `json:"hifmi_pay"`
  23051. HifpPay float64 `json:"hifp_pay"`
  23052. HospPartAmt string `json:"hosp_part_amt"`
  23053. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23054. Insutype string `json:"insutype"`
  23055. MafPay float64 `json:"maf_pay"`
  23056. MdtrtCertType string `json:"mdtrt_cert_type"`
  23057. HifobPay float64 `json:"hifob_pay"`
  23058. MdtrtID string `json:"mdtrt_id"`
  23059. MedType string `json:"med_type"`
  23060. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23061. MedinsSetlID string `json:"medins_setl_id"`
  23062. Naty string `json:"naty"`
  23063. OthPay float64 `json:"oth_pay"`
  23064. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23065. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23066. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23067. PsnCashPay float64 `json:"psn_cash_pay"`
  23068. PsnCertType string `json:"psn_cert_type"`
  23069. PsnName string `json:"psn_name"`
  23070. PsnNo string `json:"psn_no"`
  23071. PsnPartAmt float64 `json:"psn_part_amt"`
  23072. PsnType string `json:"psn_type"`
  23073. SetlID string `json:"setl_id"`
  23074. SetlTime string `json:"setl_time"`
  23075. } `json:"setlinfo"`
  23076. Setldetail interface{} `json:"setldetail"`
  23077. } `json:"output"`
  23078. RefmsgTime string `json:"refmsg_time"`
  23079. RespondTime string `json:"respond_time"`
  23080. Signtype interface{} `json:"signtype"`
  23081. WarnMsg interface{} `json:"warn_msg"`
  23082. }
  23083. type ResultSeven10633Two struct {
  23084. Cainfo string `json:"cainfo"`
  23085. ErrMsg string `json:"err_msg"`
  23086. InfRefmsgid string `json:"inf_refmsgid"`
  23087. Infcode string `json:"infcode"`
  23088. Output struct {
  23089. Setlinfo struct {
  23090. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23091. AcctPay float64 `json:"acct_pay"`
  23092. ActPayDedc float64 `json:"act_pay_dedc"`
  23093. Age float64 `json:"age"`
  23094. Balc float64 `json:"balc"`
  23095. Certno string `json:"certno"`
  23096. ClrOptins string `json:"clr_optins"`
  23097. ClrType string `json:"clr_type"`
  23098. ClrWay string `json:"clr_way"`
  23099. CvlservFlag string `json:"cvlserv_flag"`
  23100. CvlservPay float64 `json:"cvlserv_pay"`
  23101. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23102. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23103. Gend string `json:"gend"`
  23104. HifesPay float64 `json:"hifes_pay"`
  23105. HifmiPay float64 `json:"hifmi_pay"`
  23106. HifpPay float64 `json:"hifp_pay"`
  23107. HospPartAmt float64 `json:"hosp_part_amt"`
  23108. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23109. Insutype string `json:"insutype"`
  23110. MafPay float64 `json:"maf_pay"`
  23111. MdtrtCertType string `json:"mdtrt_cert_type"`
  23112. HifobPay float64 `json:"hifob_pay"`
  23113. MdtrtID string `json:"mdtrt_id"`
  23114. MedType string `json:"med_type"`
  23115. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23116. MedinsSetlID string `json:"medins_setl_id"`
  23117. Naty string `json:"naty"`
  23118. OthPay float64 `json:"oth_pay"`
  23119. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23120. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23121. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23122. PsnCashPay float64 `json:"psn_cash_pay"`
  23123. PsnCertType string `json:"psn_cert_type"`
  23124. PsnName string `json:"psn_name"`
  23125. PsnNo string `json:"psn_no"`
  23126. PsnPartAmt float64 `json:"psn_part_amt"`
  23127. PsnType string `json:"psn_type"`
  23128. SetlID string `json:"setl_id"`
  23129. SetlTime string `json:"setl_time"`
  23130. } `json:"setlinfo"`
  23131. Setldetail interface{} `json:"setldetail"`
  23132. } `json:"output"`
  23133. RefmsgTime string `json:"refmsg_time"`
  23134. RespondTime string `json:"respond_time"`
  23135. Signtype interface{} `json:"signtype"`
  23136. WarnMsg interface{} `json:"warn_msg"`
  23137. }
  23138. type ResultSeven10633Three struct {
  23139. Cainfo string `json:"cainfo"`
  23140. ErrMsg string `json:"err_msg"`
  23141. InfRefmsgid string `json:"inf_refmsgid"`
  23142. Infcode string `json:"infcode"`
  23143. Output struct {
  23144. Setlinfo struct {
  23145. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23146. AcctPay float64 `json:"acct_pay"`
  23147. ActPayDedc float64 `json:"act_pay_dedc"`
  23148. Age float64 `json:"age"`
  23149. Balc float64 `json:"balc"`
  23150. Certno string `json:"certno"`
  23151. ClrOptins string `json:"clr_optins"`
  23152. ClrType string `json:"clr_type"`
  23153. ClrWay string `json:"clr_way"`
  23154. CvlservFlag string `json:"cvlserv_flag"`
  23155. CvlservPay float64 `json:"cvlserv_pay"`
  23156. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23157. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23158. Gend string `json:"gend"`
  23159. HifesPay float64 `json:"hifes_pay"`
  23160. HifmiPay float64 `json:"hifmi_pay"`
  23161. HifpPay float64 `json:"hifp_pay"`
  23162. HospPartAmt string `json:"hosp_part_amt"`
  23163. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23164. Insutype string `json:"insutype"`
  23165. MafPay float64 `json:"maf_pay"`
  23166. MdtrtCertType string `json:"mdtrt_cert_type"`
  23167. HifobPay float64 `json:"hifob_pay"`
  23168. MdtrtID string `json:"mdtrt_id"`
  23169. MedType string `json:"med_type"`
  23170. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23171. MedinsSetlID string `json:"medins_setl_id"`
  23172. Naty string `json:"naty"`
  23173. OthPay float64 `json:"oth_pay"`
  23174. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23175. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23176. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23177. PsnCashPay float64 `json:"psn_cash_pay"`
  23178. PsnCertType string `json:"psn_cert_type"`
  23179. PsnName string `json:"psn_name"`
  23180. PsnNo string `json:"psn_no"`
  23181. PsnPartAmt float64 `json:"psn_part_amt"`
  23182. PsnType string `json:"psn_type"`
  23183. SetlID string `json:"setl_id"`
  23184. SetlTime string `json:"setl_time"`
  23185. } `json:"setlinfo"`
  23186. Setldetail interface{} `json:"setldetail"`
  23187. } `json:"output"`
  23188. RefmsgTime string `json:"refmsg_time"`
  23189. RespondTime string `json:"respond_time"`
  23190. Signtype interface{} `json:"signtype"`
  23191. WarnMsg interface{} `json:"warn_msg"`
  23192. }
  23193. type GZResultSeven10265Two struct {
  23194. Cainfo string `json:"cainfo"`
  23195. ErrMsg string `json:"err_msg"`
  23196. InfRefmsgid string `json:"inf_refmsgid"`
  23197. Infcode int64 `json:"infcode"`
  23198. Output struct {
  23199. Setlinfo struct {
  23200. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23201. AcctPay float64 `json:"acct_pay"`
  23202. ActPayDedc float64 `json:"act_pay_dedc"`
  23203. Age float64 `json:"age"`
  23204. Balc float64 `json:"balc"`
  23205. Certno string `json:"certno"`
  23206. ClrOptins string `json:"clr_optins"`
  23207. ClrType string `json:"clr_type"`
  23208. ClrWay string `json:"clr_way"`
  23209. CvlservFlag string `json:"cvlserv_flag"`
  23210. CvlservPay float64 `json:"cvlserv_pay"`
  23211. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23212. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23213. Gend string `json:"gend"`
  23214. HifesPay float64 `json:"hifes_pay"`
  23215. HifmiPay float64 `json:"hifmi_pay"`
  23216. HifpPay float64 `json:"hifp_pay"`
  23217. HospPartAmt float64 `json:"hosp_part_amt"`
  23218. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23219. Insutype string `json:"insutype"`
  23220. MafPay float64 `json:"maf_pay"`
  23221. MdtrtCertType string `json:"mdtrt_cert_type"`
  23222. HifobPay float64 `json:"hifob_pay"`
  23223. MdtrtID string `json:"mdtrt_id"`
  23224. MedType string `json:"med_type"`
  23225. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23226. MedinsSetlID string `json:"medins_setl_id"`
  23227. Naty string `json:"naty"`
  23228. OthPay float64 `json:"oth_pay"`
  23229. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23230. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23231. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23232. PsnCashPay float64 `json:"psn_cash_pay"`
  23233. PsnCertType string `json:"psn_cert_type"`
  23234. PsnName string `json:"psn_name"`
  23235. PsnNo string `json:"psn_no"`
  23236. PsnPartAmt float64 `json:"psn_part_amt"`
  23237. PsnType string `json:"psn_type"`
  23238. SetlID string `json:"setl_id"`
  23239. SetlTime string `json:"setl_time"`
  23240. } `json:"setlinfo"`
  23241. Setldetail interface{} `json:"setldetail"`
  23242. } `json:"output"`
  23243. RefmsgTime string `json:"refmsg_time"`
  23244. RespondTime string `json:"respond_time"`
  23245. Signtype interface{} `json:"signtype"`
  23246. WarnMsg interface{} `json:"warn_msg"`
  23247. }
  23248. type ResultEight struct {
  23249. Cainfo string `json:"cainfo"`
  23250. ErrMsg string `json:"err_msg"`
  23251. InfRefmsgid string `json:"inf_refmsgid"`
  23252. Infcode int64 `json:"infcode"`
  23253. Output struct {
  23254. Stmtinfo struct {
  23255. SetlOptins string `json:"setl_optins"`
  23256. StmtRslt string `json:"stmt_rslt"`
  23257. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23258. } `json:"stmtinfo"`
  23259. } `json:"output"`
  23260. RefmsgTime string `json:"refmsg_time"`
  23261. RespondTime string `json:"respond_time"`
  23262. Signtype interface{} `json:"signtype"`
  23263. WarnMsg interface{} `json:"warn_msg"`
  23264. }
  23265. type ResultEightFor10188 struct {
  23266. Cainfo string `json:"cainfo"`
  23267. ErrMsg string `json:"err_msg"`
  23268. InfRefmsgid string `json:"inf_refmsgid"`
  23269. Infcode string `json:"infcode"`
  23270. Output struct {
  23271. Stmtinfo struct {
  23272. SetlOptins string `json:"setl_optins"`
  23273. StmtRslt string `json:"stmt_rslt"`
  23274. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23275. } `json:"stmtinfo"`
  23276. } `json:"output"`
  23277. RefmsgTime string `json:"refmsg_time"`
  23278. RespondTime string `json:"respond_time"`
  23279. Signtype interface{} `json:"signtype"`
  23280. WarnMsg interface{} `json:"warn_msg"`
  23281. }
  23282. type ResultNine struct {
  23283. Cainfo string `json:"cainfo"`
  23284. ErrMsg string `json:"err_msg"`
  23285. InfRefmsgid string `json:"inf_refmsgid"`
  23286. Infcode int64 `json:"infcode"`
  23287. Output struct {
  23288. FileQuryNo string `json:"file_qury_no"`
  23289. } `json:"output"`
  23290. RefmsgTime string `json:"refmsg_time"`
  23291. RespondTime string `json:"respond_time"`
  23292. Signtype interface{} `json:"signtype"`
  23293. WarnMsg interface{} `json:"warn_msg"`
  23294. }
  23295. type ResultTen struct {
  23296. Cainfo string `json:"cainfo"`
  23297. ErrMsg string `json:"err_msg"`
  23298. InfRefmsgid string `json:"inf_refmsgid"`
  23299. Infcode int64 `json:"infcode"`
  23300. Output struct {
  23301. Fileinfo struct {
  23302. DldEndtime string `json:"dld_endtime"`
  23303. FileQuryNo string `json:"file_qury_no"`
  23304. Filename string `json:"filename"`
  23305. } `json:"fileinfo"`
  23306. } `json:"output"`
  23307. RefmsgTime string `json:"refmsg_time"`
  23308. RespondTime string `json:"respond_time"`
  23309. Signtype interface{} `json:"signtype"`
  23310. WarnMsg interface{} `json:"warn_msg"`
  23311. }
  23312. type Result5262 struct {
  23313. ErrMsg string `json:"err_msg"`
  23314. InfRefmsgid string `json:"inf_refmsgid"`
  23315. Infcode int64 `json:"infcode"`
  23316. Output struct {
  23317. PageInfo struct {
  23318. Size int `json:"size"`
  23319. RecordCounts int `json:"record_counts"`
  23320. } `json:"page_info"`
  23321. Idetinfo []interface{} `json:"idetinfo"`
  23322. Result []struct {
  23323. SetlID string `json:"setl_id"`
  23324. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23325. MdtrtID string `json:"mdtrt_id"`
  23326. InitSetlID string `json:"init_setl_id,omitempty"`
  23327. PsnNo string `json:"psn_no"`
  23328. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23329. PsnName string `json:"psn_name"`
  23330. PsnCertType string `json:"psn_cert_type"`
  23331. Certno string `json:"certno"`
  23332. Gend string `json:"gend,omitempty"`
  23333. Naty string `json:"naty,omitempty"`
  23334. Brdy string `json:"brdy,omitempty"`
  23335. Age float64 `json:"age,omitempty"`
  23336. Insutype string `json:"insutype,omitempty"`
  23337. PsnType string `json:"psn_type"`
  23338. CvlservFlag string `json:"cvlserv_flag"`
  23339. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23340. SpPsnType string `json:"sp_psn_type,omitempty"`
  23341. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23342. ClctGrde string `json:"clct_grde,omitempty"`
  23343. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23344. NwbFlag string `json:"nwb_flag,omitempty"`
  23345. InsuAdmdvs string `json:"insu_admdvs"`
  23346. EmpNo string `json:"emp_no,omitempty"`
  23347. EmpName string `json:"emp_name,omitempty"`
  23348. EmpType string `json:"emp_type,omitempty"`
  23349. EconType string `json:"econ_type,omitempty"`
  23350. AfilIndu string `json:"afil_indu,omitempty"`
  23351. AfilRlts string `json:"afil_rlts,omitempty"`
  23352. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23353. PayLoc string `json:"pay_loc,omitempty"`
  23354. FixmedinsCode string `json:"fixmedins_code"`
  23355. FixmedinsName string `json:"fixmedins_name"`
  23356. HospLv string `json:"hosp_lv,omitempty"`
  23357. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23358. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23359. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23360. Begndate string `json:"begndate"`
  23361. Enddate string `json:"enddate"`
  23362. SetlTime string `json:"setl_time"`
  23363. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23364. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23365. MedType string `json:"med_type"`
  23366. SetlType string `json:"setl_type,omitempty"`
  23367. ClrType string `json:"clr_type,omitempty"`
  23368. ClrWay string `json:"clr_way,omitempty"`
  23369. PsnSetlway string `json:"psn_setlway,omitempty"`
  23370. ClrOptins string `json:"clr_optins,omitempty"`
  23371. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23372. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23373. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23374. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23375. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23376. DedcStd float64 `json:"dedc_std,omitempty"`
  23377. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23378. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23379. HifpPay float64 `json:"hifp_pay,omitempty"`
  23380. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23381. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23382. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23383. HifesPay float64 `json:"hifes_pay,omitempty"`
  23384. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23385. HifobPay float64 `json:"hifob_pay,omitempty"`
  23386. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23387. MafPay float64 `json:"maf_pay,omitempty"`
  23388. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23389. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23390. PsnPay float64 `json:"psn_pay,omitempty"`
  23391. AcctPay float64 `json:"acct_pay,omitempty"`
  23392. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23393. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23394. Balc float64 `json:"balc,omitempty"`
  23395. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23396. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23397. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23398. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23399. Year string `json:"year,omitempty"`
  23400. DiseNo string `json:"dise_no,omitempty"`
  23401. DiseName string `json:"dise_name,omitempty"`
  23402. Invono string `json:"invono,omitempty"`
  23403. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23404. ValiFlag string `json:"vali_flag,omitempty"`
  23405. Memo string `json:"memo,omitempty"`
  23406. Rid string `json:"rid"`
  23407. UpdtTime string `json:"updt_time,omitempty"`
  23408. CrterID string `json:"crter_id,omitempty"`
  23409. CrterName string `json:"crter_name,omitempty"`
  23410. CrteTime string `json:"crte_time,omitempty"`
  23411. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  23412. OpterID string `json:"opter_id,omitempty"`
  23413. OpterName string `json:"opter_name,omitempty"`
  23414. OptTime string `json:"opt_time,omitempty"`
  23415. OptinsNo string `json:"optins_no,omitempty"`
  23416. PoolareaNo string `json:"poolarea_no,omitempty"`
  23417. } `json:"result"`
  23418. } `json:"output"`
  23419. RefmsgTime string `json:"refmsg_time"`
  23420. RespondTime string `json:"respond_time"`
  23421. Signtype interface{} `json:"signtype"`
  23422. WarnInfo interface{} `json:"warn_info"`
  23423. }
  23424. type Result5267 struct {
  23425. ErrMsg string `json:"err_msg"`
  23426. InfRefmsgid string `json:"inf_refmsgid"`
  23427. Infcode int64 `json:"infcode"`
  23428. Output struct {
  23429. PageInfo struct {
  23430. Size int `json:"size"`
  23431. RecordCounts int `json:"record_counts"`
  23432. } `json:"pageinfo"`
  23433. Result []struct {
  23434. SetlID string `json:"setl_id"`
  23435. ClrOptins string `json:"clr_optins"`
  23436. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23437. MdtrtID string `json:"mdtrt_id"`
  23438. InitSetlID string `json:"init_setl_id,omitempty"`
  23439. PsnNo string `json:"psn_no"`
  23440. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23441. PsnName string `json:"psn_name"`
  23442. PsnCertType string `json:"psn_cert_type"`
  23443. Certno string `json:"certno"`
  23444. Gend string `json:"gend,omitempty"`
  23445. Naty string `json:"naty,omitempty"`
  23446. Brdy string `json:"brdy,omitempty"`
  23447. Age float64 `json:"age,omitempty"`
  23448. Insutype string `json:"insutype,omitempty"`
  23449. PsnType string `json:"psn_type"`
  23450. CvlservFlag string `json:"cvlserv_flag"`
  23451. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23452. SpPsnType string `json:"sp_psn_type,omitempty"`
  23453. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23454. ClctGrde string `json:"clct_grde,omitempty"`
  23455. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23456. NwbFlag string `json:"nwb_flag,omitempty"`
  23457. InsuAdmdvs string `json:"insu_admdvs"`
  23458. EmpNo string `json:"emp_no,omitempty"`
  23459. EmpName string `json:"emp_name,omitempty"`
  23460. EmpType string `json:"emp_type,omitempty"`
  23461. EconType string `json:"econ_type,omitempty"`
  23462. AfilIndu string `json:"afil_indu,omitempty"`
  23463. AfilRlts string `json:"afil_rlts,omitempty"`
  23464. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23465. PayLoc string `json:"pay_loc,omitempty"`
  23466. FixmedinsCode string `json:"fixmedins_code"`
  23467. FixmedinsName string `json:"fixmedins_name"`
  23468. HospLv string `json:"hosp_lv,omitempty"`
  23469. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23470. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23471. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23472. Begndate string `json:"begndate,omitempty"`
  23473. Enddate string `json:"enddate,omitempty"`
  23474. SetlTime string `json:"setl_time,omitempty"`
  23475. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23476. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23477. MedType string `json:"med_type"`
  23478. SetlType string `json:"setl_type,omitempty"`
  23479. ClrType string `json:"clr_type,omitempty"`
  23480. ClrWay string `json:"clr_way,omitempty"`
  23481. PsnSetlway string `json:"psn_setlway,omitempty"`
  23482. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23483. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23484. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23485. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23486. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23487. DedcStd float64 `json:"dedc_std,omitempty"`
  23488. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23489. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23490. HifpPay float64 `json:"hifp_pay,omitempty"`
  23491. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23492. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23493. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23494. HifesPay float64 `json:"hifes_pay,omitempty"`
  23495. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23496. HifobPay float64 `json:"hifob_pay,omitempty"`
  23497. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23498. MafPay float64 `json:"maf_pay,omitempty"`
  23499. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23500. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23501. PsnPay float64 `json:"psn_pay,omitempty"`
  23502. AcctPay float64 `json:"acct_pay,omitempty"`
  23503. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23504. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23505. Balc float64 `json:"balc,omitempty"`
  23506. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23507. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23508. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23509. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23510. Year string `json:"year,omitempty"`
  23511. DiseNo string `json:"dise_no,omitempty"`
  23512. DiseName string `json:"dise_name,omitempty"`
  23513. Invono string `json:"invono,omitempty"`
  23514. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23515. Memo string `json:"memo,omitempty"`
  23516. UpdtTime string `json:"updt_time,omitempty"`
  23517. OpterID string `json:"opter_id,omitempty"`
  23518. OpterName string `json:"opter_name,omitempty"`
  23519. OptTime string `json:"opt_time,omitempty"`
  23520. OptinsNo string `json:"optins_no,omitempty"`
  23521. PoolareaNo string `json:"poolarea_no,omitempty"`
  23522. } `json:"result"`
  23523. } `json:"output"`
  23524. RefmsgTime string `json:"refmsg_time"`
  23525. RespondTime string `json:"respond_time"`
  23526. Signtype interface{} `json:"signtype"`
  23527. WarnInfo interface{} `json:"warn_info"`
  23528. }
  23529. // type Autogenerated struct {
  23530. // Output struct {
  23531. // Setlinfo struct {
  23532. // SetlTime string `json:"setl_time"`
  23533. // CvlservPay float64 `json:"cvlserv_pay"`
  23534. // Year string `json:"year"`
  23535. // MedType string `json:"med_type"`
  23536. // PsnPay float64 `json:"psn_pay"`
  23537. // OpterID string `json:"opter_id"`
  23538. // Begndate string `json:"begndate"`
  23539. // FlxempeFlag string `json:"flxempe_flag"`
  23540. // HifmiPay float64 `json:"hifmi_pay"`
  23541. // PsnNo string `json:"psn_no"`
  23542. // ActPayDedc float64 `json:"act_pay_dedc"`
  23543. // MedinsSetlID interface{} `json:"medins_setl_id"`
  23544. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23545. // ClrWay string `json:"clr_way"`
  23546. // OthPay float64 `json:"oth_pay"`
  23547. // Gend string `json:"gend"`
  23548. // MdtrtID string `json:"mdtrt_id"`
  23549. // AcctPay float64 `json:"acct_pay"`
  23550. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  23551. // Insutype string `json:"insutype"`
  23552. // Invono interface{} `json:"invono"`
  23553. // Enddate string `json:"enddate"`
  23554. // CashPayamt float64 `json:"cash_payamt"`
  23555. // PsnType string `json:"psn_type"`
  23556. // FixmedinsName string `json:"fixmedins_name"`
  23557. // HifpPay float64 `json:"hifp_pay"`
  23558. // NewFlag interface{} `json:"new_flag"`
  23559. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23560. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  23561. // PayLoc string `json:"pay_loc"`
  23562. // ClrType string `json:"clr_type"`
  23563. // RefdSetlFlag string `json:"refd_setl_flag"`
  23564. // CvlservFlag string `json:"cvlserv_flag"`
  23565. // EmpName string `json:"emp_name"`
  23566. // Brdy string `json:"brdy"`
  23567. // Naty string `json:"naty"`
  23568. // Certno string `json:"certno"`
  23569. // DiseCode string `json:"dise_code"`
  23570. // FixmedinsCode string `json:"fixmedins_code"`
  23571. // DedcHospLv string `json:"dedc_hosp_lv"`
  23572. // OpterName string `json:"opter_name"`
  23573. // Balc float64 `json:"balc"`
  23574. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23575. // PsnCertType string `json:"psn_cert_type"`
  23576. // HifobPay float64 `json:"hifob_pay"`
  23577. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  23578. // HifesPay float64 `json:"hifes_pay"`
  23579. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23580. // OptTime string `json:"opt_time"`
  23581. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23582. // SetlID string `json:"setl_id"`
  23583. // MafPay float64 `json:"maf_pay"`
  23584. // PsnName string `json:"psn_name"`
  23585. // InsuOptins interface{} `json:"insu_optins"`
  23586. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23587. // ClrOptins string `json:"clr_optins"`
  23588. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23589. // DiseName string `json:"dise_name"`
  23590. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23591. // Age float64 `json:"age"`
  23592. // DtrtCertType string `json:"dtrt_cert_type"`
  23593. // HospLv string `json:"hosp_lv"`
  23594. // } `json:"setlinfo"`
  23595. // Setldetail []struct {
  23596. // FundPayType string `json:"fund_pay_type"`
  23597. // FundPayamt float64 `json:"fund_payamt"`
  23598. // SetlProcInfo interface{} `json:"setl_proc_info"`
  23599. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  23600. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  23601. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  23602. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23603. // } `json:"setldetail"`
  23604. // } `json:"output"`
  23605. // Infcode int `json:"infcode"`
  23606. // WarnMsg interface{} `json:"warn_msg"`
  23607. // Cainfo interface{} `json:"cainfo"`
  23608. // ErrMsg interface{} `json:"err_msg"`
  23609. // RefmsgTime string `json:"refmsg_time"`
  23610. // Signtype interface{} `json:"signtype"`
  23611. // RespondTime string `json:"respond_time"`
  23612. // InfRefmsgid string `json:"inf_refmsgid"`
  23613. // }
  23614. type Result002 struct {
  23615. Cainfo interface{} `json:"cainfo"`
  23616. ErrMsg string `json:"err_msg"`
  23617. InfRefmsgid string `json:"inf_refmsgid"`
  23618. Infcode int64 `json:"infcode"`
  23619. Output struct {
  23620. RxFile string `json:"rx_file"`
  23621. SignDigest string `json:"sign_digest"`
  23622. SignCertSn string `json:"sign_cert_sn"`
  23623. SignCertDn string `json:"sign_cert_dn"`
  23624. } `json:"output"`
  23625. RefmsgTime string `json:"refmsg_time"`
  23626. RespondTime string `json:"respond_time"`
  23627. Signtype interface{} `json:"signtype"`
  23628. WarnMsg interface{} `json:"warn_msg"`
  23629. }
  23630. type AhResult002 struct {
  23631. RxFile string `json:"rxFile"`
  23632. SignDigest string `json:"signDigest"`
  23633. SignCertSn string `json:"signCertSn"`
  23634. SignCertDn string `json:"signCertDn"`
  23635. }
  23636. type Result003 struct {
  23637. Cainfo interface{} `json:"cainfo"`
  23638. ErrMsg string `json:"err_msg"`
  23639. InfRefmsgid string `json:"inf_refmsgid"`
  23640. Infcode int64 `json:"infcode"`
  23641. Output struct {
  23642. HiRxno string `json:"hi_rxno"`
  23643. RxStasCodg string `json:"rx_stas_codg"`
  23644. RxStasName string `json:"rx_stas_name"`
  23645. } `json:"output"`
  23646. RefmsgTime string `json:"refmsg_time"`
  23647. RespondTime string `json:"respond_time"`
  23648. Signtype interface{} `json:"signtype"`
  23649. WarnMsg interface{} `json:"warn_msg"`
  23650. }
  23651. type AHResult003 struct {
  23652. HiRxno string `json:"hiRxno"`
  23653. RxStasCodg string `json:"rxStasCodg"`
  23654. RxStasName string `json:"rxStasName"`
  23655. }
  23656. type ResultEleven struct {
  23657. Cainfo string `json:"cainfo"`
  23658. ErrMsg string `json:"err_msg"`
  23659. InfRefmsgid string `json:"inf_refmsgid"`
  23660. Infcode int64 `json:"infcode"`
  23661. Output struct {
  23662. Setlinfo struct {
  23663. SetlTime string `json:"setl_time"`
  23664. CvlservPay float64 `json:"cvlserv_pay"`
  23665. Year string `json:"year"`
  23666. MedType string `json:"med_type"`
  23667. PsnPay float64 `json:"psn_pay"`
  23668. OpterID string `json:"opter_id"`
  23669. Begndate string `json:"begndate"`
  23670. FlxempeFlag string `json:"flxempe_flag"`
  23671. HifmiPay float64 `json:"hifmi_pay"`
  23672. PsnNo string `json:"psn_no"`
  23673. ActPayDedc float64 `json:"act_pay_dedc"`
  23674. MedinsSetlID interface{} `json:"medins_setl_id"`
  23675. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23676. ClrWay string `json:"clr_way"`
  23677. OthPay float64 `json:"oth_pay"`
  23678. Gend string `json:"gend"`
  23679. MdtrtID string `json:"mdtrt_id"`
  23680. AcctPay float64 `json:"acct_pay"`
  23681. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23682. Insutype string `json:"insutype"`
  23683. Invono interface{} `json:"invono"`
  23684. Enddate string `json:"enddate"`
  23685. CashPayamt float64 `json:"cash_payamt"`
  23686. PsnType string `json:"psn_type"`
  23687. FixmedinsName string `json:"fixmedins_name"`
  23688. HifpPay float64 `json:"hifp_pay"`
  23689. NewFlag interface{} `json:"new_flag"`
  23690. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23691. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23692. PayLoc string `json:"pay_loc"`
  23693. ClrType string `json:"clr_type"`
  23694. RefdSetlFlag string `json:"refd_setl_flag"`
  23695. CvlservFlag string `json:"cvlserv_flag"`
  23696. EmpName string `json:"emp_name"`
  23697. Brdy string `json:"brdy"`
  23698. Naty string `json:"naty"`
  23699. Certno string `json:"certno"`
  23700. DiseCode string `json:"dise_code"`
  23701. FixmedinsCode string `json:"fixmedins_code"`
  23702. DedcHospLv string `json:"dedc_hosp_lv"`
  23703. OpterName string `json:"opter_name"`
  23704. Balc float64 `json:"balc"`
  23705. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23706. PsnCertType string `json:"psn_cert_type"`
  23707. HifobPay float64 `json:"hifob_pay"`
  23708. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23709. HifesPay float64 `json:"hifes_pay"`
  23710. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23711. OptTime string `json:"opt_time"`
  23712. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23713. SetlID string `json:"setl_id"`
  23714. MafPay float64 `json:"maf_pay"`
  23715. PsnName string `json:"psn_name"`
  23716. InsuOptins interface{} `json:"insu_optins"`
  23717. PrefFundPay interface{} `json:"pref_fund_pay"`
  23718. ClrOptins string `json:"clr_optins"`
  23719. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23720. DiseName string `json:"dise_name"`
  23721. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23722. Age float64 `json:"age"`
  23723. DtrtCertType string `json:"dtrt_cert_type"`
  23724. HospLv string `json:"hosp_lv"`
  23725. PsnCashPay float64 `json:"psn_cash_pay"`
  23726. } `json:"setlinfo"`
  23727. } `json:"output"`
  23728. RefmsgTime string `json:"refmsg_time"`
  23729. RespondTime string `json:"respond_time"`
  23730. Signtype interface{} `json:"signtype"`
  23731. WarnMsg interface{} `json:"warn_msg"`
  23732. }
  23733. type ResultElevenah struct {
  23734. Cainfo string `json:"cainfo"`
  23735. ErrMsg string `json:"err_msg"`
  23736. InfRefmsgid string `json:"inf_refmsgid"`
  23737. Infcode int64 `json:"infcode"`
  23738. Output struct {
  23739. Setlinfo struct {
  23740. SetlTime int64 `json:"setl_time"`
  23741. CvlservPay float64 `json:"cvlserv_pay"`
  23742. Year string `json:"year"`
  23743. MedType string `json:"med_type"`
  23744. PsnPay float64 `json:"psn_pay"`
  23745. OpterID string `json:"opter_id"`
  23746. Begndate int64 `json:"begndate"`
  23747. FlxempeFlag string `json:"flxempe_flag"`
  23748. HifmiPay float64 `json:"hifmi_pay"`
  23749. PsnNo string `json:"psn_no"`
  23750. ActPayDedc float64 `json:"act_pay_dedc"`
  23751. MedinsSetlID interface{} `json:"medins_setl_id"`
  23752. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23753. ClrWay string `json:"clr_way"`
  23754. OthPay float64 `json:"oth_pay"`
  23755. Gend string `json:"gend"`
  23756. MdtrtID string `json:"mdtrt_id"`
  23757. AcctPay float64 `json:"acct_pay"`
  23758. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23759. Insutype string `json:"insutype"`
  23760. Invono interface{} `json:"invono"`
  23761. Enddate int64 `json:"enddate"`
  23762. CashPayamt float64 `json:"cash_payamt"`
  23763. PsnType string `json:"psn_type"`
  23764. FixmedinsName string `json:"fixmedins_name"`
  23765. HifpPay float64 `json:"hifp_pay"`
  23766. NewFlag interface{} `json:"new_flag"`
  23767. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23768. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23769. PayLoc string `json:"pay_loc"`
  23770. ClrType string `json:"clr_type"`
  23771. RefdSetlFlag string `json:"refd_setl_flag"`
  23772. CvlservFlag string `json:"cvlserv_flag"`
  23773. EmpName string `json:"emp_name"`
  23774. Brdy int64 `json:"brdy"`
  23775. Naty string `json:"naty"`
  23776. Certno string `json:"certno"`
  23777. DiseCode string `json:"dise_code"`
  23778. FixmedinsCode string `json:"fixmedins_code"`
  23779. DedcHospLv string `json:"dedc_hosp_lv"`
  23780. OpterName string `json:"opter_name"`
  23781. Balc float64 `json:"balc"`
  23782. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23783. PsnCertType string `json:"psn_cert_type"`
  23784. HifobPay float64 `json:"hifob_pay"`
  23785. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23786. HifesPay float64 `json:"hifes_pay"`
  23787. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23788. OptTime int64 `json:"opt_time"`
  23789. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23790. SetlID string `json:"setl_id"`
  23791. MafPay float64 `json:"maf_pay"`
  23792. PsnName string `json:"psn_name"`
  23793. InsuOptins interface{} `json:"insu_optins"`
  23794. PrefFundPay interface{} `json:"pref_fund_pay"`
  23795. ClrOptins string `json:"clr_optins"`
  23796. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23797. DiseName string `json:"dise_name"`
  23798. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23799. Age float64 `json:"age"`
  23800. DtrtCertType string `json:"dtrt_cert_type"`
  23801. HospLv string `json:"hosp_lv"`
  23802. PsnCashPay float64 `json:"psn_cash_pay"`
  23803. } `json:"setlinfo"`
  23804. } `json:"output"`
  23805. RefmsgTime string `json:"refmsg_time"`
  23806. RespondTime string `json:"respond_time"`
  23807. Signtype interface{} `json:"signtype"`
  23808. WarnMsg interface{} `json:"warn_msg"`
  23809. }
  23810. type ResultEleven10265 struct {
  23811. Cainfo string `json:"cainfo"`
  23812. ErrMsg string `json:"err_msg"`
  23813. InfRefmsgid string `json:"inf_refmsgid"`
  23814. Infcode string `json:"infcode"`
  23815. Output struct {
  23816. Setlinfo struct {
  23817. SetlTime string `json:"setl_time"`
  23818. CvlservPay float64 `json:"cvlserv_pay"`
  23819. Year string `json:"year"`
  23820. MedType string `json:"med_type"`
  23821. PsnPay float64 `json:"psn_pay"`
  23822. OpterID string `json:"opter_id"`
  23823. Begndate string `json:"begndate"`
  23824. FlxempeFlag string `json:"flxempe_flag"`
  23825. HifmiPay float64 `json:"hifmi_pay"`
  23826. PsnNo string `json:"psn_no"`
  23827. ActPayDedc float64 `json:"act_pay_dedc"`
  23828. MedinsSetlID interface{} `json:"medins_setl_id"`
  23829. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23830. ClrWay string `json:"clr_way"`
  23831. OthPay float64 `json:"oth_pay"`
  23832. Gend string `json:"gend"`
  23833. MdtrtID string `json:"mdtrt_id"`
  23834. AcctPay float64 `json:"acct_pay"`
  23835. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23836. Insutype string `json:"insutype"`
  23837. Invono interface{} `json:"invono"`
  23838. Enddate string `json:"enddate"`
  23839. CashPayamt float64 `json:"cash_payamt"`
  23840. PsnType string `json:"psn_type"`
  23841. FixmedinsName string `json:"fixmedins_name"`
  23842. HifpPay float64 `json:"hifp_pay"`
  23843. NewFlag interface{} `json:"new_flag"`
  23844. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23845. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23846. PayLoc string `json:"pay_loc"`
  23847. ClrType string `json:"clr_type"`
  23848. RefdSetlFlag string `json:"refd_setl_flag"`
  23849. CvlservFlag string `json:"cvlserv_flag"`
  23850. EmpName string `json:"emp_name"`
  23851. Brdy string `json:"brdy"`
  23852. Naty string `json:"naty"`
  23853. Certno string `json:"certno"`
  23854. DiseCode string `json:"dise_code"`
  23855. FixmedinsCode string `json:"fixmedins_code"`
  23856. DedcHospLv string `json:"dedc_hosp_lv"`
  23857. OpterName string `json:"opter_name"`
  23858. Balc float64 `json:"balc"`
  23859. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23860. PsnCertType string `json:"psn_cert_type"`
  23861. HifobPay float64 `json:"hifob_pay"`
  23862. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23863. HifesPay float64 `json:"hifes_pay"`
  23864. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23865. OptTime string `json:"opt_time"`
  23866. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23867. SetlID string `json:"setl_id"`
  23868. MafPay float64 `json:"maf_pay"`
  23869. PsnName string `json:"psn_name"`
  23870. InsuOptins interface{} `json:"insu_optins"`
  23871. PrefFundPay interface{} `json:"pref_fund_pay"`
  23872. ClrOptins string `json:"clr_optins"`
  23873. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23874. DiseName string `json:"dise_name"`
  23875. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23876. Age float64 `json:"age"`
  23877. DtrtCertType string `json:"dtrt_cert_type"`
  23878. HospLv string `json:"hosp_lv"`
  23879. PsnCashPay float64 `json:"psn_cash_pay"`
  23880. } `json:"setlinfo"`
  23881. } `json:"output"`
  23882. RefmsgTime string `json:"refmsg_time"`
  23883. RespondTime string `json:"respond_time"`
  23884. Signtype interface{} `json:"signtype"`
  23885. WarnMsg interface{} `json:"warn_msg"`
  23886. }
  23887. type ResultTwelve struct {
  23888. Cainfo string `json:"cainfo"`
  23889. ErrMsg string `json:"err_msg"`
  23890. InfRefmsgid string `json:"inf_refmsgid"`
  23891. Infcode int64 `json:"infcode"`
  23892. Output struct {
  23893. MdtrtId string `json:"mdtrt_id"`
  23894. ChrgBchno string `json:"chrg_bchno"`
  23895. PsnNo string `json:"psn_no"`
  23896. } `json:"output"`
  23897. RefmsgTime string `json:"refmsg_time"`
  23898. RespondTime string `json:"respond_time"`
  23899. Signtype interface{} `json:"signtype"`
  23900. WarnMsg interface{} `json:"warn_msg"`
  23901. }
  23902. type ResultThirteen struct {
  23903. ErrMsg string `json:"err_msg"`
  23904. InfRefmsgid string `json:"inf_refmsgid"`
  23905. Infcode int64 `json:"infcode"`
  23906. Output struct {
  23907. Result struct {
  23908. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23909. } `json:"result"`
  23910. } `json:"output"`
  23911. RefmsgTime string `json:"refmsg_time"`
  23912. RespondTime string `json:"respond_time"`
  23913. Signtype interface{} `json:"signtype"`
  23914. WarnInfo interface{} `json:"warn_info"`
  23915. }
  23916. type ResultThirteen10265 struct {
  23917. ErrMsg string `json:"err_msg"`
  23918. InfRefmsgid string `json:"inf_refmsgid"`
  23919. Infcode string `json:"infcode"`
  23920. Output struct {
  23921. Result struct {
  23922. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23923. } `json:"result"`
  23924. } `json:"output"`
  23925. RefmsgTime string `json:"refmsg_time"`
  23926. RespondTime string `json:"respond_time"`
  23927. Signtype interface{} `json:"signtype"`
  23928. WarnInfo interface{} `json:"warn_info"`
  23929. }
  23930. type ResultFourteen struct {
  23931. ErrMsg string `json:"err_msg"`
  23932. InfRefmsgid string `json:"inf_refmsgid"`
  23933. Infcode int64 `json:"infcode"`
  23934. Output struct {
  23935. } `json:"output"`
  23936. RefmsgTime string `json:"refmsg_time"`
  23937. RespondTime string `json:"respond_time"`
  23938. Signtype interface{} `json:"signtype"`
  23939. WarnInfo interface{} `json:"warn_info"`
  23940. }
  23941. type ResultCFYLJG001 struct {
  23942. ErrMsg string `json:"err_msg"`
  23943. InfRefmsgid string `json:"inf_refmsgid"`
  23944. Infcode int64 `json:"infcode"`
  23945. Output struct {
  23946. RxTraceCode string `json:"rx_trace_code"`
  23947. HiRxno string `json:"hi_rxno"`
  23948. } `json:"output"`
  23949. RefmsgTime string `json:"refmsg_time"`
  23950. RespondTime string `json:"respond_time"`
  23951. Signtype interface{} `json:"signtype"`
  23952. WarnInfo interface{} `json:"warn_info"`
  23953. }
  23954. type ResultCFYLJG001AH struct {
  23955. RxTraceCode string `json:"rxTraceCode"`
  23956. HiRxno string `json:"hiRxno"`
  23957. }
  23958. type ResultCFYLJG007 struct {
  23959. ErrMsg string `json:"err_msg"`
  23960. InfRefmsgid string `json:"inf_refmsgid"`
  23961. Infcode int64 `json:"infcode"`
  23962. Output struct {
  23963. HiRxno string `json:"hi_rxno"`
  23964. RxStasName string `json:"rx_stas_name"`
  23965. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  23966. Seltdelts []interface{} `json:"seltdelts"`
  23967. RxUsedStasName string `json:"rx_used_stas_name"`
  23968. RxStasCodg string `json:"rx_stas_codg"`
  23969. } `json:"output"`
  23970. RefmsgTime string `json:"refmsg_time"`
  23971. RespondTime string `json:"respond_time"`
  23972. Signtype interface{} `json:"signtype"`
  23973. WarnInfo interface{} `json:"warn_info"`
  23974. }
  23975. type ResultCFYLJG002 struct {
  23976. ErrMsg string `json:"err_msg"`
  23977. InfRefmsgid string `json:"inf_refmsgid"`
  23978. Infcode int64 `json:"infcode"`
  23979. Output struct {
  23980. RxFile string `json:"rx_file"`
  23981. SignDigest string `json:"sign_digest"`
  23982. SignCertSn string `json:"sign_cert_sn"`
  23983. SignCertDn string `json:"sign_cert_dn"`
  23984. } `json:"output"`
  23985. RefmsgTime string `json:"refmsg_time"`
  23986. RespondTime string `json:"respond_time"`
  23987. Signtype interface{} `json:"signtype"`
  23988. WarnInfo interface{} `json:"warn_info"`
  23989. }
  23990. type ResultCFYLJG003 struct {
  23991. ErrMsg string `json:"err_msg"`
  23992. InfRefmsgid string `json:"inf_refmsgid"`
  23993. Infcode int64 `json:"infcode"`
  23994. Output struct {
  23995. HiRxno string `json:"hi_rxno"`
  23996. RxStasCodg string `json:"rx_stas_codg"`
  23997. RxStasName string `json:"rx_stas_name"`
  23998. } `json:"output"`
  23999. RefmsgTime string `json:"refmsg_time"`
  24000. RespondTime string `json:"respond_time"`
  24001. Signtype interface{} `json:"signtype"`
  24002. WarnInfo interface{} `json:"warn_info"`
  24003. }
  24004. type ResultCFYLJG004 struct {
  24005. ErrMsg string `json:"err_msg"`
  24006. InfRefmsgid string `json:"inf_refmsgid"`
  24007. Infcode int64 `json:"infcode"`
  24008. Output struct {
  24009. HiRxno string `json:"hi_rxno"`
  24010. RxStasCodg string `json:"rx_stas_codg"`
  24011. RxStasName string `json:"rx_stas_name"`
  24012. } `json:"output"`
  24013. RefmsgTime string `json:"refmsg_time"`
  24014. RespondTime string `json:"respond_time"`
  24015. Signtype interface{} `json:"signtype"`
  24016. WarnInfo interface{} `json:"warn_info"`
  24017. }
  24018. type ResultCFYLJG008 struct {
  24019. ErrMsg string `json:"err_msg"`
  24020. InfRefmsgid string `json:"inf_refmsgid"`
  24021. Infcode int64 `json:"infcode"`
  24022. Output struct {
  24023. PoolareaNo string `json:"poolareaNo"`
  24024. AdmdvsName string `json:"admdvsName"`
  24025. Count string `json:"count"`
  24026. } `json:"output"`
  24027. RefmsgTime string `json:"refmsg_time"`
  24028. RespondTime string `json:"respond_time"`
  24029. Signtype interface{} `json:"signtype"`
  24030. WarnInfo interface{} `json:"warn_info"`
  24031. }
  24032. type ResultCFYLJG005 struct {
  24033. ErrMsg string `json:"err_msg"`
  24034. InfRefmsgid string `json:"inf_refmsgid"`
  24035. Infcode int64 `json:"infcode"`
  24036. Output struct {
  24037. HiRxNo string `json:"hi_rxno"`
  24038. FixMedinsCode string `json:"fixmedins_code"`
  24039. FixMedinsName string `json:"fixmedins_name"`
  24040. RxStasCodg string `json:"rx_stas_codg"`
  24041. RxStasName string `json:"rx_stas_name"`
  24042. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  24043. RxUserdStasName string `json:"rx_userd_stas_name"`
  24044. PrscTime string `json:"prsc_time"`
  24045. RxDrugCnt float64 `json:"rx_drug_cnt"`
  24046. RxUsedWayCodg string `json:"rx_used_way_codg"`
  24047. RxUsedWayName string `json:"rx_used_way_name"`
  24048. RxFrquCodg string `json:"rx_frqu_codg"`
  24049. RxFrquName string `json:"rx_frqu_name"`
  24050. RxDosunt string `json:"rx_dosunt"`
  24051. RxDoscnt float64 `json:"rx_doscnt"`
  24052. RxDrordDscr string `json:"rx_drord_dscr"`
  24053. ValiDays int64 `json:"vali_days"`
  24054. ValiEndTime string `json:"vali_end_time"`
  24055. ReptFlag string `json:"rept_flag"`
  24056. MaxReptCnt int64 `json:"max_rept_cnt"`
  24057. ReptdCnt int64 `json:"reptd_cnt"`
  24058. MinInrvDays int64 `json:"min_inrv_days"`
  24059. RxTypeCode string `json:"rx_type_code"`
  24060. RxTypeName string `json:"rx_type_name"`
  24061. LongRxFlag string `json:"long_rx_flag"`
  24062. RxDetlList []struct {
  24063. MedListCodg string `json:"med_list_codg"`
  24064. MedinsListCodg string `json:"medins_list_codg"`
  24065. HospPrepFlag string `json:"hosp_prep_flag"`
  24066. RxItemTypeCode string `json:"rx_item_type_code"`
  24067. RxItemTypeName string `json:"rx_item_type_name"`
  24068. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  24069. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  24070. TcmHerbFoote string `json:"tcmherb_foote"`
  24071. MednTypeCode string `json:"medn_type_code"`
  24072. MednTypeName string `json:"medn_type_name"`
  24073. MainMedcFlag string `json:"main_medc_flag"`
  24074. UrgtFlag string `json:"urgt_flag"`
  24075. BasMednFlag string `json:"bas_medn_flag"`
  24076. ImpDrugFlag string `json:"imp_drug_flag"`
  24077. ProdBarc string `json:"prod_barc"`
  24078. DrugProdname string `json:"drug_prodname"`
  24079. GennameCodg string `json:"genname_codg"`
  24080. DrugGenname string `json:"drug_genname"`
  24081. DrugDosform string `json:"drug_dosform"`
  24082. DrugSpec string `json:"drug_spec"`
  24083. PrdrName string `json:"prdr_name"`
  24084. MedcWayCodg string `json:"medc_way_codg"`
  24085. MedcWayDscr string `json:"medc_way_dscr"`
  24086. MedcBegntime string `json:"medc_begntime"`
  24087. MedcEndtime string `json:"medc_endtime"`
  24088. MedcDays float64 `json:"medc_days"`
  24089. DrugPric float64 `json:"drug_pric"`
  24090. DrugSumamt float64 `json:"drug_sumamt"`
  24091. DrugCnt float64 `json:"drug_cnt"`
  24092. DrugDosunt string `json:"drug_dosunt"`
  24093. SinDoscnt float64 `json:"sin_doscnt"`
  24094. SinDosunt string `json:"sin_dosunt"`
  24095. UsedFrquCodg string `json:"used_frqu_codg"`
  24096. UsedFrquName string `json:"used_frqu_name"`
  24097. DrugTotlcnt string `json:"drug_totlcnt"`
  24098. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  24099. DiseCodg string `json:"dise_codg"`
  24100. HospApprFlag string `json:"hosp_appr_flag"`
  24101. } `json:"rx_detl_list"`
  24102. RxOtpinfo struct {
  24103. MedType string `json:"med_type"`
  24104. IptOtpNo string `json:"ipt_otp_no"`
  24105. OtpIptFlag string `json:"otp_ipt_flag"`
  24106. PatnName string `json:"patn_name"`
  24107. PatnAge float64 `json:"patn_age"`
  24108. PatnHgt float64 `json:"patn_hgt"`
  24109. PatnWt float64 `json:"patn_wt"`
  24110. Gend string `json:"gend"`
  24111. GesoVal float64 `json:"geso_val"`
  24112. NwbFlag string `json:"nwb_flag"`
  24113. NwbAge string `json:"nwb_age"`
  24114. SuckPrdFlag string `json:"suck_prd_flag"`
  24115. AlgsHis string `json:"algs_his"`
  24116. Insutype string `json:"insutype"`
  24117. PrscDeptName string `json:"prsc_dept_name"`
  24118. PrscDrName string `json:"prsc_dr_name"`
  24119. PharName string `json:"phar_name"`
  24120. PharChkTime string `json:"phar_chk_time"`
  24121. MdtrtTime string `json:"mdtrt_time"`
  24122. DiseCodg string `json:"dise_codg"`
  24123. DiseName string `json:"dise_name"`
  24124. SpDiseFlag string `json:"sp_dise_flag"`
  24125. MaindiagCode string `json:"maindiag_code"`
  24126. MaindiagName string `json:"maindiag_name"`
  24127. DiseCondDscr string `json:"dise_cond_dscr"`
  24128. FstdiagFlag string `json:"fstdiag_flag"`
  24129. } `json:"rx_otpinfo"`
  24130. RxDiseList []struct {
  24131. DiagType string `json:"diag_type"`
  24132. MaindiagFlag string `json:"maindiag_flag"`
  24133. DiagSrtNo string `json:"diag_srt_no"`
  24134. DiagCode string `json:"diag_code"`
  24135. DiagName string `json:"diag_name"`
  24136. DiagDept string `json:"diag_dept"`
  24137. DiagDrNo string `json:"diag_dr_no"`
  24138. DiagDrName string `json:"diag_dr_name"`
  24139. DiagTime string `json:"diag_time"`
  24140. TcmDiseCode string `json:"tcm_dise_code"`
  24141. TcmDiseName string `json:"tcm_dise_name"`
  24142. TcmSympCode string `json:"tcmsymp_code"`
  24143. TcmSymp string `json:"tcmsymp"`
  24144. } `json:"rx_dise_list"`
  24145. } `json:"output"`
  24146. RefmsgTime string `json:"refmsg_time"`
  24147. RespondTime string `json:"respond_time"`
  24148. Signtype interface{} `json:"signtype"`
  24149. WarnInfo interface{} `json:"warn_info"`
  24150. }
  24151. type ResultCFYLJG006 struct {
  24152. ErrMsg string `json:"err_msg"`
  24153. InfRefmsgid string `json:"inf_refmsgid"`
  24154. Infcode int64 `json:"infcode"`
  24155. Output struct {
  24156. HiRxNo string `json:"hi_rxno"`
  24157. PharCode string `json:"phar_code"`
  24158. PharName string `json:"phar_name"`
  24159. RxChkOpnn string `json:"rx_chk_opnn"`
  24160. RxChkTime string `json:"rx_chk_time"`
  24161. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  24162. RxChkStasName string `json:"rx_chk_stas_name"`
  24163. RxStasCodg string `json:"rx_stas_codg"`
  24164. RxStasName string `json:"rx_stas_name"`
  24165. } `json:"output"`
  24166. RefmsgTime string `json:"refmsg_time"`
  24167. RespondTime string `json:"respond_time"`
  24168. Signtype interface{} `json:"signtype"`
  24169. WarnInfo interface{} `json:"warn_info"`
  24170. }
  24171. type ResultFourteen10265 struct {
  24172. ErrMsg string `json:"err_msg"`
  24173. InfRefmsgid string `json:"inf_refmsgid"`
  24174. Infcode string `json:"infcode"`
  24175. Output struct {
  24176. } `json:"output"`
  24177. RefmsgTime string `json:"refmsg_time"`
  24178. RespondTime string `json:"respond_time"`
  24179. Signtype interface{} `json:"signtype"`
  24180. WarnInfo interface{} `json:"warn_info"`
  24181. }
  24182. type ResultSixteen struct {
  24183. Cainfo string `json:"cainfo"`
  24184. ErrMsg string `json:"err_msg"`
  24185. InfRefmsgid string `json:"inf_refmsgid"`
  24186. Infcode int64 `json:"infcode"`
  24187. Output struct {
  24188. Setlinfo struct {
  24189. MdtrtID string `json:"mdtrt_id"`
  24190. SetlID string `json:"setl_id"`
  24191. ClrOptins string `json:"clr_optins"`
  24192. SetlTime string `json:"setl_time"`
  24193. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24194. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24195. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24196. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24197. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24198. ActPayDedc float64 `json:"act_pay_dedc"`
  24199. HifpPay float64 `json:"hifp_pay"`
  24200. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24201. Lfpay float64 `json:"selfpay"`
  24202. CvlservPay float64 `json:"cvlserv_pay"`
  24203. HifesPay float64 `json:"hifes_pay"`
  24204. HifmiPay float64 `json:"hifmi_pay"`
  24205. HifobPay float64 `json:"hifob_pay"`
  24206. MafPay float64 `json:"maf_pay"`
  24207. OthPay float64 `json:"oth_pay"`
  24208. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24209. PsnPartAmt float64 `json:"psn_part_amt"`
  24210. AcctPay float64 `json:"acct_pay"`
  24211. Balc float64 `json:"balc"`
  24212. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24213. HospPartAmt float64 `json:"hosp_part_amt"`
  24214. MedinsSetlID string `json:"medins_setl_id"`
  24215. PdnCashPay string `json:"pdn_cash_pay"`
  24216. } `json:"setlinfo"`
  24217. } `json:"output"`
  24218. RefmsgTime string `json:"refmsg_time"`
  24219. RespondTime string `json:"respond_time"`
  24220. Signtype interface{} `json:"signtype"`
  24221. WarnMsg interface{} `json:"warn_msg"`
  24222. }
  24223. type ResultSixteen10265 struct {
  24224. Cainfo string `json:"cainfo"`
  24225. ErrMsg string `json:"err_msg"`
  24226. InfRefmsgid string `json:"inf_refmsgid"`
  24227. Infcode string `json:"infcode"`
  24228. Output struct {
  24229. Setlinfo struct {
  24230. MdtrtID string `json:"mdtrt_id"`
  24231. SetlID string `json:"setl_id"`
  24232. ClrOptins string `json:"clr_optins"`
  24233. SetlTime string `json:"setl_time"`
  24234. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24235. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24236. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24237. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24238. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24239. ActPayDedc float64 `json:"act_pay_dedc"`
  24240. HifpPay float64 `json:"hifp_pay"`
  24241. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24242. Lfpay float64 `json:"selfpay"`
  24243. CvlservPay float64 `json:"cvlserv_pay"`
  24244. HifesPay float64 `json:"hifes_pay"`
  24245. HifmiPay float64 `json:"hifmi_pay"`
  24246. HifobPay float64 `json:"hifob_pay"`
  24247. MafPay float64 `json:"maf_pay"`
  24248. OthPay float64 `json:"oth_pay"`
  24249. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24250. PsnPartAmt float64 `json:"psn_part_amt"`
  24251. AcctPay float64 `json:"acct_pay"`
  24252. Balc float64 `json:"balc"`
  24253. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24254. HospPartAmt float64 `json:"hosp_part_amt"`
  24255. MedinsSetlID string `json:"medins_setl_id"`
  24256. PdnCashPay string `json:"pdn_cash_pay"`
  24257. } `json:"setlinfo"`
  24258. } `json:"output"`
  24259. RefmsgTime string `json:"refmsg_time"`
  24260. RespondTime string `json:"respond_time"`
  24261. Signtype interface{} `json:"signtype"`
  24262. WarnMsg interface{} `json:"warn_msg"`
  24263. }
  24264. type ResultSixteen10265Two struct {
  24265. Cainfo string `json:"cainfo"`
  24266. ErrMsg string `json:"err_msg"`
  24267. InfRefmsgid string `json:"inf_refmsgid"`
  24268. Infcode string `json:"infcode"`
  24269. Output struct {
  24270. Setlinfo interface{} `json:"setlinfo"`
  24271. } `json:"output"`
  24272. RefmsgTime string `json:"refmsg_time"`
  24273. RespondTime string `json:"respond_time"`
  24274. Signtype interface{} `json:"signtype"`
  24275. WarnMsg interface{} `json:"warn_msg"`
  24276. }
  24277. type ResultgzSixteen10265Two struct {
  24278. Cainfo string `json:"cainfo"`
  24279. ErrMsg string `json:"err_msg"`
  24280. InfRefmsgid string `json:"inf_refmsgid"`
  24281. Infcode int64 `json:"infcode"`
  24282. Output struct {
  24283. Setlinfo interface{} `json:"setlinfo"`
  24284. } `json:"output"`
  24285. RefmsgTime string `json:"refmsg_time"`
  24286. RespondTime string `json:"respond_time"`
  24287. Signtype interface{} `json:"signtype"`
  24288. WarnMsg interface{} `json:"warn_msg"`
  24289. }
  24290. type ResultSeventeen struct {
  24291. ErrMsg string `json:"err_msg"`
  24292. InfRefmsgid string `json:"inf_refmsgid"`
  24293. Infcode int64 `json:"infcode"`
  24294. Output struct {
  24295. SetlListId string `json:"setl_list_id"`
  24296. } `json:"output"`
  24297. RefmsgTime string `json:"refmsg_time"`
  24298. RespondTime string `json:"respond_time"`
  24299. Signtype string `json:"signtype"`
  24300. WarnInfo string `json:"warn_info"`
  24301. }
  24302. type ResultSeventeenOther struct {
  24303. ErrMsg string `json:"err_msg"`
  24304. InfRefmsgid string `json:"inf_refmsgid"`
  24305. Infcode string `json:"infcode"`
  24306. Output struct {
  24307. SetlListId string `json:"setl_list_id"`
  24308. } `json:"output"`
  24309. RefmsgTime string `json:"refmsg_time"`
  24310. RespondTime string `json:"respond_time"`
  24311. Signtype string `json:"signtype"`
  24312. WarnInfo string `json:"warn_info"`
  24313. }
  24314. type Result90991 struct {
  24315. ErrMsg string `json:"err_msg"`
  24316. InfRefmsgid string `json:"inf_refmsgid"`
  24317. Infcode int64 `json:"infcode"`
  24318. Output struct {
  24319. Result struct {
  24320. PsnNo string `json:"psn_no"`
  24321. CardStat string `json:"card_stat"`
  24322. Certno string `json:"certno"`
  24323. PsnName string `json:"psn_name"`
  24324. CheckStat string `json:"check_stat"`
  24325. SscnoCheckStat string `json:"sscno_check_stat"`
  24326. } `json:"result"`
  24327. } `json:"output"`
  24328. RefmsgTime string `json:"refmsg_time"`
  24329. RespondTime string `json:"respond_time"`
  24330. Signtype interface{} `json:"signtype"`
  24331. WarnInfo interface{} `json:"warn_info"`
  24332. }
  24333. type Result90100 struct {
  24334. ErrMsg string `json:"err_msg"`
  24335. InfRefmsgid string `json:"inf_refmsgid"`
  24336. Infcode int64 `json:"infcode"`
  24337. Output struct {
  24338. PoolareaNo string `json:"poolarea_no"`
  24339. PoolareaNoName string `json:"poolarea_no_name"`
  24340. Insutype string `json:"insutype"`
  24341. InsutypeName string `json:"insutype_name"`
  24342. ClctType string `json:"clct_type"`
  24343. ClctTypeName string `json:"clct_type_name"`
  24344. ClctFlag string `json:"clct_flag"`
  24345. ClctFlagName string `json:"clct_flag_name"`
  24346. AccrymBegn string `json:"accrym_begn"`
  24347. AccrymEnd string `json:"accrym_end"`
  24348. ClctTime string `json:"clct_time"`
  24349. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  24350. } `json:"output"`
  24351. RefmsgTime string `json:"refmsg_time"`
  24352. RespondTime string `json:"respond_time"`
  24353. Signtype interface{} `json:"signtype"`
  24354. WarnInfo interface{} `json:"warn_info"`
  24355. }
  24356. type Custom struct {
  24357. DetItemFeeSumamt string
  24358. Cut string
  24359. FeedetlSn string
  24360. Price string
  24361. MedListCodg string
  24362. Type int64
  24363. AdviceId int64
  24364. ProjectId int64
  24365. ItemId int64
  24366. }
  24367. type Result5301 struct {
  24368. ErrMsg string `json:"err_msg"`
  24369. InfRefmsgid string `json:"inf_refmsgid"`
  24370. Infcode int64 `json:"infcode"`
  24371. Output struct {
  24372. Result []struct {
  24373. OpspDiseCode string `json:"opsp_dise_code"`
  24374. OpspDiseName string `json:"opsp_dise_name"`
  24375. Begndate string `json:"begndate"`
  24376. Enddate string `json:"enddate"`
  24377. } `json:"feedetail"`
  24378. } `json:"output"`
  24379. RefmsgTime string `json:"refmsg_time"`
  24380. RespondTime string `json:"respond_time"`
  24381. Signtype interface{} `json:"signtype"`
  24382. WarnInfo interface{} `json:"warn_info"`
  24383. }
  24384. type Result5301For10265 struct {
  24385. ErrMsg string `json:"err_msg"`
  24386. InfRefmsgid string `json:"inf_refmsgid"`
  24387. Infcode string `json:"infcode"`
  24388. Output struct {
  24389. Result []struct {
  24390. OpspDiseCode string `json:"opsp_dise_code"`
  24391. OpspDiseName string `json:"opsp_dise_name"`
  24392. Begndate string `json:"begndate"`
  24393. Enddate string `json:"enddate"`
  24394. } `json:"feedetail"`
  24395. } `json:"output"`
  24396. RefmsgTime string `json:"refmsg_time"`
  24397. RespondTime string `json:"respond_time"`
  24398. Signtype interface{} `json:"signtype"`
  24399. WarnInfo interface{} `json:"warn_info"`
  24400. }
  24401. //获取个人信息----挂号-----上传就诊信息
  24402. func (c *HisApiController) GetRegisterInfo() {
  24403. id, _ := c.GetInt64("id")
  24404. record_time := c.GetString("record_time")
  24405. settlementValue, _ := c.GetInt64("settlement_value")
  24406. medical_insurance_card := c.GetString("medical_insurance_card")
  24407. name := c.GetString("name")
  24408. id_card_type, _ := c.GetInt64("id_card_type")
  24409. certificates, _ := c.GetInt64("certificates")
  24410. medical_care, _ := c.GetInt64("medical_care")
  24411. birthday := c.GetString("birthday")
  24412. id_card := c.GetString("id_card")
  24413. register_type, _ := c.GetInt64("register")
  24414. doctor, _ := c.GetInt64("doctor")
  24415. department, _ := c.GetInt64("department")
  24416. gender, _ := c.GetInt64("sex")
  24417. registration_fee, _ := c.GetFloat("registration_fee")
  24418. medical_expenses, _ := c.GetFloat("medical_expenses")
  24419. social_type, _ := c.GetInt64("social_type")
  24420. admin_user_id, _ := c.GetInt64("admin_user_id")
  24421. insuplc_admdvs := c.GetString("insuplc_admdvs")
  24422. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  24423. mdtrt_type := c.GetString("mdtrt_type")
  24424. if id_card_type == 5 {
  24425. id_card_type = 4
  24426. }
  24427. timeLayout := "2006-01-02"
  24428. loc, _ := time.LoadLocation("Local")
  24429. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  24430. birthUnix := birthdays.Unix()
  24431. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24432. if err != nil {
  24433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24434. return
  24435. }
  24436. recordDateTime := theTime.Unix()
  24437. adminInfo := c.GetAdminUserInfo()
  24438. var patient service.Patients
  24439. if id == 0 {
  24440. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  24441. } else {
  24442. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  24443. }
  24444. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24445. if patientPrescription.ID == 0 {
  24446. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24447. }
  24448. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  24449. if patient.ID == 0 {
  24450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  24451. return
  24452. }
  24453. if len(patient.IdCardNo) == 0 {
  24454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  24455. return
  24456. }
  24457. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  24458. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  24459. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  24460. //就诊结算未完成,不能进行二次挂号
  24461. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  24462. if len(his) >= 1 {
  24463. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  24464. if len(his) >= 1 && order.ID == 0 {
  24465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  24466. return
  24467. }
  24468. }
  24469. var aaaa string
  24470. //var register_log string
  24471. if config.IsOpen == 1 {
  24472. var res ResultTwo
  24473. var res10265 ResultTwo10265
  24474. var PsnNo string
  24475. var PsnCertType string
  24476. var Certno string
  24477. var PsnName string
  24478. var Gend string
  24479. var Naty string
  24480. var Brdy string
  24481. var Age float64
  24482. var infoStr string
  24483. var idetinfoStr string
  24484. var infocode int64
  24485. var verify_number string
  24486. fmt.Println(verify_number)
  24487. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  24488. psn_info, _ := service.GetPsnByPatientId(id)
  24489. PsnNo = psn_info.PsnNo
  24490. PsnCertType = psn_info.PsnCertType
  24491. Certno = psn_info.Certno
  24492. PsnName = psn_info.PsnName
  24493. Gend = psn_info.Gend
  24494. Naty = psn_info.Naty
  24495. Brdy = psn_info.Brdy
  24496. Age = psn_info.Age
  24497. infoStr = psn_info.Insuinfo
  24498. idetinfoStr = psn_info.Idetinfo
  24499. infocode = 0
  24500. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  24501. psn_info, _ := service.GetPsnByPatientId(id)
  24502. PsnNo = psn_info.PsnNo
  24503. PsnCertType = psn_info.PsnCertType
  24504. Certno = psn_info.Certno
  24505. PsnName = psn_info.PsnName
  24506. Gend = psn_info.Gend
  24507. Naty = psn_info.Naty
  24508. Brdy = psn_info.Brdy
  24509. Age = psn_info.Age
  24510. infoStr = psn_info.Insuinfo
  24511. idetinfoStr = psn_info.Idetinfo
  24512. infocode = 0
  24513. verify_number = psn_info.VerifyNumber
  24514. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24515. if id_card_type == 2 {
  24516. //请求内网数据
  24517. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  24518. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24519. "&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
  24520. resp, requestErr := http.Get(api)
  24521. if requestErr != nil {
  24522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24523. return
  24524. }
  24525. body, ioErr := ioutil.ReadAll(resp.Body)
  24526. if ioErr != nil {
  24527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24529. return
  24530. }
  24531. var respJSON map[string]interface{}
  24532. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24535. return
  24536. }
  24537. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24538. result_byte, _ := json.Marshal(respJSON)
  24539. result := string(result_byte)
  24540. var dat map[string]interface{}
  24541. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24542. fmt.Println(dat)
  24543. } else {
  24544. fmt.Println(err)
  24545. }
  24546. userJSONBytes, _ := json.Marshal(dat)
  24547. var res ResultTwo
  24548. var resTwo10265 ResultTwo10265
  24549. if miConfig.Code == "H15049901371" {
  24550. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  24551. utils.ErrorLog("解析失败:%v", err)
  24552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24553. return
  24554. }
  24555. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  24556. res.Infcode = Infcode
  24557. res.ErrMsg = resTwo10265.ErrMsg
  24558. res.Output = resTwo10265.Output
  24559. res.InfRefmsgid = resTwo10265.InfRefmsgid
  24560. res.RespondTime = resTwo10265.RespondTime
  24561. res.WarnInfo = resTwo10265.WarnInfo
  24562. } else {
  24563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24564. utils.ErrorLog("解析失败:%v", err)
  24565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24566. return
  24567. }
  24568. }
  24569. //var insutypes []string
  24570. //var insutype string
  24571. //var is390 int = 0
  24572. //var is310 int = 0
  24573. //for _, item := range res.Output.Iinfo {
  24574. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24575. // insutypes = append(insutypes, item.Insutype)
  24576. // }
  24577. //}
  24578. //if len(insutypes) == 1 {
  24579. // insutype = insutypes[0]
  24580. //} else {
  24581. // for _, i := range insutypes {
  24582. // if i == "390" {
  24583. // is390 = 1
  24584. // }
  24585. //
  24586. // if i == "310" {
  24587. // is310 = 1
  24588. // }
  24589. // }
  24590. //}
  24591. //if is390 == 1 {
  24592. // insutype = "390"
  24593. //}
  24594. //if is310 == 1 {
  24595. // insutype = "310"
  24596. //}
  24597. //if len(insutypes) == 0 {
  24598. // insutype = "310"
  24599. //}
  24600. PsnNo = res.Output.Baseinfo.PsnNo
  24601. PsnCertType = res.Output.Baseinfo.PsnCertType
  24602. Certno = res.Output.Baseinfo.Certno
  24603. PsnName = res.Output.Baseinfo.PsnName
  24604. Gend = res.Output.Baseinfo.Gend
  24605. Naty = res.Output.Baseinfo.Naty
  24606. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24607. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24608. infoStr = string(Iinfos)
  24609. idetinfoStr = string(Idetinfos)
  24610. infocode = res.Infcode
  24611. //infocode = 0
  24612. //verify_number = psn_info.VerifyNumber
  24613. } else {
  24614. psn_info, _ := service.GetPsnByPatientId(id)
  24615. PsnNo = psn_info.PsnNo
  24616. PsnCertType = psn_info.PsnCertType
  24617. Certno = psn_info.Certno
  24618. PsnName = psn_info.PsnName
  24619. Gend = psn_info.Gend
  24620. Naty = psn_info.Naty
  24621. Brdy = psn_info.Brdy
  24622. Age = psn_info.Age
  24623. infoStr = psn_info.Insuinfo
  24624. idetinfoStr = psn_info.Idetinfo
  24625. infocode = 0
  24626. verify_number = psn_info.VerifyNumber
  24627. }
  24628. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24629. if id_card_type == 1 {
  24630. psn_info, _ := service.GetPsnByPatientId(id)
  24631. PsnNo = psn_info.PsnNo
  24632. PsnCertType = psn_info.PsnCertType
  24633. Certno = psn_info.Certno
  24634. PsnName = psn_info.PsnName
  24635. Gend = psn_info.Gend
  24636. Naty = psn_info.Naty
  24637. Brdy = psn_info.Brdy
  24638. Age = psn_info.Age
  24639. infoStr = psn_info.Insuinfo
  24640. idetinfoStr = psn_info.Idetinfo
  24641. infocode = 0
  24642. verify_number = psn_info.VerifyNumber
  24643. } else if id_card_type == 2 {
  24644. 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)
  24645. fmt.Println(errMsgLog)
  24646. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24647. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24648. utils.ErrorLog("解析失败:%v", err)
  24649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24650. return
  24651. }
  24652. PsnNo = res.Output.Baseinfo.PsnNo
  24653. PsnCertType = res.Output.Baseinfo.PsnCertType
  24654. Certno = res.Output.Baseinfo.Certno
  24655. PsnName = res.Output.Baseinfo.PsnName
  24656. Gend = res.Output.Baseinfo.Gend
  24657. Naty = res.Output.Baseinfo.Naty
  24658. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24659. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24660. infoStr = string(Iinfos)
  24661. idetinfoStr = string(Idetinfos)
  24662. infocode = res.Infcode
  24663. }
  24664. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24665. if id_card_type == 1 {
  24666. psn_info, _ := service.GetPsnByPatientId(id)
  24667. PsnNo = psn_info.PsnNo
  24668. PsnCertType = psn_info.PsnCertType
  24669. Certno = psn_info.Certno
  24670. PsnName = psn_info.PsnName
  24671. Gend = psn_info.Gend
  24672. Naty = psn_info.Naty
  24673. Brdy = psn_info.Brdy
  24674. Age = psn_info.Age
  24675. infoStr = psn_info.Insuinfo
  24676. idetinfoStr = psn_info.Idetinfo
  24677. infocode = 0
  24678. verify_number = psn_info.VerifyNumber
  24679. } else if id_card_type == 2 {
  24680. 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, "")
  24681. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24682. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24683. utils.ErrorLog("解析失败:%v", err)
  24684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24685. return
  24686. }
  24687. PsnNo = res.Output.Baseinfo.PsnNo
  24688. PsnCertType = res.Output.Baseinfo.PsnCertType
  24689. Certno = res.Output.Baseinfo.Certno
  24690. PsnName = res.Output.Baseinfo.PsnName
  24691. Gend = res.Output.Baseinfo.Gend
  24692. Naty = res.Output.Baseinfo.Naty
  24693. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24694. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24695. infoStr = string(Iinfos)
  24696. idetinfoStr = string(Idetinfos)
  24697. infocode = res.Infcode
  24698. } else {
  24699. psn_info, _ := service.GetPsnByPatientId(id)
  24700. PsnNo = psn_info.PsnNo
  24701. PsnCertType = psn_info.PsnCertType
  24702. Certno = psn_info.Certno
  24703. PsnName = psn_info.PsnName
  24704. Gend = psn_info.Gend
  24705. Naty = psn_info.Naty
  24706. Brdy = psn_info.Brdy
  24707. Age = psn_info.Age
  24708. infoStr = psn_info.Insuinfo
  24709. idetinfoStr = psn_info.Idetinfo
  24710. infocode = 0
  24711. verify_number = psn_info.VerifyNumber
  24712. }
  24713. } else if miConfig.MdtrtareaAdmvs == "361025" {
  24714. if id_card_type == 1 {
  24715. psn_info, _ := service.GetPsnByPatientId(id)
  24716. PsnNo = psn_info.PsnNo
  24717. PsnCertType = psn_info.PsnCertType
  24718. Certno = psn_info.Certno
  24719. PsnName = psn_info.PsnName
  24720. Gend = psn_info.Gend
  24721. Naty = psn_info.Naty
  24722. Brdy = psn_info.Brdy
  24723. Age = psn_info.Age
  24724. infoStr = psn_info.Insuinfo
  24725. idetinfoStr = psn_info.Idetinfo
  24726. infocode = 0
  24727. verify_number = psn_info.VerifyNumber
  24728. } else if id_card_type == 2 {
  24729. psn_info, _ := service.GetPsnByPatientId(id)
  24730. PsnNo = psn_info.PsnNo
  24731. PsnCertType = psn_info.PsnCertType
  24732. Certno = psn_info.Certno
  24733. PsnName = psn_info.PsnName
  24734. Gend = psn_info.Gend
  24735. Naty = psn_info.Naty
  24736. Brdy = psn_info.Brdy
  24737. Age = psn_info.Age
  24738. infoStr = psn_info.Insuinfo
  24739. idetinfoStr = psn_info.Idetinfo
  24740. infocode = 0
  24741. verify_number = psn_info.VerifyNumber
  24742. } else {
  24743. psn_info, _ := service.GetPsnByPatientId(id)
  24744. PsnNo = psn_info.PsnNo
  24745. PsnCertType = psn_info.PsnCertType
  24746. Certno = psn_info.Certno
  24747. PsnName = psn_info.PsnName
  24748. Gend = psn_info.Gend
  24749. Naty = psn_info.Naty
  24750. Brdy = psn_info.Brdy
  24751. Age = psn_info.Age
  24752. infoStr = psn_info.Insuinfo
  24753. idetinfoStr = psn_info.Idetinfo
  24754. infocode = 0
  24755. verify_number = psn_info.VerifyNumber
  24756. }
  24757. } else if miConfig.MdtrtareaAdmvs == "360100" {
  24758. if id_card_type == 1 {
  24759. psn_info, _ := service.GetPsnByPatientId(id)
  24760. PsnNo = psn_info.PsnNo
  24761. PsnCertType = psn_info.PsnCertType
  24762. Certno = psn_info.Certno
  24763. PsnName = psn_info.PsnName
  24764. Gend = psn_info.Gend
  24765. Naty = psn_info.Naty
  24766. Brdy = psn_info.Brdy
  24767. Age = psn_info.Age
  24768. infoStr = psn_info.Insuinfo
  24769. idetinfoStr = psn_info.Idetinfo
  24770. infocode = 0
  24771. verify_number = psn_info.VerifyNumber
  24772. } else if id_card_type == 2 {
  24773. psn_info, _ := service.GetPsnByPatientId(id)
  24774. PsnNo = psn_info.PsnNo
  24775. PsnCertType = psn_info.PsnCertType
  24776. Certno = psn_info.Certno
  24777. PsnName = psn_info.PsnName
  24778. Gend = psn_info.Gend
  24779. Naty = psn_info.Naty
  24780. Brdy = psn_info.Brdy
  24781. Age = psn_info.Age
  24782. infoStr = psn_info.Insuinfo
  24783. idetinfoStr = psn_info.Idetinfo
  24784. infocode = 0
  24785. verify_number = psn_info.VerifyNumber
  24786. } else {
  24787. psn_info, _ := service.GetPsnByPatientId(id)
  24788. PsnNo = psn_info.PsnNo
  24789. PsnCertType = psn_info.PsnCertType
  24790. Certno = psn_info.Certno
  24791. PsnName = psn_info.PsnName
  24792. Gend = psn_info.Gend
  24793. Naty = psn_info.Naty
  24794. Brdy = psn_info.Brdy
  24795. Age = psn_info.Age
  24796. infoStr = psn_info.Insuinfo
  24797. idetinfoStr = psn_info.Idetinfo
  24798. infocode = 0
  24799. verify_number = psn_info.VerifyNumber
  24800. }
  24801. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  24802. psn_info, _ := service.GetPsnByPatientId(id)
  24803. PsnNo = psn_info.PsnNo
  24804. PsnCertType = psn_info.PsnCertType
  24805. Certno = psn_info.Certno
  24806. PsnName = psn_info.PsnName
  24807. Gend = psn_info.Gend
  24808. Naty = psn_info.Naty
  24809. Brdy = psn_info.Brdy
  24810. Age = psn_info.Age
  24811. infoStr = psn_info.Insuinfo
  24812. idetinfoStr = psn_info.Idetinfo
  24813. infocode = 0
  24814. verify_number = psn_info.VerifyNumber
  24815. idetinfoStr = psn_info.Idetinfo
  24816. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24817. if id_card_type == 1 {
  24818. psn_info, _ := service.GetPsnByPatientId(id)
  24819. PsnNo = psn_info.PsnNo
  24820. PsnCertType = psn_info.PsnCertType
  24821. Certno = psn_info.Certno
  24822. PsnName = psn_info.PsnName
  24823. Gend = psn_info.Gend
  24824. Naty = psn_info.Naty
  24825. Brdy = psn_info.Brdy
  24826. Age = psn_info.Age
  24827. infoStr = psn_info.Insuinfo
  24828. idetinfoStr = psn_info.Idetinfo
  24829. infocode = 0
  24830. verify_number = psn_info.VerifyNumber
  24831. } else if id_card_type == 2 {
  24832. 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)
  24833. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24834. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24835. utils.ErrorLog("解析失败:%v", err)
  24836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24837. return
  24838. }
  24839. PsnNo = res.Output.Baseinfo.PsnNo
  24840. PsnCertType = res.Output.Baseinfo.PsnCertType
  24841. Certno = res.Output.Baseinfo.Certno
  24842. PsnName = res.Output.Baseinfo.PsnName
  24843. Gend = res.Output.Baseinfo.Gend
  24844. Naty = res.Output.Baseinfo.Naty
  24845. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24846. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24847. infoStr = string(Iinfos)
  24848. idetinfoStr = string(Idetinfos)
  24849. infocode = res.Infcode
  24850. } else if id_card_type == 4 {
  24851. psn_info, _ := service.GetPsnByPatientId(id)
  24852. PsnNo = psn_info.PsnNo
  24853. PsnCertType = psn_info.PsnCertType
  24854. Certno = psn_info.Certno
  24855. PsnName = psn_info.PsnName
  24856. Gend = psn_info.Gend
  24857. Naty = psn_info.Naty
  24858. Brdy = psn_info.Brdy
  24859. Age = psn_info.Age
  24860. infoStr = psn_info.Insuinfo
  24861. idetinfoStr = psn_info.Idetinfo
  24862. infocode = 0
  24863. verify_number = psn_info.VerifyNumber
  24864. }
  24865. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24866. var result string
  24867. var requestLog string
  24868. 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), "")
  24869. if id_card_type == 4 {
  24870. psn_info, _ := service.GetPsnByPatientId(id)
  24871. PsnNo = psn_info.PsnNo
  24872. PsnCertType = psn_info.PsnCertType
  24873. Certno = psn_info.Certno
  24874. PsnName = psn_info.PsnName
  24875. Gend = psn_info.Gend
  24876. Naty = psn_info.Naty
  24877. Brdy = psn_info.Brdy
  24878. Age = psn_info.Age
  24879. infoStr = psn_info.Insuinfo
  24880. idetinfoStr = psn_info.Idetinfo
  24881. infocode = 0
  24882. verify_number = psn_info.VerifyNumber
  24883. } else {
  24884. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24885. if miConfig.Code == "H15049901371" {
  24886. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24887. utils.ErrorLog("解析失败:%v", err)
  24888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24889. return
  24890. }
  24891. res.ErrMsg = res10265.ErrMsg
  24892. res.Output = res10265.Output
  24893. res.InfRefmsgid = res10265.InfRefmsgid
  24894. } else {
  24895. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24896. utils.ErrorLog("解析失败:%v", err)
  24897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24898. return
  24899. }
  24900. }
  24901. PsnNo = res.Output.Baseinfo.PsnNo
  24902. PsnCertType = res.Output.Baseinfo.PsnCertType
  24903. Certno = res.Output.Baseinfo.Certno
  24904. PsnName = res.Output.Baseinfo.PsnName
  24905. Gend = res.Output.Baseinfo.Gend
  24906. Naty = res.Output.Baseinfo.Naty
  24907. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24908. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24909. infoStr = string(Iinfos)
  24910. idetinfoStr = string(Idetinfos)
  24911. if miConfig.Code == "H15049901371" {
  24912. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24913. } else {
  24914. infocode = res.Infcode
  24915. }
  24916. }
  24917. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24918. psn_info, _ := service.GetPsnByPatientId(id)
  24919. PsnNo = psn_info.PsnNo
  24920. PsnCertType = psn_info.PsnCertType
  24921. Certno = psn_info.Certno
  24922. PsnName = psn_info.PsnName
  24923. Gend = psn_info.Gend
  24924. Naty = psn_info.Naty
  24925. Brdy = psn_info.Brdy
  24926. Age = psn_info.Age
  24927. infoStr = psn_info.Insuinfo
  24928. idetinfoStr = psn_info.Idetinfo
  24929. infocode = 0
  24930. verify_number = psn_info.VerifyNumber
  24931. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24932. psn_info, _ := service.GetPsnByPatientId(id)
  24933. PsnNo = psn_info.PsnNo
  24934. PsnCertType = psn_info.PsnCertType
  24935. Certno = psn_info.Certno
  24936. PsnName = psn_info.PsnName
  24937. Gend = psn_info.Gend
  24938. Naty = psn_info.Naty
  24939. Brdy = psn_info.Brdy
  24940. Age = psn_info.Age
  24941. infoStr = psn_info.Insuinfo
  24942. idetinfoStr = psn_info.Idetinfo
  24943. infocode = 0
  24944. verify_number = psn_info.VerifyNumber
  24945. } else {
  24946. var result string
  24947. var requestLog string
  24948. //if miConfig.UserOrgId == 10138 {
  24949. if id_card_type != 4 || id_card_type != 1 {
  24950. var insa string
  24951. if len(patient.InsuplcAdmdvs) > 0 {
  24952. insa = patient.InsuplcAdmdvs
  24953. } else {
  24954. insa = miConfig.InsuplcAdmdvs
  24955. }
  24956. //psn_info, _ := service.GetPsnByPatientId(id)
  24957. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  24958. 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)
  24959. }
  24960. //}
  24961. //else {
  24962. // var insa string
  24963. // if len(patient.InsuplcAdmdvs) > 0 {
  24964. // insa = patient.InsuplcAdmdvs
  24965. // } else {
  24966. // insa = miConfig.InsuplcAdmdvs
  24967. // }
  24968. // 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)
  24969. //}
  24970. if id_card_type == 4 || id_card_type == 1 {
  24971. psn_info, _ := service.GetPsnByPatientId(id)
  24972. PsnNo = psn_info.PsnNo
  24973. PsnCertType = psn_info.PsnCertType
  24974. Certno = psn_info.Certno
  24975. PsnName = psn_info.PsnName
  24976. Gend = psn_info.Gend
  24977. Naty = psn_info.Naty
  24978. Brdy = psn_info.Brdy
  24979. Age = psn_info.Age
  24980. infoStr = psn_info.Insuinfo
  24981. idetinfoStr = psn_info.Idetinfo
  24982. infocode = 0
  24983. verify_number = psn_info.VerifyNumber
  24984. } else {
  24985. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24986. if miConfig.Code == "H15049901371" {
  24987. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24988. utils.ErrorLog("解析失败:%v", err)
  24989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24990. return
  24991. }
  24992. res.ErrMsg = res10265.ErrMsg
  24993. res.Output = res10265.Output
  24994. res.InfRefmsgid = res10265.InfRefmsgid
  24995. } else {
  24996. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24997. utils.ErrorLog("解析失败:%v", err)
  24998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24999. return
  25000. }
  25001. }
  25002. PsnNo = res.Output.Baseinfo.PsnNo
  25003. PsnCertType = res.Output.Baseinfo.PsnCertType
  25004. Certno = res.Output.Baseinfo.Certno
  25005. PsnName = res.Output.Baseinfo.PsnName
  25006. Gend = res.Output.Baseinfo.Gend
  25007. Naty = res.Output.Baseinfo.Naty
  25008. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25009. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25010. infoStr = string(Iinfos)
  25011. idetinfoStr = string(Idetinfos)
  25012. if miConfig.Code == "H15049901371" {
  25013. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25014. } else {
  25015. infocode = res.Infcode
  25016. }
  25017. }
  25018. }
  25019. if infocode == 0 {
  25020. his := models.VMHisPatient{
  25021. Name: name,
  25022. Gender: gender,
  25023. Birthday: birthUnix,
  25024. MedicalTreatmentType: medical_care,
  25025. IdType: certificates,
  25026. IdCardNo: id_card,
  25027. BalanceAccountsType: settlementValue,
  25028. SocialType: social_type,
  25029. MedicalInsuranceNumber: medical_insurance_card,
  25030. RegisterType: register_type,
  25031. RegisterCost: registration_fee,
  25032. TreatmentCost: medical_expenses,
  25033. Status: 1,
  25034. Ctime: time.Now().Unix(),
  25035. Mtime: time.Now().Unix(),
  25036. PsnNo: PsnNo,
  25037. PsnCertType: PsnCertType,
  25038. Certno: Certno,
  25039. PsnName: PsnName,
  25040. Gend: Gend,
  25041. Naty: Naty,
  25042. Brdy: Brdy,
  25043. Age: Age,
  25044. Iinfo: infoStr,
  25045. Idetinfo: idetinfoStr,
  25046. PatientId: patient.ID,
  25047. RecordDate: theTime.Unix(),
  25048. UserOrgId: adminInfo.CurrentOrgId,
  25049. AdminUserId: admin_user_id,
  25050. IsReturn: 1,
  25051. IdCardType: id_card_type,
  25052. Doctor: doctor,
  25053. Departments: department,
  25054. MdtrtGrpType: mdtrt_type,
  25055. }
  25056. timestamp := time.Now().Unix()
  25057. tempTime := time.Unix(timestamp, 0)
  25058. timeFormat := tempTime.Format("20060102150405")
  25059. chrgBchno := rand.Intn(100000) + 10000
  25060. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25061. his.Number = ipt_otp_no
  25062. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  25063. department, _ := service.GetDepartMentDetail(department)
  25064. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  25065. IdCardNo := ""
  25066. if id_card_type == 1 {
  25067. // IdCardNo = medical_insurance_card
  25068. IdCardNo = patient.IdCardNo
  25069. } else {
  25070. IdCardNo = patient.IdCardNo
  25071. }
  25072. var rf []*ResultFive
  25073. json.Unmarshal([]byte(his.Iinfo), &rf)
  25074. var insutypes []*ResultFive
  25075. var insutype string
  25076. var insuplc_admdvs_temp string
  25077. var is390 int = 0
  25078. var is310 int = 0
  25079. for _, item := range rf {
  25080. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25081. insutypes = append(insutypes, item)
  25082. }
  25083. }
  25084. if len(insutypes) == 1 {
  25085. insutype = insutypes[0].Insutype
  25086. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25087. if insutype == "390" {
  25088. is390 = 1
  25089. }
  25090. if insutype == "310" {
  25091. is310 = 1
  25092. }
  25093. } else {
  25094. for _, i := range insutypes {
  25095. if i.Insutype == "390" {
  25096. is390 = 1
  25097. }
  25098. if i.Insutype == "310" {
  25099. is310 = 1
  25100. }
  25101. }
  25102. }
  25103. if is390 == 1 {
  25104. insutype = "390"
  25105. }
  25106. if is310 == 1 {
  25107. insutype = "310"
  25108. }
  25109. fmt.Println(social_type)
  25110. if social_type > 0 {
  25111. insutype = strconv.FormatInt(social_type, 10)
  25112. }
  25113. var infocode int64
  25114. var resThree ResultThree
  25115. var resThree10265 ResultThree10265
  25116. if len(insuplc_admdvs) == 0 {
  25117. psn_info, _ := service.GetPsnByPatientId(id)
  25118. //if len(psn_info.InsuplcAdmdvs) > 0 {
  25119. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25120. //}
  25121. } else {
  25122. insuplc_admdvs_temp = insuplc_admdvs
  25123. }
  25124. if miConfig.MdtrtareaAdmvs == "421300" {
  25125. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25126. psn_info, _ := service.GetPsnByPatientId(id)
  25127. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25128. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25129. "&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
  25130. resp, requestErr := http.Get(api)
  25131. if requestErr != nil {
  25132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25133. return
  25134. }
  25135. body, ioErr := ioutil.ReadAll(resp.Body)
  25136. if ioErr != nil {
  25137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25139. return
  25140. }
  25141. var respJSON map[string]interface{}
  25142. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25145. return
  25146. }
  25147. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25148. result, _ := json.Marshal(respJSON)
  25149. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25150. utils.ErrorLog("解析失败:%v", err)
  25151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25152. return
  25153. }
  25154. infocode = resThree.Infcode
  25155. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25156. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25157. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25158. // insuplc_admdvs_temp =
  25159. //}
  25160. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25161. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25162. //}
  25163. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25164. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25165. "&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
  25166. resp, requestErr := http.Get(api)
  25167. if requestErr != nil {
  25168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25169. return
  25170. }
  25171. body, ioErr := ioutil.ReadAll(resp.Body)
  25172. if ioErr != nil {
  25173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25175. return
  25176. }
  25177. var respJSON map[string]interface{}
  25178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25181. return
  25182. }
  25183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25184. result, _ := json.Marshal(respJSON)
  25185. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25186. utils.ErrorLog("解析失败:%v", err)
  25187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25188. return
  25189. }
  25190. infocode = resThree.Infcode
  25191. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25192. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25193. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25194. // insuplc_admdvs_temp =
  25195. //}
  25196. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25197. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25198. //}
  25199. utils.ErrorLog("解析失败:%v", insutype)
  25200. utils.ErrorLog("解析失败:%v", PsnNo)
  25201. utils.ErrorLog("解析失败:%v", Certno)
  25202. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  25203. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  25204. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  25205. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  25206. utils.ErrorLog("解析失败:%v", PsnNo)
  25207. utils.ErrorLog("解析失败:%v", department.Number)
  25208. utils.ErrorLog("解析失败:%v", department.Name)
  25209. utils.ErrorLog("解析失败:%v", roles.UserName)
  25210. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25211. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25212. "&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
  25213. resp, requestErr := http.Get(api)
  25214. if requestErr != nil {
  25215. utils.ErrorLog("解析失败:%v", requestErr)
  25216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25217. return
  25218. }
  25219. body, ioErr := ioutil.ReadAll(resp.Body)
  25220. if ioErr != nil {
  25221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25223. return
  25224. }
  25225. var respJSON map[string]interface{}
  25226. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25229. return
  25230. }
  25231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25232. result, _ := json.Marshal(respJSON)
  25233. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25234. utils.ErrorLog("解析失败:%v", err)
  25235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25236. return
  25237. }
  25238. infocode = resThree.Infcode
  25239. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25240. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25241. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25242. // insuplc_admdvs_temp =
  25243. //}
  25244. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25245. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25246. //}
  25247. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25248. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25249. "&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
  25250. resp, requestErr := http.Get(api)
  25251. if requestErr != nil {
  25252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25253. return
  25254. }
  25255. body, ioErr := ioutil.ReadAll(resp.Body)
  25256. if ioErr != nil {
  25257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25259. return
  25260. }
  25261. var respJSON map[string]interface{}
  25262. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25265. return
  25266. }
  25267. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25268. result, _ := json.Marshal(respJSON)
  25269. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25270. utils.ErrorLog("解析失败:%v", err)
  25271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25272. return
  25273. }
  25274. infocode = resThree.Infcode
  25275. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25276. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25277. psn_info, _ := service.GetPsnByPatientId(id)
  25278. var verify_number string
  25279. if id_card_type == 4 {
  25280. verify_number = psn_info.VerifyNumber
  25281. } else if id_card_type == 1 {
  25282. bas := strings.Split(psn_info.CardInfo, "|")
  25283. cardNumber := bas[2]
  25284. verify_number = cardNumber
  25285. }
  25286. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25287. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25288. "&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
  25289. resp, requestErr := http.Get(api)
  25290. if requestErr != nil {
  25291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25292. return
  25293. }
  25294. body, ioErr := ioutil.ReadAll(resp.Body)
  25295. if ioErr != nil {
  25296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25298. return
  25299. }
  25300. var respJSON map[string]interface{}
  25301. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25304. return
  25305. }
  25306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25307. result, _ := json.Marshal(respJSON)
  25308. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25309. // utils.ErrorLog("解析失败:%v", err)
  25310. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25311. // return
  25312. //}
  25313. //infocode = resThree.Infcode
  25314. //result, _ := json.Marshal(respJSON)
  25315. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25316. utils.ErrorLog("解析失败:%v", err)
  25317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25318. return
  25319. }
  25320. resThree.ErrMsg = resThree10265.ErrMsg
  25321. resThree.Output = resThree10265.Output
  25322. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25323. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25324. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  25325. psn_info, _ := service.GetPsnByPatientId(id)
  25326. his.PsnNo = psn_info.PsnNo
  25327. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25328. var cert_no string
  25329. if id_card_type == 3 {
  25330. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  25331. cert_no = IdCardNo
  25332. } else if id_card_type == 4 {
  25333. cert_no = IdCardNo
  25334. psn_info.VerifyNumber = psn_info.VerifyNumber
  25335. } else {
  25336. bas := strings.Split(psn_info.CardInfo, "|")
  25337. cert_no = bas[2]
  25338. }
  25339. var hisPrescription []*models.HisPrescription
  25340. fmt.Println(hisPrescription)
  25341. for _, item := range rf {
  25342. if item.Insutype == insutype {
  25343. //insuplc_admdvs = item.InsuplcAdmdvs
  25344. his.InsuplcAdmdvs = insuplc_admdvs
  25345. }
  25346. }
  25347. his.Insutype = insutype
  25348. var res3101 Result3101
  25349. res3101.Infcode = "0"
  25350. //res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25351. if res3101.Infcode == "0" {
  25352. fmt.Println("33333333")
  25353. if len(res3101.Output.Result) > 0 {
  25354. fmt.Println("222222")
  25355. for _, item := range res3101.Output.Result {
  25356. if len(res3101.ErrMsg) == 0 {
  25357. res3101.ErrMsg = item.VolaCont
  25358. } else {
  25359. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25360. }
  25361. }
  25362. c.ServeSuccessJSON(map[string]interface{}{
  25363. "failed_code": -10,
  25364. "msg": res3101.ErrMsg,
  25365. })
  25366. return
  25367. } else {
  25368. fmt.Println("11111")
  25369. var api string
  25370. if miConfig.MdtrtareaAdmvs == "320830" {
  25371. ipt_otp_no = timeFormat
  25372. api = miConfig.AppSecret + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25373. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25374. "&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
  25375. } else if miConfig.MdtrtareaAdmvs == "320921" {
  25376. ipt_otp_no = timeFormat
  25377. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25378. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25379. "&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
  25380. } else {
  25381. ipt_otp_no = timeFormat
  25382. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25383. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25384. "&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
  25385. }
  25386. resp, requestErr := http.Get(api)
  25387. if requestErr != nil {
  25388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25389. return
  25390. }
  25391. body, ioErr := ioutil.ReadAll(resp.Body)
  25392. if ioErr != nil {
  25393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25395. return
  25396. }
  25397. var respJSON map[string]interface{}
  25398. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25401. return
  25402. }
  25403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25404. result, _ := json.Marshal(respJSON)
  25405. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25406. utils.ErrorLog("解析失败:%v", err)
  25407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25408. return
  25409. }
  25410. resThree.ErrMsg = resThree10265.ErrMsg
  25411. resThree.Output = resThree10265.Output
  25412. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25413. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25414. }
  25415. } else if res3101.Infcode != "0" {
  25416. c.ServeSuccessJSON(map[string]interface{}{
  25417. "failed_code": -10,
  25418. "msg": res3101.ErrMsg,
  25419. })
  25420. return
  25421. }
  25422. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25423. psn_info, _ := service.GetPsnByPatientId(id)
  25424. var cert_no string
  25425. if id_card_type == 1 {
  25426. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25427. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25428. } else if id_card_type == 4 {
  25429. cert_no = psn_info.VerifyNumber
  25430. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25431. } else {
  25432. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25433. cert_no = psn_info.VerifyNumber
  25434. }
  25435. 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)
  25436. saveLog(result, requestLog, "2201", "挂号")
  25437. if miConfig.Code == "H15049901371" {
  25438. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25439. utils.ErrorLog("解析失败:%v", err)
  25440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25441. return
  25442. }
  25443. resThree.ErrMsg = resThree10265.ErrMsg
  25444. resThree.Output = resThree10265.Output
  25445. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25446. } else {
  25447. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25448. utils.ErrorLog("解析失败:%v", err)
  25449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25450. return
  25451. }
  25452. }
  25453. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25454. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  25455. psn_info, _ := service.GetPsnByPatientId(id)
  25456. var result string
  25457. var requestLog string
  25458. if id_card_type == 1 {
  25459. bas := strings.Split(psn_info.CardInfo, "|")
  25460. basNumber := bas[2]
  25461. card_sn := bas[3]
  25462. 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)
  25463. saveLog(result, requestLog, "2201A", "挂号")
  25464. } else if id_card_type == 2 {
  25465. 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, "", "", "", "", "", "")
  25466. saveLog(result, requestLog, "2201A", "挂号")
  25467. } else {
  25468. 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)
  25469. saveLog(result, requestLog, "2201A", "挂号")
  25470. }
  25471. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25472. utils.ErrorLog("解析失败:%v", err)
  25473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25474. return
  25475. }
  25476. infocode = resThree.Infcode
  25477. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  25478. psn_info, _ := service.GetPsnByPatientId(id)
  25479. var result string
  25480. var requestLog string
  25481. if id_card_type == 1 {
  25482. bas := strings.Split(psn_info.CardInfo, "|")
  25483. basNumber := bas[2]
  25484. card_sn := ""
  25485. 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)
  25486. saveLog(result, requestLog, "2201A", "挂号")
  25487. } else if id_card_type == 2 {
  25488. 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, "", "", "", "", "", "")
  25489. saveLog(result, requestLog, "2201A", "挂号")
  25490. } else {
  25491. 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)
  25492. saveLog(result, requestLog, "2201A", "挂号")
  25493. }
  25494. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25495. utils.ErrorLog("解析失败:%v", err)
  25496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25497. return
  25498. }
  25499. infocode = resThree.Infcode
  25500. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  25501. psn_info, _ := service.GetPsnByPatientId(id)
  25502. var result string
  25503. var requestLog string
  25504. if id_card_type == 1 {
  25505. bas := strings.Split(psn_info.CardInfo, "|")
  25506. basNumber := bas[2]
  25507. card_sn := ""
  25508. 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)
  25509. saveLog(result, requestLog, "2201A", "挂号")
  25510. } else if id_card_type == 2 {
  25511. 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, "", "", "", "", "", "")
  25512. saveLog(result, requestLog, "2201A", "挂号")
  25513. } else {
  25514. 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)
  25515. saveLog(result, requestLog, "2201A", "挂号")
  25516. }
  25517. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25518. utils.ErrorLog("解析失败:%v", err)
  25519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25520. return
  25521. }
  25522. infocode = resThree.Infcode
  25523. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25524. psn_info, _ := service.GetPsnByPatientId(id)
  25525. his.PsnNo = psn_info.PsnNo
  25526. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25527. var cert_no string
  25528. if id_card_type == 1 {
  25529. bas := strings.Split(psn_info.CardInfo, "|")
  25530. cert_no = bas[2]
  25531. } else if id_card_type == 4 {
  25532. cert_no = psn_info.VerifyNumber
  25533. psn_info.VerifyNumber = psn_info.VerifyNumber
  25534. IdCardNo = psn_info.VerifyNumber
  25535. } else {
  25536. cert_no = IdCardNo
  25537. psn_info.VerifyNumber = cert_no
  25538. }
  25539. for _, item := range rf {
  25540. if item.Insutype == insutype {
  25541. his.InsuplcAdmdvs = insuplc_admdvs
  25542. }
  25543. }
  25544. his.Insutype = insutype
  25545. var api string
  25546. ipt_otp_no = timeFormat
  25547. 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 +
  25548. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25549. "&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
  25550. resp, requestErr := http.Get(api)
  25551. if requestErr != nil {
  25552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25553. return
  25554. }
  25555. body, ioErr := ioutil.ReadAll(resp.Body)
  25556. if ioErr != nil {
  25557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25559. return
  25560. }
  25561. var respJSON map[string]interface{}
  25562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25565. return
  25566. }
  25567. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25568. if status == "0" {
  25569. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25570. c.ServeSuccessJSON(map[string]interface{}{
  25571. "failed_code": -10,
  25572. "msg": err_msg,
  25573. })
  25574. return
  25575. }
  25576. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25577. result, _ := json.Marshal(respJSON)
  25578. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25579. utils.ErrorLog("解析失败:%v", err)
  25580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25581. return
  25582. }
  25583. infocode = resThree.Infcode
  25584. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25585. psn_info, _ := service.GetPsnByPatientId(id)
  25586. his.PsnNo = psn_info.PsnNo
  25587. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25588. var cert_no string
  25589. if id_card_type == 1 {
  25590. bas := strings.Split(psn_info.CardInfo, "|")
  25591. cert_no = bas[2]
  25592. } else if id_card_type == 4 {
  25593. cert_no = psn_info.VerifyNumber
  25594. psn_info.VerifyNumber = psn_info.VerifyNumber
  25595. IdCardNo = psn_info.VerifyNumber
  25596. } else {
  25597. cert_no = IdCardNo
  25598. psn_info.VerifyNumber = cert_no
  25599. }
  25600. for _, item := range rf {
  25601. if item.Insutype == insutype {
  25602. his.InsuplcAdmdvs = insuplc_admdvs
  25603. patient.InsuplcAdmdvs = insuplc_admdvs
  25604. }
  25605. }
  25606. his.Insutype = insutype
  25607. var api string
  25608. ipt_otp_no = timeFormat
  25609. 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 +
  25610. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25611. "&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
  25612. resp, requestErr := http.Get(api)
  25613. if requestErr != nil {
  25614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25615. return
  25616. }
  25617. body, ioErr := ioutil.ReadAll(resp.Body)
  25618. if ioErr != nil {
  25619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25621. return
  25622. }
  25623. var respJSON map[string]interface{}
  25624. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25627. return
  25628. }
  25629. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25630. if status == "0" {
  25631. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25632. c.ServeSuccessJSON(map[string]interface{}{
  25633. "failed_code": -10,
  25634. "msg": err_msg,
  25635. })
  25636. return
  25637. }
  25638. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25639. result, _ := json.Marshal(respJSON)
  25640. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25641. utils.ErrorLog("解析失败:%v", err)
  25642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25643. return
  25644. }
  25645. infocode = resThree.Infcode
  25646. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25647. hour := time.Now().Format("15")
  25648. min := time.Now().Format("04")
  25649. sec := time.Now().Format("05")
  25650. begin := record_time + " " + hour + ":" + min + ":" + sec
  25651. psn_info, _ := service.GetPsnByPatientId(id)
  25652. var result string
  25653. var requestLog string
  25654. if id_card_type == 1 {
  25655. bas := strings.Split(psn_info.CardInfo, "|")
  25656. basNumber := bas[2]
  25657. card_sn := bas[3]
  25658. 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)
  25659. saveLog(result, requestLog, "2201A", "挂号")
  25660. } else if id_card_type == 2 {
  25661. 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)
  25662. saveLog(result, requestLog, "2201A", "挂号")
  25663. } else {
  25664. 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)
  25665. saveLog(result, requestLog, "2201A", "挂号")
  25666. }
  25667. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25668. utils.ErrorLog("解析失败:%v", err)
  25669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25670. return
  25671. }
  25672. infocode = resThree.Infcode
  25673. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25674. psn_info, _ := service.GetPsnByPatientId(id)
  25675. 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)
  25676. saveLog(result, requestLog, "2201A", "挂号")
  25677. if miConfig.Code == "H15049901371" {
  25678. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25679. utils.ErrorLog("解析失败:%v", err)
  25680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25681. return
  25682. }
  25683. resThree.ErrMsg = resThree10265.ErrMsg
  25684. resThree.Output = resThree10265.Output
  25685. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25686. } else {
  25687. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25688. utils.ErrorLog("解析失败:%v", err)
  25689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25690. return
  25691. }
  25692. }
  25693. if miConfig.Code == "H15049901371" {
  25694. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25695. } else {
  25696. infocode = resThree.Infcode
  25697. }
  25698. } else {
  25699. psn_info, _ := service.GetPsnByPatientId(id)
  25700. if id_card_type == 4 || id_card_type == 1 {
  25701. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25702. }
  25703. var rf []*ResultFive
  25704. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25705. var insutypes []*ResultFive
  25706. var insutype string
  25707. var is390 int = 0
  25708. var is310 int = 0
  25709. for _, item := range rf {
  25710. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25711. insutypes = append(insutypes, item)
  25712. }
  25713. }
  25714. if len(insutypes) == 1 {
  25715. insutype = insutypes[0].Insutype
  25716. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25717. } else {
  25718. for _, i := range insutypes {
  25719. if i.Insutype == "390" {
  25720. is390 = 1
  25721. }
  25722. if i.Insutype == "310" {
  25723. is310 = 1
  25724. }
  25725. }
  25726. }
  25727. if is390 == 1 {
  25728. insutype = "390"
  25729. }
  25730. if is310 == 1 {
  25731. insutype = "310"
  25732. }
  25733. fmt.Println(len(insutypes))
  25734. if len(insutypes) == 0 {
  25735. for index, item := range rf {
  25736. if index == 0 {
  25737. insutype = item.Insutype
  25738. insuplc_admdvs = item.InsuplcAdmdvs
  25739. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25740. }
  25741. }
  25742. fmt.Println(insutype)
  25743. fmt.Println(insuplc_admdvs)
  25744. }
  25745. if social_type > 0 {
  25746. insutype = strconv.FormatInt(social_type, 10)
  25747. }
  25748. fmt.Println("--------")
  25749. fmt.Println(psn_info)
  25750. fmt.Println(psn_info.PsnNo)
  25751. for _, item := range rf {
  25752. if item.Insutype == insutype {
  25753. insutype = item.Insutype
  25754. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25755. }
  25756. }
  25757. if miConfig.MdtrtareaAdmvs == "441202" {
  25758. var hisPrescription []*models.HisPrescription
  25759. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25760. if res3101.Infcode == 0 {
  25761. fmt.Println("33333333")
  25762. if len(res3101.Output.Result) > 0 {
  25763. fmt.Println("222222")
  25764. for _, item := range res3101.Output.Result {
  25765. if len(res3101.ErrMsg) == 0 {
  25766. res3101.ErrMsg = item.VolaCont
  25767. } else {
  25768. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25769. }
  25770. }
  25771. c.ServeSuccessJSON(map[string]interface{}{
  25772. "failed_code": -10,
  25773. "msg": res3101.ErrMsg,
  25774. })
  25775. return
  25776. } else {
  25777. hour := time.Now().Format("15")
  25778. min := time.Now().Format("04")
  25779. sec := time.Now().Format("05")
  25780. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25781. fmt.Println(record_time_two)
  25782. 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)
  25783. saveLog(result, requestLog, "2201A", "挂号")
  25784. if miConfig.Code == "H15049901371" {
  25785. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25786. utils.ErrorLog("解析失败:%v", err)
  25787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25788. return
  25789. }
  25790. resThree.ErrMsg = resThree10265.ErrMsg
  25791. resThree.Output = resThree10265.Output
  25792. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25793. } else {
  25794. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25795. utils.ErrorLog("解析失败:%v", err)
  25796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25797. return
  25798. }
  25799. }
  25800. if miConfig.Code == "H15049901371" {
  25801. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25802. } else {
  25803. infocode = resThree.Infcode
  25804. }
  25805. }
  25806. } else if res3101.Infcode != 0 {
  25807. c.ServeSuccessJSON(map[string]interface{}{
  25808. "failed_code": -10,
  25809. "msg": res3101.ErrMsg,
  25810. })
  25811. return
  25812. }
  25813. } else if miConfig.MdtrtareaAdmvs == "440205" {
  25814. var hisPrescription []*models.HisPrescription
  25815. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25816. if res3101.Infcode == 0 {
  25817. fmt.Println("33333333")
  25818. if len(res3101.Output.Result) > 0 {
  25819. fmt.Println("222222")
  25820. for _, item := range res3101.Output.Result {
  25821. if len(res3101.ErrMsg) == 0 {
  25822. res3101.ErrMsg = item.VolaCont
  25823. } else {
  25824. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25825. }
  25826. }
  25827. c.ServeSuccessJSON(map[string]interface{}{
  25828. "failed_code": -10,
  25829. "msg": res3101.ErrMsg,
  25830. })
  25831. return
  25832. } else {
  25833. hour := time.Now().Format("15")
  25834. min := time.Now().Format("04")
  25835. sec := time.Now().Format("05")
  25836. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25837. fmt.Println(record_time_two)
  25838. 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)
  25839. saveLog(result, requestLog, "2201A", "挂号")
  25840. if miConfig.Code == "H15049901371" {
  25841. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25842. utils.ErrorLog("解析失败:%v", err)
  25843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25844. return
  25845. }
  25846. resThree.ErrMsg = resThree10265.ErrMsg
  25847. resThree.Output = resThree10265.Output
  25848. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25849. } else {
  25850. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25851. utils.ErrorLog("解析失败:%v", err)
  25852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25853. return
  25854. }
  25855. }
  25856. if miConfig.Code == "H15049901371" {
  25857. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25858. } else {
  25859. infocode = resThree.Infcode
  25860. }
  25861. }
  25862. } else if res3101.Infcode != 0 {
  25863. c.ServeSuccessJSON(map[string]interface{}{
  25864. "failed_code": -10,
  25865. "msg": res3101.ErrMsg,
  25866. })
  25867. return
  25868. }
  25869. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25870. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25871. psn_info, _ := service.GetPsnByPatientId(id)
  25872. var verify_number string
  25873. if id_card_type == 4 {
  25874. verify_number = psn_info.VerifyNumber
  25875. } else if id_card_type == 1 {
  25876. bas := strings.Split(psn_info.CardInfo, "|")
  25877. cardNumber := bas[2]
  25878. verify_number = cardNumber
  25879. } else {
  25880. verify_number = psn_info.Certno
  25881. }
  25882. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25883. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25884. "&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
  25885. resp, requestErr := http.Get(api)
  25886. if requestErr != nil {
  25887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25888. return
  25889. }
  25890. body, ioErr := ioutil.ReadAll(resp.Body)
  25891. if ioErr != nil {
  25892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25894. return
  25895. }
  25896. var respJSON map[string]interface{}
  25897. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25900. return
  25901. }
  25902. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25903. result, _ := json.Marshal(respJSON)
  25904. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25905. utils.ErrorLog("解析失败:%v", err)
  25906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25907. return
  25908. }
  25909. infocode = resThree.Infcode
  25910. } else {
  25911. hour := time.Now().Format("15")
  25912. min := time.Now().Format("04")
  25913. sec := time.Now().Format("05")
  25914. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25915. if id_card_type == 1 {
  25916. for _, item := range rf {
  25917. if item.Insutype == strconv.FormatInt(social_type, 10) {
  25918. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  25919. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25920. } else if strconv.FormatInt(social_type, 10) == "390" {
  25921. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25922. } else {
  25923. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25924. }
  25925. }
  25926. }
  25927. }
  25928. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  25929. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25930. }
  25931. if id_card_type == 1 {
  25932. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  25933. bas := strings.Split(psn_info.CardInfo, "|")
  25934. basNumber := bas[1]
  25935. IdCardNo = basNumber
  25936. }
  25937. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  25938. IdCardNo = psn_info.VerifyNumber
  25939. }
  25940. if len(insuplc_admdvs_temp) == 0 {
  25941. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25942. }
  25943. var result string
  25944. var requestLog string
  25945. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  25946. var hisPrescription []*models.HisPrescription
  25947. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25948. if res3101.Infcode == 0 {
  25949. if len(res3101.Output.Result) > 0 {
  25950. if len(res3101.Output.Result) > 0 {
  25951. c.ServeSuccessJSON(map[string]interface{}{
  25952. "failed_code": -10,
  25953. "failed_type": 100,
  25954. "warm_type": 1,
  25955. "msg": res3101,
  25956. })
  25957. return
  25958. } else {
  25959. c.ServeSuccessJSON(map[string]interface{}{
  25960. "failed_code": -10,
  25961. "msg": res3101.ErrMsg,
  25962. })
  25963. return
  25964. }
  25965. } else {
  25966. hour := time.Now().Format("15")
  25967. min := time.Now().Format("04")
  25968. sec := time.Now().Format("05")
  25969. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25970. fmt.Println(record_time_two)
  25971. if his.IdCardType == 2 {
  25972. IdCardNo = psn_info.Certno
  25973. psn_info.VerifyNumber = psn_info.Certno
  25974. } else if his.IdCardType == 4 {
  25975. IdCardNo = psn_info.Certno
  25976. } else {
  25977. bas := strings.Split(psn_info.CardInfo, "|")
  25978. IdCardNo = bas[2]
  25979. }
  25980. aaaa = insutype
  25981. result, requestLog = service.Gdyb2201A(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time_two, psn_info.VerifyNumber, admin_user_id)
  25982. saveLog(result, requestLog, "2201A", "挂号")
  25983. if miConfig.Code == "H15049901371" {
  25984. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25985. utils.ErrorLog("解析失败:%v", err)
  25986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25987. return
  25988. }
  25989. resThree.ErrMsg = resThree10265.ErrMsg
  25990. resThree.Output = resThree10265.Output
  25991. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25992. } else {
  25993. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25994. utils.ErrorLog("解析失败:%v", err)
  25995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25996. return
  25997. }
  25998. }
  25999. if miConfig.Code == "H15049901371" {
  26000. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26001. } else {
  26002. infocode = resThree.Infcode
  26003. }
  26004. }
  26005. } else if res3101.Infcode != 0 {
  26006. c.ServeSuccessJSON(map[string]interface{}{
  26007. "failed_code": -10,
  26008. "msg": res3101.ErrMsg,
  26009. })
  26010. return
  26011. }
  26012. } else {
  26013. psn_info, _ := service.GetPsnByPatientId(id)
  26014. var rf []*ResultFive
  26015. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  26016. //var insutypes []*ResultFive
  26017. var insutype string
  26018. var insutypes []*ResultFive
  26019. var is390 int = 0
  26020. var is310 int = 0
  26021. for _, item := range rf {
  26022. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26023. insutypes = append(insutypes, item)
  26024. }
  26025. }
  26026. if len(insutypes) == 1 {
  26027. insutype = insutypes[0].Insutype
  26028. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  26029. } else {
  26030. for _, i := range insutypes {
  26031. if i.Insutype == "390" {
  26032. is390 = 1
  26033. }
  26034. if i.Insutype == "310" {
  26035. is310 = 1
  26036. }
  26037. }
  26038. }
  26039. if is390 == 1 {
  26040. insutype = "390"
  26041. }
  26042. if is310 == 1 {
  26043. insutype = "310"
  26044. }
  26045. if len(insutypes) == 0 {
  26046. insutype = "310"
  26047. }
  26048. if social_type > 0 {
  26049. insutype = strconv.FormatInt(social_type, 10)
  26050. }
  26051. for _, item := range rf {
  26052. if item.Insutype == insutype {
  26053. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26054. }
  26055. }
  26056. if len(insuplc_admdvs_tt) > 0 {
  26057. insuplc_admdvs_temp = insuplc_admdvs_tt
  26058. }
  26059. 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)
  26060. saveLog(result, requestLog, "2201A", "挂号")
  26061. }
  26062. if miConfig.Code == "H15049901371" {
  26063. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26064. utils.ErrorLog("解析失败:%v", err)
  26065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26066. return
  26067. }
  26068. resThree.ErrMsg = resThree10265.ErrMsg
  26069. resThree.Output = resThree10265.Output
  26070. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26071. } else {
  26072. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26073. utils.ErrorLog("解析失败:%v", err)
  26074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26075. return
  26076. }
  26077. }
  26078. if miConfig.Code == "H15049901371" {
  26079. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26080. } else {
  26081. infocode = resThree.Infcode
  26082. }
  26083. }
  26084. }
  26085. if infocode == -1 {
  26086. adminUser := c.GetAdminUserInfo()
  26087. errlog := &models.HisOrderError{
  26088. UserOrgId: adminUser.CurrentOrgId,
  26089. Ctime: time.Now().Unix(),
  26090. Mtime: time.Now().Unix(),
  26091. ErrMsg: resThree.ErrMsg,
  26092. Status: 1,
  26093. PatientId: id,
  26094. RecordTime: recordDateTime,
  26095. Stage: 2,
  26096. }
  26097. service.CreateErrMsgLog(errlog)
  26098. c.ServeSuccessJSON(map[string]interface{}{
  26099. "failed_code": -10,
  26100. "msg": resThree.ErrMsg,
  26101. })
  26102. return
  26103. }
  26104. utils.ErrorLog("解析失败:%v", insutype)
  26105. his.Number = resThree.Output.Data.MdtrtID
  26106. his.PsnNo = resThree.Output.Data.PsnNo
  26107. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  26108. his.IdCardNo = patient.IdCardNo
  26109. his.PhoneNumber = patient.Phone
  26110. his.UserOrgId = adminInfo.CurrentOrgId
  26111. his.Insutype = insutype
  26112. if miConfig.Code == "H44030500255" {
  26113. his.Insutype = aaaa
  26114. }
  26115. his.Ctime = time.Now().Unix()
  26116. his.Mtime = time.Now().Unix()
  26117. his.InsuplcAdmdvs = insuplc_admdvs_temp
  26118. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  26119. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26120. }
  26121. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  26122. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26123. }
  26124. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  26125. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26126. }
  26127. his.Status = 1
  26128. his.MdtrtGrpType = mdtrt_type
  26129. service.UpdateHisPatientStatus(&his)
  26130. service.UpdateHisPatient123(&patient)
  26131. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  26132. c.ServeSuccessJSON(map[string]interface{}{
  26133. "his_info": his,
  26134. })
  26135. } else {
  26136. adminUser := c.GetAdminUserInfo()
  26137. errlog := &models.HisOrderError{
  26138. UserOrgId: adminUser.CurrentOrgId,
  26139. Ctime: time.Now().Unix(),
  26140. Mtime: time.Now().Unix(),
  26141. ErrMsg: res.ErrMsg,
  26142. Status: 1,
  26143. PatientId: id,
  26144. RecordTime: recordDateTime,
  26145. Stage: 1,
  26146. }
  26147. service.CreateErrMsgLog(errlog)
  26148. c.ServeSuccessJSON(map[string]interface{}{
  26149. "failed_code": -10,
  26150. "msg": res.ErrMsg,
  26151. })
  26152. return
  26153. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26154. }
  26155. }
  26156. }
  26157. func (c *HisApiController) GetUploadInfo() {
  26158. id, _ := c.GetInt64("id")
  26159. record_time := c.GetString("record_time")
  26160. his_patient_id, _ := c.GetInt64("his_patient_id")
  26161. order_id, _ := c.GetInt64("order_id")
  26162. pay_way, _ := c.GetInt64("pay_way")
  26163. pay_ways := c.GetString("pay_ways")
  26164. oth_desc := c.GetString("oth_desc")
  26165. pay_price, _ := c.GetFloat("pay_price")
  26166. pay_card_no := c.GetString("pay_card_no")
  26167. discount_price, _ := c.GetFloat("discount_price")
  26168. preferential_price, _ := c.GetFloat("preferential_price")
  26169. reality_price, _ := c.GetFloat("reality_price")
  26170. found_price, _ := c.GetFloat("found_price")
  26171. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  26172. private_price, _ := c.GetFloat("private_price")
  26173. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  26174. admin_user_id, _ := c.GetInt64("admin_user_id")
  26175. fapiao_code := c.GetString("fapiao_code")
  26176. fapiao_number := c.GetString("fapiao_number")
  26177. diagnosis_id := c.GetString("diagnosis")
  26178. sick_type, _ := c.GetInt64("sick_type")
  26179. reg_type, _ := c.GetInt64("p_type")
  26180. begin_time := c.GetString("begin_time")
  26181. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  26182. cash_pay := c.GetString("cash_pay")
  26183. band_card_pay := c.GetString("band_card_pay")
  26184. wechat_pay := c.GetString("wechat_pay")
  26185. ali_pay := c.GetString("ali_pay")
  26186. jifen_pay := c.GetString("jifen_pay")
  26187. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  26188. fmt.Println(acct_used_flag)
  26189. id_str := c.GetString("ids")
  26190. ids_arr := strings.Split(id_str, ",")
  26191. timeLayout := "2006-01-02"
  26192. loc, _ := time.LoadLocation("Local")
  26193. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26194. if err != nil {
  26195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26196. return
  26197. }
  26198. recordDateTime := theTime.Unix()
  26199. adminUser := c.GetAdminUserInfo()
  26200. var tempOrder models.HisOrder
  26201. tempOrder, _ = service.GetHisOrderByID(order_id)
  26202. var prescriptions []*models.HisPrescription
  26203. var start_time int64
  26204. var end_time int64
  26205. //押金模块
  26206. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  26207. tmp_decimal := c.GetString("tmp_decimal")
  26208. var decimal float64 //本次使用的押金
  26209. var errmsg error
  26210. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  26211. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  26212. return
  26213. }
  26214. if len(tmp_decimal) > 0 {
  26215. if tmp_decimal[0] == 45 {
  26216. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  26217. return
  26218. }
  26219. }
  26220. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  26221. fmt.Println(errs)
  26222. decimal = tt
  26223. //if adminUser.CurrentOrgId == 10106{
  26224. // if len(fapiao_code) == 0{
  26225. // fapiao_code = "144072080589"
  26226. // }
  26227. // if len(fapiao_number) == 0{
  26228. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  26229. // if order.ID == 0{
  26230. // fapiao_number = "00001520"
  26231. // }else{
  26232. // //fapiao_code = "00001520"
  26233. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  26234. // var zero string
  26235. // if fpNumber >= 1000{
  26236. // zero = "0000" + strconv.Itoa(fpNumber)
  26237. // }else if fpNumber >= 10000{
  26238. // zero = "000" + strconv.Itoa(fpNumber)
  26239. // } else if fpNumber >= 100000{
  26240. // zero = "00" + strconv.Itoa(fpNumber)
  26241. // } else if fpNumber >= 1000000{
  26242. // zero = "0" + strconv.Itoa(fpNumber)
  26243. // }else {
  26244. // zero = strconv.Itoa(fpNumber)
  26245. // }
  26246. // fapiao_number = zero
  26247. // }
  26248. // }
  26249. //}
  26250. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26251. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26252. var patientPrescription models.HisPrescriptionInfo
  26253. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26254. if patientPrescription.ID == 0 {
  26255. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26256. }
  26257. //if patientPrescription.Do
  26258. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26259. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26260. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26261. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26262. var config []*models.HisXtDiagnoseConfig
  26263. for _, item := range diagnosis_ids {
  26264. id, _ := strconv.ParseInt(item, 10, 64)
  26265. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26266. config = append(config, &diagnosisConfig)
  26267. }
  26268. sickConfig, _ := service.FindSickById(sick_type)
  26269. //if tempOrder.ID == 0 {
  26270. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  26271. //}
  26272. if tempOrder.ID == 0 {
  26273. var result string
  26274. var requestLog string
  26275. var res2 ResultSix
  26276. var res3 GZResultSix
  26277. var ressix10265 ResultSix10265
  26278. if miConfig.MdtrtareaAdmvs == "421300" {
  26279. data := make(map[string]interface{})
  26280. client := &http.Client{}
  26281. data["psn_no"] = his.PsnNo
  26282. data["mdtrt_id"] = his.Number
  26283. data["opter"] = roles.UserName
  26284. data["org_name"] = miConfig.OrgName
  26285. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26286. data["doctor_id"] = doctor_info.DoctorNumber
  26287. data["doctor_name"] = doctor_info.UserName
  26288. data["department"] = department.Name
  26289. data["fixmedins_code"] = miConfig.Code
  26290. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26291. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26292. data["secret_key"] = miConfig.SecretKey
  26293. data["sick_code"] = sickConfig.CountryCode
  26294. data["sick_name"] = sickConfig.ClassName
  26295. data["dept"] = strconv.FormatInt(department.ID, 10)
  26296. data["config"] = config
  26297. data["begin_time"] = begin_time
  26298. bytesData, _ := json.Marshal(data)
  26299. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26300. resp, _ := client.Do(req)
  26301. defer resp.Body.Close()
  26302. body, ioErr := ioutil.ReadAll(resp.Body)
  26303. if ioErr != nil {
  26304. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26306. return
  26307. }
  26308. var respJSON map[string]interface{}
  26309. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26312. return
  26313. }
  26314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26315. userJSONBytes, _ := json.Marshal(respJSON)
  26316. fmt.Println("log")
  26317. fmt.Println(string(userJSONBytes))
  26318. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26319. utils.ErrorLog("解析失败:%v", err)
  26320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26321. return
  26322. }
  26323. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26324. data := make(map[string]interface{})
  26325. client := &http.Client{}
  26326. data["psn_no"] = his.PsnNo
  26327. data["mdtrt_id"] = his.Number
  26328. data["opter"] = roles.UserName
  26329. data["org_name"] = miConfig.OrgName
  26330. if reg_type == 11 && his.Insutype == "390" {
  26331. data["med_type"] = "110104"
  26332. } else {
  26333. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26334. }
  26335. data["doctor_id"] = doctor_info.DoctorNumber
  26336. data["doctor_name"] = doctor_info.UserName
  26337. data["department"] = department.Name
  26338. data["fixmedins_code"] = miConfig.Code
  26339. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26340. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26341. data["secret_key"] = miConfig.SecretKey
  26342. data["sick_code"] = sickConfig.CountryCode
  26343. data["sick_name"] = sickConfig.ClassName
  26344. data["dept"] = strconv.FormatInt(department.ID, 10)
  26345. data["config"] = config
  26346. data["begin_time"] = begin_time
  26347. bytesData, _ := json.Marshal(data)
  26348. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26349. resp, _ := client.Do(req)
  26350. defer resp.Body.Close()
  26351. body, ioErr := ioutil.ReadAll(resp.Body)
  26352. if ioErr != nil {
  26353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26355. return
  26356. }
  26357. var respJSON map[string]interface{}
  26358. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26361. return
  26362. }
  26363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26364. userJSONBytes, _ := json.Marshal(respJSON)
  26365. fmt.Println("log")
  26366. fmt.Println(string(userJSONBytes))
  26367. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26368. utils.ErrorLog("解析失败:%v", err)
  26369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26370. return
  26371. }
  26372. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26373. data := make(map[string]interface{})
  26374. client := &http.Client{}
  26375. data["psn_no"] = his.PsnNo
  26376. data["mdtrt_id"] = his.Number
  26377. data["opter"] = roles.UserName
  26378. data["org_name"] = miConfig.OrgName
  26379. if reg_type == 11 && his.Insutype == "390" {
  26380. data["med_type"] = "110104"
  26381. } else {
  26382. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26383. }
  26384. data["doctor_id"] = doctor_info.DoctorNumber
  26385. data["doctor_name"] = doctor_info.UserName
  26386. data["department"] = department.Name
  26387. data["fixmedins_code"] = miConfig.Code
  26388. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26389. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26390. data["secret_key"] = miConfig.SecretKey
  26391. data["sick_code"] = sickConfig.CountryCode
  26392. data["sick_name"] = sickConfig.ClassName
  26393. data["dept"] = strconv.FormatInt(department.ID, 10)
  26394. data["config"] = config
  26395. data["begin_time"] = begin_time
  26396. bytesData, _ := json.Marshal(data)
  26397. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26398. resp, _ := client.Do(req)
  26399. defer resp.Body.Close()
  26400. body, ioErr := ioutil.ReadAll(resp.Body)
  26401. if ioErr != nil {
  26402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26404. return
  26405. }
  26406. var respJSON map[string]interface{}
  26407. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26410. return
  26411. }
  26412. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26413. userJSONBytes, _ := json.Marshal(respJSON)
  26414. fmt.Println("log")
  26415. fmt.Println(string(userJSONBytes))
  26416. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26417. utils.ErrorLog("解析失败:%v", err)
  26418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26419. return
  26420. }
  26421. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26422. data := make(map[string]interface{})
  26423. client := &http.Client{}
  26424. data["psn_no"] = his.PsnNo
  26425. data["mdtrt_id"] = his.Number
  26426. data["opter"] = roles.UserName
  26427. data["org_name"] = miConfig.OrgName
  26428. if reg_type == 11 && his.Insutype == "390" {
  26429. data["med_type"] = "110104"
  26430. } else {
  26431. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26432. }
  26433. data["doctor_id"] = doctor_info.DoctorNumber
  26434. data["doctor_name"] = doctor_info.UserName
  26435. data["department"] = department.Name
  26436. data["fixmedins_code"] = miConfig.Code
  26437. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26438. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26439. data["secret_key"] = miConfig.SecretKey
  26440. data["sick_code"] = sickConfig.CountryCode
  26441. data["sick_name"] = sickConfig.ClassName
  26442. data["dept"] = strconv.FormatInt(department.ID, 10)
  26443. data["config"] = config
  26444. data["begin_time"] = begin_time
  26445. bytesData, _ := json.Marshal(data)
  26446. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26447. resp, _ := client.Do(req)
  26448. defer resp.Body.Close()
  26449. body, ioErr := ioutil.ReadAll(resp.Body)
  26450. if ioErr != nil {
  26451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26453. return
  26454. }
  26455. var respJSON map[string]interface{}
  26456. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26459. return
  26460. }
  26461. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26462. userJSONBytes, _ := json.Marshal(respJSON)
  26463. fmt.Println("log")
  26464. fmt.Println(string(userJSONBytes))
  26465. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26466. utils.ErrorLog("解析失败:%v", err)
  26467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26468. return
  26469. }
  26470. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26471. utils.ErrorLog("解析失败:%v", doctor_info)
  26472. data := make(map[string]interface{})
  26473. client := &http.Client{}
  26474. data["psn_no"] = his.PsnNo
  26475. data["mdtrt_id"] = his.Number
  26476. data["doctor"] = roles.UserName
  26477. data["department"] = department.Name
  26478. data["org_name"] = miConfig.OrgName
  26479. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26480. data["doctor_id"] = doctor_info.DoctorNumber
  26481. data["new_doctor_name"] = doctor_info.UserName
  26482. data["fixmedins_code"] = miConfig.Code
  26483. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26484. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26485. data["secret_key"] = miConfig.SecretKey
  26486. data["sick_code"] = sickConfig.CountryCode
  26487. data["sick_name"] = sickConfig.ClassName
  26488. data["url"] = miConfig.Url
  26489. data["ak"] = miConfig.AccessKey
  26490. data["begin_time"] = begin_time
  26491. data["cainfo"] = miConfig.Cainfo
  26492. data["dept"] = strconv.FormatInt(department.ID, 10)
  26493. data["config"] = config
  26494. bytesData, _ := json.Marshal(data)
  26495. var req *http.Request
  26496. if miConfig.MdtrtareaAdmvs == "320830" {
  26497. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  26498. //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 +
  26499. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26500. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26501. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26502. //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 +
  26503. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26504. } else {
  26505. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26506. }
  26507. resp, _ := client.Do(req)
  26508. defer resp.Body.Close()
  26509. body, ioErr := ioutil.ReadAll(resp.Body)
  26510. if ioErr != nil {
  26511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26513. return
  26514. }
  26515. var respJSON map[string]interface{}
  26516. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26519. return
  26520. }
  26521. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26522. userJSONBytes, _ := json.Marshal(respJSON)
  26523. fmt.Println("log")
  26524. fmt.Println(string(userJSONBytes))
  26525. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26526. utils.ErrorLog("解析失败:%v", err)
  26527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26528. return
  26529. }
  26530. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26531. res2.Output = ressix10265.Output
  26532. res2.ErrMsg = ressix10265.ErrMsg
  26533. res2.Cainfo = ressix10265.Cainfo
  26534. res2.WarnMsg = ressix10265.WarnMsg
  26535. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26536. res2.Infcode = infocode
  26537. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26538. data := make(map[string]interface{})
  26539. client := &http.Client{}
  26540. data["psn_no"] = his.PsnNo
  26541. data["mdtrt_id"] = his.Number
  26542. data["doctor"] = roles.UserName
  26543. data["department"] = department.Name
  26544. data["org_name"] = miConfig.OrgName
  26545. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26546. data["doctor_id"] = doctor_info.DoctorNumber
  26547. data["new_doctor_name"] = doctor_info.UserName
  26548. data["fixmedins_code"] = miConfig.Code
  26549. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26550. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26551. data["secret_key"] = miConfig.SecretKey
  26552. data["sick_code"] = sickConfig.CountryCode
  26553. data["sick_name"] = sickConfig.ClassName
  26554. data["url"] = miConfig.Url
  26555. data["ak"] = miConfig.AccessKey
  26556. data["begin_time"] = begin_time
  26557. data["cainfo"] = miConfig.Cainfo
  26558. data["dept"] = strconv.FormatInt(department.ID, 10)
  26559. data["config"] = config
  26560. bytesData, _ := json.Marshal(data)
  26561. var req *http.Request
  26562. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26563. resp, _ := client.Do(req)
  26564. defer resp.Body.Close()
  26565. body, ioErr := ioutil.ReadAll(resp.Body)
  26566. if ioErr != nil {
  26567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26569. return
  26570. }
  26571. var respJSON map[string]interface{}
  26572. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26575. return
  26576. }
  26577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26578. userJSONBytes, _ := json.Marshal(respJSON)
  26579. fmt.Println("log")
  26580. fmt.Println(string(userJSONBytes))
  26581. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26582. utils.ErrorLog("解析失败:%v", err)
  26583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26584. return
  26585. }
  26586. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26587. res2.Output = ressix10265.Output
  26588. res2.ErrMsg = ressix10265.ErrMsg
  26589. res2.Cainfo = ressix10265.Cainfo
  26590. res2.WarnMsg = ressix10265.WarnMsg
  26591. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26592. res2.Infcode = infocode
  26593. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26594. 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)
  26595. saveLog(result, requestLog, "2203", "上传就诊信息")
  26596. var respJSON2 map[string]interface{}
  26597. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26600. return
  26601. }
  26602. userJSONBytes2, _ := json.Marshal(respJSON2)
  26603. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26604. utils.ErrorLog("解析失败:%v", err)
  26605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26606. return
  26607. }
  26608. 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)
  26609. fmt.Println(result2)
  26610. fmt.Println(src_request)
  26611. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26612. data := make(map[string]interface{})
  26613. client := &http.Client{}
  26614. data["psn_no"] = his.PsnNo
  26615. data["mdtrt_id"] = his.Number
  26616. data["doctor"] = roles.UserName
  26617. data["department"] = department.Name
  26618. data["org_name"] = miConfig.OrgName
  26619. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26620. data["doctor_id"] = doctor_info.DoctorNumber
  26621. data["new_doctor_name"] = doctor_info.UserName
  26622. data["fixmedins_code"] = miConfig.Code
  26623. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26624. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26625. data["secret_key"] = miConfig.SecretKey
  26626. data["sick_code"] = sickConfig.CountryCode
  26627. data["sick_name"] = sickConfig.ClassName
  26628. data["url"] = miConfig.Url
  26629. data["ak"] = miConfig.AccessKey
  26630. data["begin_time"] = begin_time
  26631. data["cainfo"] = miConfig.Cainfo
  26632. data["dept"] = strconv.FormatInt(department.ID, 10)
  26633. data["config"] = config
  26634. bytesData, _ := json.Marshal(data)
  26635. var req *http.Request
  26636. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  26637. resp, _ := client.Do(req)
  26638. defer resp.Body.Close()
  26639. body, ioErr := ioutil.ReadAll(resp.Body)
  26640. if ioErr != nil {
  26641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26643. return
  26644. }
  26645. var respJSON map[string]interface{}
  26646. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26649. return
  26650. }
  26651. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26652. userJSONBytes, _ := json.Marshal(respJSON)
  26653. fmt.Println("log")
  26654. fmt.Println(string(userJSONBytes))
  26655. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26656. utils.ErrorLog("解析失败:%v", err)
  26657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26658. return
  26659. }
  26660. } else {
  26661. if miConfig.MdtrtareaAdmvs == "440781" { //
  26662. 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)
  26663. } else {
  26664. if miConfig.Code == "H15049901371" {
  26665. //赤峰地区国家医保医疗类别
  26666. //职工透析:医疗类别选特殊情况门诊990502
  26667. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26668. var med_type string
  26669. if his.Insutype == "390" {
  26670. if reg_type == 14 {
  26671. med_type = "9933"
  26672. } else if reg_type == 11 {
  26673. med_type = "11"
  26674. }
  26675. } else if his.Insutype == "310" {
  26676. if reg_type == 14 {
  26677. med_type = "990502"
  26678. } else if reg_type == 11 {
  26679. med_type = "11"
  26680. }
  26681. }
  26682. 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)
  26683. } else {
  26684. 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)
  26685. }
  26686. }
  26687. saveLog(result, requestLog, "2203", "上传就诊信息")
  26688. var respJSON2 map[string]interface{}
  26689. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26692. return
  26693. }
  26694. userJSONBytes2, _ := json.Marshal(respJSON2)
  26695. if miConfig.Code == "H15049901371" {
  26696. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  26697. utils.ErrorLog("解析失败:%v", err)
  26698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26699. return
  26700. }
  26701. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26702. res2.Output = ressix10265.Output
  26703. res2.ErrMsg = ressix10265.ErrMsg
  26704. res2.Cainfo = ressix10265.Cainfo
  26705. res2.WarnMsg = ressix10265.WarnMsg
  26706. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26707. res2.Infcode = infocode
  26708. } else {
  26709. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26710. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26711. utils.ErrorLog("解析失败:%v", err)
  26712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26713. return
  26714. }
  26715. res2.Infcode = res3.Infcode
  26716. } else {
  26717. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26718. utils.ErrorLog("解析失败:%v", err)
  26719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26720. return
  26721. }
  26722. }
  26723. }
  26724. }
  26725. if res2.Infcode == -1 {
  26726. adminUser := c.GetAdminUserInfo()
  26727. errlog := &models.HisOrderError{
  26728. UserOrgId: adminUser.CurrentOrgId,
  26729. Ctime: time.Now().Unix(),
  26730. Mtime: time.Now().Unix(),
  26731. ErrMsg: res2.ErrMsg,
  26732. Status: 1,
  26733. PatientId: id,
  26734. RecordTime: recordDateTime,
  26735. Stage: 3,
  26736. }
  26737. service.CreateErrMsgLog(errlog)
  26738. c.ServeSuccessJSON(map[string]interface{}{
  26739. "failed_code": -10,
  26740. "msg": res2.ErrMsg,
  26741. })
  26742. return
  26743. } else {
  26744. his.Diagnosis = diagnosis_id
  26745. his.SickType = sickConfig.ID
  26746. //var p_type int64
  26747. //if reg_type == 1111 || reg_type == 1112 {
  26748. // p_type = 11
  26749. //
  26750. //}
  26751. his.PType = fmt.Sprintf("%d", reg_type)
  26752. service.UpdateHisPatientThree(&his)
  26753. data := make(map[string]interface{})
  26754. if settle_accounts_type == 1 { //日结
  26755. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26756. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26757. } else {
  26758. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26759. }
  26760. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  26761. data["pre"] = prescriptions
  26762. } else { //月结
  26763. start_time_str := c.GetString("start_time")
  26764. end_time_str := c.GetString("end_time")
  26765. timeLayout := "2006-01-02"
  26766. loc, _ := time.LoadLocation("Local")
  26767. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26768. if err != nil {
  26769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26770. return
  26771. }
  26772. recordStartTime := theStartTime.Unix()
  26773. start_time = recordStartTime
  26774. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26775. if err != nil {
  26776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26777. return
  26778. }
  26779. recordEndTime := theEndTime.Unix()
  26780. end_time = recordEndTime
  26781. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26782. data["pre"] = prescriptions
  26783. }
  26784. timestamp := time.Now().Unix()
  26785. tempTime := time.Unix(timestamp, 0)
  26786. timeFormat := tempTime.Format("20060102150405")
  26787. chrgBchno := rand.Intn(100000) + 10000
  26788. new_chrg_bchno := ""
  26789. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  26790. new_chrg_bchno = chrg_bchno
  26791. strconv.FormatInt(his.PatientId, 10)
  26792. client := &http.Client{}
  26793. if adminUser.CurrentOrgId == 10265 {
  26794. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26795. new_chrg_bchno = "0000"
  26796. }
  26797. }
  26798. data["psn_no"] = his.PsnNo
  26799. data["mdtrt_id"] = his.Number
  26800. data["chrg_bchno"] = new_chrg_bchno
  26801. data["org_name"] = miConfig.OrgName
  26802. data["doctor"] = doctor_info.UserName
  26803. data["doctor_id"] = doctor_info.DoctorNumber
  26804. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  26805. data["fixmedins_code"] = miConfig.Code
  26806. data["dept_code"] = department.Number
  26807. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26808. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26809. data["secret_key"] = miConfig.SecretKey
  26810. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26811. data["url"] = miConfig.Url
  26812. data["ak"] = miConfig.AccessKey
  26813. data["new_doctor_name"] = patientPrescription.Doctor
  26814. data["diag_code"] = sickConfig.CountryCode
  26815. data["cainfo"] = miConfig.Cainfo
  26816. data["opter"] = roles.UserName
  26817. var ids []int64
  26818. for _, item := range prescriptions {
  26819. ids = append(ids, item.ID)
  26820. }
  26821. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26822. if config.IsOpen == 1 { //对接了医保,走医保流程
  26823. var res ResultFour
  26824. var resFour10265 ResultFour10265
  26825. if miConfig.MdtrtareaAdmvs == "421300" {
  26826. bytesData, _ := json.Marshal(data)
  26827. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26828. resp, _ := client.Do(req)
  26829. defer resp.Body.Close()
  26830. body, ioErr := ioutil.ReadAll(resp.Body)
  26831. if ioErr != nil {
  26832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26834. return
  26835. }
  26836. var respJSON map[string]interface{}
  26837. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26840. return
  26841. }
  26842. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26843. userJSONBytes, _ := json.Marshal(respJSON)
  26844. fmt.Println("log")
  26845. fmt.Println(string(userJSONBytes))
  26846. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26847. utils.ErrorLog("解析失败:%v", err)
  26848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26849. return
  26850. }
  26851. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26852. bytesData, _ := json.Marshal(data)
  26853. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26854. resp, _ := client.Do(req)
  26855. defer resp.Body.Close()
  26856. body, ioErr := ioutil.ReadAll(resp.Body)
  26857. if ioErr != nil {
  26858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26860. return
  26861. }
  26862. var respJSON map[string]interface{}
  26863. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26866. return
  26867. }
  26868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26869. userJSONBytes, _ := json.Marshal(respJSON)
  26870. fmt.Println("log")
  26871. fmt.Println(string(userJSONBytes))
  26872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26873. utils.ErrorLog("解析失败:%v", err)
  26874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26875. return
  26876. }
  26877. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26878. bytesData, _ := json.Marshal(data)
  26879. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26880. resp, _ := client.Do(req)
  26881. defer resp.Body.Close()
  26882. body, ioErr := ioutil.ReadAll(resp.Body)
  26883. if ioErr != nil {
  26884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26886. return
  26887. }
  26888. var respJSON map[string]interface{}
  26889. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26892. return
  26893. }
  26894. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26895. userJSONBytes, _ := json.Marshal(respJSON)
  26896. fmt.Println("log")
  26897. fmt.Println(string(userJSONBytes))
  26898. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26899. utils.ErrorLog("解析失败:%v", err)
  26900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26901. return
  26902. }
  26903. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26904. bytesData, _ := json.Marshal(data)
  26905. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26906. resp, _ := client.Do(req)
  26907. defer resp.Body.Close()
  26908. body, ioErr := ioutil.ReadAll(resp.Body)
  26909. if ioErr != nil {
  26910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26912. return
  26913. }
  26914. var respJSON map[string]interface{}
  26915. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26918. return
  26919. }
  26920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26921. userJSONBytes, _ := json.Marshal(respJSON)
  26922. fmt.Println("log")
  26923. fmt.Println(string(userJSONBytes))
  26924. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26925. utils.ErrorLog("解析失败:%v", err)
  26926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26927. return
  26928. }
  26929. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26930. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26931. var result3101 Result3101
  26932. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26933. result3101.Infcode = "0"
  26934. if result3101.Infcode == "0" {
  26935. if len(result3101.Output.Result) > 0 {
  26936. var errMsgs []string
  26937. for _, item := range result3101.Output.Result {
  26938. errMsgs = append(errMsgs, item.VolaCont)
  26939. }
  26940. c.ServeSuccessJSON(map[string]interface{}{
  26941. "failed_code": -10,
  26942. "msg": errMsgs,
  26943. })
  26944. return
  26945. }
  26946. }
  26947. bytesData, _ := json.Marshal(data)
  26948. var req *http.Request
  26949. if miConfig.MdtrtareaAdmvs == "320830" {
  26950. data["diag_code"] = sickConfig.CountryCode
  26951. fmt.Println(data)
  26952. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  26953. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26954. data["diag_code"] = sickConfig.CountryCode
  26955. fmt.Println(data)
  26956. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26957. } else {
  26958. data["diag_code"] = sickConfig.CountryCode
  26959. fmt.Println(data)
  26960. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26961. }
  26962. resp, _ := client.Do(req)
  26963. defer resp.Body.Close()
  26964. body, ioErr := ioutil.ReadAll(resp.Body)
  26965. if ioErr != nil {
  26966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26968. return
  26969. }
  26970. var respJSON map[string]interface{}
  26971. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26974. return
  26975. }
  26976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26977. userJSONBytes, _ := json.Marshal(respJSON)
  26978. fmt.Println("log")
  26979. fmt.Println(string(userJSONBytes))
  26980. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26981. utils.ErrorLog("解析失败:%v", err)
  26982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26983. return
  26984. }
  26985. res.InfRefmsgid = resFour10265.InfRefmsgid
  26986. res.Output = resFour10265.Output
  26987. res.ErrMsg = resFour10265.ErrMsg
  26988. res.Cainfo = resFour10265.Cainfo
  26989. res.WarnMsg = resFour10265.WarnMsg
  26990. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26991. res.Infcode = infocode
  26992. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26993. var pagesize int = 2
  26994. var start int = 1
  26995. var stop int
  26996. var pagecount int
  26997. var curpage int
  26998. var isSuccess bool = true
  26999. data["doctor_id"] = doctor_info.DoctorNumber
  27000. //总页数,向上取整,注意除之前要先转换类型为float64
  27001. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  27002. for curpage = 1; curpage <= pagecount; curpage++ {
  27003. if curpage == 1 {
  27004. start = 1
  27005. } else {
  27006. start = (curpage-1)*pagesize + 1
  27007. }
  27008. stop = curpage * pagesize
  27009. if stop > len(prescriptions) {
  27010. stop = len(prescriptions)
  27011. }
  27012. //var requestLog string
  27013. data["pre"] = prescriptions[start-1 : stop]
  27014. fmt.Println(data["pre"])
  27015. bytesData, _ := json.Marshal(data)
  27016. var req *http.Request
  27017. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  27018. resp, _ := client.Do(req)
  27019. defer resp.Body.Close()
  27020. body, ioErr := ioutil.ReadAll(resp.Body)
  27021. if ioErr != nil {
  27022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27024. return
  27025. }
  27026. var respJSON map[string]interface{}
  27027. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27030. return
  27031. }
  27032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27033. userJSONBytes, _ := json.Marshal(respJSON)
  27034. fmt.Println("log")
  27035. fmt.Println(string(userJSONBytes))
  27036. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27037. utils.ErrorLog("解析失败:%v", err)
  27038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27039. return
  27040. }
  27041. res.InfRefmsgid = resFour10265.InfRefmsgid
  27042. res.Output = resFour10265.Output
  27043. res.ErrMsg = resFour10265.ErrMsg
  27044. res.Cainfo = resFour10265.Cainfo
  27045. res.WarnMsg = resFour10265.WarnMsg
  27046. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27047. res.Infcode = infocode
  27048. if infocode == 0 {
  27049. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  27050. } else {
  27051. isSuccess = false
  27052. errlog := &models.HisOrderError{
  27053. UserOrgId: adminUser.CurrentOrgId,
  27054. Ctime: time.Now().Unix(),
  27055. Mtime: time.Now().Unix(),
  27056. Number: chrg_bchno,
  27057. ErrMsg: "",
  27058. Status: 1,
  27059. PatientId: id,
  27060. RecordTime: recordDateTime,
  27061. Stage: 4,
  27062. }
  27063. service.CreateErrMsgLog(errlog)
  27064. c.ServeSuccessJSON(map[string]interface{}{
  27065. "failed_code": -10,
  27066. "msg": res.ErrMsg,
  27067. })
  27068. return
  27069. }
  27070. }
  27071. if isSuccess {
  27072. res.Infcode = 0
  27073. }
  27074. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27075. 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)
  27076. var dat map[string]interface{}
  27077. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27078. fmt.Println(dat)
  27079. } else {
  27080. fmt.Println(err)
  27081. }
  27082. saveLog(result, request_log, "2204", "上传费用明细")
  27083. userJSONBytes, _ := json.Marshal(dat)
  27084. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27085. utils.ErrorLog("解析失败:%v", err)
  27086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27087. return
  27088. }
  27089. res.InfRefmsgid = resFour10265.InfRefmsgid
  27090. res.Output = resFour10265.Output
  27091. res.ErrMsg = resFour10265.ErrMsg
  27092. res.Cainfo = resFour10265.Cainfo
  27093. res.WarnMsg = resFour10265.WarnMsg
  27094. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27095. res.Infcode = infocode
  27096. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27097. bytesData, _ := json.Marshal(data)
  27098. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  27099. resp, _ := client.Do(req)
  27100. defer resp.Body.Close()
  27101. body, ioErr := ioutil.ReadAll(resp.Body)
  27102. if ioErr != nil {
  27103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27105. return
  27106. }
  27107. var respJSON map[string]interface{}
  27108. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27111. return
  27112. }
  27113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27114. userJSONBytes, _ := json.Marshal(respJSON)
  27115. fmt.Println("log")
  27116. fmt.Println(string(userJSONBytes))
  27117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27118. utils.ErrorLog("解析失败:%v", err)
  27119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27120. return
  27121. }
  27122. } else {
  27123. if miConfig.Code == "H15049901371" {
  27124. 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)
  27125. var dat map[string]interface{}
  27126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27127. fmt.Println(dat)
  27128. } else {
  27129. fmt.Println(err)
  27130. }
  27131. saveLog(result, request_log, "2204", "上传费用明细")
  27132. userJSONBytes, _ := json.Marshal(dat)
  27133. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27134. utils.ErrorLog("解析失败:%v", err)
  27135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27136. return
  27137. }
  27138. res.InfRefmsgid = resFour10265.InfRefmsgid
  27139. res.Output = resFour10265.Output
  27140. res.ErrMsg = resFour10265.ErrMsg
  27141. res.Cainfo = resFour10265.Cainfo
  27142. res.WarnMsg = resFour10265.WarnMsg
  27143. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27144. res.Infcode = infocode
  27145. } else {
  27146. 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)
  27147. var dat map[string]interface{}
  27148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27149. fmt.Println(dat)
  27150. } else {
  27151. fmt.Println(err)
  27152. }
  27153. saveLog(result, request_log, "2204", "上传费用明细")
  27154. userJSONBytes, _ := json.Marshal(dat)
  27155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27156. utils.ErrorLog("解析失败:%v", err)
  27157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27158. return
  27159. }
  27160. }
  27161. }
  27162. if res.Infcode == 0 {
  27163. order := &models.HisOrder{
  27164. UserOrgId: adminUser.CurrentOrgId,
  27165. HisPatientId: his.ID,
  27166. PatientId: his.PatientId,
  27167. SettleAccountsDate: recordDateTime,
  27168. MdtrtId: his.Number,
  27169. PsnNo: his.PsnNo,
  27170. MedType: strconv.FormatInt(reg_type, 10),
  27171. Ctime: time.Now().Unix(),
  27172. Mtime: time.Now().Unix(),
  27173. Status: 1,
  27174. Number: chrg_bchno,
  27175. Infcode: res.Infcode,
  27176. WarnMsg: res.WarnMsg,
  27177. Cainfo: res.Cainfo,
  27178. ErrMsg: res.ErrMsg,
  27179. RespondTime: res.RefmsgTime,
  27180. InfRefmsgid: res.InfRefmsgid,
  27181. OrderStatus: 1,
  27182. PayWay: pay_way,
  27183. PayWays: pay_ways,
  27184. OthDesc: oth_desc,
  27185. PayPrice: pay_price,
  27186. PayCardNo: pay_card_no,
  27187. DiscountPrice: discount_price,
  27188. PreferentialPrice: preferential_price,
  27189. RealityPrice: reality_price,
  27190. FoundPrice: found_price,
  27191. MedicalInsurancePrice: medical_insurance_price,
  27192. PrivatePrice: private_price,
  27193. IsMedicineInsurance: 1,
  27194. SettleType: settle_accounts_type,
  27195. SettleStartTime: start_time,
  27196. SettleEndTime: end_time,
  27197. Creator: roles.AdminUserId,
  27198. Modify: roles.AdminUserId,
  27199. FaPiaoNumber: fapiao_number,
  27200. FaPiaoCode: fapiao_code,
  27201. PType: 2,
  27202. Diagnosis: diagnosis_id,
  27203. CashPay: cash_pay,
  27204. WechatPay: wechat_pay,
  27205. AliPay: ali_pay,
  27206. JifenPay: jifen_pay,
  27207. BandCardPay: band_card_pay,
  27208. }
  27209. err = service.CreateOrder(order)
  27210. if err != nil {
  27211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27212. return
  27213. }
  27214. for _, item := range res.Output.Result {
  27215. temp := strings.Split(item.FeedetlSn, "-")
  27216. var advice_id int64 = 0
  27217. var project_id int64 = 0
  27218. var types int64 = 0
  27219. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27220. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27221. if temp[1] == "1" {
  27222. advice_id = id
  27223. project_id = 0
  27224. } else if temp[1] == "2" {
  27225. advice_id = 0
  27226. project_id = id
  27227. }
  27228. if item.MedChrgitmType == "9" {
  27229. item.MedChrgitmType = "09"
  27230. }
  27231. info := &models.HisOrderInfo{
  27232. OrderNumber: order.Number,
  27233. FeedetlSn: item.FeedetlSn,
  27234. UploadDate: time.Now().Unix(),
  27235. AdviceId: advice_id,
  27236. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27237. Cnt: item.Cnt,
  27238. Pric: float64(item.Pric),
  27239. PatientId: his.PatientId,
  27240. PricUplmtAmt: item.PricUplmtAmt,
  27241. SelfpayProp: item.SelfpayProp,
  27242. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27243. OverlmtAmt: item.OverlmtAmt,
  27244. PreselfpayAmt: item.PreselfpayAmt,
  27245. BasMednFlag: item.BasMednFlag,
  27246. MedChrgitmType: item.MedChrgitmType,
  27247. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27248. Status: 1,
  27249. Memo: item.Memo,
  27250. Mtime: time.Now().Unix(),
  27251. InscpScpAmt: item.InscpScpAmt,
  27252. DrtReimFlag: item.DrtReimFlag,
  27253. Ctime: time.Now().Unix(),
  27254. ListSpItemFlag: item.ListSpItemFlag,
  27255. ChldMedcFlag: item.ChldMedcFlag,
  27256. LmtUsedFlag: item.LmtUsedFlag,
  27257. ChrgitmLv: item.ChrgitmLv,
  27258. UserOrgId: adminUser.CurrentOrgId,
  27259. HisPatientId: his.ID,
  27260. OrderId: order.ID,
  27261. ProjectId: project_id,
  27262. Type: types,
  27263. }
  27264. service.CreateOrderInfo(info)
  27265. }
  27266. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27267. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27268. var total float64
  27269. for _, item := range prescriptions {
  27270. if item.Type == 1 { //药品
  27271. for _, subItem := range item.HisDoctorAdviceInfo {
  27272. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27273. total_one := price * subItem.PrescribingNumber
  27274. total = total + total_one
  27275. }
  27276. }
  27277. if item.Type == 2 { //项目
  27278. for _, subItem := range item.HisPrescriptionProject {
  27279. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27280. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27281. total_one := price * cnt
  27282. total = total + total_one
  27283. }
  27284. }
  27285. }
  27286. allTotal := fmt.Sprintf("%.2f", total)
  27287. //if adminUser.CurrentOrgId == 9919 {
  27288. //
  27289. // allTotal = fmt.Sprintf("%.2f", total)
  27290. //
  27291. //} else {
  27292. //
  27293. // allTotal = fmt.Sprintf("%.2f", total)
  27294. //
  27295. //}
  27296. if res.Infcode == 0 {
  27297. var rf []*ResultFive
  27298. json.Unmarshal([]byte(his.Iinfo), &rf)
  27299. chrg_bchno := chrg_bchno
  27300. cert_no := his.Certno
  27301. var insutypes []string
  27302. var insutype string
  27303. var is390 int = 0
  27304. var is310 int = 0
  27305. for _, item := range rf {
  27306. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27307. insutypes = append(insutypes, item.Insutype)
  27308. }
  27309. }
  27310. if len(insutypes) == 1 {
  27311. insutype = insutypes[0]
  27312. } else {
  27313. for _, i := range insutypes {
  27314. if i == "390" {
  27315. is390 = 1
  27316. }
  27317. if i == "310" {
  27318. is310 = 1
  27319. }
  27320. }
  27321. }
  27322. if is390 == 1 {
  27323. insutype = "390"
  27324. }
  27325. if is310 == 1 {
  27326. insutype = "310"
  27327. }
  27328. if len(insutypes) == 0 {
  27329. insutype = "310"
  27330. }
  27331. if len(insutypes) == 2 {
  27332. insutype = strconv.FormatInt(his.SocialType, 10)
  27333. }
  27334. insutype = strconv.FormatInt(his.SocialType, 10)
  27335. //insutype = "390"
  27336. if his.IdCardType == 1 {
  27337. // cert_no = his.MedicalInsuranceNumber
  27338. cert_no = his.Certno
  27339. } else {
  27340. cert_no = his.Certno
  27341. }
  27342. var res ResultSeven
  27343. var resSeven10265 ResultSeven10265
  27344. var gzresSeven10265Two GZResultSeven10265Two
  27345. var src_resquest string
  27346. var result2 string
  27347. if miConfig.MdtrtareaAdmvs == "421300" {
  27348. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27349. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27350. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27351. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27352. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27353. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27354. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27355. resp, requestErr := http.Get(api)
  27356. if requestErr != nil {
  27357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27358. return
  27359. }
  27360. body, ioErr := ioutil.ReadAll(resp.Body)
  27361. if ioErr != nil {
  27362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27364. return
  27365. }
  27366. var respJSON map[string]interface{}
  27367. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27370. return
  27371. }
  27372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27373. result, _ := json.Marshal(respJSON)
  27374. if miConfig.Code == "H15049901371" {
  27375. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27376. utils.ErrorLog("解析失败:%v", err)
  27377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27378. return
  27379. }
  27380. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27381. res.Output = resSeven10265.Output
  27382. res.ErrMsg = resSeven10265.ErrMsg
  27383. res.Cainfo = resSeven10265.Cainfo
  27384. res.WarnMsg = resSeven10265.WarnMsg
  27385. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27386. res.Infcode = infocode
  27387. } else {
  27388. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27389. utils.ErrorLog("解析失败:%v", err)
  27390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27391. return
  27392. }
  27393. }
  27394. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27395. if reg_type == 11 && his.Insutype == "390" {
  27396. reg_type = 110104
  27397. }
  27398. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27399. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27400. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27401. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27402. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27403. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27404. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27405. resp, requestErr := http.Get(api)
  27406. if requestErr != nil {
  27407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27408. return
  27409. }
  27410. body, ioErr := ioutil.ReadAll(resp.Body)
  27411. if ioErr != nil {
  27412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27414. return
  27415. }
  27416. var respJSON map[string]interface{}
  27417. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27420. return
  27421. }
  27422. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27423. result, _ := json.Marshal(respJSON)
  27424. if miConfig.Code == "H15049901371" {
  27425. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27426. utils.ErrorLog("解析失败:%v", err)
  27427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27428. return
  27429. }
  27430. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27431. res.Output = resSeven10265.Output
  27432. res.ErrMsg = resSeven10265.ErrMsg
  27433. res.Cainfo = resSeven10265.Cainfo
  27434. res.WarnMsg = resSeven10265.WarnMsg
  27435. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27436. res.Infcode = infocode
  27437. } else {
  27438. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27439. utils.ErrorLog("解析失败:%v", err)
  27440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27441. return
  27442. }
  27443. }
  27444. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27445. if reg_type == 11 && his.Insutype == "390" {
  27446. reg_type = 110104
  27447. }
  27448. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27449. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27450. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27451. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27452. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27453. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27454. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27455. resp, requestErr := http.Get(api)
  27456. if requestErr != nil {
  27457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27458. return
  27459. }
  27460. body, ioErr := ioutil.ReadAll(resp.Body)
  27461. if ioErr != nil {
  27462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27464. return
  27465. }
  27466. var respJSON map[string]interface{}
  27467. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27470. return
  27471. }
  27472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27473. result, _ := json.Marshal(respJSON)
  27474. if miConfig.Code == "H15049901371" {
  27475. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27476. utils.ErrorLog("解析失败:%v", err)
  27477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27478. return
  27479. }
  27480. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27481. res.Output = resSeven10265.Output
  27482. res.ErrMsg = resSeven10265.ErrMsg
  27483. res.Cainfo = resSeven10265.Cainfo
  27484. res.WarnMsg = resSeven10265.WarnMsg
  27485. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27486. res.Infcode = infocode
  27487. } else {
  27488. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27489. utils.ErrorLog("解析失败:%v", err)
  27490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27491. return
  27492. }
  27493. }
  27494. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27495. if reg_type == 11 && his.Insutype == "390" {
  27496. reg_type = 110104
  27497. }
  27498. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27499. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27500. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27501. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27502. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27503. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27504. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27505. resp, requestErr := http.Get(api)
  27506. if requestErr != nil {
  27507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27508. return
  27509. }
  27510. body, ioErr := ioutil.ReadAll(resp.Body)
  27511. if ioErr != nil {
  27512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27514. return
  27515. }
  27516. var respJSON map[string]interface{}
  27517. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27520. return
  27521. }
  27522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27523. result, _ := json.Marshal(respJSON)
  27524. if miConfig.Code == "H15049901371" {
  27525. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27526. utils.ErrorLog("解析失败:%v", err)
  27527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27528. return
  27529. }
  27530. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27531. res.Output = resSeven10265.Output
  27532. res.ErrMsg = resSeven10265.ErrMsg
  27533. res.Cainfo = resSeven10265.Cainfo
  27534. res.WarnMsg = resSeven10265.WarnMsg
  27535. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27536. res.Infcode = infocode
  27537. } else {
  27538. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27539. utils.ErrorLog("解析失败:%v", err)
  27540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27541. return
  27542. }
  27543. }
  27544. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27545. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  27546. var result3101 Result3101
  27547. //utils.ErrorLog("解析失败:%v", result3101)
  27548. result3101.Infcode = "0"
  27549. if result3101.Infcode == "0" {
  27550. if len(result3101.Output.Result) > 0 {
  27551. var errMsgs []string
  27552. for _, item := range result3101.Output.Result {
  27553. errMsgs = append(errMsgs, item.VolaCont)
  27554. }
  27555. c.ServeSuccessJSON(map[string]interface{}{
  27556. "failed_code": -10,
  27557. "msg": errMsgs,
  27558. })
  27559. return
  27560. } else {
  27561. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27562. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27563. bas := strings.Split(psn_info.CardInfo, "|")
  27564. if his.IdCardType == 1 {
  27565. cert_no = bas[2]
  27566. } else if his.IdCardType == 3 {
  27567. cert_no = his.Certno
  27568. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27569. } else if his.IdCardType == 4 {
  27570. cert_no = his.Certno
  27571. psn_info.VerifyNumber = psn_info.VerifyNumber
  27572. }
  27573. var api string
  27574. if miConfig.MdtrtareaAdmvs == "320830" {
  27575. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27576. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27577. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27578. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27579. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27580. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27581. "&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
  27582. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27583. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27584. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27585. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27586. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27587. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27588. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27589. "&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
  27590. } else {
  27591. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27592. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27593. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27594. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27595. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27596. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27597. "&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
  27598. }
  27599. resp, requestErr := http.Get(api)
  27600. if requestErr != nil {
  27601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27602. return
  27603. }
  27604. body, ioErr := ioutil.ReadAll(resp.Body)
  27605. if ioErr != nil {
  27606. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27608. return
  27609. }
  27610. var respJSON map[string]interface{}
  27611. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27612. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27614. return
  27615. }
  27616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27617. result, _ := json.Marshal(respJSON)
  27618. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27619. utils.ErrorLog("解析失败:%v", err)
  27620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27621. return
  27622. }
  27623. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27624. res.Output = resSeven10265.Output
  27625. res.ErrMsg = resSeven10265.ErrMsg
  27626. res.Cainfo = resSeven10265.Cainfo
  27627. res.WarnMsg = resSeven10265.WarnMsg
  27628. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27629. res.Infcode = infocode
  27630. }
  27631. }
  27632. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27633. psn_info, _ := service.GetPsnByPatientId(id)
  27634. var verify_number string
  27635. if psn_info.IdCardType == 4 {
  27636. verify_number = psn_info.VerifyNumber
  27637. } else if psn_info.IdCardType == 1 {
  27638. bas := strings.Split(psn_info.CardInfo, "|")
  27639. cardNumber := bas[2]
  27640. verify_number = cardNumber
  27641. } else {
  27642. psn_info.IdCardType = 2
  27643. verify_number = psn_info.Certno
  27644. }
  27645. var api string
  27646. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27647. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27648. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27649. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27650. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27651. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27652. "&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
  27653. resp, requestErr := http.Get(api)
  27654. if requestErr != nil {
  27655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27656. return
  27657. }
  27658. body, ioErr := ioutil.ReadAll(resp.Body)
  27659. if ioErr != nil {
  27660. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27662. return
  27663. }
  27664. var respJSON map[string]interface{}
  27665. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27668. return
  27669. }
  27670. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27671. result, _ := json.Marshal(respJSON)
  27672. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27673. utils.ErrorLog("解析失败:%v", err)
  27674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27675. return
  27676. }
  27677. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27678. res.Output = resSeven10265.Output
  27679. res.ErrMsg = resSeven10265.ErrMsg
  27680. res.Cainfo = resSeven10265.Cainfo
  27681. res.WarnMsg = resSeven10265.WarnMsg
  27682. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27683. res.Infcode = infocode
  27684. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27685. var cert_no string
  27686. if his.IdCardType == 4 {
  27687. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27688. cert_no = psn_info.VerifyNumber
  27689. 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)
  27690. } else if his.IdCardType == 1 {
  27691. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27692. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27693. 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)
  27694. }
  27695. //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)
  27696. var dat map[string]interface{}
  27697. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27698. fmt.Println(dat)
  27699. } else {
  27700. fmt.Println(err)
  27701. }
  27702. saveLog(result2, src_resquest, "2207", "结算")
  27703. userJSONBytes, _ := json.Marshal(dat)
  27704. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27705. utils.ErrorLog("解析失败:%v", err)
  27706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27707. return
  27708. }
  27709. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27710. res.Output = resSeven10265.Output
  27711. res.ErrMsg = resSeven10265.ErrMsg
  27712. res.Cainfo = resSeven10265.Cainfo
  27713. res.WarnMsg = resSeven10265.WarnMsg
  27714. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27715. res.Infcode = infocode
  27716. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27717. res2 := c.GetoleInfo()
  27718. if res2.Infcode == 0 {
  27719. var result string
  27720. var request_log string
  27721. var result_log string
  27722. if res2.Output.MdtrtCertType == "02" {
  27723. 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)
  27724. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27725. } else if res2.Output.MdtrtCertType == "01" {
  27726. 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)
  27727. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27728. } else {
  27729. 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)
  27730. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27731. }
  27732. var dat map[string]interface{}
  27733. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27734. fmt.Println(dat)
  27735. } else {
  27736. fmt.Println(err)
  27737. }
  27738. userJSONBytes, _ := json.Marshal(dat)
  27739. var res5 ResultTwo
  27740. //var resTwo10265 ResultTwo10265
  27741. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27742. utils.ErrorLog("解析失败:%v", err)
  27743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27744. return
  27745. }
  27746. if res5.Infcode == -1 {
  27747. c.ServeSuccessJSON(map[string]interface{}{
  27748. "failed_code": -10,
  27749. "msg": res5.ErrMsg,
  27750. })
  27751. return
  27752. }
  27753. var insutypes []string
  27754. var insutype string
  27755. var is390 int = 0
  27756. var is310 int = 0
  27757. for _, item := range res5.Output.Iinfo {
  27758. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27759. insutypes = append(insutypes, item.Insutype)
  27760. }
  27761. }
  27762. if len(insutypes) == 1 {
  27763. insutype = insutypes[0]
  27764. } else {
  27765. for _, i := range insutypes {
  27766. if i == "390" {
  27767. is390 = 1
  27768. }
  27769. if i == "310" {
  27770. is310 = 1
  27771. }
  27772. }
  27773. }
  27774. if is390 == 1 {
  27775. insutype = "390"
  27776. }
  27777. if is310 == 1 {
  27778. insutype = "310"
  27779. }
  27780. if len(insutypes) == 0 {
  27781. insutype = "310"
  27782. }
  27783. fmt.Println(insutype)
  27784. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27785. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27786. infoStr := string(Iinfos)
  27787. idetinfoStr := string(Idetinfos)
  27788. psn := &models.HisPsn{
  27789. PsnNo: res5.Output.Baseinfo.PsnNo,
  27790. PatientId: id,
  27791. Certno: res5.Output.Baseinfo.Certno,
  27792. Gend: res5.Output.Baseinfo.Gend,
  27793. Naty: res5.Output.Baseinfo.Naty,
  27794. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27795. PsnName: res5.Output.Baseinfo.PsnName,
  27796. Idetinfo: idetinfoStr,
  27797. Insuinfo: infoStr,
  27798. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27799. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27800. VerifyNumber: res2.Output.EcToken,
  27801. }
  27802. if res2.Output.MdtrtCertType == "01" {
  27803. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27804. psn.VerifyNumber = res2.Output.EcToken
  27805. } else if res2.Output.MdtrtCertType == "02" {
  27806. psn.VerifyNumber = res2.Output.CardNo
  27807. } else {
  27808. psn.VerifyNumber = res2.Output.MdtrtCertNo
  27809. }
  27810. service.CreateHisPsn(psn)
  27811. if res2.Output.MdtrtCertType == "01" {
  27812. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27813. token := res2.Output.EcToken
  27814. 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)
  27815. } else if res2.Output.MdtrtCertType == "02" {
  27816. 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)
  27817. } else {
  27818. 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)
  27819. }
  27820. var dat2 map[string]interface{}
  27821. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27822. fmt.Println(dat2)
  27823. } else {
  27824. fmt.Println(err)
  27825. }
  27826. userJSONBytes3, _ := json.Marshal(dat2)
  27827. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27828. utils.ErrorLog("解析失败:%v", err)
  27829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27830. return
  27831. }
  27832. saveLog(result2, src_resquest, "2207", "结算")
  27833. } else {
  27834. c.ServeSuccessJSON(map[string]interface{}{
  27835. "failed_code": -10,
  27836. "msg": res2.ErrMsg,
  27837. })
  27838. return
  27839. }
  27840. } else {
  27841. if miConfig.Code == "H15049901371" {
  27842. //赤峰地区国家医保医疗类别
  27843. //职工透析:医疗类别选特殊情况门诊990502
  27844. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27845. var med_type string
  27846. if his.Insutype == "390" {
  27847. if reg_type == 14 {
  27848. med_type = "9933"
  27849. } else if reg_type == 11 {
  27850. med_type = "11"
  27851. }
  27852. } else if his.Insutype == "310" {
  27853. if reg_type == 14 {
  27854. med_type = "990502"
  27855. } else if reg_type == 11 {
  27856. med_type = "11"
  27857. }
  27858. }
  27859. 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)
  27860. } else {
  27861. if his.IdCardType == 4 {
  27862. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27863. var token string
  27864. token = psn_info.VerifyNumber
  27865. 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)
  27866. } else {
  27867. if his.IdCardType == 1 {
  27868. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27869. bas := strings.Split(psn_info.CardInfo, "|")
  27870. basNumber := bas[2]
  27871. cert_no = basNumber
  27872. }
  27873. 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)
  27874. }
  27875. }
  27876. //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)
  27877. var dat map[string]interface{}
  27878. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27879. fmt.Println(dat)
  27880. } else {
  27881. fmt.Println(err)
  27882. }
  27883. saveLog(result2, src_resquest, "2207", "结算")
  27884. userJSONBytes, _ := json.Marshal(dat)
  27885. if miConfig.Code == "H15049901371" {
  27886. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27887. utils.ErrorLog("解析失败:%v", err)
  27888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27889. return
  27890. }
  27891. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27892. res.Output = resSeven10265.Output
  27893. res.ErrMsg = resSeven10265.ErrMsg
  27894. res.Cainfo = resSeven10265.Cainfo
  27895. res.WarnMsg = resSeven10265.WarnMsg
  27896. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27897. res.Infcode = infocode
  27898. } else {
  27899. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27900. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27901. utils.ErrorLog("解析失败:%v", err)
  27902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27903. return
  27904. }
  27905. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27906. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27907. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27908. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27909. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27910. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27911. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27912. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27913. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27914. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27915. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27916. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27917. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27918. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27919. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27920. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27921. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27922. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27923. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27924. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27925. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27926. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27927. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27928. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27929. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27930. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27931. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27932. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27933. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27934. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27935. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27936. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27937. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27938. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27939. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27940. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27941. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27942. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27943. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27944. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27945. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27946. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27947. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27948. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27949. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27950. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27951. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27952. res.Cainfo = gzresSeven10265Two.Cainfo
  27953. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27954. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27955. //res.Infcode = infocode
  27956. } else {
  27957. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27958. utils.ErrorLog("解析失败:%v", err)
  27959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27960. return
  27961. }
  27962. }
  27963. }
  27964. }
  27965. if res.Infcode == -1 {
  27966. errlog := &models.HisOrderError{
  27967. UserOrgId: adminUser.CurrentOrgId,
  27968. Ctime: time.Now().Unix(),
  27969. Mtime: time.Now().Unix(),
  27970. Number: chrg_bchno,
  27971. ErrMsg: res.ErrMsg,
  27972. Status: 1,
  27973. PatientId: id,
  27974. RecordTime: recordDateTime,
  27975. Stage: 6,
  27976. }
  27977. service.CreateErrMsgLog(errlog)
  27978. c.ServeSuccessJSON(map[string]interface{}{
  27979. "failed_code": -10,
  27980. "msg": res.ErrMsg,
  27981. })
  27982. return
  27983. } else {
  27984. sickConfig, _ := service.FindSickById(his.SickType)
  27985. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27986. order.OrderStatus = 2
  27987. order.Status = 1
  27988. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27989. order.SetlId = res.Output.Setlinfo.SetlID
  27990. order.PsnNo = res.Output.Setlinfo.PsnNo
  27991. order.PsnName = res.Output.Setlinfo.PsnName
  27992. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27993. order.Certno = res.Output.Setlinfo.Certno
  27994. order.Gend = res.Output.Setlinfo.Gend
  27995. order.Naty = res.Output.Setlinfo.Naty
  27996. order.Age = res.Output.Setlinfo.Age
  27997. order.Insutype = res.Output.Setlinfo.Insutype
  27998. order.PsnType = res.Output.Setlinfo.PsnType
  27999. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28000. order.SetlTime = res.Output.Setlinfo.SetlTime
  28001. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28002. if res.Output.Setlinfo.MedType == "140101" {
  28003. order.MedType = "14"
  28004. } else {
  28005. if res.Output.Setlinfo.MedType == "110104" {
  28006. order.MedType = "11"
  28007. } else {
  28008. order.MedType = res.Output.Setlinfo.MedType
  28009. }
  28010. }
  28011. if reg_type == 1112 {
  28012. order.MedType = "1112"
  28013. }
  28014. if reg_type == 1111 {
  28015. order.MedType = "1111"
  28016. }
  28017. order.ClrType = res.Output.Setlinfo.ClrType
  28018. if adminUser.CurrentOrgId == 10480 {
  28019. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28020. order.ClrType = "11"
  28021. } else {
  28022. order.ClrType = "9903"
  28023. }
  28024. }
  28025. if adminUser.CurrentOrgId == 10721 {
  28026. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28027. order.ClrType = "11"
  28028. } else {
  28029. order.ClrType = "9903"
  28030. }
  28031. }
  28032. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28033. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28034. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28035. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28036. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28037. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28038. order.HifpPay = res.Output.Setlinfo.HifpPay
  28039. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28040. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28041. order.HifesPay = res.Output.Setlinfo.HifesPay
  28042. order.HifobPay = res.Output.Setlinfo.HifobPay
  28043. order.MafPay = res.Output.Setlinfo.MafPay
  28044. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28045. order.OthPay = res.Output.Setlinfo.OthPay
  28046. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28047. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28048. order.AcctPay = res.Output.Setlinfo.AcctPay
  28049. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28050. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28051. order.Balc = res.Output.Setlinfo.Balc
  28052. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28053. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28054. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28055. //order.ClrType = res.Output.Setlinfo.ClrType
  28056. order.ClrWay = res.Output.Setlinfo.ClrWay
  28057. order.Creator = order.Creator
  28058. order.Modify = roles.AdminUserId
  28059. order.RequestLog = src_resquest
  28060. order.FaPiaoNumber = fapiao_number
  28061. order.FaPiaoCode = fapiao_code
  28062. order.SickName = sickConfig.ClassName
  28063. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28064. //detailStr := string(setlDetail)
  28065. //order.SetlDetail = detailStr
  28066. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28067. err = service.UpDateOrder(order)
  28068. if err == nil {
  28069. //判断是否使用了押金
  28070. if dec_way == "true" {
  28071. tmpstring := strconv.FormatInt(order.ID, 10)
  28072. order.Decimal = decimal
  28073. service.UpDateOrder(order)
  28074. //扣押金
  28075. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28076. if errmsg != nil {
  28077. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28078. return
  28079. }
  28080. }
  28081. c.ServeSuccessJSON(map[string]interface{}{
  28082. "msg": "结算成功",
  28083. })
  28084. } else {
  28085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28086. return
  28087. }
  28088. }
  28089. } else {
  28090. adminUser := c.GetAdminUserInfo()
  28091. errlog := &models.HisOrderError{
  28092. UserOrgId: adminUser.CurrentOrgId,
  28093. Ctime: time.Now().Unix(),
  28094. Mtime: time.Now().Unix(),
  28095. ErrMsg: res.ErrMsg,
  28096. Status: 1,
  28097. PatientId: id,
  28098. RecordTime: recordDateTime,
  28099. Stage: 4,
  28100. }
  28101. service.CreateErrMsgLog(errlog)
  28102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28103. return
  28104. }
  28105. } else {
  28106. adminUser := c.GetAdminUserInfo()
  28107. errlog := &models.HisOrderError{
  28108. UserOrgId: adminUser.CurrentOrgId,
  28109. Ctime: time.Now().Unix(),
  28110. Mtime: time.Now().Unix(),
  28111. ErrMsg: res.ErrMsg,
  28112. Status: 1,
  28113. PatientId: id,
  28114. RecordTime: recordDateTime,
  28115. Stage: 4,
  28116. }
  28117. service.CreateErrMsgLog(errlog)
  28118. c.ServeSuccessJSON(map[string]interface{}{
  28119. "failed_code": -10,
  28120. "msg": res.ErrMsg,
  28121. })
  28122. return
  28123. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  28124. //return
  28125. }
  28126. }
  28127. }
  28128. } else if tempOrder.ID > 0 {
  28129. if tempOrder.IsPre == 1 {
  28130. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  28131. var rf []*ResultFive
  28132. json.Unmarshal([]byte(his.Iinfo), &rf)
  28133. chrg_bchno := tempOrder.Number
  28134. cert_no := his.Certno
  28135. var insutypes []string
  28136. var insutype string
  28137. var is390 int = 0
  28138. var is310 int = 0
  28139. for _, item := range rf {
  28140. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28141. insutypes = append(insutypes, item.Insutype)
  28142. }
  28143. }
  28144. if len(insutypes) == 1 {
  28145. insutype = insutypes[0]
  28146. } else {
  28147. for _, i := range insutypes {
  28148. if i == "390" {
  28149. is390 = 1
  28150. }
  28151. if i == "310" {
  28152. is310 = 1
  28153. }
  28154. }
  28155. }
  28156. if is390 == 1 {
  28157. insutype = "390"
  28158. }
  28159. if is310 == 1 {
  28160. insutype = "310"
  28161. }
  28162. if len(insutypes) == 0 {
  28163. insutype = "310"
  28164. }
  28165. if len(insutypes) == 2 {
  28166. insutype = strconv.FormatInt(his.SocialType, 10)
  28167. }
  28168. //insutype = "390"
  28169. if his.IdCardType == 1 {
  28170. // cert_no = his.MedicalInsuranceNumber
  28171. cert_no = his.Certno
  28172. } else {
  28173. cert_no = his.Certno
  28174. }
  28175. var res ResultSeven
  28176. var ahres ResultSevenAH
  28177. var resSeven10265 ResultSeven10265
  28178. var gzresSeven10265Two GZResultSeven10265Two
  28179. var src_resquest string
  28180. var result2 string
  28181. if miConfig.MdtrtareaAdmvs == "450721" {
  28182. res2 := c.GetoleInfo()
  28183. if res2.Infcode == 0 {
  28184. var result string
  28185. var request_log string
  28186. var result_log string
  28187. if res2.Output.MdtrtCertType == "02" {
  28188. 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)
  28189. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28190. } else if res2.Output.MdtrtCertType == "01" {
  28191. 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)
  28192. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28193. } else {
  28194. 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)
  28195. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28196. }
  28197. var dat map[string]interface{}
  28198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28199. fmt.Println(dat)
  28200. } else {
  28201. fmt.Println(err)
  28202. }
  28203. userJSONBytes, _ := json.Marshal(dat)
  28204. var res5 ResultTwo
  28205. //var resTwo10265 ResultTwo10265
  28206. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  28207. utils.ErrorLog("解析失败:%v", err)
  28208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28209. return
  28210. }
  28211. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  28212. if res5.Infcode == -1 {
  28213. c.ServeSuccessJSON(map[string]interface{}{
  28214. "failed_code": -10,
  28215. "msg": res5.ErrMsg,
  28216. })
  28217. return
  28218. }
  28219. var insutypes []string
  28220. var insutype string
  28221. var is390 int = 0
  28222. var is310 int = 0
  28223. for _, item := range res5.Output.Iinfo {
  28224. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28225. insutypes = append(insutypes, item.Insutype)
  28226. }
  28227. }
  28228. if len(insutypes) == 1 {
  28229. insutype = insutypes[0]
  28230. } else {
  28231. for _, i := range insutypes {
  28232. if i == "390" {
  28233. is390 = 1
  28234. }
  28235. if i == "310" {
  28236. is310 = 1
  28237. }
  28238. }
  28239. }
  28240. if is390 == 1 {
  28241. insutype = "390"
  28242. }
  28243. if is310 == 1 {
  28244. insutype = "310"
  28245. }
  28246. if len(insutypes) == 0 {
  28247. insutype = "310"
  28248. }
  28249. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  28250. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  28251. infoStr := string(Iinfos)
  28252. idetinfoStr := string(Idetinfos)
  28253. psn := &models.HisPsn{
  28254. PsnNo: res5.Output.Baseinfo.PsnNo,
  28255. PatientId: id,
  28256. Certno: res5.Output.Baseinfo.Certno,
  28257. Gend: res5.Output.Baseinfo.Gend,
  28258. Naty: res5.Output.Baseinfo.Naty,
  28259. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28260. PsnName: res5.Output.Baseinfo.PsnName,
  28261. Idetinfo: idetinfoStr,
  28262. Insuinfo: infoStr,
  28263. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28264. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28265. VerifyNumber: res2.Output.EcToken,
  28266. }
  28267. service.CreateHisPsn(psn)
  28268. if res2.Output.MdtrtCertType == "01" {
  28269. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28270. token := res2.Output.EcToken
  28271. 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)
  28272. } else if res2.Output.MdtrtCertType == "02" {
  28273. 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)
  28274. } else {
  28275. 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)
  28276. }
  28277. var dat2 map[string]interface{}
  28278. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28279. fmt.Println(dat2)
  28280. } else {
  28281. fmt.Println(err)
  28282. }
  28283. userJSONBytes3, _ := json.Marshal(dat2)
  28284. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28285. utils.ErrorLog("解析失败:%v", err)
  28286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28287. return
  28288. }
  28289. saveLog(result2, src_resquest, "2207", "结算")
  28290. } else {
  28291. c.ServeSuccessJSON(map[string]interface{}{
  28292. "failed_code": -10,
  28293. "msg": res2.ErrMsg,
  28294. })
  28295. return
  28296. }
  28297. } else if miConfig.MdtrtareaAdmvs == "421300" {
  28298. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28299. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28300. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28301. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28302. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28303. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28304. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28305. resp, requestErr := http.Get(api)
  28306. if requestErr != nil {
  28307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28308. return
  28309. }
  28310. body, ioErr := ioutil.ReadAll(resp.Body)
  28311. if ioErr != nil {
  28312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28314. return
  28315. }
  28316. var respJSON map[string]interface{}
  28317. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28320. return
  28321. }
  28322. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28323. result, _ := json.Marshal(respJSON)
  28324. fmt.Println("log")
  28325. fmt.Println(string(result))
  28326. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28327. utils.ErrorLog("解析失败:%v", err)
  28328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28329. return
  28330. }
  28331. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28332. if reg_type == 11 && his.Insutype == "390" {
  28333. reg_type = 110104
  28334. }
  28335. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28336. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28337. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28338. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28339. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28340. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28341. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28342. resp, requestErr := http.Get(api)
  28343. if requestErr != nil {
  28344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28345. return
  28346. }
  28347. body, ioErr := ioutil.ReadAll(resp.Body)
  28348. if ioErr != nil {
  28349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28351. return
  28352. }
  28353. var respJSON map[string]interface{}
  28354. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28357. return
  28358. }
  28359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28360. result, _ := json.Marshal(respJSON)
  28361. fmt.Println("log")
  28362. fmt.Println(string(result))
  28363. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28364. utils.ErrorLog("解析失败:%v", err)
  28365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28366. return
  28367. }
  28368. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28369. if reg_type == 11 && his.Insutype == "390" {
  28370. reg_type = 110104
  28371. }
  28372. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28373. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28374. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28375. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28376. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28377. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28378. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28379. resp, requestErr := http.Get(api)
  28380. if requestErr != nil {
  28381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28382. return
  28383. }
  28384. body, ioErr := ioutil.ReadAll(resp.Body)
  28385. if ioErr != nil {
  28386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28388. return
  28389. }
  28390. var respJSON map[string]interface{}
  28391. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28394. return
  28395. }
  28396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28397. result, _ := json.Marshal(respJSON)
  28398. fmt.Println("log")
  28399. fmt.Println(string(result))
  28400. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28401. utils.ErrorLog("解析失败:%v", err)
  28402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28403. return
  28404. }
  28405. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28406. if reg_type == 11 && his.Insutype == "390" {
  28407. reg_type = 110104
  28408. }
  28409. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28410. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28411. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28412. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28413. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28414. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28415. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28416. resp, requestErr := http.Get(api)
  28417. if requestErr != nil {
  28418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28419. return
  28420. }
  28421. body, ioErr := ioutil.ReadAll(resp.Body)
  28422. if ioErr != nil {
  28423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28425. return
  28426. }
  28427. var respJSON map[string]interface{}
  28428. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28431. return
  28432. }
  28433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28434. result, _ := json.Marshal(respJSON)
  28435. fmt.Println("log")
  28436. fmt.Println(string(result))
  28437. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28438. utils.ErrorLog("解析失败:%v", err)
  28439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28440. return
  28441. }
  28442. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  28443. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28444. var result3101 Result3101
  28445. //utils.ErrorLog("解析失败:%v", result3101)
  28446. result3101.Infcode = "0"
  28447. if result3101.Infcode == "0" {
  28448. if len(result3101.Output.Result) > 0 {
  28449. var errMsgs []string
  28450. for _, item := range result3101.Output.Result {
  28451. errMsgs = append(errMsgs, item.VolaCont)
  28452. }
  28453. c.ServeSuccessJSON(map[string]interface{}{
  28454. "failed_code": -10,
  28455. "msg": errMsgs,
  28456. })
  28457. return
  28458. } else {
  28459. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28460. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28461. bas := strings.Split(psn_info.CardInfo, "|")
  28462. if his.IdCardType == 1 {
  28463. cert_no = bas[2]
  28464. } else if his.IdCardType == 3 {
  28465. cert_no = his.Certno
  28466. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28467. } else if his.IdCardType == 4 {
  28468. cert_no = his.Certno
  28469. psn_info.VerifyNumber = psn_info.VerifyNumber
  28470. }
  28471. //江苏地区国家医保医疗类别
  28472. //职工透析:医疗类别选特殊情况门诊9933
  28473. //居民血透门慢: 医疗类别选门诊慢病1402
  28474. //var med_type string
  28475. //if his.Insutype == "310" {
  28476. // if reg_type == 14 {
  28477. // med_type = "9933"
  28478. // } else if reg_type == 11 {
  28479. // med_type = "11"
  28480. //
  28481. // }
  28482. //} else if his.Insutype == "390" {
  28483. // if reg_type == 14 {
  28484. // med_type = "1402"
  28485. // } else if reg_type == 11 {
  28486. // med_type = "11"
  28487. // }
  28488. //}
  28489. var api string
  28490. if miConfig.MdtrtareaAdmvs == "320830" {
  28491. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28492. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28493. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28495. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28496. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28497. "&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
  28498. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28499. } else if miConfig.MdtrtareaAdmvs == "320921" {
  28500. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28501. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28502. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28503. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28504. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28505. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28506. "&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
  28507. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28508. } else {
  28509. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28510. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28511. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28512. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28513. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28514. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28515. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28516. "&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
  28517. }
  28518. resp, requestErr := http.Get(api)
  28519. if requestErr != nil {
  28520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28521. return
  28522. }
  28523. body, ioErr := ioutil.ReadAll(resp.Body)
  28524. if ioErr != nil {
  28525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28527. return
  28528. }
  28529. var respJSON map[string]interface{}
  28530. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28533. return
  28534. }
  28535. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28536. result, _ := json.Marshal(respJSON)
  28537. fmt.Println("log")
  28538. fmt.Println(string(result))
  28539. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28540. utils.ErrorLog("解析失败:%v", err)
  28541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28542. return
  28543. }
  28544. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28545. res.Output = resSeven10265.Output
  28546. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28547. res.ErrMsg = resSeven10265.ErrMsg
  28548. res.Cainfo = resSeven10265.Cainfo
  28549. res.WarnMsg = resSeven10265.WarnMsg
  28550. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28551. res.Infcode = infocode
  28552. }
  28553. }
  28554. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28555. psn_info, _ := service.GetPsnByPatientId(id)
  28556. var verify_number string
  28557. if psn_info.IdCardType == 4 {
  28558. verify_number = psn_info.VerifyNumber
  28559. } else if psn_info.IdCardType == 1 {
  28560. bas := strings.Split(psn_info.CardInfo, "|")
  28561. cardNumber := bas[2]
  28562. verify_number = cardNumber
  28563. } else {
  28564. verify_number = psn_info.Certno
  28565. psn_info.IdCardType = 2
  28566. }
  28567. var api string
  28568. new_chrg_bchno := chrg_bchno
  28569. if adminUser.CurrentOrgId == 10265 {
  28570. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28571. new_chrg_bchno = "0000"
  28572. }
  28573. }
  28574. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28575. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  28576. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28577. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28578. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28579. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28580. "&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
  28581. resp, requestErr := http.Get(api)
  28582. if requestErr != nil {
  28583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28584. return
  28585. }
  28586. body, ioErr := ioutil.ReadAll(resp.Body)
  28587. if ioErr != nil {
  28588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28590. return
  28591. }
  28592. var respJSON map[string]interface{}
  28593. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28596. return
  28597. }
  28598. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28599. result, _ := json.Marshal(respJSON)
  28600. fmt.Println("log")
  28601. fmt.Println(string(result))
  28602. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28603. utils.ErrorLog("解析失败:%v", err)
  28604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28605. return
  28606. }
  28607. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28608. res.Output = resSeven10265.Output
  28609. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28610. res.ErrMsg = resSeven10265.ErrMsg
  28611. res.Cainfo = resSeven10265.Cainfo
  28612. res.WarnMsg = resSeven10265.WarnMsg
  28613. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28614. res.Infcode = infocode
  28615. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28616. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28617. var cert_no string
  28618. if his.IdCardType == 1 {
  28619. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28620. } else {
  28621. cert_no = psn_info.VerifyNumber
  28622. }
  28623. 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)
  28624. var dat map[string]interface{}
  28625. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28626. fmt.Println(dat)
  28627. } else {
  28628. fmt.Println(err)
  28629. }
  28630. saveLog(result2, src_resquest, "2207", "结算")
  28631. userJSONBytes, _ := json.Marshal(dat)
  28632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28633. utils.ErrorLog("解析失败:%v", err)
  28634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28635. return
  28636. }
  28637. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28638. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28639. var cert_no string
  28640. var card_sn string
  28641. if his.IdCardType == 1 {
  28642. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28643. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28644. bas := strings.Split(psn_info.CardInfo, "|")
  28645. card_sn = bas[3]
  28646. } else if his.IdCardType == 2 {
  28647. cert_no = his.IdCardNo
  28648. } else {
  28649. cert_no = psn_info.VerifyNumber
  28650. }
  28651. var rf []*ResultFive
  28652. json.Unmarshal([]byte(his.Iinfo), &rf)
  28653. var psn_type string
  28654. for _, item := range rf {
  28655. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28656. psn_type = item.PsnType
  28657. }
  28658. }
  28659. 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)
  28660. var dat map[string]interface{}
  28661. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28662. fmt.Println(dat)
  28663. } else {
  28664. fmt.Println(err)
  28665. }
  28666. saveLog(result2, src_resquest, "2207", "结算")
  28667. userJSONBytes, _ := json.Marshal(dat)
  28668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28669. utils.ErrorLog("解析失败:%v", err)
  28670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28671. return
  28672. }
  28673. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28674. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28675. var cert_no string
  28676. var card_sn string
  28677. if his.IdCardType == 1 {
  28678. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28679. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28680. //bas := strings.Split(psn_info.CardInfo, "|")
  28681. card_sn = ""
  28682. } else if his.IdCardType == 2 {
  28683. cert_no = his.IdCardNo
  28684. } else {
  28685. cert_no = psn_info.VerifyNumber
  28686. }
  28687. var rf []*ResultFive
  28688. json.Unmarshal([]byte(his.Iinfo), &rf)
  28689. var psn_type string
  28690. for _, item := range rf {
  28691. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28692. psn_type = item.PsnType
  28693. }
  28694. }
  28695. 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)
  28696. var dat map[string]interface{}
  28697. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28698. fmt.Println(dat)
  28699. } else {
  28700. fmt.Println(err)
  28701. }
  28702. saveLog(result2, src_resquest, "2207", "结算")
  28703. userJSONBytes, _ := json.Marshal(dat)
  28704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28705. utils.ErrorLog("解析失败:%v", err)
  28706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28707. return
  28708. }
  28709. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28710. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28711. var cert_no string
  28712. var card_sn string
  28713. if his.IdCardType == 1 {
  28714. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28715. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28716. //bas := strings.Split(psn_info.CardInfo, "|")
  28717. card_sn = ""
  28718. } else if his.IdCardType == 2 {
  28719. cert_no = his.IdCardNo
  28720. } else {
  28721. cert_no = psn_info.VerifyNumber
  28722. }
  28723. var rf []*ResultFive
  28724. json.Unmarshal([]byte(his.Iinfo), &rf)
  28725. var psn_type string
  28726. for _, item := range rf {
  28727. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28728. psn_type = item.PsnType
  28729. }
  28730. }
  28731. 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)
  28732. var dat map[string]interface{}
  28733. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28734. fmt.Println(dat)
  28735. } else {
  28736. fmt.Println(err)
  28737. }
  28738. saveLog(result2, src_resquest, "2207", "结算")
  28739. userJSONBytes, _ := json.Marshal(dat)
  28740. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28741. utils.ErrorLog("解析失败:%v", err)
  28742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28743. return
  28744. }
  28745. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28746. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28747. if his.IdCardType == 1 {
  28748. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28749. bas := strings.Split(psn_info.CardInfo, "|")
  28750. cert_no = bas[2]
  28751. } else if his.IdCardType == 3 {
  28752. cert_no = his.Certno
  28753. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28754. } else if his.IdCardType == 4 {
  28755. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28756. cert_no = psn_info.VerifyNumber
  28757. psn_info.VerifyNumber = psn_info.VerifyNumber
  28758. } else {
  28759. cert_no = his.Certno
  28760. psn_info.VerifyNumber = his.Certno
  28761. }
  28762. var api string
  28763. var med_type string
  28764. if his.Insutype == "390" {
  28765. if reg_type == 992102 {
  28766. med_type = "992102"
  28767. }
  28768. if reg_type == 1104 {
  28769. med_type = "1104"
  28770. }
  28771. if reg_type == 1104 {
  28772. med_type = "1104"
  28773. }
  28774. if reg_type == 140104 {
  28775. med_type = "140104"
  28776. }
  28777. if reg_type == 140201 {
  28778. med_type = "140201"
  28779. }
  28780. if reg_type == 14 {
  28781. med_type = "14"
  28782. }
  28783. } else if his.Insutype == "310" {
  28784. if reg_type == 1104 {
  28785. med_type = "1104"
  28786. }
  28787. if reg_type == 992102 {
  28788. med_type = "992102"
  28789. }
  28790. if reg_type == 140104 {
  28791. med_type = "140104"
  28792. }
  28793. if reg_type == 140201 {
  28794. med_type = "140201"
  28795. }
  28796. if reg_type == 14 {
  28797. med_type = "14"
  28798. }
  28799. }
  28800. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28801. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28802. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28803. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28804. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28805. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28806. "&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
  28807. resp, requestErr := http.Get(api)
  28808. if requestErr != nil {
  28809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28810. return
  28811. }
  28812. body, ioErr := ioutil.ReadAll(resp.Body)
  28813. if ioErr != nil {
  28814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28816. return
  28817. }
  28818. var respJSON map[string]interface{}
  28819. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28822. return
  28823. }
  28824. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28825. if status == "0" {
  28826. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28827. c.ServeSuccessJSON(map[string]interface{}{
  28828. "failed_code": -10,
  28829. "msg": err_msg,
  28830. })
  28831. return
  28832. }
  28833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28834. result, _ := json.Marshal(respJSON)
  28835. fmt.Println("log")
  28836. fmt.Println(string(result))
  28837. if err := json.Unmarshal(result, &ahres); err != nil {
  28838. utils.ErrorLog("解析失败:%v", err)
  28839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28840. return
  28841. }
  28842. res.InfRefmsgid = ahres.InfRefmsgid
  28843. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28844. // 创建对应的Time类型
  28845. t := time.UnixMilli(timestamp)
  28846. // 格式化成指定的日期字符串
  28847. str := t.Format("2006-01-02 15:04:05")
  28848. res.Output.Setlinfo.SetlTime = str
  28849. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28850. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28851. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28852. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28853. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28854. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28855. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28856. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28857. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28858. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28859. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28860. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28861. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28862. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28863. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28864. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28865. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28866. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28867. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28868. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28869. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28870. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28871. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28872. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28873. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28874. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28875. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28876. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28877. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28878. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28879. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28880. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28881. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28882. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28883. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28884. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28885. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28886. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28887. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28888. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28889. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28890. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28891. res.Output.Setldetail = ahres.Output.Setldetail
  28892. res.ErrMsg = ahres.ErrMsg
  28893. res.Cainfo = ahres.Cainfo
  28894. res.WarnMsg = ahres.WarnMsg
  28895. res.Infcode = ahres.Infcode
  28896. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28897. res.Output.Setlinfo.ClrType = "11"
  28898. } else {
  28899. res.Output.Setlinfo.ClrType = "9903"
  28900. }
  28901. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28902. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28903. if his.IdCardType == 1 {
  28904. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28905. bas := strings.Split(psn_info.CardInfo, "|")
  28906. cert_no = bas[2]
  28907. } else if his.IdCardType == 3 {
  28908. cert_no = his.Certno
  28909. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28910. } else if his.IdCardType == 4 {
  28911. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28912. cert_no = his.Certno
  28913. psn_info.VerifyNumber = psn_info.VerifyNumber
  28914. } else {
  28915. cert_no = his.Certno
  28916. psn_info.VerifyNumber = his.Certno
  28917. }
  28918. var api string
  28919. var med_type string
  28920. if his.Insutype == "390" {
  28921. if reg_type == 1104 {
  28922. med_type = "1104"
  28923. }
  28924. if reg_type == 992102 {
  28925. med_type = "992102"
  28926. }
  28927. if reg_type == 140104 {
  28928. med_type = "140104"
  28929. }
  28930. if reg_type == 14 {
  28931. med_type = "14"
  28932. }
  28933. if reg_type == 140201 {
  28934. med_type = "140201"
  28935. }
  28936. } else if his.Insutype == "310" {
  28937. if reg_type == 1104 {
  28938. med_type = "1104"
  28939. }
  28940. if reg_type == 992102 {
  28941. med_type = "992102"
  28942. }
  28943. if reg_type == 14 {
  28944. med_type = "14"
  28945. }
  28946. if reg_type == 140104 {
  28947. med_type = "140104"
  28948. }
  28949. if reg_type == 140201 {
  28950. med_type = "140201"
  28951. }
  28952. }
  28953. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28954. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28955. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28956. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28957. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28958. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28959. "&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
  28960. resp, requestErr := http.Get(api)
  28961. if requestErr != nil {
  28962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28963. return
  28964. }
  28965. body, ioErr := ioutil.ReadAll(resp.Body)
  28966. if ioErr != nil {
  28967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28969. return
  28970. }
  28971. var respJSON map[string]interface{}
  28972. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28975. return
  28976. }
  28977. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28978. if status == "0" {
  28979. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28980. c.ServeSuccessJSON(map[string]interface{}{
  28981. "failed_code": -10,
  28982. "msg": err_msg,
  28983. })
  28984. return
  28985. }
  28986. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28987. result, _ := json.Marshal(respJSON)
  28988. fmt.Println("log")
  28989. fmt.Println(string(result))
  28990. if err := json.Unmarshal(result, &ahres); err != nil {
  28991. utils.ErrorLog("解析失败:%v", err)
  28992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28993. return
  28994. }
  28995. res.InfRefmsgid = ahres.InfRefmsgid
  28996. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28997. // 创建对应的Time类型
  28998. t := time.UnixMilli(timestamp)
  28999. // 格式化成指定的日期字符串
  29000. str := t.Format("2006-01-02 15:04:05")
  29001. res.Output.Setlinfo.SetlTime = str
  29002. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29003. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29004. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29005. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29006. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29007. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29008. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29009. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29010. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29011. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29012. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29013. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29014. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29015. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29016. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29017. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29018. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29019. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29020. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29021. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29022. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29023. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29024. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29025. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29026. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29027. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29028. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29029. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29030. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29031. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29032. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29033. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29034. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29035. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29036. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29037. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29038. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29039. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29040. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29041. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29042. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29043. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29044. res.Output.Setldetail = ahres.Output.Setldetail
  29045. res.ErrMsg = ahres.ErrMsg
  29046. res.Cainfo = ahres.Cainfo
  29047. res.WarnMsg = ahres.WarnMsg
  29048. res.Infcode = ahres.Infcode
  29049. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  29050. res.Output.Setlinfo.ClrType = "11"
  29051. } else {
  29052. res.Output.Setlinfo.ClrType = "9903"
  29053. }
  29054. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29055. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29056. var cert_no string
  29057. if his.IdCardType == 1 {
  29058. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  29059. } else if his.IdCardType == 2 {
  29060. cert_no = his.IdCardNo
  29061. } else {
  29062. cert_no = psn_info.VerifyNumber
  29063. }
  29064. 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, "")
  29065. var dat map[string]interface{}
  29066. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29067. fmt.Println(dat)
  29068. } else {
  29069. fmt.Println(err)
  29070. }
  29071. saveLog(result2, src_resquest, "2207", "结算")
  29072. userJSONBytes, _ := json.Marshal(dat)
  29073. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29074. utils.ErrorLog("解析失败:%v", err)
  29075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29076. return
  29077. }
  29078. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29079. psn_info, _ := service.GetPsnByPatientId(id)
  29080. var verify_number string
  29081. if psn_info.IdCardType == 4 {
  29082. verify_number = psn_info.VerifyNumber
  29083. } else if psn_info.IdCardType == 1 {
  29084. bas := strings.Split(psn_info.CardInfo, "|")
  29085. cardNumber := bas[2]
  29086. verify_number = cardNumber
  29087. } else {
  29088. verify_number = psn_info.Certno
  29089. psn_info.IdCardType = 2
  29090. }
  29091. var api string
  29092. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29093. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29094. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29095. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29096. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29097. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29098. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  29099. resp, requestErr := http.Get(api)
  29100. if requestErr != nil {
  29101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29102. return
  29103. }
  29104. body, ioErr := ioutil.ReadAll(resp.Body)
  29105. if ioErr != nil {
  29106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29108. return
  29109. }
  29110. var respJSON map[string]interface{}
  29111. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29114. return
  29115. }
  29116. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29117. result, _ := json.Marshal(respJSON)
  29118. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29119. utils.ErrorLog("解析失败:%v", err)
  29120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29121. return
  29122. }
  29123. } else {
  29124. var src_resquest string
  29125. if miConfig.Code == "H15049901371" {
  29126. //赤峰地区国家医保医疗类别
  29127. //职工透析:医疗类别选特殊情况门诊990502
  29128. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29129. var med_type string
  29130. if his.Insutype == "390" {
  29131. if reg_type == 14 {
  29132. med_type = "9933"
  29133. } else if reg_type == 11 {
  29134. med_type = "11"
  29135. }
  29136. } else if his.Insutype == "310" {
  29137. if reg_type == 14 {
  29138. med_type = "990502"
  29139. } else if reg_type == 11 {
  29140. med_type = "11"
  29141. }
  29142. }
  29143. 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)
  29144. } else {
  29145. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  29146. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  29147. if result3101.Infcode == 0 {
  29148. if len(result3101.Output.Result) > 0 {
  29149. c.ServeSuccessJSON(map[string]interface{}{
  29150. "failed_code": -10,
  29151. "failed_type": 100,
  29152. "warm_type": 2,
  29153. "msg": result3101,
  29154. })
  29155. return
  29156. }
  29157. } else {
  29158. c.ServeSuccessJSON(map[string]interface{}{
  29159. "failed_code": -10,
  29160. "msg": result3101.ErrMsg,
  29161. })
  29162. return
  29163. }
  29164. }
  29165. if his.IdCardType == 4 {
  29166. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29167. token := psn_info.VerifyNumber
  29168. 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)
  29169. } else {
  29170. 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)
  29171. }
  29172. }
  29173. var dat map[string]interface{}
  29174. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29175. fmt.Println(dat)
  29176. } else {
  29177. fmt.Println(err)
  29178. }
  29179. saveLog(result2, src_resquest, "2207", "结算")
  29180. userJSONBytes, _ := json.Marshal(dat)
  29181. if miConfig.Code == "H15049901371" {
  29182. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29183. utils.ErrorLog("解析失败:%v", err)
  29184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29185. return
  29186. }
  29187. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29188. res.Output = resSeven10265.Output
  29189. res.ErrMsg = resSeven10265.ErrMsg
  29190. res.Cainfo = resSeven10265.Cainfo
  29191. res.WarnMsg = resSeven10265.WarnMsg
  29192. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29193. res.Infcode = infocode
  29194. } else {
  29195. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29196. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29197. utils.ErrorLog("解析失败:%v", err)
  29198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29199. return
  29200. }
  29201. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29202. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29203. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29204. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29205. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29206. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29207. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29208. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29209. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29210. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29211. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29212. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29213. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29214. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29215. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29216. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29217. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29218. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29219. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29220. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29221. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29222. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29223. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29224. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29225. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29226. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29227. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29228. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29229. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29230. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29231. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29232. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29233. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29234. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29235. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29236. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29237. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29238. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29239. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29240. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29241. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29242. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29243. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29244. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29245. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29246. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29247. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29248. res.Cainfo = gzresSeven10265Two.Cainfo
  29249. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29250. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29251. //res.Infcode = infocode
  29252. } else {
  29253. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29254. utils.ErrorLog("解析失败:%v", err)
  29255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29256. return
  29257. }
  29258. }
  29259. }
  29260. }
  29261. if res.Infcode != 0 {
  29262. errlog := &models.HisOrderError{
  29263. UserOrgId: adminUser.CurrentOrgId,
  29264. Ctime: time.Now().Unix(),
  29265. Mtime: time.Now().Unix(),
  29266. Number: chrg_bchno,
  29267. ErrMsg: res.ErrMsg,
  29268. Status: 1,
  29269. PatientId: id,
  29270. RecordTime: recordDateTime,
  29271. Stage: 6,
  29272. }
  29273. service.CreateErrMsgLog(errlog)
  29274. c.ServeSuccessJSON(map[string]interface{}{
  29275. "failed_code": -10,
  29276. "msg": res.ErrMsg,
  29277. })
  29278. return
  29279. } else {
  29280. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29281. order.OrderStatus = 2
  29282. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29283. order.SetlId = res.Output.Setlinfo.SetlID
  29284. order.PsnNo = res.Output.Setlinfo.PsnNo
  29285. order.PsnName = res.Output.Setlinfo.PsnName
  29286. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29287. order.Certno = res.Output.Setlinfo.Certno
  29288. order.Gend = res.Output.Setlinfo.Gend
  29289. order.Naty = res.Output.Setlinfo.Naty
  29290. order.Age = res.Output.Setlinfo.Age
  29291. order.Insutype = res.Output.Setlinfo.Insutype
  29292. order.PsnType = res.Output.Setlinfo.PsnType
  29293. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29294. order.SetlTime = res.Output.Setlinfo.SetlTime
  29295. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29296. order.PayWays = pay_ways
  29297. order.AcctUsedFlag = acct_used_flag
  29298. order.WechatPay = wechat_pay
  29299. order.AliPay = ali_pay
  29300. order.JifenPay = jifen_pay
  29301. order.BandCardPay = band_card_pay
  29302. order.CashPay = cash_pay
  29303. order.OthDesc = oth_desc
  29304. //order.MedType = res.Output.Setlinfo.MedType
  29305. if reg_type == 1112 {
  29306. order.MedType = "1112"
  29307. }
  29308. if reg_type == 1111 {
  29309. order.MedType = "1111"
  29310. }
  29311. order.ClrType = res.Output.Setlinfo.ClrType
  29312. if adminUser.CurrentOrgId == 10480 {
  29313. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29314. order.ClrType = "11"
  29315. } else {
  29316. order.ClrType = "9903"
  29317. }
  29318. }
  29319. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29320. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29321. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29322. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29323. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29324. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29325. order.HifpPay = res.Output.Setlinfo.HifpPay
  29326. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29327. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29328. order.HifesPay = res.Output.Setlinfo.HifesPay
  29329. order.HifobPay = res.Output.Setlinfo.HifobPay
  29330. order.MafPay = res.Output.Setlinfo.MafPay
  29331. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29332. order.OthPay = res.Output.Setlinfo.OthPay
  29333. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29334. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29335. order.AcctPay = res.Output.Setlinfo.AcctPay
  29336. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29337. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29338. order.Balc = res.Output.Setlinfo.Balc
  29339. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29340. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29341. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29342. order.ClrWay = res.Output.Setlinfo.ClrWay
  29343. order.Creator = order.Creator
  29344. order.Modify = roles.AdminUserId
  29345. order.RequestLog = src_resquest
  29346. order.Diagnosis = diagnosis_id
  29347. order.FaPiaoNumber = fapiao_number
  29348. order.FaPiaoCode = fapiao_code
  29349. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29350. detailStr := string(setlDetail)
  29351. order.SetlDetail = detailStr
  29352. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29353. err = service.UpDateOrder(order)
  29354. if err == nil {
  29355. //判断是否使用了押金
  29356. if dec_way == "true" {
  29357. tmpstring := strconv.FormatInt(order.ID, 10)
  29358. //扣押金
  29359. order.Decimal = decimal
  29360. service.UpDateOrder(order)
  29361. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  29362. if errmsg != nil {
  29363. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  29364. return
  29365. }
  29366. }
  29367. c.ServeSuccessJSON(map[string]interface{}{
  29368. "msg": "结算成功",
  29369. })
  29370. } else {
  29371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29372. return
  29373. }
  29374. }
  29375. }
  29376. }
  29377. }
  29378. // 上传明细-预结算-
  29379. func (c *HisApiController) GetPreUploadInfo() {
  29380. id, _ := c.GetInt64("id")
  29381. record_time := c.GetString("record_time")
  29382. his_patient_id, _ := c.GetInt64("his_patient_id")
  29383. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  29384. admin_user_id, _ := c.GetInt64("admin_user_id")
  29385. diagnosis_id := c.GetString("diagnosis")
  29386. sick_type, _ := c.GetInt64("sick_type")
  29387. reg_type, _ := c.GetInt64("p_type")
  29388. begin_time := c.GetString("begin_time")
  29389. acct_used_flag := c.GetString("acct_used_flag")
  29390. id_str := c.GetString("ids")
  29391. ids_arr := strings.Split(id_str, ",")
  29392. timeLayout := "2006-01-02"
  29393. loc, _ := time.LoadLocation("Local")
  29394. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29395. if err != nil {
  29396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29397. return
  29398. }
  29399. recordDateTime := theTime.Unix()
  29400. adminUser := c.GetAdminUserInfo()
  29401. diagnosis_ids := strings.Split(diagnosis_id, ",")
  29402. var config []*models.HisXtDiagnoseConfig
  29403. for _, item := range diagnosis_ids {
  29404. id, _ := strconv.ParseInt(item, 10, 64)
  29405. if id > 0 {
  29406. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29407. config = append(config, &diagnosisConfig)
  29408. }
  29409. }
  29410. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  29411. sickConfig, _ := service.FindSickById(sick_type)
  29412. var prescriptions []*models.HisPrescription
  29413. var start_time int64
  29414. var end_time int64
  29415. var isSuccess bool = true
  29416. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29417. fmt.Println(his_patient_id)
  29418. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29419. timestamp := time.Now().Unix()
  29420. tempTime := time.Unix(timestamp, 0)
  29421. timeFormat := tempTime.Format("20060102150405")
  29422. chrgBchno := rand.Intn(100000) + 10000
  29423. new_chrg_bchno := ""
  29424. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  29425. new_chrg_bchno = chrg_bchno
  29426. if adminUser.CurrentOrgId == 10265 {
  29427. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29428. new_chrg_bchno = "0000"
  29429. }
  29430. }
  29431. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29432. var patientPrescription models.HisPrescriptionInfo
  29433. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29434. if patientPrescription.ID == 0 {
  29435. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  29436. }
  29437. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29438. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29439. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29440. strconv.FormatInt(his.PatientId, 10)
  29441. var res2406 Result2406
  29442. //安徽单病种处理
  29443. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  29444. data := make(map[string]interface{})
  29445. client := &http.Client{}
  29446. data["psn_no"] = his.PsnNo
  29447. data["mdtrt_id"] = his.Number
  29448. data["operator"] = roles.UserName
  29449. data["cert_no"] = his.IdCardNo
  29450. data["org_name"] = miConfig.OrgName
  29451. data["psn_name"] = his.Name
  29452. data["ipt_otp_no"] = his.IptOtpNo
  29453. data["ipt_psn_sp_flag_type"] = "0901"
  29454. data["ipt_psn_sp_flag"] = "1"
  29455. data["fixmedins_code"] = miConfig.Code
  29456. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29457. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29458. data["url"] = miConfig.Url
  29459. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29460. bytesData, _ := json.Marshal(data)
  29461. var req *http.Request
  29462. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29463. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29464. resp, _ := client.Do(req)
  29465. defer resp.Body.Close()
  29466. body, ioErr := ioutil.ReadAll(resp.Body)
  29467. if ioErr != nil {
  29468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29470. return
  29471. }
  29472. var respJSON map[string]interface{}
  29473. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29476. return
  29477. }
  29478. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29479. if status == "0" {
  29480. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29481. c.ServeSuccessJSON(map[string]interface{}{
  29482. "failed_code": -10,
  29483. "msg": err_msg,
  29484. })
  29485. return
  29486. }
  29487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29488. userJSONBytes, _ := json.Marshal(respJSON)
  29489. fmt.Println("log")
  29490. fmt.Println(string(userJSONBytes))
  29491. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29492. utils.ErrorLog("解析失败:%v", err)
  29493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29494. return
  29495. }
  29496. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  29497. data := make(map[string]interface{})
  29498. client := &http.Client{}
  29499. data["psn_no"] = his.PsnNo
  29500. data["mdtrt_id"] = his.Number
  29501. data["operator"] = roles.UserName
  29502. data["cert_no"] = his.IdCardNo
  29503. data["org_name"] = miConfig.OrgName
  29504. data["psn_name"] = his.Name
  29505. data["ipt_otp_no"] = his.IptOtpNo
  29506. data["ipt_psn_sp_flag_type"] = "0901"
  29507. data["ipt_psn_sp_flag"] = "1"
  29508. data["fixmedins_code"] = miConfig.Code
  29509. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29510. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29511. data["url"] = miConfig.Url
  29512. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29513. bytesData, _ := json.Marshal(data)
  29514. var req *http.Request
  29515. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29516. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29517. resp, _ := client.Do(req)
  29518. defer resp.Body.Close()
  29519. body, ioErr := ioutil.ReadAll(resp.Body)
  29520. if ioErr != nil {
  29521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29523. return
  29524. }
  29525. var respJSON map[string]interface{}
  29526. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29529. return
  29530. }
  29531. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29532. if status == "0" {
  29533. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29534. c.ServeSuccessJSON(map[string]interface{}{
  29535. "failed_code": -10,
  29536. "msg": err_msg,
  29537. })
  29538. return
  29539. }
  29540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29541. userJSONBytes, _ := json.Marshal(respJSON)
  29542. fmt.Println("log")
  29543. fmt.Println(string(userJSONBytes))
  29544. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29545. utils.ErrorLog("解析失败:%v", err)
  29546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29547. return
  29548. }
  29549. }
  29550. if res2406.Infcode != 0 {
  29551. adminUser := c.GetAdminUserInfo()
  29552. errlog := &models.HisOrderError{
  29553. UserOrgId: adminUser.CurrentOrgId,
  29554. Ctime: time.Now().Unix(),
  29555. Mtime: time.Now().Unix(),
  29556. ErrMsg: res2406.ErrMsg,
  29557. Status: 1,
  29558. PatientId: id,
  29559. RecordTime: recordDateTime,
  29560. Stage: 3,
  29561. }
  29562. service.CreateErrMsgLog(errlog)
  29563. c.ServeSuccessJSON(map[string]interface{}{
  29564. "failed_code": -10,
  29565. "msg": res2406.ErrMsg,
  29566. })
  29567. return
  29568. }
  29569. var res2 ResultSix
  29570. var res3 GZResultSix
  29571. var resSix10265 ResultSix10265
  29572. //var time_stamp string
  29573. if miConfig.MdtrtareaAdmvs == "421300" {
  29574. data := make(map[string]interface{})
  29575. client := &http.Client{}
  29576. data["psn_no"] = his.PsnNo
  29577. data["mdtrt_id"] = his.Number
  29578. data["department"] = department.Name
  29579. data["org_name"] = miConfig.OrgName
  29580. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29581. data["doctor_id"] = doctor_info.DoctorNumber
  29582. data["doctor_name"] = roles.UserName
  29583. data["fixmedins_code"] = miConfig.Code
  29584. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29585. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29586. data["secret_key"] = miConfig.SecretKey
  29587. data["sick_code"] = sickConfig.CountryCode
  29588. data["sick_name"] = sickConfig.ClassName
  29589. data["begin_time"] = begin_time
  29590. data["dept"] = strconv.FormatInt(department.ID, 10)
  29591. data["config"] = config
  29592. data["opter"] = roles.UserName
  29593. fmt.Println(data)
  29594. bytesData, _ := json.Marshal(data)
  29595. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29596. resp, _ := client.Do(req)
  29597. defer resp.Body.Close()
  29598. body, ioErr := ioutil.ReadAll(resp.Body)
  29599. if ioErr != nil {
  29600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29602. return
  29603. }
  29604. var respJSON map[string]interface{}
  29605. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29608. return
  29609. }
  29610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29611. userJSONBytes, _ := json.Marshal(respJSON)
  29612. fmt.Println("log")
  29613. fmt.Println(string(userJSONBytes))
  29614. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29615. utils.ErrorLog("解析失败:%v", err)
  29616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29617. return
  29618. }
  29619. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29620. data := make(map[string]interface{})
  29621. client := &http.Client{}
  29622. data["psn_no"] = his.PsnNo
  29623. data["mdtrt_id"] = his.Number
  29624. data["department"] = department.Name
  29625. data["org_name"] = miConfig.OrgName
  29626. if reg_type == 11 && his.Insutype == "390" {
  29627. data["med_type"] = "110104"
  29628. } else {
  29629. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29630. }
  29631. data["doctor_id"] = doctor_info.DoctorNumber
  29632. data["doctor_name"] = roles.UserName
  29633. data["fixmedins_code"] = miConfig.Code
  29634. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29635. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29636. data["secret_key"] = miConfig.SecretKey
  29637. data["sick_code"] = sickConfig.CountryCode
  29638. data["sick_name"] = sickConfig.ClassName
  29639. data["begin_time"] = begin_time
  29640. data["dept"] = strconv.FormatInt(department.ID, 10)
  29641. data["config"] = config
  29642. data["opter"] = roles.UserName
  29643. fmt.Println(data)
  29644. bytesData, _ := json.Marshal(data)
  29645. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29646. resp, _ := client.Do(req)
  29647. defer resp.Body.Close()
  29648. body, ioErr := ioutil.ReadAll(resp.Body)
  29649. if ioErr != nil {
  29650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29652. return
  29653. }
  29654. var respJSON map[string]interface{}
  29655. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29658. return
  29659. }
  29660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29661. userJSONBytes, _ := json.Marshal(respJSON)
  29662. fmt.Println("log")
  29663. fmt.Println(string(userJSONBytes))
  29664. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29665. utils.ErrorLog("解析失败:%v", err)
  29666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29667. return
  29668. }
  29669. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29670. data := make(map[string]interface{})
  29671. client := &http.Client{}
  29672. data["psn_no"] = his.PsnNo
  29673. data["mdtrt_id"] = his.Number
  29674. data["department"] = department.Name
  29675. data["org_name"] = miConfig.OrgName
  29676. if reg_type == 11 && his.Insutype == "390" {
  29677. data["med_type"] = "110104"
  29678. } else {
  29679. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29680. }
  29681. data["doctor_id"] = doctor_info.DoctorNumber
  29682. data["doctor_name"] = roles.UserName
  29683. data["fixmedins_code"] = miConfig.Code
  29684. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29685. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29686. data["secret_key"] = miConfig.SecretKey
  29687. data["sick_code"] = sickConfig.CountryCode
  29688. data["sick_name"] = sickConfig.ClassName
  29689. data["begin_time"] = begin_time
  29690. data["dept"] = strconv.FormatInt(department.ID, 10)
  29691. data["config"] = config
  29692. data["opter"] = roles.UserName
  29693. fmt.Println(data)
  29694. bytesData, _ := json.Marshal(data)
  29695. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29696. resp, _ := client.Do(req)
  29697. defer resp.Body.Close()
  29698. body, ioErr := ioutil.ReadAll(resp.Body)
  29699. if ioErr != nil {
  29700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29702. return
  29703. }
  29704. var respJSON map[string]interface{}
  29705. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29708. return
  29709. }
  29710. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29711. userJSONBytes, _ := json.Marshal(respJSON)
  29712. fmt.Println("log")
  29713. fmt.Println(string(userJSONBytes))
  29714. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29715. utils.ErrorLog("解析失败:%v", err)
  29716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29717. return
  29718. }
  29719. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29720. data := make(map[string]interface{})
  29721. client := &http.Client{}
  29722. data["psn_no"] = his.PsnNo
  29723. data["mdtrt_id"] = his.Number
  29724. data["department"] = department.Name
  29725. data["org_name"] = miConfig.OrgName
  29726. if reg_type == 11 && his.Insutype == "390" {
  29727. data["med_type"] = "110104"
  29728. } else {
  29729. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29730. }
  29731. data["doctor_id"] = doctor_info.DoctorNumber
  29732. data["doctor_name"] = roles.UserName
  29733. data["fixmedins_code"] = miConfig.Code
  29734. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29735. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29736. data["secret_key"] = miConfig.SecretKey
  29737. data["sick_code"] = sickConfig.CountryCode
  29738. data["sick_name"] = sickConfig.ClassName
  29739. data["begin_time"] = begin_time
  29740. data["dept"] = strconv.FormatInt(department.ID, 10)
  29741. data["config"] = config
  29742. data["opter"] = roles.UserName
  29743. fmt.Println(data)
  29744. bytesData, _ := json.Marshal(data)
  29745. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29746. resp, _ := client.Do(req)
  29747. defer resp.Body.Close()
  29748. body, ioErr := ioutil.ReadAll(resp.Body)
  29749. if ioErr != nil {
  29750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29752. return
  29753. }
  29754. var respJSON map[string]interface{}
  29755. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29758. return
  29759. }
  29760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29761. userJSONBytes, _ := json.Marshal(respJSON)
  29762. fmt.Println("log")
  29763. fmt.Println(string(userJSONBytes))
  29764. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29765. utils.ErrorLog("解析失败:%v", err)
  29766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29767. return
  29768. }
  29769. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  29770. utils.ErrorLog("解析失败:%v", doctor_info)
  29771. data := make(map[string]interface{})
  29772. client := &http.Client{}
  29773. data["psn_no"] = his.PsnNo
  29774. data["mdtrt_id"] = his.Number
  29775. data["doctor"] = roles.UserName
  29776. data["department"] = department.Name
  29777. data["org_name"] = miConfig.OrgName
  29778. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29779. data["doctor_id"] = doctor_info.DoctorNumber
  29780. data["new_doctor_name"] = doctor_info.UserName
  29781. data["fixmedins_code"] = miConfig.Code
  29782. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29783. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29784. data["secret_key"] = miConfig.SecretKey
  29785. data["sick_code"] = sickConfig.CountryCode
  29786. data["sick_name"] = sickConfig.ClassName
  29787. data["url"] = miConfig.Url
  29788. data["ak"] = miConfig.AccessKey
  29789. data["begin_time"] = begin_time
  29790. data["cainfo"] = miConfig.Cainfo
  29791. data["dept"] = strconv.FormatInt(department.ID, 10)
  29792. data["config"] = config
  29793. bytesData, _ := json.Marshal(data)
  29794. var req *http.Request
  29795. if miConfig.MdtrtareaAdmvs == "320830" {
  29796. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  29797. } else if miConfig.MdtrtareaAdmvs == "320921" {
  29798. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29799. } else {
  29800. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29801. }
  29802. resp, _ := client.Do(req)
  29803. defer resp.Body.Close()
  29804. body, ioErr := ioutil.ReadAll(resp.Body)
  29805. if ioErr != nil {
  29806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29808. return
  29809. }
  29810. var respJSON map[string]interface{}
  29811. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29814. return
  29815. }
  29816. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29817. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29818. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29819. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29820. userJSONBytes, _ := json.Marshal(respJSON)
  29821. fmt.Println("log")
  29822. fmt.Println(string(userJSONBytes))
  29823. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29824. utils.ErrorLog("解析失败:%v", err)
  29825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29826. return
  29827. }
  29828. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29829. res2.Output = resSix10265.Output
  29830. res2.ErrMsg = resSix10265.ErrMsg
  29831. res2.Cainfo = resSix10265.Cainfo
  29832. res2.WarnMsg = resSix10265.WarnMsg
  29833. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29834. res2.Infcode = infocode
  29835. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29836. data := make(map[string]interface{})
  29837. client := &http.Client{}
  29838. data["psn_no"] = his.PsnNo
  29839. data["mdtrt_id"] = his.Number
  29840. data["doctor"] = roles.UserName
  29841. data["department"] = department.Name
  29842. data["org_name"] = miConfig.OrgName
  29843. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29844. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  29845. data["fixmedins_code"] = miConfig.Code
  29846. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29847. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29848. data["secret_key"] = miConfig.SecretKey
  29849. data["sick_code"] = sickConfig.CountryCode
  29850. data["sick_name"] = sickConfig.ClassName
  29851. data["begin_time"] = begin_time
  29852. data["dept"] = strconv.FormatInt(department.ID, 10)
  29853. data["config"] = config
  29854. //data["url"] = miConfig.Url
  29855. //data["ak"] = miConfig.AccessKey
  29856. data["cainfo"] = miConfig.Cainfo
  29857. fmt.Println(data)
  29858. bytesData, _ := json.Marshal(data)
  29859. var req *http.Request
  29860. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  29861. resp, _ := client.Do(req)
  29862. defer resp.Body.Close()
  29863. body, ioErr := ioutil.ReadAll(resp.Body)
  29864. if ioErr != nil {
  29865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29867. return
  29868. }
  29869. var respJSON map[string]interface{}
  29870. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29873. return
  29874. }
  29875. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29876. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29877. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29879. userJSONBytes, _ := json.Marshal(respJSON)
  29880. fmt.Println("log")
  29881. fmt.Println(string(userJSONBytes))
  29882. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29883. utils.ErrorLog("解析失败:%v", err)
  29884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29885. return
  29886. }
  29887. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29888. res2.Output = resSix10265.Output
  29889. res2.ErrMsg = resSix10265.ErrMsg
  29890. res2.Cainfo = resSix10265.Cainfo
  29891. res2.WarnMsg = resSix10265.WarnMsg
  29892. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29893. res2.Infcode = infocode
  29894. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29895. 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)
  29896. saveLog(result, requestLog, "2203", "上传就诊信息")
  29897. var respJSON2 map[string]interface{}
  29898. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29901. return
  29902. }
  29903. userJSONBytes2, _ := json.Marshal(respJSON2)
  29904. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29905. utils.ErrorLog("解析失败:%v", err)
  29906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29907. return
  29908. }
  29909. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29910. var result string
  29911. var requestLog string
  29912. 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, "")
  29913. saveLog(result, requestLog, "2203", "上传就诊信息")
  29914. var respJSON2 map[string]interface{}
  29915. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29918. return
  29919. }
  29920. userJSONBytes2, _ := json.Marshal(respJSON2)
  29921. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29922. utils.ErrorLog("解析失败:%v", err)
  29923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29924. return
  29925. }
  29926. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29927. var result string
  29928. var requestLog string
  29929. 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, "")
  29930. saveLog(result, requestLog, "2203", "上传就诊信息")
  29931. var respJSON2 map[string]interface{}
  29932. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29935. return
  29936. }
  29937. userJSONBytes2, _ := json.Marshal(respJSON2)
  29938. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29939. utils.ErrorLog("解析失败:%v", err)
  29940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29941. return
  29942. }
  29943. } else if miConfig.MdtrtareaAdmvs == "360100" {
  29944. var result string
  29945. var requestLog string
  29946. 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, "")
  29947. saveLog(result, requestLog, "2203", "上传就诊信息")
  29948. var respJSON2 map[string]interface{}
  29949. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29952. return
  29953. }
  29954. userJSONBytes2, _ := json.Marshal(respJSON2)
  29955. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29956. utils.ErrorLog("解析失败:%v", err)
  29957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29958. return
  29959. }
  29960. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29961. data := make(map[string]interface{})
  29962. client := &http.Client{}
  29963. data["psn_no"] = his.PsnNo
  29964. data["mdtrt_id"] = his.Number
  29965. data["operator"] = roles.UserName
  29966. data["department"] = department.Name
  29967. data["org_name"] = miConfig.OrgName
  29968. var med_type string
  29969. if his.Insutype == "390" {
  29970. if reg_type == 992102 {
  29971. med_type = "992102"
  29972. data["sick_code"] = "ZDZ940"
  29973. data["sick_name"] = "慢性肾衰竭"
  29974. }
  29975. if reg_type == 140104 {
  29976. med_type = "140104"
  29977. data["sick_code"] = sickConfig.CountryCode
  29978. data["sick_name"] = sickConfig.ClassName
  29979. }
  29980. if reg_type == 14 {
  29981. med_type = "140104"
  29982. data["sick_code"] = sickConfig.CountryCode
  29983. data["sick_name"] = sickConfig.ClassName
  29984. }
  29985. if reg_type == 1104 {
  29986. med_type = "1104"
  29987. data["sick_code"] = sickConfig.CountryCode
  29988. data["sick_name"] = sickConfig.ClassName
  29989. }
  29990. } else if his.Insutype == "310" {
  29991. if reg_type == 992102 {
  29992. med_type = "992102"
  29993. data["sick_code"] = "ZDZ940"
  29994. data["sick_name"] = "慢性肾衰竭"
  29995. }
  29996. if reg_type == 140104 {
  29997. med_type = "140104"
  29998. data["sick_code"] = sickConfig.CountryCode
  29999. data["sick_name"] = sickConfig.ClassName
  30000. }
  30001. if reg_type == 14 {
  30002. med_type = "14"
  30003. data["sick_code"] = sickConfig.CountryCode
  30004. data["sick_name"] = sickConfig.ClassName
  30005. }
  30006. if reg_type == 1104 {
  30007. med_type = "1104"
  30008. data["sick_code"] = sickConfig.CountryCode
  30009. data["sick_name"] = sickConfig.ClassName
  30010. }
  30011. }
  30012. data["med_type"] = med_type
  30013. data["doctor_number"] = doctor_info.DoctorNumber
  30014. data["doctor_name"] = doctor_info.UserName
  30015. data["fixmedins_code"] = miConfig.Code
  30016. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30017. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30018. data["secret_key"] = miConfig.SecretKey
  30019. data["begin_time"] = begin_time
  30020. data["dept"] = strconv.FormatInt(department.ID, 10)
  30021. data["config"] = config
  30022. data["url"] = miConfig.Url
  30023. data["ak"] = miConfig.AccessKey
  30024. data["cainfo"] = miConfig.Cainfo
  30025. bytesData, _ := json.Marshal(data)
  30026. var req *http.Request
  30027. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30028. resp, _ := client.Do(req)
  30029. defer resp.Body.Close()
  30030. body, ioErr := ioutil.ReadAll(resp.Body)
  30031. if ioErr != nil {
  30032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30034. return
  30035. }
  30036. var respJSON map[string]interface{}
  30037. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30040. return
  30041. }
  30042. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30043. if status == "0" {
  30044. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30045. c.ServeSuccessJSON(map[string]interface{}{
  30046. "failed_code": -10,
  30047. "msg": err_msg,
  30048. })
  30049. return
  30050. }
  30051. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30052. userJSONBytes, _ := json.Marshal(respJSON)
  30053. fmt.Println("log")
  30054. fmt.Println(string(userJSONBytes))
  30055. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30056. utils.ErrorLog("解析失败:%v", err)
  30057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30058. return
  30059. }
  30060. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30061. data := make(map[string]interface{})
  30062. client := &http.Client{}
  30063. data["psn_no"] = his.PsnNo
  30064. data["mdtrt_id"] = his.Number
  30065. data["operator"] = roles.UserName
  30066. data["department"] = department.Name
  30067. data["org_name"] = miConfig.OrgName
  30068. var med_type string
  30069. if his.Insutype == "390" {
  30070. if reg_type == 992102 {
  30071. med_type = "992102"
  30072. data["sick_code"] = sickConfig.CountryCode
  30073. data["sick_name"] = sickConfig.ClassName
  30074. }
  30075. if reg_type == 140104 {
  30076. med_type = "140104"
  30077. data["sick_code"] = sickConfig.CountryCode
  30078. data["sick_name"] = sickConfig.ClassName
  30079. }
  30080. if reg_type == 140201 {
  30081. med_type = "140201"
  30082. data["sick_code"] = sickConfig.CountryCode
  30083. data["sick_name"] = sickConfig.ClassName
  30084. }
  30085. if reg_type == 14 {
  30086. med_type = "14"
  30087. data["sick_code"] = sickConfig.CountryCode
  30088. data["sick_name"] = sickConfig.ClassName
  30089. }
  30090. if reg_type == 11 {
  30091. med_type = "11"
  30092. data["sick_code"] = sickConfig.CountryCode
  30093. data["sick_name"] = sickConfig.ClassName
  30094. }
  30095. } else if his.Insutype == "310" {
  30096. if reg_type == 992102 {
  30097. med_type = "992102"
  30098. data["sick_code"] = sickConfig.CountryCode
  30099. data["sick_name"] = sickConfig.ClassName
  30100. }
  30101. if reg_type == 140104 {
  30102. med_type = "140104"
  30103. data["sick_code"] = sickConfig.CountryCode
  30104. data["sick_name"] = sickConfig.ClassName
  30105. }
  30106. if reg_type == 140201 {
  30107. med_type = "140201"
  30108. data["sick_code"] = sickConfig.CountryCode
  30109. data["sick_name"] = sickConfig.ClassName
  30110. }
  30111. if reg_type == 14 {
  30112. med_type = "14"
  30113. data["sick_code"] = sickConfig.CountryCode
  30114. data["sick_name"] = sickConfig.ClassName
  30115. }
  30116. if reg_type == 11 {
  30117. med_type = "11"
  30118. data["sick_code"] = sickConfig.CountryCode
  30119. data["sick_name"] = sickConfig.ClassName
  30120. }
  30121. }
  30122. data["med_type"] = med_type
  30123. data["doctor_number"] = doctor_info.DoctorNumber
  30124. data["doctor_name"] = doctor_info.UserName
  30125. data["fixmedins_code"] = miConfig.Code
  30126. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30127. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30128. data["secret_key"] = miConfig.SecretKey
  30129. data["begin_time"] = begin_time
  30130. data["dept"] = strconv.FormatInt(department.ID, 10)
  30131. data["config"] = config
  30132. data["url"] = miConfig.Url
  30133. data["ak"] = miConfig.AccessKey
  30134. data["cainfo"] = miConfig.Cainfo
  30135. bytesData, _ := json.Marshal(data)
  30136. var req *http.Request
  30137. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30138. resp, _ := client.Do(req)
  30139. defer resp.Body.Close()
  30140. body, ioErr := ioutil.ReadAll(resp.Body)
  30141. if ioErr != nil {
  30142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30144. return
  30145. }
  30146. var respJSON map[string]interface{}
  30147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30150. return
  30151. }
  30152. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30153. if status == "0" {
  30154. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30155. c.ServeSuccessJSON(map[string]interface{}{
  30156. "failed_code": -10,
  30157. "msg": err_msg,
  30158. })
  30159. return
  30160. }
  30161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30162. userJSONBytes, _ := json.Marshal(respJSON)
  30163. fmt.Println("log")
  30164. fmt.Println(string(userJSONBytes))
  30165. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30166. utils.ErrorLog("解析失败:%v", err)
  30167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30168. return
  30169. }
  30170. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30171. var result string
  30172. var requestLog string
  30173. 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)
  30174. saveLog(result, requestLog, "2203", "上传就诊信息")
  30175. var respJSON2 map[string]interface{}
  30176. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30179. return
  30180. }
  30181. userJSONBytes2, _ := json.Marshal(respJSON2)
  30182. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30183. utils.ErrorLog("解析失败:%v", err)
  30184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30185. return
  30186. }
  30187. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30188. data := make(map[string]interface{})
  30189. client := &http.Client{}
  30190. data["psn_no"] = his.PsnNo
  30191. data["mdtrt_id"] = his.Number
  30192. data["doctor"] = roles.UserName
  30193. data["department"] = department.Name
  30194. data["org_name"] = miConfig.OrgName
  30195. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30196. data["doctor_id"] = doctor_info.DoctorNumber
  30197. data["fixmedins_code"] = miConfig.Code
  30198. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30199. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30200. data["secret_key"] = miConfig.SecretKey
  30201. data["sick_code"] = sickConfig.CountryCode
  30202. data["sick_name"] = sickConfig.ClassName
  30203. data["begin_time"] = begin_time
  30204. data["new_doctor_name"] = doctor_info.UserName
  30205. data["dept"] = strconv.FormatInt(department.ID, 10)
  30206. data["config"] = config
  30207. bytesData, _ := json.Marshal(data)
  30208. var req *http.Request
  30209. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  30210. resp, _ := client.Do(req)
  30211. defer resp.Body.Close()
  30212. body, ioErr := ioutil.ReadAll(resp.Body)
  30213. if ioErr != nil {
  30214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30216. return
  30217. }
  30218. var respJSON map[string]interface{}
  30219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30222. return
  30223. }
  30224. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30225. userJSONBytes, _ := json.Marshal(respJSON)
  30226. fmt.Println("log")
  30227. fmt.Println(string(userJSONBytes))
  30228. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30229. utils.ErrorLog("解析失败:%v", err)
  30230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30231. return
  30232. }
  30233. } else {
  30234. var result string
  30235. var requestLog string
  30236. if miConfig.MdtrtareaAdmvs == "440781" { //
  30237. 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)
  30238. } else {
  30239. if miConfig.Code == "H15049901371" {
  30240. //赤峰地区国家医保医疗类别
  30241. //职工透析:医疗类别选特殊情况门诊990502
  30242. //居民定额血透门慢: 医疗类别选门诊慢病140104
  30243. var med_type string
  30244. if his.Insutype == "390" {
  30245. if reg_type == 14 {
  30246. med_type = "9933"
  30247. } else if reg_type == 11 {
  30248. med_type = "11"
  30249. }
  30250. } else if his.Insutype == "310" {
  30251. if reg_type == 14 {
  30252. med_type = "990502"
  30253. } else if reg_type == 11 {
  30254. med_type = "11"
  30255. }
  30256. }
  30257. 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)
  30258. } else {
  30259. 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)
  30260. }
  30261. saveLog(result, requestLog, "2203", "上传就诊信息")
  30262. var respJSON2 map[string]interface{}
  30263. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30266. return
  30267. }
  30268. userJSONBytes2, _ := json.Marshal(respJSON2)
  30269. if miConfig.Code == "H15049901371" {
  30270. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  30271. utils.ErrorLog("解析失败:%v", err)
  30272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30273. return
  30274. }
  30275. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30276. res2.Output = resSix10265.Output
  30277. res2.ErrMsg = resSix10265.ErrMsg
  30278. res2.Cainfo = resSix10265.Cainfo
  30279. res2.WarnMsg = resSix10265.WarnMsg
  30280. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30281. res2.Infcode = infocode
  30282. } else {
  30283. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30284. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  30285. utils.ErrorLog("解析失败:%v", err)
  30286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30287. return
  30288. }
  30289. res2.Infcode = res3.Infcode
  30290. } else {
  30291. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30292. utils.ErrorLog("解析失败:%v", err)
  30293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30294. return
  30295. }
  30296. }
  30297. }
  30298. }
  30299. }
  30300. if res2.Infcode == -1 {
  30301. adminUser := c.GetAdminUserInfo()
  30302. errlog := &models.HisOrderError{
  30303. UserOrgId: adminUser.CurrentOrgId,
  30304. Ctime: time.Now().Unix(),
  30305. Mtime: time.Now().Unix(),
  30306. ErrMsg: res2.ErrMsg,
  30307. Status: 1,
  30308. PatientId: id,
  30309. RecordTime: recordDateTime,
  30310. Stage: 3,
  30311. }
  30312. service.CreateErrMsgLog(errlog)
  30313. c.ServeSuccessJSON(map[string]interface{}{
  30314. "failed_code": -10,
  30315. "msg": res2.ErrMsg,
  30316. })
  30317. return
  30318. }
  30319. if res2.Infcode != 0 {
  30320. adminUser := c.GetAdminUserInfo()
  30321. errlog := &models.HisOrderError{
  30322. UserOrgId: adminUser.CurrentOrgId,
  30323. Ctime: time.Now().Unix(),
  30324. Mtime: time.Now().Unix(),
  30325. ErrMsg: res2.ErrMsg,
  30326. Status: 1,
  30327. PatientId: id,
  30328. RecordTime: recordDateTime,
  30329. Stage: 3,
  30330. }
  30331. service.CreateErrMsgLog(errlog)
  30332. c.ServeSuccessJSON(map[string]interface{}{
  30333. "failed_code": -10,
  30334. "msg": res2.ErrMsg,
  30335. })
  30336. return
  30337. } else {
  30338. his.Diagnosis = diagnosis_id
  30339. his.SickType = sickConfig.ID
  30340. his.PType = fmt.Sprintf("%d", reg_type)
  30341. service.UpdateHisPatientThree(&his)
  30342. data := make(map[string]interface{})
  30343. if settle_accounts_type == 1 { //日结
  30344. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  30345. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  30346. } else {
  30347. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  30348. }
  30349. data["pre"] = prescriptions
  30350. } else { //月结
  30351. start_time_str := c.GetString("start_time")
  30352. end_time_str := c.GetString("end_time")
  30353. timeLayout := "2006-01-02"
  30354. loc, _ := time.LoadLocation("Local")
  30355. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  30356. if err != nil {
  30357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30358. return
  30359. }
  30360. recordStartTime := theStartTime.Unix()
  30361. start_time = recordStartTime
  30362. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  30363. if err != nil {
  30364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30365. return
  30366. }
  30367. recordEndTime := theEndTime.Unix()
  30368. end_time = recordEndTime
  30369. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  30370. data["pre"] = prescriptions
  30371. }
  30372. client := &http.Client{}
  30373. data["psn_no"] = his.PsnNo
  30374. data["mdtrt_id"] = his.Number
  30375. data["chrg_bchno"] = new_chrg_bchno
  30376. data["org_name"] = miConfig.OrgName
  30377. data["doctor"] = doctor_info.UserName
  30378. data["doctor_id"] = doctor_info.DoctorNumber
  30379. data["dept"] = department.Name
  30380. data["fixmedins_code"] = miConfig.Code
  30381. data["opter"] = roles.UserName
  30382. data["dept_code"] = department.Number
  30383. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30384. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30385. data["secret_key"] = miConfig.SecretKey
  30386. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  30387. data["url"] = miConfig.Url
  30388. data["ak"] = miConfig.AccessKey
  30389. data["new_doctor_name"] = patientPrescription.Doctor
  30390. if his.Insutype == "390" {
  30391. if reg_type == 992102 {
  30392. data["diag_code"] = "ZDZ940"
  30393. }
  30394. if reg_type == 140104 {
  30395. data["diag_code"] = sickConfig.CountryCode
  30396. }
  30397. if reg_type == 140201 {
  30398. data["diag_code"] = sickConfig.CountryCode
  30399. }
  30400. if reg_type == 14 {
  30401. data["diag_code"] = sickConfig.CountryCode
  30402. }
  30403. if reg_type == 1104 {
  30404. data["diag_code"] = sickConfig.CountryCode
  30405. }
  30406. } else if his.Insutype == "310" {
  30407. if miConfig.MdtrtareaAdmvs == "341203" {
  30408. if reg_type == 992102 {
  30409. data["diag_code"] = "ZDZ940"
  30410. }
  30411. if reg_type != 992102 {
  30412. data["diag_code"] = sickConfig.CountryCode
  30413. }
  30414. } else {
  30415. data["diag_code"] = sickConfig.CountryCode
  30416. }
  30417. }
  30418. data["cainfo"] = miConfig.Cainfo
  30419. data["opter"] = roles.UserName
  30420. var ids []int64
  30421. for _, item := range prescriptions {
  30422. ids = append(ids, item.ID)
  30423. }
  30424. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30425. if config.IsOpen == 1 { //对接了医保,走医保流程
  30426. var res ResultFour
  30427. var resFour10265 ResultFour10265
  30428. if miConfig.MdtrtareaAdmvs == "421300" {
  30429. bytesData, _ := json.Marshal(data)
  30430. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30431. resp, _ := client.Do(req)
  30432. defer resp.Body.Close()
  30433. body, ioErr := ioutil.ReadAll(resp.Body)
  30434. if ioErr != nil {
  30435. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30437. return
  30438. }
  30439. var respJSON map[string]interface{}
  30440. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30441. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30443. return
  30444. }
  30445. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30446. userJSONBytes, _ := json.Marshal(respJSON)
  30447. fmt.Println("log")
  30448. fmt.Println(string(userJSONBytes))
  30449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30450. utils.ErrorLog("解析失败:%v", err)
  30451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30452. return
  30453. }
  30454. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30455. bytesData, _ := json.Marshal(data)
  30456. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30457. resp, _ := client.Do(req)
  30458. defer resp.Body.Close()
  30459. body, ioErr := ioutil.ReadAll(resp.Body)
  30460. if ioErr != nil {
  30461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30463. return
  30464. }
  30465. var respJSON map[string]interface{}
  30466. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30469. return
  30470. }
  30471. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30472. userJSONBytes, _ := json.Marshal(respJSON)
  30473. fmt.Println("log")
  30474. fmt.Println(string(userJSONBytes))
  30475. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30476. utils.ErrorLog("解析失败:%v", err)
  30477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30478. return
  30479. }
  30480. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30481. bytesData, _ := json.Marshal(data)
  30482. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30483. resp, _ := client.Do(req)
  30484. defer resp.Body.Close()
  30485. body, ioErr := ioutil.ReadAll(resp.Body)
  30486. if ioErr != nil {
  30487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30489. return
  30490. }
  30491. var respJSON map[string]interface{}
  30492. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30495. return
  30496. }
  30497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30498. userJSONBytes, _ := json.Marshal(respJSON)
  30499. fmt.Println("log")
  30500. fmt.Println(string(userJSONBytes))
  30501. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30502. utils.ErrorLog("解析失败:%v", err)
  30503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30504. return
  30505. }
  30506. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30507. bytesData, _ := json.Marshal(data)
  30508. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30509. resp, _ := client.Do(req)
  30510. defer resp.Body.Close()
  30511. body, ioErr := ioutil.ReadAll(resp.Body)
  30512. if ioErr != nil {
  30513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30515. return
  30516. }
  30517. var respJSON map[string]interface{}
  30518. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30521. return
  30522. }
  30523. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30524. userJSONBytes, _ := json.Marshal(respJSON)
  30525. fmt.Println("log")
  30526. fmt.Println(string(userJSONBytes))
  30527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30528. utils.ErrorLog("解析失败:%v", err)
  30529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30530. return
  30531. }
  30532. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  30533. var result3101 Result3101
  30534. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30535. result3101.Infcode = "0"
  30536. if result3101.Infcode == "0" {
  30537. if len(result3101.Output.Result) > 0 {
  30538. var errMsgs []string
  30539. for _, item := range result3101.Output.Result {
  30540. errMsgs = append(errMsgs, item.VolaCont)
  30541. }
  30542. c.ServeSuccessJSON(map[string]interface{}{
  30543. "failed_code": -10,
  30544. "msg": errMsgs,
  30545. })
  30546. return
  30547. } else {
  30548. if miConfig.MdtrtareaAdmvs == "320921" {
  30549. data["doctor_id"] = doctor_info.DoctorNumber
  30550. } else {
  30551. data["doctor_id"] = doctor_info.DoctorNumber
  30552. }
  30553. bytesData, _ := json.Marshal(data)
  30554. var req *http.Request
  30555. if miConfig.MdtrtareaAdmvs == "320830" {
  30556. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  30557. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30558. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30559. } else {
  30560. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30561. }
  30562. resp, _ := client.Do(req)
  30563. defer resp.Body.Close()
  30564. body, ioErr := ioutil.ReadAll(resp.Body)
  30565. if ioErr != nil {
  30566. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30568. return
  30569. }
  30570. var respJSON map[string]interface{}
  30571. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30572. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30574. return
  30575. }
  30576. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30577. userJSONBytes, _ := json.Marshal(respJSON)
  30578. fmt.Println("log")
  30579. fmt.Println(string(userJSONBytes))
  30580. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30581. utils.ErrorLog("解析失败:%v", err)
  30582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30583. return
  30584. }
  30585. res.InfRefmsgid = resFour10265.InfRefmsgid
  30586. res.Output = resFour10265.Output
  30587. res.ErrMsg = resFour10265.ErrMsg
  30588. res.Cainfo = resFour10265.Cainfo
  30589. res.WarnMsg = resFour10265.WarnMsg
  30590. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30591. res.Infcode = infocode
  30592. }
  30593. }
  30594. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30595. var pagesize int = 5
  30596. var start int = 1
  30597. var stop int
  30598. var pagecount int
  30599. var curpage int
  30600. data["doctor_id"] = doctor_info.DoctorNumber
  30601. var res2 ResultFour
  30602. //var result res.
  30603. //总页数,向上取整,注意除之前要先转换类型为float64
  30604. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  30605. for curpage = 1; curpage <= pagecount; curpage++ {
  30606. if curpage == 1 {
  30607. start = 1
  30608. } else {
  30609. start = (curpage-1)*pagesize + 1
  30610. }
  30611. stop = curpage * pagesize
  30612. if stop > len(prescriptions) {
  30613. stop = len(prescriptions)
  30614. }
  30615. //var requestLog string
  30616. data["pre"] = prescriptions[start-1 : stop]
  30617. fmt.Println(data["pre"])
  30618. bytesData, _ := json.Marshal(data)
  30619. var req *http.Request
  30620. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  30621. resp, _ := client.Do(req)
  30622. defer resp.Body.Close()
  30623. body, ioErr := ioutil.ReadAll(resp.Body)
  30624. if ioErr != nil {
  30625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30627. return
  30628. }
  30629. var respJSON map[string]interface{}
  30630. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30633. return
  30634. }
  30635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30636. userJSONBytes, _ := json.Marshal(respJSON)
  30637. fmt.Println("log")
  30638. fmt.Println(string(userJSONBytes))
  30639. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30640. utils.ErrorLog("解析失败:%v", err)
  30641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30642. return
  30643. }
  30644. res.InfRefmsgid = resFour10265.InfRefmsgid
  30645. res.Output = resFour10265.Output
  30646. res.ErrMsg = resFour10265.ErrMsg
  30647. res.Cainfo = resFour10265.Cainfo
  30648. res.WarnMsg = resFour10265.WarnMsg
  30649. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30650. res.Infcode = infocode
  30651. if infocode == 0 {
  30652. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  30653. } else {
  30654. isSuccess = false
  30655. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  30656. res.Infcode = -1
  30657. res.ErrMsg = resFour10265.ErrMsg
  30658. errlog := &models.HisOrderError{
  30659. UserOrgId: adminUser.CurrentOrgId,
  30660. Ctime: time.Now().Unix(),
  30661. Mtime: time.Now().Unix(),
  30662. Number: chrg_bchno,
  30663. ErrMsg: "",
  30664. Status: 1,
  30665. PatientId: id,
  30666. RecordTime: recordDateTime,
  30667. Stage: 4,
  30668. }
  30669. service.CreateErrMsgLog(errlog)
  30670. }
  30671. }
  30672. if isSuccess {
  30673. res.Infcode = 0
  30674. res.Output.Result = res2.Output.Result
  30675. } else {
  30676. order := &models.HisOrder{
  30677. UserOrgId: adminUser.CurrentOrgId,
  30678. HisPatientId: his.ID,
  30679. PatientId: his.PatientId,
  30680. SettleAccountsDate: recordDateTime,
  30681. Ctime: time.Now().Unix(),
  30682. Mtime: time.Now().Unix(),
  30683. MdtrtId: his.Number,
  30684. PsnNo: his.PsnNo,
  30685. MedType: strconv.FormatInt(reg_type, 10),
  30686. Status: 1,
  30687. Number: chrg_bchno,
  30688. Infcode: res.Infcode,
  30689. WarnMsg: res.WarnMsg,
  30690. Cainfo: res.Cainfo,
  30691. ErrMsg: res.ErrMsg,
  30692. RespondTime: res.RefmsgTime,
  30693. InfRefmsgid: res.InfRefmsgid,
  30694. OrderStatus: 1,
  30695. IsMedicineInsurance: 1,
  30696. SettleType: settle_accounts_type,
  30697. SettleStartTime: start_time,
  30698. SettleEndTime: end_time,
  30699. Creator: roles.AdminUserId,
  30700. Modify: roles.AdminUserId,
  30701. PType: 2,
  30702. Diagnosis: diagnosis_id,
  30703. }
  30704. err = service.CreateOrder(order)
  30705. if err != nil {
  30706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30707. return
  30708. }
  30709. c.ServeSuccessJSON(map[string]interface{}{
  30710. "failed_code": -10,
  30711. "msg": res2.ErrMsg,
  30712. })
  30713. return
  30714. }
  30715. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30716. 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)
  30717. var dat map[string]interface{}
  30718. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30719. fmt.Println(dat)
  30720. } else {
  30721. fmt.Println(err)
  30722. }
  30723. saveLog(result, request_log, "2204", "上传费用明细")
  30724. userJSONBytes, _ := json.Marshal(dat)
  30725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30726. utils.ErrorLog("解析失败:%v", err)
  30727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30728. return
  30729. }
  30730. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30731. 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, "", "")
  30732. var dat map[string]interface{}
  30733. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30734. fmt.Println(dat)
  30735. } else {
  30736. fmt.Println(err)
  30737. }
  30738. saveLog(result, request_log, "2204", "上传费用明细")
  30739. userJSONBytes, _ := json.Marshal(dat)
  30740. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30741. utils.ErrorLog("解析失败:%v", err)
  30742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30743. return
  30744. }
  30745. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30746. 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, "", "")
  30747. var dat map[string]interface{}
  30748. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30749. fmt.Println(dat)
  30750. } else {
  30751. fmt.Println(err)
  30752. }
  30753. saveLog(result, request_log, "2204", "上传费用明细")
  30754. userJSONBytes, _ := json.Marshal(dat)
  30755. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30756. utils.ErrorLog("解析失败:%v", err)
  30757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30758. return
  30759. }
  30760. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30761. 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, "", "")
  30762. var dat map[string]interface{}
  30763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30764. fmt.Println(dat)
  30765. } else {
  30766. fmt.Println(err)
  30767. }
  30768. saveLog(result, request_log, "2204", "上传费用明细")
  30769. userJSONBytes, _ := json.Marshal(dat)
  30770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30771. utils.ErrorLog("解析失败:%v", err)
  30772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30773. return
  30774. }
  30775. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30776. bytesData, _ := json.Marshal(data)
  30777. var req *http.Request
  30778. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30779. resp, _ := client.Do(req)
  30780. defer resp.Body.Close()
  30781. body, ioErr := ioutil.ReadAll(resp.Body)
  30782. if ioErr != nil {
  30783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30785. return
  30786. }
  30787. var respJSON map[string]interface{}
  30788. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30791. return
  30792. }
  30793. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30794. if status == "0" {
  30795. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30796. c.ServeSuccessJSON(map[string]interface{}{
  30797. "failed_code": -10,
  30798. "msg": err_msg,
  30799. })
  30800. return
  30801. }
  30802. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30803. userJSONBytes, _ := json.Marshal(respJSON)
  30804. fmt.Println("log")
  30805. fmt.Println(string(userJSONBytes))
  30806. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30807. utils.ErrorLog("解析失败:%v", err)
  30808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30809. return
  30810. }
  30811. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30812. bytesData, _ := json.Marshal(data)
  30813. var req *http.Request
  30814. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30815. resp, _ := client.Do(req)
  30816. defer resp.Body.Close()
  30817. body, ioErr := ioutil.ReadAll(resp.Body)
  30818. if ioErr != nil {
  30819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30821. return
  30822. }
  30823. var respJSON map[string]interface{}
  30824. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30827. return
  30828. }
  30829. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30830. if status == "0" {
  30831. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30832. c.ServeSuccessJSON(map[string]interface{}{
  30833. "failed_code": -10,
  30834. "msg": err_msg,
  30835. })
  30836. return
  30837. }
  30838. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30839. userJSONBytes, _ := json.Marshal(respJSON)
  30840. fmt.Println("log")
  30841. fmt.Println(string(userJSONBytes))
  30842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30843. utils.ErrorLog("解析失败:%v", err)
  30844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30845. return
  30846. }
  30847. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30848. 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, "", "")
  30849. var dat map[string]interface{}
  30850. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30851. fmt.Println(dat)
  30852. } else {
  30853. fmt.Println(err)
  30854. }
  30855. saveLog(result, request_log, "2204", "上传费用明细")
  30856. userJSONBytes, _ := json.Marshal(dat)
  30857. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30858. utils.ErrorLog("解析失败:%v", err)
  30859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30860. return
  30861. }
  30862. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30863. bytesData, _ := json.Marshal(data)
  30864. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  30865. resp, _ := client.Do(req)
  30866. defer resp.Body.Close()
  30867. body, ioErr := ioutil.ReadAll(resp.Body)
  30868. if ioErr != nil {
  30869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30871. return
  30872. }
  30873. var respJSON map[string]interface{}
  30874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30877. return
  30878. }
  30879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30880. userJSONBytes, _ := json.Marshal(respJSON)
  30881. fmt.Println("log")
  30882. fmt.Println(string(userJSONBytes))
  30883. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30884. utils.ErrorLog("解析失败:%v", err)
  30885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30886. return
  30887. }
  30888. } else {
  30889. if miConfig.MdtrtareaAdmvs == "441202" {
  30890. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30891. if result3101.Infcode == 0 {
  30892. if len(result3101.Output.Result) > 0 {
  30893. var errMsgs []string
  30894. for _, item := range result3101.Output.Result {
  30895. errMsgs = append(errMsgs, item.VolaCont)
  30896. }
  30897. c.ServeSuccessJSON(map[string]interface{}{
  30898. "failed_code": -10,
  30899. "msg": errMsgs,
  30900. })
  30901. return
  30902. } else {
  30903. 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)
  30904. var dat map[string]interface{}
  30905. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30906. fmt.Println(dat)
  30907. } else {
  30908. fmt.Println(err)
  30909. }
  30910. saveLog(result, request_log, "2204", "上传费用明细")
  30911. userJSONBytes, _ := json.Marshal(dat)
  30912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30913. utils.ErrorLog("解析失败:%v", err)
  30914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30915. return
  30916. }
  30917. }
  30918. } else {
  30919. c.ServeSuccessJSON(map[string]interface{}{
  30920. "failed_code": -10,
  30921. "msg": result3101.ErrMsg,
  30922. })
  30923. return
  30924. }
  30925. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30926. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30927. if result3101.Infcode == 0 {
  30928. if len(result3101.Output.Result) > 0 {
  30929. var errMsgs []string
  30930. for _, item := range result3101.Output.Result {
  30931. errMsgs = append(errMsgs, item.VolaCont)
  30932. }
  30933. c.ServeSuccessJSON(map[string]interface{}{
  30934. "failed_code": -10,
  30935. "msg": errMsgs,
  30936. })
  30937. return
  30938. } else {
  30939. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode, admin_user_id)
  30940. var dat map[string]interface{}
  30941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30942. fmt.Println(dat)
  30943. } else {
  30944. fmt.Println(err)
  30945. }
  30946. saveLog(result, request_log, "2204", "上传费用明细")
  30947. userJSONBytes, _ := json.Marshal(dat)
  30948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30949. utils.ErrorLog("解析失败:%v", err)
  30950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30951. return
  30952. }
  30953. }
  30954. } else {
  30955. c.ServeSuccessJSON(map[string]interface{}{
  30956. "failed_code": -10,
  30957. "msg": result3101.ErrMsg,
  30958. })
  30959. return
  30960. }
  30961. } else {
  30962. if miConfig.Code == "H15049901371" {
  30963. 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)
  30964. var dat map[string]interface{}
  30965. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30966. fmt.Println(dat)
  30967. } else {
  30968. fmt.Println(err)
  30969. }
  30970. saveLog(result, request_log, "2204", "上传费用明细")
  30971. userJSONBytes, _ := json.Marshal(dat)
  30972. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30973. utils.ErrorLog("解析失败:%v", err)
  30974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30975. return
  30976. }
  30977. res.InfRefmsgid = resFour10265.InfRefmsgid
  30978. res.Output = resFour10265.Output
  30979. res.ErrMsg = resFour10265.ErrMsg
  30980. res.Cainfo = resFour10265.Cainfo
  30981. res.WarnMsg = resFour10265.WarnMsg
  30982. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30983. res.Infcode = infocode
  30984. } else {
  30985. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  30986. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30987. if result3101.Infcode == 0 {
  30988. if len(result3101.Output.Result) > 0 {
  30989. c.ServeSuccessJSON(map[string]interface{}{
  30990. "failed_code": -10,
  30991. "failed_type": 100,
  30992. "warm_type": 1,
  30993. "msg": result3101,
  30994. })
  30995. return
  30996. } else {
  30997. 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)
  30998. var dat map[string]interface{}
  30999. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31000. fmt.Println(dat)
  31001. } else {
  31002. fmt.Println(err)
  31003. }
  31004. saveLog(result, request_log, "2204", "上传费用明细")
  31005. userJSONBytes, _ := json.Marshal(dat)
  31006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31007. utils.ErrorLog("解析失败:%v", err)
  31008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31009. return
  31010. }
  31011. }
  31012. } else {
  31013. c.ServeSuccessJSON(map[string]interface{}{
  31014. "failed_code": -10,
  31015. "msg": result3101.ErrMsg,
  31016. })
  31017. return
  31018. }
  31019. } else {
  31020. 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)
  31021. var dat map[string]interface{}
  31022. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31023. fmt.Println(dat)
  31024. } else {
  31025. fmt.Println(err)
  31026. }
  31027. saveLog(result, request_log, "2204", "上传费用明细")
  31028. userJSONBytes, _ := json.Marshal(dat)
  31029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31030. utils.ErrorLog("解析失败:%v", err)
  31031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31032. return
  31033. }
  31034. }
  31035. }
  31036. }
  31037. }
  31038. var total_two float64
  31039. if res.Infcode == -1 {
  31040. errlog := &models.HisOrderError{
  31041. UserOrgId: adminUser.CurrentOrgId,
  31042. Ctime: time.Now().Unix(),
  31043. Mtime: time.Now().Unix(),
  31044. Number: chrg_bchno,
  31045. ErrMsg: res.ErrMsg,
  31046. Status: 1,
  31047. PatientId: id,
  31048. RecordTime: recordDateTime,
  31049. Stage: 4,
  31050. }
  31051. service.CreateErrMsgLog(errlog)
  31052. c.ServeSuccessJSON(map[string]interface{}{
  31053. "failed_code": -10,
  31054. "msg": res.ErrMsg,
  31055. })
  31056. return
  31057. }
  31058. if res.Infcode == 0 {
  31059. order := &models.HisOrder{
  31060. UserOrgId: adminUser.CurrentOrgId,
  31061. HisPatientId: his.ID,
  31062. PatientId: his.PatientId,
  31063. SettleAccountsDate: recordDateTime,
  31064. Ctime: time.Now().Unix(),
  31065. Mtime: time.Now().Unix(),
  31066. MdtrtId: his.Number,
  31067. PsnNo: his.PsnNo,
  31068. MedType: strconv.FormatInt(reg_type, 10),
  31069. Status: 1,
  31070. Number: chrg_bchno,
  31071. Infcode: res.Infcode,
  31072. WarnMsg: res.WarnMsg,
  31073. Cainfo: res.Cainfo,
  31074. ErrMsg: res.ErrMsg,
  31075. RespondTime: res.RefmsgTime,
  31076. InfRefmsgid: res.InfRefmsgid,
  31077. OrderStatus: 1,
  31078. IsMedicineInsurance: 1,
  31079. SettleType: settle_accounts_type,
  31080. SettleStartTime: start_time,
  31081. SettleEndTime: end_time,
  31082. Creator: roles.AdminUserId,
  31083. Modify: roles.AdminUserId,
  31084. PType: 2,
  31085. Diagnosis: diagnosis_id,
  31086. }
  31087. err = service.CreateOrder(order)
  31088. if err != nil {
  31089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31090. return
  31091. }
  31092. for _, item := range res.Output.Result {
  31093. temp := strings.Split(item.FeedetlSn, "-")
  31094. var advice_id int64 = 0
  31095. var project_id int64 = 0
  31096. var types int64 = 0
  31097. id, _ := strconv.ParseInt(temp[2], 10, 64)
  31098. types, _ = strconv.ParseInt(temp[1], 10, 64)
  31099. if temp[1] == "1" {
  31100. advice_id = id
  31101. project_id = 0
  31102. } else if temp[1] == "2" {
  31103. advice_id = 0
  31104. project_id = id
  31105. }
  31106. total_two = total_two + item.DetItemFeeSumamt
  31107. info := &models.HisOrderInfo{
  31108. OrderNumber: order.Number,
  31109. FeedetlSn: item.FeedetlSn,
  31110. UploadDate: time.Now().Unix(),
  31111. AdviceId: advice_id,
  31112. DetItemFeeSumamt: item.DetItemFeeSumamt,
  31113. Cnt: item.Cnt,
  31114. Pric: float64(item.Pric),
  31115. PatientId: his.PatientId,
  31116. PricUplmtAmt: item.PricUplmtAmt,
  31117. SelfpayProp: item.SelfpayProp,
  31118. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  31119. OverlmtAmt: item.OverlmtAmt,
  31120. PreselfpayAmt: item.PreselfpayAmt,
  31121. BasMednFlag: item.BasMednFlag,
  31122. MedChrgitmType: item.MedChrgitmType,
  31123. HiNegoDrugFlag: item.HiNegoDrugFlag,
  31124. Status: 1,
  31125. Memo: item.Memo,
  31126. Mtime: time.Now().Unix(),
  31127. InscpScpAmt: item.InscpScpAmt,
  31128. DrtReimFlag: item.DrtReimFlag,
  31129. Ctime: time.Now().Unix(),
  31130. ListSpItemFlag: item.ListSpItemFlag,
  31131. ChldMedcFlag: item.ChldMedcFlag,
  31132. LmtUsedFlag: item.LmtUsedFlag,
  31133. ChrgitmLv: item.ChrgitmLv,
  31134. UserOrgId: adminUser.CurrentOrgId,
  31135. HisPatientId: his.ID,
  31136. OrderId: order.ID,
  31137. ProjectId: project_id,
  31138. Type: types,
  31139. }
  31140. service.CreateOrderInfo(info)
  31141. }
  31142. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  31143. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  31144. var total float64
  31145. for _, item := range prescriptions {
  31146. if item.Type == 1 { //药品
  31147. for _, subItem := range item.HisDoctorAdviceInfo {
  31148. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  31149. total_one := price * subItem.PrescribingNumber
  31150. fmt.Println("subItem")
  31151. fmt.Println(subItem.Price)
  31152. fmt.Println("price")
  31153. fmt.Println(price)
  31154. fmt.Println("total_one")
  31155. fmt.Println(total_one)
  31156. total = total + total_one
  31157. fmt.Println(total)
  31158. }
  31159. }
  31160. if item.Type == 2 { //项目
  31161. for _, subItem := range item.HisPrescriptionProject {
  31162. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  31163. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  31164. total_one := price * cnt
  31165. total = total + total_one
  31166. }
  31167. }
  31168. }
  31169. allTotal := fmt.Sprintf("%.2f", total)
  31170. if res.Infcode == 0 {
  31171. var rf []*ResultFive
  31172. json.Unmarshal([]byte(his.Iinfo), &rf)
  31173. chrg_bchno := chrg_bchno
  31174. cert_no := his.Certno
  31175. var insutypes []string
  31176. var insutype string
  31177. var is390 int = 0
  31178. var is310 int = 0
  31179. for _, item := range rf {
  31180. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  31181. insutypes = append(insutypes, item.Insutype)
  31182. }
  31183. }
  31184. if len(insutypes) == 1 {
  31185. insutype = insutypes[0]
  31186. } else {
  31187. for _, i := range insutypes {
  31188. if i == "390" {
  31189. is390 = 1
  31190. }
  31191. if i == "310" {
  31192. is310 = 1
  31193. }
  31194. }
  31195. }
  31196. if is390 == 1 {
  31197. insutype = "390"
  31198. }
  31199. if is310 == 1 {
  31200. insutype = "310"
  31201. }
  31202. if len(insutypes) == 0 {
  31203. insutype = "390"
  31204. }
  31205. if len(insutypes) == 2 {
  31206. insutype = strconv.FormatInt(his.SocialType, 10)
  31207. }
  31208. //insutype = "390"
  31209. if his.IdCardType == 1 {
  31210. cert_no = his.MedicalInsuranceNumber
  31211. } else {
  31212. cert_no = his.Certno
  31213. }
  31214. var res ResultSeven
  31215. var ahres ResultSevenAH
  31216. var resSeven10265 ResultSeven10265
  31217. var resSeven10265Two ResultSeven10265Two
  31218. var resSeven10633Three ResultSeven10633Three
  31219. var gzresSeven10265Two GZResultSeven10265Two
  31220. if miConfig.MdtrtareaAdmvs == "421300" {
  31221. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  31222. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31223. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31224. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31225. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31226. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31227. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31228. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31229. resp, requestErr := http.Get(api)
  31230. if requestErr != nil {
  31231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31232. return
  31233. }
  31234. body, ioErr := ioutil.ReadAll(resp.Body)
  31235. if ioErr != nil {
  31236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31238. return
  31239. }
  31240. var respJSON map[string]interface{}
  31241. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31244. return
  31245. }
  31246. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31247. result, _ := json.Marshal(respJSON)
  31248. fmt.Println("log")
  31249. fmt.Println(string(result))
  31250. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31251. utils.ErrorLog("解析失败:%v", err)
  31252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31253. return
  31254. }
  31255. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31256. if reg_type == 11 && his.Insutype == "390" {
  31257. reg_type = 110104
  31258. }
  31259. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31260. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31261. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31262. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31263. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31264. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31265. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31266. resp, requestErr := http.Get(api)
  31267. if requestErr != nil {
  31268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31269. return
  31270. }
  31271. body, ioErr := ioutil.ReadAll(resp.Body)
  31272. if ioErr != nil {
  31273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31275. return
  31276. }
  31277. var respJSON map[string]interface{}
  31278. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31281. return
  31282. }
  31283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31284. result, _ := json.Marshal(respJSON)
  31285. fmt.Println("log")
  31286. fmt.Println(string(result))
  31287. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31288. utils.ErrorLog("解析失败:%v", err)
  31289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31290. return
  31291. }
  31292. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31293. if reg_type == 11 && his.Insutype == "390" {
  31294. reg_type = 110104
  31295. }
  31296. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31297. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31298. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31299. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31300. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31301. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31302. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31303. resp, requestErr := http.Get(api)
  31304. if requestErr != nil {
  31305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31306. return
  31307. }
  31308. body, ioErr := ioutil.ReadAll(resp.Body)
  31309. if ioErr != nil {
  31310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31312. return
  31313. }
  31314. var respJSON map[string]interface{}
  31315. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31318. return
  31319. }
  31320. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31321. result, _ := json.Marshal(respJSON)
  31322. fmt.Println("log")
  31323. fmt.Println(string(result))
  31324. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31325. utils.ErrorLog("解析失败:%v", err)
  31326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31327. return
  31328. }
  31329. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31330. if reg_type == 11 && his.Insutype == "390" {
  31331. reg_type = 110104
  31332. }
  31333. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31334. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31335. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31336. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31337. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31338. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31339. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31340. resp, requestErr := http.Get(api)
  31341. if requestErr != nil {
  31342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31343. return
  31344. }
  31345. body, ioErr := ioutil.ReadAll(resp.Body)
  31346. if ioErr != nil {
  31347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31349. return
  31350. }
  31351. var respJSON map[string]interface{}
  31352. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31355. return
  31356. }
  31357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31358. result, _ := json.Marshal(respJSON)
  31359. fmt.Println("log")
  31360. fmt.Println(string(result))
  31361. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31362. utils.ErrorLog("解析失败:%v", err)
  31363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31364. return
  31365. }
  31366. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  31367. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31368. var result3101 Result3101
  31369. //utils.ErrorLog("解析失败:%v", result3101)
  31370. result3101.Infcode = "0"
  31371. if result3101.Infcode == "0" {
  31372. if len(result3101.Output.Result) > 0 {
  31373. var errMsgs []string
  31374. for _, item := range result3101.Output.Result {
  31375. errMsgs = append(errMsgs, item.VolaCont)
  31376. }
  31377. c.ServeSuccessJSON(map[string]interface{}{
  31378. "failed_code": -10,
  31379. "msg": errMsgs,
  31380. })
  31381. return
  31382. } else {
  31383. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31384. if his.IdCardType != 4 {
  31385. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31386. bas := strings.Split(psn_info.CardInfo, "|")
  31387. if his.IdCardType == 1 {
  31388. cert_no = bas[2]
  31389. } else {
  31390. cert_no = bas[1]
  31391. }
  31392. } else {
  31393. cert_no = his.Certno
  31394. }
  31395. //江苏地区国家医保医疗类别
  31396. //职工透析:医疗类别选特殊情况门诊9933
  31397. //居民血透门慢: 医疗类别选门诊慢病1402
  31398. //var med_type string
  31399. //if his.Insutype == "310" {
  31400. // if reg_type == 14 {
  31401. // med_type = "9933"
  31402. // } else if reg_type == 11 {
  31403. // med_type = "11"
  31404. //
  31405. // }
  31406. //} else if his.Insutype == "390" {
  31407. // if reg_type == 14 {
  31408. // med_type = "1402"
  31409. // } else if reg_type == 11 {
  31410. // med_type = "11"
  31411. // }
  31412. //}
  31413. var api string
  31414. if miConfig.MdtrtareaAdmvs == "320830" {
  31415. api = miConfig.AppSecret + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31416. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31417. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31418. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31419. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31420. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31421. "&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
  31422. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31423. } else if miConfig.MdtrtareaAdmvs == "320921" {
  31424. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31425. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31426. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31427. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31428. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31429. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31430. "&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
  31431. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31432. } else {
  31433. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31434. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31435. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31436. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31437. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31438. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31439. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31440. "&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
  31441. }
  31442. resp, requestErr := http.Get(api)
  31443. if requestErr != nil {
  31444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31445. return
  31446. }
  31447. body, ioErr := ioutil.ReadAll(resp.Body)
  31448. if ioErr != nil {
  31449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31451. return
  31452. }
  31453. var respJSON map[string]interface{}
  31454. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31457. return
  31458. }
  31459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31460. result, _ := json.Marshal(respJSON)
  31461. fmt.Println("log")
  31462. fmt.Println(string(result))
  31463. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  31464. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31465. utils.ErrorLog("解析失败:%v", err)
  31466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31467. return
  31468. }
  31469. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31470. res.Output = resSeven10265.Output
  31471. res.ErrMsg = resSeven10265.ErrMsg
  31472. res.Cainfo = resSeven10265.Cainfo
  31473. res.WarnMsg = resSeven10265.WarnMsg
  31474. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31475. res.Infcode = infocode
  31476. } else {
  31477. if miConfig.MdtrtareaAdmvs == "320830" {
  31478. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3208") {
  31479. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31480. utils.ErrorLog("解析失败:%v", err)
  31481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31482. return
  31483. }
  31484. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31485. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31486. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31487. res.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31488. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31489. res.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31490. res.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31491. res.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31492. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31493. res.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31494. res.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31495. res.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31496. res.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31497. res.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31498. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31499. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31500. res.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31501. res.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31502. res.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31503. res.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31504. res.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31505. HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31506. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31507. res.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31508. res.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31509. res.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31510. res.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31511. res.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31512. res.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31513. res.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31514. res.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31515. res.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31516. res.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31517. res.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31518. res.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31519. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31520. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31521. res.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31522. res.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31523. res.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31524. res.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31525. res.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31526. res.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31527. res.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31528. res.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31529. res.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31530. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31531. res.ErrMsg = resSeven10633Three.ErrMsg
  31532. res.Cainfo = resSeven10633Three.Cainfo
  31533. res.WarnMsg = resSeven10633Three.WarnMsg
  31534. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31535. res.Infcode = infocode
  31536. } else {
  31537. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31538. utils.ErrorLog("解析失败:%v", err)
  31539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31540. return
  31541. }
  31542. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31543. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31544. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31545. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31546. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31547. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31548. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31549. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31550. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31551. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31552. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31553. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31554. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31555. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31556. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31557. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31558. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31559. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31560. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31561. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31562. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31563. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31564. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31565. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31566. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31567. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31568. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31569. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31570. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31571. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31572. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31573. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31574. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31575. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31576. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31577. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31578. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31579. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31580. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31581. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31582. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31583. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31584. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31585. res.ErrMsg = resSeven10265Two.ErrMsg
  31586. res.Cainfo = resSeven10265Two.Cainfo
  31587. res.WarnMsg = resSeven10265Two.WarnMsg
  31588. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31589. res.Infcode = infocode
  31590. }
  31591. } else {
  31592. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3209") {
  31593. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31594. utils.ErrorLog("解析失败:%v", err)
  31595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31596. return
  31597. }
  31598. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31599. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31600. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31601. res.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31602. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31603. res.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31604. res.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31605. res.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31606. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31607. res.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31608. res.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31609. res.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31610. res.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31611. res.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31612. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31613. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31614. res.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31615. res.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31616. res.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31617. res.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31618. res.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31619. HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31620. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31621. res.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31622. res.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31623. res.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31624. res.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31625. res.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31626. res.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31627. res.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31628. res.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31629. res.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31630. res.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31631. res.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31632. res.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31633. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31634. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31635. res.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31636. res.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31637. res.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31638. res.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31639. res.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31640. res.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31641. res.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31642. res.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31643. res.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31644. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31645. res.ErrMsg = resSeven10633Three.ErrMsg
  31646. res.Cainfo = resSeven10633Three.Cainfo
  31647. res.WarnMsg = resSeven10633Three.WarnMsg
  31648. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31649. res.Infcode = infocode
  31650. } else {
  31651. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31652. utils.ErrorLog("解析失败:%v", err)
  31653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31654. return
  31655. }
  31656. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31657. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31658. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31659. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31660. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31661. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31662. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31663. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31664. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31665. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31666. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31667. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31668. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31669. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31670. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31671. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31672. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31673. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31674. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31675. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31676. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31677. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31678. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31679. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31680. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31681. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31682. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31683. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31684. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31685. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31686. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31687. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31688. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31689. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31690. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31691. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31692. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31693. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31694. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31695. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31696. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31697. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31698. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31699. res.ErrMsg = resSeven10265Two.ErrMsg
  31700. res.Cainfo = resSeven10265Two.Cainfo
  31701. res.WarnMsg = resSeven10265Two.WarnMsg
  31702. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31703. res.Infcode = infocode
  31704. }
  31705. }
  31706. }
  31707. }
  31708. }
  31709. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31710. psn_info, _ := service.GetPsnByPatientId(id)
  31711. var verify_number string
  31712. if psn_info.IdCardType == 4 {
  31713. verify_number = psn_info.VerifyNumber
  31714. } else if psn_info.IdCardType == 1 {
  31715. bas := strings.Split(psn_info.CardInfo, "|")
  31716. cardNumber := bas[2]
  31717. verify_number = cardNumber
  31718. } else {
  31719. psn_info.IdCardType = 2
  31720. verify_number = psn_info.Certno
  31721. }
  31722. var api string
  31723. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31724. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  31725. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31726. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31727. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  31728. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31729. "&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
  31730. resp, requestErr := http.Get(api)
  31731. if requestErr != nil {
  31732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31733. return
  31734. }
  31735. body, ioErr := ioutil.ReadAll(resp.Body)
  31736. if ioErr != nil {
  31737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31739. return
  31740. }
  31741. var respJSON map[string]interface{}
  31742. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31745. return
  31746. }
  31747. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31748. result, _ := json.Marshal(respJSON)
  31749. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31750. utils.ErrorLog("解析失败:%v", err)
  31751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31752. return
  31753. }
  31754. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31755. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  31756. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  31757. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31758. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  31759. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  31760. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  31761. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  31762. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  31763. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  31764. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  31765. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  31766. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  31767. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31768. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  31769. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  31770. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  31771. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  31772. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  31773. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  31774. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31775. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  31776. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  31777. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  31778. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  31779. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  31780. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  31781. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  31782. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  31783. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  31784. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  31785. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  31786. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  31787. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  31788. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31789. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  31790. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  31791. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  31792. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  31793. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  31794. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  31795. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  31796. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  31797. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  31798. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  31799. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  31800. res.ErrMsg = resSeven10265.ErrMsg
  31801. res.Cainfo = resSeven10265.Cainfo
  31802. res.WarnMsg = resSeven10265.WarnMsg
  31803. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31804. res.Infcode = infocode
  31805. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31806. acct_used_flag := "1"
  31807. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  31808. var result string
  31809. var request_log string
  31810. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  31811. 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)
  31812. } else {
  31813. 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)
  31814. }
  31815. var dat map[string]interface{}
  31816. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31817. fmt.Println(dat)
  31818. } else {
  31819. fmt.Println(err)
  31820. }
  31821. saveLog(result, request_log, "2206", "预结算")
  31822. userJSONBytes, _ := json.Marshal(dat)
  31823. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31824. utils.ErrorLog("解析失败:%v", err)
  31825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31826. return
  31827. }
  31828. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31829. var result string
  31830. var request_log string
  31831. if his.IdCardType == 2 {
  31832. insutype = strconv.FormatInt(his.SocialType, 10)
  31833. 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, "")
  31834. } else if his.IdCardType == 1 {
  31835. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31836. bas := strings.Split(psn_info.CardInfo, "|")
  31837. basNumber := bas[2]
  31838. card_sn := bas[3]
  31839. var rf []*ResultFive
  31840. json.Unmarshal([]byte(his.Iinfo), &rf)
  31841. var psn_type string
  31842. for _, item := range rf {
  31843. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31844. psn_type = item.PsnType
  31845. }
  31846. }
  31847. insutype = strconv.FormatInt(his.SocialType, 10)
  31848. 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)
  31849. } else {
  31850. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31851. //bas := strings.Split(psn_info.CardInfo, "|")
  31852. //basNumber := bas[2]
  31853. //card_sn := bas[3]
  31854. var rf []*ResultFive
  31855. json.Unmarshal([]byte(his.Iinfo), &rf)
  31856. var psn_type string
  31857. for _, item := range rf {
  31858. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31859. psn_type = item.PsnType
  31860. }
  31861. }
  31862. insutype = strconv.FormatInt(his.SocialType, 10)
  31863. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31864. 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)
  31865. }
  31866. var dat map[string]interface{}
  31867. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31868. fmt.Println(dat)
  31869. } else {
  31870. fmt.Println(err)
  31871. }
  31872. saveLog(result, request_log, "2206", "预结算")
  31873. userJSONBytes, _ := json.Marshal(dat)
  31874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31875. utils.ErrorLog("解析失败:%v", err)
  31876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31877. return
  31878. }
  31879. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31880. var result string
  31881. var request_log string
  31882. if his.IdCardType == 2 {
  31883. insutype = strconv.FormatInt(his.SocialType, 10)
  31884. 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, "")
  31885. } else if his.IdCardType == 1 {
  31886. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31887. bas := strings.Split(psn_info.CardInfo, "|")
  31888. basNumber := bas[0]
  31889. card_sn := ""
  31890. var rf []*ResultFive
  31891. json.Unmarshal([]byte(his.Iinfo), &rf)
  31892. var psn_type string
  31893. for _, item := range rf {
  31894. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31895. psn_type = item.PsnType
  31896. }
  31897. }
  31898. insutype = strconv.FormatInt(his.SocialType, 10)
  31899. 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)
  31900. } else {
  31901. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31902. //bas := strings.Split(psn_info.CardInfo, "|")
  31903. //basNumber := bas[2]
  31904. //card_sn := bas[3]
  31905. var rf []*ResultFive
  31906. json.Unmarshal([]byte(his.Iinfo), &rf)
  31907. var psn_type string
  31908. for _, item := range rf {
  31909. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31910. psn_type = item.PsnType
  31911. }
  31912. }
  31913. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31914. 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)
  31915. }
  31916. var dat map[string]interface{}
  31917. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31918. fmt.Println(dat)
  31919. } else {
  31920. fmt.Println(err)
  31921. }
  31922. saveLog(result, request_log, "2206", "预结算")
  31923. userJSONBytes, _ := json.Marshal(dat)
  31924. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31925. utils.ErrorLog("解析失败:%v", err)
  31926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31927. return
  31928. }
  31929. } else if miConfig.MdtrtareaAdmvs == "360100" {
  31930. var result string
  31931. var request_log string
  31932. if his.IdCardType == 2 {
  31933. insutype = strconv.FormatInt(his.SocialType, 10)
  31934. 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, "")
  31935. } else if his.IdCardType == 1 {
  31936. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31937. bas := strings.Split(psn_info.CardInfo, "|")
  31938. basNumber := bas[0]
  31939. card_sn := ""
  31940. var rf []*ResultFive
  31941. json.Unmarshal([]byte(his.Iinfo), &rf)
  31942. var psn_type string
  31943. for _, item := range rf {
  31944. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31945. psn_type = item.PsnType
  31946. }
  31947. }
  31948. insutype = strconv.FormatInt(his.SocialType, 10)
  31949. 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)
  31950. } else {
  31951. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31952. //bas := strings.Split(psn_info.CardInfo, "|")
  31953. //basNumber := bas[2]
  31954. //card_sn := bas[3]
  31955. var rf []*ResultFive
  31956. json.Unmarshal([]byte(his.Iinfo), &rf)
  31957. var psn_type string
  31958. for _, item := range rf {
  31959. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31960. psn_type = item.PsnType
  31961. }
  31962. }
  31963. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31964. 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)
  31965. }
  31966. var dat map[string]interface{}
  31967. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31968. fmt.Println(dat)
  31969. } else {
  31970. fmt.Println(err)
  31971. }
  31972. saveLog(result, request_log, "2206", "预结算")
  31973. userJSONBytes, _ := json.Marshal(dat)
  31974. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31975. utils.ErrorLog("解析失败:%v", err)
  31976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31977. return
  31978. }
  31979. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31980. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31981. if his.IdCardType == 4 {
  31982. psn_info.VerifyNumber = psn_info.VerifyNumber
  31983. cert_no = psn_info.VerifyNumber
  31984. } else if his.IdCardType == 2 {
  31985. cert_no = psn_info.Certno
  31986. psn_info.VerifyNumber = psn_info.Certno
  31987. } else {
  31988. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31989. bas := strings.Split(psn_info.CardInfo, "|")
  31990. if his.IdCardType == 1 {
  31991. cert_no = bas[2]
  31992. } else {
  31993. cert_no = bas[1]
  31994. }
  31995. }
  31996. var api string
  31997. var med_type string
  31998. if his.Insutype == "390" {
  31999. if reg_type == 992102 {
  32000. med_type = "992102"
  32001. }
  32002. if reg_type == 140104 {
  32003. med_type = "140104"
  32004. }
  32005. if reg_type == 140201 {
  32006. med_type = "140201"
  32007. }
  32008. if reg_type == 14 {
  32009. med_type = "140104"
  32010. }
  32011. if reg_type == 1104 {
  32012. med_type = "1104"
  32013. }
  32014. } else if his.Insutype == "310" {
  32015. if reg_type == 1104 {
  32016. med_type = "1104"
  32017. }
  32018. if reg_type == 992102 {
  32019. med_type = "992102"
  32020. }
  32021. if reg_type == 140104 {
  32022. med_type = "140104"
  32023. }
  32024. if reg_type == 140201 {
  32025. med_type = "140201"
  32026. }
  32027. if reg_type == 14 {
  32028. med_type = "140104"
  32029. }
  32030. }
  32031. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32032. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32033. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32034. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32035. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32036. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32037. "&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
  32038. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32039. resp, requestErr := http.Get(api)
  32040. if requestErr != nil {
  32041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32042. return
  32043. }
  32044. body, ioErr := ioutil.ReadAll(resp.Body)
  32045. if ioErr != nil {
  32046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32048. return
  32049. }
  32050. var respJSON map[string]interface{}
  32051. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32054. return
  32055. }
  32056. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32057. if status == "0" {
  32058. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32059. c.ServeSuccessJSON(map[string]interface{}{
  32060. "failed_code": -10,
  32061. "msg": err_msg,
  32062. })
  32063. return
  32064. }
  32065. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32066. result, _ := json.Marshal(respJSON)
  32067. fmt.Println("log")
  32068. fmt.Println(string(result))
  32069. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32070. utils.ErrorLog("解析失败:%v", err)
  32071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32072. return
  32073. }
  32074. res.InfRefmsgid = ahres.InfRefmsgid
  32075. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32076. // 创建对应的Time类型
  32077. t := time.UnixMilli(timestamp)
  32078. // 格式化成指定的日期字符串
  32079. str := t.Format("2006-01-02 15:04:05")
  32080. res.Output.Setlinfo.SetlTime = str
  32081. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32082. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32083. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32084. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32085. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32086. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32087. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32088. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32089. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32090. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32091. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32092. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32093. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32094. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32095. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32096. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32097. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32098. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32099. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32100. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32101. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32102. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32103. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32104. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32105. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32106. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32107. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32108. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32109. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32110. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32111. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32112. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32113. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32114. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32115. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32116. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32117. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32118. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32119. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32120. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32121. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32122. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32123. //res.Output.Setldetail = ahres.Output.Setldetail
  32124. res.ErrMsg = ahres.ErrMsg
  32125. res.Cainfo = ahres.Cainfo
  32126. res.WarnMsg = ahres.WarnMsg
  32127. res.Infcode = ahres.Infcode
  32128. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32129. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32130. if his.IdCardType == 4 {
  32131. psn_info.VerifyNumber = psn_info.VerifyNumber
  32132. cert_no = psn_info.Certno
  32133. } else if his.IdCardType == 2 {
  32134. cert_no = psn_info.Certno
  32135. psn_info.VerifyNumber = psn_info.Certno
  32136. } else {
  32137. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32138. bas := strings.Split(psn_info.CardInfo, "|")
  32139. if his.IdCardType == 1 {
  32140. cert_no = bas[2]
  32141. } else {
  32142. cert_no = bas[1]
  32143. }
  32144. }
  32145. var api string
  32146. var med_type string
  32147. if his.Insutype == "390" {
  32148. if reg_type == 992102 {
  32149. med_type = "992102"
  32150. }
  32151. if reg_type == 140104 {
  32152. med_type = "140104"
  32153. }
  32154. if reg_type == 140201 {
  32155. med_type = "140201"
  32156. }
  32157. if reg_type == 14 {
  32158. med_type = "14"
  32159. }
  32160. } else if his.Insutype == "310" {
  32161. if reg_type == 992102 {
  32162. med_type = "992102"
  32163. }
  32164. if reg_type == 140104 {
  32165. med_type = "140104"
  32166. }
  32167. if reg_type == 140201 {
  32168. med_type = "140201"
  32169. }
  32170. if reg_type == 14 {
  32171. med_type = "14"
  32172. }
  32173. }
  32174. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32175. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32176. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32177. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32178. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32179. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32180. "&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
  32181. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32182. resp, requestErr := http.Get(api)
  32183. if requestErr != nil {
  32184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32185. return
  32186. }
  32187. body, ioErr := ioutil.ReadAll(resp.Body)
  32188. if ioErr != nil {
  32189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32191. return
  32192. }
  32193. var respJSON map[string]interface{}
  32194. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32197. return
  32198. }
  32199. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32200. if status == "0" {
  32201. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32202. c.ServeSuccessJSON(map[string]interface{}{
  32203. "failed_code": -10,
  32204. "msg": err_msg,
  32205. })
  32206. return
  32207. }
  32208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32209. result, _ := json.Marshal(respJSON)
  32210. fmt.Println("log")
  32211. fmt.Println(string(result))
  32212. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32213. utils.ErrorLog("解析失败:%v", err)
  32214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32215. return
  32216. }
  32217. res.InfRefmsgid = ahres.InfRefmsgid
  32218. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32219. // 创建对应的Time类型
  32220. t := time.UnixMilli(timestamp)
  32221. // 格式化成指定的日期字符串
  32222. str := t.Format("2006-01-02 15:04:05")
  32223. res.Output.Setlinfo.SetlTime = str
  32224. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32225. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32226. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32227. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32228. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32229. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32230. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32231. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32232. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32233. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32234. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32235. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32236. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32237. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32238. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32239. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32240. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32241. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32242. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32243. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32244. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32245. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32246. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32247. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32248. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32249. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32250. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32251. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32252. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32253. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32254. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32255. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32256. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32257. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32258. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32259. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32260. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32261. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32262. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32263. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32264. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32265. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32266. //res.Output.Setldetail = ahres.Output.Setldetail
  32267. res.ErrMsg = ahres.ErrMsg
  32268. res.Cainfo = ahres.Cainfo
  32269. res.WarnMsg = ahres.WarnMsg
  32270. res.Infcode = ahres.Infcode
  32271. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32272. var result string
  32273. var request_log string
  32274. if his.IdCardType == 2 {
  32275. 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")
  32276. } else if his.IdCardType == 1 {
  32277. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32278. bas := strings.Split(psn_info.CardInfo, "|")
  32279. basNumber := bas[2]
  32280. card_sn := bas[3]
  32281. 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")
  32282. } else {
  32283. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32284. 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")
  32285. }
  32286. var dat map[string]interface{}
  32287. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32288. fmt.Println(dat)
  32289. } else {
  32290. fmt.Println(err)
  32291. }
  32292. saveLog(result, request_log, "2206", "预结算")
  32293. userJSONBytes, _ := json.Marshal(dat)
  32294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32295. utils.ErrorLog("解析失败:%v", err)
  32296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32297. return
  32298. }
  32299. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32300. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32301. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32302. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32303. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32304. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32305. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32306. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  32307. resp, requestErr := http.Get(api)
  32308. if requestErr != nil {
  32309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32310. return
  32311. }
  32312. body, ioErr := ioutil.ReadAll(resp.Body)
  32313. if ioErr != nil {
  32314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32316. return
  32317. }
  32318. var respJSON map[string]interface{}
  32319. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32322. return
  32323. }
  32324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32325. result, _ := json.Marshal(respJSON)
  32326. fmt.Println("log")
  32327. fmt.Println(string(result))
  32328. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32329. utils.ErrorLog("解析失败:%v", err)
  32330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32331. return
  32332. }
  32333. } else {
  32334. if miConfig.MdtrtareaAdmvs == "441202" {
  32335. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32336. if result3101.Infcode == 0 {
  32337. if len(result3101.Output.Result) > 0 {
  32338. c.ServeSuccessJSON(map[string]interface{}{
  32339. "failed_code": -10,
  32340. "failed_type": 100,
  32341. "msg": result3101.Output.Result,
  32342. })
  32343. return
  32344. } else {
  32345. var result string
  32346. var request_log string
  32347. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32348. allTotal = fmt.Sprintf("%.2f", total_two)
  32349. if his.IdCardType == 4 {
  32350. 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)
  32351. } else {
  32352. 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)
  32353. }
  32354. var dat map[string]interface{}
  32355. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32356. fmt.Println(dat)
  32357. } else {
  32358. fmt.Println(err)
  32359. }
  32360. saveLog(result, request_log, "2206", "预结算")
  32361. //userJSONBytes, _ := json.Marshal(dat)
  32362. //
  32363. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32364. // utils.ErrorLog("解析失败:%v", err)
  32365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32366. // return
  32367. //}
  32368. userJSONBytes, _ := json.Marshal(dat)
  32369. if miConfig.Code == "H15049901371" {
  32370. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32371. utils.ErrorLog("解析失败:%v", err)
  32372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32373. return
  32374. }
  32375. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32376. res.Output = resSeven10265.Output
  32377. res.ErrMsg = resSeven10265.ErrMsg
  32378. res.Cainfo = resSeven10265.Cainfo
  32379. res.WarnMsg = resSeven10265.WarnMsg
  32380. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32381. res.Infcode = infocode
  32382. } else {
  32383. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32384. utils.ErrorLog("解析失败:%v", err)
  32385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32386. return
  32387. }
  32388. }
  32389. }
  32390. } else {
  32391. c.ServeSuccessJSON(map[string]interface{}{
  32392. "failed_code": -10,
  32393. "msg": result3101.ErrMsg,
  32394. })
  32395. return
  32396. }
  32397. } else if miConfig.MdtrtareaAdmvs == "440205" {
  32398. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32399. if result3101.Infcode == 0 {
  32400. if len(result3101.Output.Result) > 0 {
  32401. var errMsgs []string
  32402. for _, item := range result3101.Output.Result {
  32403. errMsgs = append(errMsgs, item.VolaCont)
  32404. }
  32405. c.ServeSuccessJSON(map[string]interface{}{
  32406. "failed_code": -10,
  32407. "msg": errMsgs,
  32408. })
  32409. return
  32410. } else {
  32411. var result string
  32412. var request_log string
  32413. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32414. allTotal = fmt.Sprintf("%.2f", total_two)
  32415. if his.IdCardType == 4 {
  32416. 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)
  32417. } else {
  32418. 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)
  32419. }
  32420. var dat map[string]interface{}
  32421. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32422. fmt.Println(dat)
  32423. } else {
  32424. fmt.Println(err)
  32425. }
  32426. saveLog(result, request_log, "2206", "预结算")
  32427. //userJSONBytes, _ := json.Marshal(dat)
  32428. //
  32429. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32430. // utils.ErrorLog("解析失败:%v", err)
  32431. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32432. // return
  32433. //}
  32434. userJSONBytes, _ := json.Marshal(dat)
  32435. if miConfig.Code == "H15049901371" {
  32436. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32437. utils.ErrorLog("解析失败:%v", err)
  32438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32439. return
  32440. }
  32441. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32442. res.Output = resSeven10265.Output
  32443. res.ErrMsg = resSeven10265.ErrMsg
  32444. res.Cainfo = resSeven10265.Cainfo
  32445. res.WarnMsg = resSeven10265.WarnMsg
  32446. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32447. res.Infcode = infocode
  32448. } else {
  32449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32450. utils.ErrorLog("解析失败:%v", err)
  32451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32452. return
  32453. }
  32454. }
  32455. }
  32456. } else {
  32457. c.ServeSuccessJSON(map[string]interface{}{
  32458. "failed_code": -10,
  32459. "msg": result3101.ErrMsg,
  32460. })
  32461. return
  32462. }
  32463. } else {
  32464. var result string
  32465. var request_log string
  32466. var dat map[string]interface{}
  32467. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32468. allTotal = fmt.Sprintf("%.2f", total_two)
  32469. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  32470. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32471. if result3101.Infcode == 0 {
  32472. if len(result3101.Output.Result) > 0 {
  32473. c.ServeSuccessJSON(map[string]interface{}{
  32474. "failed_code": -10,
  32475. "failed_type": 100,
  32476. "warm_type": 2,
  32477. "msg": result3101,
  32478. })
  32479. return
  32480. } else {
  32481. var result string
  32482. var request_log string
  32483. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32484. allTotal = fmt.Sprintf("%.2f", total_two)
  32485. if his.IdCardType == 4 {
  32486. 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)
  32487. } else {
  32488. if his.IdCardType == 2 {
  32489. cert_no = psn_info.Certno
  32490. psn_info.VerifyNumber = psn_info.Certno
  32491. } else {
  32492. bas := strings.Split(psn_info.CardInfo, "|")
  32493. cert_no = bas[2]
  32494. }
  32495. 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)
  32496. }
  32497. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32498. fmt.Println(dat)
  32499. } else {
  32500. fmt.Println(err)
  32501. }
  32502. saveLog(result, request_log, "2206", "预结算")
  32503. }
  32504. } else {
  32505. c.ServeSuccessJSON(map[string]interface{}{
  32506. "failed_code": -10,
  32507. "msg": result3101.ErrMsg,
  32508. })
  32509. return
  32510. }
  32511. } else {
  32512. if his.IdCardType == 4 {
  32513. 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)
  32514. } else {
  32515. if his.IdCardType == 2 {
  32516. cert_no = psn_info.Certno
  32517. psn_info.VerifyNumber = psn_info.Certno
  32518. } else {
  32519. bas := strings.Split(psn_info.CardInfo, "|")
  32520. cert_no = bas[2]
  32521. }
  32522. 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)
  32523. }
  32524. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32525. fmt.Println(dat)
  32526. } else {
  32527. fmt.Println(err)
  32528. }
  32529. saveLog(result, request_log, "2206", "预结算")
  32530. }
  32531. //userJSONBytes, _ := json.Marshal(dat)
  32532. //
  32533. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32534. // utils.ErrorLog("解析失败:%v", err)
  32535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32536. // return
  32537. //}
  32538. userJSONBytes, _ := json.Marshal(dat)
  32539. if miConfig.Code == "H15049901371" {
  32540. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32541. utils.ErrorLog("解析失败:%v", err)
  32542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32543. return
  32544. }
  32545. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32546. res.Output = resSeven10265.Output
  32547. res.ErrMsg = resSeven10265.ErrMsg
  32548. res.Cainfo = resSeven10265.Cainfo
  32549. res.WarnMsg = resSeven10265.WarnMsg
  32550. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32551. res.Infcode = infocode
  32552. } else {
  32553. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32554. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  32555. utils.ErrorLog("解析失败:%v", err)
  32556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32557. return
  32558. }
  32559. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  32560. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  32561. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  32562. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32563. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  32564. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  32565. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  32566. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32567. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  32568. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32569. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32570. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32571. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32572. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32573. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  32574. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  32575. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  32576. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  32577. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  32578. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  32579. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32580. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  32581. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  32582. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  32583. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  32584. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  32585. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  32586. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  32587. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  32588. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  32589. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  32590. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  32591. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  32592. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  32593. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32594. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  32595. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  32596. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  32597. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32598. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  32599. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  32600. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  32601. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  32602. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  32603. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  32604. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  32605. res.ErrMsg = gzresSeven10265Two.ErrMsg
  32606. res.Cainfo = gzresSeven10265Two.Cainfo
  32607. res.WarnMsg = gzresSeven10265Two.WarnMsg
  32608. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  32609. //res.Infcode = infocode
  32610. } else {
  32611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32612. utils.ErrorLog("解析失败:%v", err)
  32613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32614. return
  32615. }
  32616. }
  32617. }
  32618. }
  32619. }
  32620. utils.ErrorLog("解析失败:%v", res.Infcode)
  32621. if res.Infcode == -1 {
  32622. errlog := &models.HisOrderError{
  32623. UserOrgId: adminUser.CurrentOrgId,
  32624. Ctime: time.Now().Unix(),
  32625. Mtime: time.Now().Unix(),
  32626. Number: chrg_bchno,
  32627. ErrMsg: res.ErrMsg,
  32628. Status: 1,
  32629. PatientId: id,
  32630. RecordTime: recordDateTime,
  32631. Stage: 20,
  32632. }
  32633. service.CreateErrMsgLog(errlog)
  32634. c.ServeSuccessJSON(map[string]interface{}{
  32635. "failed_code": -10,
  32636. "msg": res.ErrMsg,
  32637. })
  32638. return
  32639. }
  32640. if res.Infcode != 0 {
  32641. errlog := &models.HisOrderError{
  32642. UserOrgId: adminUser.CurrentOrgId,
  32643. Ctime: time.Now().Unix(),
  32644. Mtime: time.Now().Unix(),
  32645. Number: chrg_bchno,
  32646. ErrMsg: res.ErrMsg,
  32647. Status: 1,
  32648. PatientId: id,
  32649. RecordTime: recordDateTime,
  32650. Stage: 20,
  32651. }
  32652. service.CreateErrMsgLog(errlog)
  32653. c.ServeSuccessJSON(map[string]interface{}{
  32654. "failed_code": -10,
  32655. "msg": res.ErrMsg,
  32656. })
  32657. return
  32658. } else {
  32659. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32660. order.OrderStatus = 1
  32661. order.IsPre = 1
  32662. order.Status = 1
  32663. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  32664. order.SetlId = res.Output.Setlinfo.SetlID
  32665. order.PsnNo = res.Output.Setlinfo.PsnNo
  32666. order.PsnName = res.Output.Setlinfo.PsnName
  32667. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  32668. order.Certno = res.Output.Setlinfo.Certno
  32669. order.Gend = res.Output.Setlinfo.Gend
  32670. order.Naty = res.Output.Setlinfo.Naty
  32671. order.Age = res.Output.Setlinfo.Age
  32672. order.Insutype = res.Output.Setlinfo.Insutype
  32673. order.PsnType = res.Output.Setlinfo.PsnType
  32674. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  32675. order.SetlTime = res.Output.Setlinfo.SetlTime
  32676. order.AcctUsedFlag = acct_used_flag
  32677. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  32678. if res.Output.Setlinfo.MedType == "140101" {
  32679. order.MedType = "14"
  32680. } else {
  32681. if res.Output.Setlinfo.MedType == "110104" {
  32682. order.MedType = "11"
  32683. } else {
  32684. order.MedType = res.Output.Setlinfo.MedType
  32685. }
  32686. }
  32687. if res.Output.Setlinfo.MedType == "992102" {
  32688. order.MedType = "992102"
  32689. }
  32690. if res.Output.Setlinfo.MedType == "140104" {
  32691. order.MedType = "140104"
  32692. }
  32693. if res.Output.Setlinfo.MedType == "1104" {
  32694. order.MedType = "1104"
  32695. }
  32696. if res.Output.Setlinfo.MedType == "140201" {
  32697. order.MedType = "140201"
  32698. }
  32699. if res.Output.Setlinfo.MedType == "14" {
  32700. order.MedType = "14"
  32701. }
  32702. if reg_type == 1112 {
  32703. order.MedType = "1112"
  32704. }
  32705. if reg_type == 1111 {
  32706. order.MedType = "1111"
  32707. }
  32708. order.ClrType = res.Output.Setlinfo.ClrType
  32709. if adminUser.CurrentOrgId == 10480 {
  32710. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32711. order.ClrType = "11"
  32712. } else {
  32713. order.ClrType = "9903"
  32714. }
  32715. }
  32716. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  32717. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  32718. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  32719. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  32720. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  32721. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  32722. order.HifpPay = res.Output.Setlinfo.HifpPay
  32723. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  32724. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  32725. order.HifesPay = res.Output.Setlinfo.HifesPay
  32726. order.HifobPay = res.Output.Setlinfo.HifobPay
  32727. order.MafPay = res.Output.Setlinfo.MafPay
  32728. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  32729. order.OthPay = res.Output.Setlinfo.OthPay
  32730. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  32731. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  32732. order.AcctPay = res.Output.Setlinfo.AcctPay
  32733. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  32734. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  32735. order.Balc = res.Output.Setlinfo.Balc
  32736. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  32737. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  32738. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  32739. order.ClrWay = res.Output.Setlinfo.ClrWay
  32740. order.Creator = order.Creator
  32741. order.Modify = roles.AdminUserId
  32742. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32743. //detailStr := string(setlDetail)
  32744. //order.SetlDetail = detailStr
  32745. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32746. err = service.UpDateOrder(order)
  32747. if err == nil {
  32748. c.ServeSuccessJSON(map[string]interface{}{
  32749. "msg": "预结算成功",
  32750. })
  32751. } else {
  32752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32753. return
  32754. }
  32755. }
  32756. } else {
  32757. adminUser := c.GetAdminUserInfo()
  32758. errlog := &models.HisOrderError{
  32759. UserOrgId: adminUser.CurrentOrgId,
  32760. Ctime: time.Now().Unix(),
  32761. Mtime: time.Now().Unix(),
  32762. ErrMsg: res.ErrMsg,
  32763. Status: 1,
  32764. PatientId: id,
  32765. RecordTime: recordDateTime,
  32766. Stage: 4,
  32767. }
  32768. service.CreateErrMsgLog(errlog)
  32769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  32770. return
  32771. }
  32772. } else {
  32773. if miConfig.MdtrtareaAdmvs == "150499" {
  32774. order := &models.HisOrder{
  32775. UserOrgId: adminUser.CurrentOrgId,
  32776. HisPatientId: his.ID,
  32777. PatientId: his.PatientId,
  32778. SettleAccountsDate: recordDateTime,
  32779. Ctime: time.Now().Unix(),
  32780. Mtime: time.Now().Unix(),
  32781. MdtrtId: his.Number,
  32782. PsnNo: his.PsnNo,
  32783. MedType: strconv.FormatInt(reg_type, 10),
  32784. Status: 1,
  32785. Number: chrg_bchno,
  32786. Infcode: res.Infcode,
  32787. WarnMsg: res.WarnMsg,
  32788. Cainfo: res.Cainfo,
  32789. ErrMsg: res.ErrMsg,
  32790. RespondTime: res.RefmsgTime,
  32791. InfRefmsgid: res.InfRefmsgid,
  32792. OrderStatus: 1,
  32793. IsMedicineInsurance: 1,
  32794. SettleType: settle_accounts_type,
  32795. SettleStartTime: start_time,
  32796. SettleEndTime: end_time,
  32797. Creator: roles.AdminUserId,
  32798. Modify: roles.AdminUserId,
  32799. PType: 2,
  32800. Diagnosis: diagnosis_id,
  32801. }
  32802. err = service.CreateOrder(order)
  32803. if err != nil {
  32804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  32805. return
  32806. }
  32807. }
  32808. adminUser := c.GetAdminUserInfo()
  32809. errlog := &models.HisOrderError{
  32810. UserOrgId: adminUser.CurrentOrgId,
  32811. Ctime: time.Now().Unix(),
  32812. Mtime: time.Now().Unix(),
  32813. ErrMsg: res.ErrMsg,
  32814. Status: 1,
  32815. PatientId: id,
  32816. RecordTime: recordDateTime,
  32817. Stage: 4,
  32818. }
  32819. service.CreateErrMsgLog(errlog)
  32820. c.ServeSuccessJSON(map[string]interface{}{
  32821. "failed_code": -10,
  32822. "msg": res.ErrMsg,
  32823. })
  32824. return
  32825. }
  32826. }
  32827. }
  32828. }
  32829. // 退款
  32830. func (c *HisApiController) Refund() {
  32831. order_id, _ := c.GetInt64("order_id")
  32832. admin_user_id, _ := c.GetInt64("admin_user_id")
  32833. adminUser := c.GetAdminUserInfo()
  32834. var order models.HisOrder
  32835. order, _ = service.GetHisOrderByID(order_id)
  32836. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  32837. if fapiao.ID > 0 {
  32838. c.ServeSuccessJSON(map[string]interface{}{
  32839. "failed_code": -10,
  32840. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  32841. })
  32842. return
  32843. }
  32844. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32845. if order.ID == 0 {
  32846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32847. return
  32848. }
  32849. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32850. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32851. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32852. if config.IsOpen == 1 { //对接了医保,走医保流程
  32853. var res ResultSixteen
  32854. var ahres ResultSevenAH
  32855. var resSixteen10265 ResultSixteen10265
  32856. var resSixteen10265Two ResultSixteen10265Two
  32857. var gz ResultgzSixteen10265Two
  32858. var src_resquest string
  32859. var result string
  32860. if miConfig.MdtrtareaAdmvs == "421300" {
  32861. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32862. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32863. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32864. resp3, requestErr3 := http.Get(api3)
  32865. if requestErr3 != nil {
  32866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32867. return
  32868. }
  32869. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32870. if ioErr3 != nil {
  32871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32873. return
  32874. }
  32875. var respJSON3 map[string]interface{}
  32876. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32879. return
  32880. }
  32881. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32882. userJSONBytes3, _ := json.Marshal(respJSON3)
  32883. fmt.Println("log")
  32884. fmt.Println(string(userJSONBytes3))
  32885. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32886. utils.ErrorLog("解析失败:%v", err)
  32887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32888. return
  32889. }
  32890. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32891. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32892. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32893. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32894. resp3, requestErr3 := http.Get(api3)
  32895. if requestErr3 != nil {
  32896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32897. return
  32898. }
  32899. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32900. if ioErr3 != nil {
  32901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32903. return
  32904. }
  32905. var respJSON3 map[string]interface{}
  32906. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32909. return
  32910. }
  32911. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32912. userJSONBytes3, _ := json.Marshal(respJSON3)
  32913. fmt.Println("log")
  32914. fmt.Println(string(userJSONBytes3))
  32915. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32916. utils.ErrorLog("解析失败:%v", err)
  32917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32918. return
  32919. }
  32920. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32921. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32922. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32923. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32924. resp3, requestErr3 := http.Get(api3)
  32925. if requestErr3 != nil {
  32926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32927. return
  32928. }
  32929. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32930. if ioErr3 != nil {
  32931. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32933. return
  32934. }
  32935. var respJSON3 map[string]interface{}
  32936. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32939. return
  32940. }
  32941. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32942. userJSONBytes3, _ := json.Marshal(respJSON3)
  32943. fmt.Println("log")
  32944. fmt.Println(string(userJSONBytes3))
  32945. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32946. utils.ErrorLog("解析失败:%v", err)
  32947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32948. return
  32949. }
  32950. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32951. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32952. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32953. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32954. resp3, requestErr3 := http.Get(api3)
  32955. if requestErr3 != nil {
  32956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32957. return
  32958. }
  32959. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32960. if ioErr3 != nil {
  32961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32963. return
  32964. }
  32965. var respJSON3 map[string]interface{}
  32966. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32969. return
  32970. }
  32971. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32972. userJSONBytes3, _ := json.Marshal(respJSON3)
  32973. fmt.Println("log")
  32974. fmt.Println(string(userJSONBytes3))
  32975. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32976. utils.ErrorLog("解析失败:%v", err)
  32977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32978. return
  32979. }
  32980. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  32981. var api3 string
  32982. if miConfig.MdtrtareaAdmvs == "320830" {
  32983. api3 = miConfig.AppSecret + "jsyb/2208?psn_no=" + order.PsnNo +
  32984. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32985. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32986. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32987. } else if miConfig.MdtrtareaAdmvs == "320921" {
  32988. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32989. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32990. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32991. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32992. } else {
  32993. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32994. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32995. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32996. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32997. }
  32998. resp3, requestErr3 := http.Get(api3)
  32999. if requestErr3 != nil {
  33000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33001. return
  33002. }
  33003. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33004. if ioErr3 != nil {
  33005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33007. return
  33008. }
  33009. var respJSON3 map[string]interface{}
  33010. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33013. return
  33014. }
  33015. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33016. userJSONBytes3, _ := json.Marshal(respJSON3)
  33017. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33018. utils.ErrorLog("解析失败:%v", err)
  33019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33020. return
  33021. }
  33022. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33023. res.Output = resSixteen10265.Output
  33024. res.ErrMsg = resSixteen10265.ErrMsg
  33025. res.Cainfo = resSixteen10265.Cainfo
  33026. res.WarnMsg = resSixteen10265.WarnMsg
  33027. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33028. res.Infcode = infocode
  33029. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33030. var api3 string
  33031. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  33032. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33033. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33034. resp3, requestErr3 := http.Get(api3)
  33035. if requestErr3 != nil {
  33036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33037. return
  33038. }
  33039. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33040. if ioErr3 != nil {
  33041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33043. return
  33044. }
  33045. var respJSON3 map[string]interface{}
  33046. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33049. return
  33050. }
  33051. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33052. userJSONBytes3, _ := json.Marshal(respJSON3)
  33053. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33054. utils.ErrorLog("解析失败:%v", err)
  33055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33056. return
  33057. }
  33058. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33059. res.Output = resSixteen10265.Output
  33060. res.ErrMsg = resSixteen10265.ErrMsg
  33061. res.Cainfo = resSixteen10265.Cainfo
  33062. res.WarnMsg = resSixteen10265.WarnMsg
  33063. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33064. res.Infcode = infocode
  33065. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33066. 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)
  33067. var dat map[string]interface{}
  33068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33069. fmt.Println(dat)
  33070. } else {
  33071. fmt.Println(err)
  33072. }
  33073. saveLog(result, src_resquest, "2208", "退费")
  33074. userJSONBytes, _ := json.Marshal(dat)
  33075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33076. utils.ErrorLog("解析失败:%v", err)
  33077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33078. return
  33079. }
  33080. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33081. 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, "")
  33082. var dat map[string]interface{}
  33083. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33084. fmt.Println(dat)
  33085. } else {
  33086. fmt.Println(err)
  33087. }
  33088. saveLog(result, src_resquest, "2208", "退费")
  33089. userJSONBytes, _ := json.Marshal(dat)
  33090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33091. utils.ErrorLog("解析失败:%v", err)
  33092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33093. return
  33094. }
  33095. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33096. 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, "")
  33097. var dat map[string]interface{}
  33098. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33099. fmt.Println(dat)
  33100. } else {
  33101. fmt.Println(err)
  33102. }
  33103. saveLog(result, src_resquest, "2208", "退费")
  33104. userJSONBytes, _ := json.Marshal(dat)
  33105. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33106. utils.ErrorLog("解析失败:%v", err)
  33107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33108. return
  33109. }
  33110. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33111. 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, "")
  33112. var dat map[string]interface{}
  33113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33114. fmt.Println(dat)
  33115. } else {
  33116. fmt.Println(err)
  33117. }
  33118. saveLog(result, src_resquest, "2208", "退费")
  33119. userJSONBytes, _ := json.Marshal(dat)
  33120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33121. utils.ErrorLog("解析失败:%v", err)
  33122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33123. return
  33124. }
  33125. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33126. var api3 string
  33127. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33128. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33129. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33130. resp3, requestErr3 := http.Get(api3)
  33131. if requestErr3 != nil {
  33132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33133. return
  33134. }
  33135. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33136. if ioErr3 != nil {
  33137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33139. return
  33140. }
  33141. var respJSON3 map[string]interface{}
  33142. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33145. return
  33146. }
  33147. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33148. if status == "0" {
  33149. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33150. c.ServeSuccessJSON(map[string]interface{}{
  33151. "failed_code": -10,
  33152. "msg": err_msg,
  33153. })
  33154. return
  33155. }
  33156. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33157. userJSONBytes3, _ := json.Marshal(respJSON3)
  33158. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33159. // utils.ErrorLog("解析失败:%v", err)
  33160. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33161. // return
  33162. //}
  33163. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33164. utils.ErrorLog("解析失败:%v", err)
  33165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33166. return
  33167. }
  33168. res.InfRefmsgid = ahres.InfRefmsgid
  33169. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33170. // 创建对应的Time类型
  33171. t := time.UnixMilli(timestamp)
  33172. // 格式化成指定的日期字符串
  33173. str := t.Format("2006-01-02 15:04:05")
  33174. res.Output.Setlinfo.SetlTime = str
  33175. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33176. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33177. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33178. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33179. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33180. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33181. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33182. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33183. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33184. //
  33185. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33186. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33187. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33188. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33189. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33190. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33191. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33192. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33193. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33194. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33195. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33196. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33197. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33198. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33199. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33200. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33201. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33202. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33203. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33204. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33205. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33206. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33207. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33208. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33209. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33210. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33211. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33212. //res.Output.Setldetail = ahres.Output.Setldetail
  33213. res.ErrMsg = ahres.ErrMsg
  33214. res.Cainfo = ahres.Cainfo
  33215. res.WarnMsg = ahres.WarnMsg
  33216. res.Infcode = ahres.Infcode
  33217. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33218. var api3 string
  33219. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33220. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33221. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33222. resp3, requestErr3 := http.Get(api3)
  33223. if requestErr3 != nil {
  33224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33225. return
  33226. }
  33227. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33228. if ioErr3 != nil {
  33229. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33231. return
  33232. }
  33233. var respJSON3 map[string]interface{}
  33234. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33237. return
  33238. }
  33239. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33240. if status == "0" {
  33241. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33242. c.ServeSuccessJSON(map[string]interface{}{
  33243. "failed_code": -10,
  33244. "msg": err_msg,
  33245. })
  33246. return
  33247. }
  33248. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33249. userJSONBytes3, _ := json.Marshal(respJSON3)
  33250. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33251. // utils.ErrorLog("解析失败:%v", err)
  33252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33253. // return
  33254. //}
  33255. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33256. utils.ErrorLog("解析失败:%v", err)
  33257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33258. return
  33259. }
  33260. res.InfRefmsgid = ahres.InfRefmsgid
  33261. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33262. // 创建对应的Time类型
  33263. t := time.UnixMilli(timestamp)
  33264. // 格式化成指定的日期字符串
  33265. str := t.Format("2006-01-02 15:04:05")
  33266. res.Output.Setlinfo.SetlTime = str
  33267. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33268. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33269. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33270. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33271. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33272. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33273. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33274. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33275. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33276. //
  33277. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33278. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33279. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33280. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33281. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33282. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33283. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33284. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33285. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33286. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33287. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33288. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33289. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33290. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33291. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33292. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33293. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33294. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33295. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33296. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33297. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33298. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33299. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33300. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33301. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33302. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33303. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33304. //res.Output.Setldetail = ahres.Output.Setldetail
  33305. res.ErrMsg = ahres.ErrMsg
  33306. res.Cainfo = ahres.Cainfo
  33307. res.WarnMsg = ahres.WarnMsg
  33308. res.Infcode = ahres.Infcode
  33309. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33310. 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, "")
  33311. var dat map[string]interface{}
  33312. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33313. fmt.Println(dat)
  33314. } else {
  33315. fmt.Println(err)
  33316. }
  33317. saveLog(result, src_resquest, "2208", "退费")
  33318. userJSONBytes, _ := json.Marshal(dat)
  33319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33320. utils.ErrorLog("解析失败:%v", err)
  33321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33322. return
  33323. }
  33324. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33325. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  33326. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33327. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33328. resp3, requestErr3 := http.Get(api3)
  33329. if requestErr3 != nil {
  33330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33331. return
  33332. }
  33333. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33334. if ioErr3 != nil {
  33335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33337. return
  33338. }
  33339. var respJSON3 map[string]interface{}
  33340. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33343. return
  33344. }
  33345. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33346. userJSONBytes3, _ := json.Marshal(respJSON3)
  33347. fmt.Println("log")
  33348. fmt.Println(string(userJSONBytes3))
  33349. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33350. utils.ErrorLog("解析失败:%v", err)
  33351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33352. return
  33353. }
  33354. } else {
  33355. if miConfig.Code == "H15049901371" {
  33356. 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)
  33357. var dat map[string]interface{}
  33358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33359. fmt.Println(dat)
  33360. } else {
  33361. fmt.Println(err)
  33362. }
  33363. saveLog(result, src_resquest, "2208", "退费")
  33364. if strings.Contains(result, "Post") {
  33365. res.Infcode = -1
  33366. res.ErrMsg = result
  33367. }
  33368. userJSONBytes, _ := json.Marshal(dat)
  33369. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  33370. utils.ErrorLog("解析失败:%v", err)
  33371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33372. return
  33373. }
  33374. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33375. res.Output = resSixteen10265.Output
  33376. res.ErrMsg = resSixteen10265.ErrMsg
  33377. res.Cainfo = resSixteen10265.Cainfo
  33378. res.WarnMsg = resSixteen10265.WarnMsg
  33379. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33380. res.Infcode = infocode
  33381. } else {
  33382. 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)
  33383. var dat map[string]interface{}
  33384. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33385. fmt.Println(dat)
  33386. } else {
  33387. fmt.Println(err)
  33388. }
  33389. saveLog(result, src_resquest, "2208", "退费")
  33390. userJSONBytes, _ := json.Marshal(dat)
  33391. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33392. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  33393. utils.ErrorLog("解析失败:%v", err)
  33394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33395. return
  33396. }
  33397. res.Infcode = gz.Infcode
  33398. } else {
  33399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33400. utils.ErrorLog("解析失败:%v", err)
  33401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33402. return
  33403. }
  33404. }
  33405. if strings.Contains(result, "Post") {
  33406. res.Infcode = -1
  33407. res.ErrMsg = result
  33408. }
  33409. }
  33410. }
  33411. if res.Infcode == -1 {
  33412. c.ServeSuccessJSON(map[string]interface{}{
  33413. "failed_code": -10,
  33414. "msg": res.ErrMsg,
  33415. })
  33416. return
  33417. }
  33418. if res.Infcode != -1 {
  33419. var res2 ResultSix
  33420. var resSix10265 ResultSix10265
  33421. if miConfig.MdtrtareaAdmvs == "421300" {
  33422. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33423. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33424. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33425. resp3, requestErr3 := http.Get(api3)
  33426. if requestErr3 != nil {
  33427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33428. return
  33429. }
  33430. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33431. if ioErr3 != nil {
  33432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33434. return
  33435. }
  33436. var respJSON3 map[string]interface{}
  33437. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33440. return
  33441. }
  33442. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33443. userJSONBytes3, _ := json.Marshal(respJSON3)
  33444. fmt.Println("log")
  33445. fmt.Println(string(userJSONBytes3))
  33446. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33447. utils.ErrorLog("解析失败:%v", err)
  33448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33449. return
  33450. }
  33451. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33452. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33453. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33454. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33455. resp3, requestErr3 := http.Get(api3)
  33456. if requestErr3 != nil {
  33457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33458. return
  33459. }
  33460. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33461. if ioErr3 != nil {
  33462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33464. return
  33465. }
  33466. var respJSON3 map[string]interface{}
  33467. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33470. return
  33471. }
  33472. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33473. userJSONBytes3, _ := json.Marshal(respJSON3)
  33474. fmt.Println("log")
  33475. fmt.Println(string(userJSONBytes3))
  33476. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33477. utils.ErrorLog("解析失败:%v", err)
  33478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33479. return
  33480. }
  33481. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33482. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33483. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33484. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33485. resp3, requestErr3 := http.Get(api3)
  33486. if requestErr3 != nil {
  33487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33488. return
  33489. }
  33490. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33491. if ioErr3 != nil {
  33492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33494. return
  33495. }
  33496. var respJSON3 map[string]interface{}
  33497. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33500. return
  33501. }
  33502. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33503. userJSONBytes3, _ := json.Marshal(respJSON3)
  33504. fmt.Println("log")
  33505. fmt.Println(string(userJSONBytes3))
  33506. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33507. utils.ErrorLog("解析失败:%v", err)
  33508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33509. return
  33510. }
  33511. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33512. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33513. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33514. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33515. resp3, requestErr3 := http.Get(api3)
  33516. if requestErr3 != nil {
  33517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33518. return
  33519. }
  33520. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33521. if ioErr3 != nil {
  33522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33524. return
  33525. }
  33526. var respJSON3 map[string]interface{}
  33527. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33530. return
  33531. }
  33532. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33533. userJSONBytes3, _ := json.Marshal(respJSON3)
  33534. fmt.Println("log")
  33535. fmt.Println(string(userJSONBytes3))
  33536. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33537. utils.ErrorLog("解析失败:%v", err)
  33538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33539. return
  33540. }
  33541. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33542. var api3 string
  33543. if miConfig.MdtrtareaAdmvs == "320830" {
  33544. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  33545. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33546. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33547. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33548. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33549. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33550. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33551. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33552. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33553. } else {
  33554. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33555. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33556. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33557. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33558. }
  33559. resp3, requestErr3 := http.Get(api3)
  33560. if requestErr3 != nil {
  33561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33562. return
  33563. }
  33564. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33565. if ioErr3 != nil {
  33566. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33568. return
  33569. }
  33570. var respJSON3 map[string]interface{}
  33571. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33572. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33574. return
  33575. }
  33576. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33577. userJSONBytes3, _ := json.Marshal(respJSON3)
  33578. fmt.Println("log")
  33579. fmt.Println(string(userJSONBytes3))
  33580. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33581. utils.ErrorLog("解析失败:%v", err)
  33582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33583. return
  33584. }
  33585. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33586. res2.Output = resSix10265.Output
  33587. res2.ErrMsg = resSix10265.ErrMsg
  33588. res2.Cainfo = resSix10265.Cainfo
  33589. res2.WarnMsg = resSix10265.WarnMsg
  33590. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33591. res2.Infcode = infocode
  33592. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33593. var api3 string
  33594. new_chrg_bchno := order.Number
  33595. if adminUser.CurrentOrgId == 10265 {
  33596. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33597. new_chrg_bchno = "0000"
  33598. }
  33599. }
  33600. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33601. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33602. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33603. resp3, requestErr3 := http.Get(api3)
  33604. if requestErr3 != nil {
  33605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33606. return
  33607. }
  33608. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33609. if ioErr3 != nil {
  33610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33612. return
  33613. }
  33614. var respJSON3 map[string]interface{}
  33615. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33618. return
  33619. }
  33620. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33621. userJSONBytes3, _ := json.Marshal(respJSON3)
  33622. fmt.Println("log")
  33623. fmt.Println(string(userJSONBytes3))
  33624. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33625. utils.ErrorLog("解析失败:%v", err)
  33626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33627. return
  33628. }
  33629. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33630. res2.Output = resSix10265.Output
  33631. res2.ErrMsg = resSix10265.ErrMsg
  33632. res2.Cainfo = resSix10265.Cainfo
  33633. res2.WarnMsg = resSix10265.WarnMsg
  33634. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33635. res2.Infcode = infocode
  33636. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33637. 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)
  33638. var dat map[string]interface{}
  33639. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33640. fmt.Println(dat)
  33641. } else {
  33642. fmt.Println(err)
  33643. }
  33644. saveLog(result2, src_request, "2205", "撤销明细")
  33645. userJSONBytes, _ := json.Marshal(dat)
  33646. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33647. utils.ErrorLog("解析失败:%v", err)
  33648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33649. return
  33650. }
  33651. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33652. 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, "")
  33653. var dat map[string]interface{}
  33654. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33655. fmt.Println(dat)
  33656. } else {
  33657. fmt.Println(err)
  33658. }
  33659. saveLog(result2, src_request, "2205", "撤销明细")
  33660. userJSONBytes, _ := json.Marshal(dat)
  33661. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33662. utils.ErrorLog("解析失败:%v", err)
  33663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33664. return
  33665. }
  33666. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33667. 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, "")
  33668. var dat map[string]interface{}
  33669. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33670. fmt.Println(dat)
  33671. } else {
  33672. fmt.Println(err)
  33673. }
  33674. saveLog(result2, src_request, "2205", "撤销明细")
  33675. userJSONBytes, _ := json.Marshal(dat)
  33676. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33677. utils.ErrorLog("解析失败:%v", err)
  33678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33679. return
  33680. }
  33681. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33682. 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, "")
  33683. var dat map[string]interface{}
  33684. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33685. fmt.Println(dat)
  33686. } else {
  33687. fmt.Println(err)
  33688. }
  33689. saveLog(result2, src_request, "2205", "撤销明细")
  33690. userJSONBytes, _ := json.Marshal(dat)
  33691. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33692. utils.ErrorLog("解析失败:%v", err)
  33693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33694. return
  33695. }
  33696. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33697. var api3 string
  33698. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33699. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33700. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33701. resp3, requestErr3 := http.Get(api3)
  33702. if requestErr3 != nil {
  33703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33704. return
  33705. }
  33706. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33707. if ioErr3 != nil {
  33708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33710. return
  33711. }
  33712. var respJSON3 map[string]interface{}
  33713. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33716. return
  33717. }
  33718. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33719. if status == "0" {
  33720. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33721. c.ServeSuccessJSON(map[string]interface{}{
  33722. "failed_code": -10,
  33723. "msg": err_msg,
  33724. })
  33725. return
  33726. }
  33727. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33728. userJSONBytes3, _ := json.Marshal(respJSON3)
  33729. fmt.Println("log")
  33730. fmt.Println(string(userJSONBytes3))
  33731. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33732. utils.ErrorLog("解析失败:%v", err)
  33733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33734. return
  33735. }
  33736. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33737. 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, "")
  33738. var dat map[string]interface{}
  33739. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33740. fmt.Println(dat)
  33741. } else {
  33742. fmt.Println(err)
  33743. }
  33744. saveLog(result2, src_request, "2205", "撤销明细")
  33745. userJSONBytes, _ := json.Marshal(dat)
  33746. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33747. utils.ErrorLog("解析失败:%v", err)
  33748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33749. return
  33750. }
  33751. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33752. 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, "")
  33753. var dat map[string]interface{}
  33754. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33755. fmt.Println(dat)
  33756. } else {
  33757. fmt.Println(err)
  33758. }
  33759. saveLog(result2, src_request, "2205", "撤销明细")
  33760. userJSONBytes, _ := json.Marshal(dat)
  33761. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33762. utils.ErrorLog("解析失败:%v", err)
  33763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33764. return
  33765. }
  33766. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33767. 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, "")
  33768. var dat map[string]interface{}
  33769. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33770. fmt.Println(dat)
  33771. } else {
  33772. fmt.Println(err)
  33773. }
  33774. saveLog(result2, src_request, "2205", "撤销明细")
  33775. userJSONBytes, _ := json.Marshal(dat)
  33776. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33777. utils.ErrorLog("解析失败:%v", err)
  33778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33779. return
  33780. }
  33781. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33782. var api3 string
  33783. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33784. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33785. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33786. resp3, requestErr3 := http.Get(api3)
  33787. if requestErr3 != nil {
  33788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33789. return
  33790. }
  33791. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33792. if ioErr3 != nil {
  33793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33795. return
  33796. }
  33797. var respJSON3 map[string]interface{}
  33798. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33801. return
  33802. }
  33803. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33804. if status == "0" {
  33805. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33806. c.ServeSuccessJSON(map[string]interface{}{
  33807. "failed_code": -10,
  33808. "msg": err_msg,
  33809. })
  33810. return
  33811. }
  33812. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33813. userJSONBytes3, _ := json.Marshal(respJSON3)
  33814. fmt.Println("log")
  33815. fmt.Println(string(userJSONBytes3))
  33816. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33817. utils.ErrorLog("解析失败:%v", err)
  33818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33819. return
  33820. }
  33821. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33822. 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, "")
  33823. var dat map[string]interface{}
  33824. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33825. fmt.Println(dat)
  33826. } else {
  33827. fmt.Println(err)
  33828. }
  33829. saveLog(result2, src_request, "2205", "撤销明细")
  33830. userJSONBytes, _ := json.Marshal(dat)
  33831. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33832. utils.ErrorLog("解析失败:%v", err)
  33833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33834. return
  33835. }
  33836. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33837. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  33838. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33839. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33840. resp3, requestErr3 := http.Get(api3)
  33841. if requestErr3 != nil {
  33842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33843. return
  33844. }
  33845. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33846. if ioErr3 != nil {
  33847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33849. return
  33850. }
  33851. var respJSON3 map[string]interface{}
  33852. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33855. return
  33856. }
  33857. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33858. userJSONBytes3, _ := json.Marshal(respJSON3)
  33859. fmt.Println("log")
  33860. fmt.Println(string(userJSONBytes3))
  33861. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33862. utils.ErrorLog("解析失败:%v", err)
  33863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33864. return
  33865. }
  33866. } else {
  33867. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33868. res2.Infcode = 0
  33869. } else {
  33870. 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)
  33871. var dat map[string]interface{}
  33872. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33873. fmt.Println(dat)
  33874. } else {
  33875. fmt.Println(err)
  33876. }
  33877. saveLog(result2, src_request, "2205", "撤销明细")
  33878. userJSONBytes, _ := json.Marshal(dat)
  33879. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33880. utils.ErrorLog("解析失败:%v", err)
  33881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33882. return
  33883. }
  33884. }
  33885. }
  33886. if res2.Infcode == -1 {
  33887. c.ServeSuccessJSON(map[string]interface{}{
  33888. "failed_code": -10,
  33889. "msg": res2.ErrMsg,
  33890. })
  33891. return
  33892. }
  33893. if res2.Infcode == 0 {
  33894. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  33895. if err == nil {
  33896. //当押金不为零时产生退费记录
  33897. if order.Decimal != 0 {
  33898. tmp := strconv.FormatInt(order.ID, 10)
  33899. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  33900. if err != nil {
  33901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33902. return
  33903. }
  33904. }
  33905. c.ServeSuccessJSON(map[string]interface{}{
  33906. "msg": "退费成功",
  33907. })
  33908. } else {
  33909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33910. return
  33911. }
  33912. } else {
  33913. c.ServeSuccessJSON(map[string]interface{}{
  33914. "failed_code": -10,
  33915. "msg": res2.ErrMsg,
  33916. })
  33917. }
  33918. } else {
  33919. c.ServeSuccessJSON(map[string]interface{}{
  33920. "failed_code": -10,
  33921. "msg": res.ErrMsg,
  33922. })
  33923. }
  33924. }
  33925. }
  33926. func (c *HisApiController) RefundNumber() {
  33927. record_time := c.GetString("record_time")
  33928. //patient_id, _ := c.GetInt64("patient_id")
  33929. admin_user_id, _ := c.GetInt64("admin_user_id")
  33930. his_patient_id, _ := c.GetInt64("id")
  33931. timeLayout := "2006-01-02"
  33932. loc, _ := time.LoadLocation("Local")
  33933. adminUser := c.GetAdminUserInfo()
  33934. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33935. fmt.Println(err)
  33936. if err != nil {
  33937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33938. return
  33939. }
  33940. recordDateTime := theTime.Unix()
  33941. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33942. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  33943. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33944. //order, _ := service.GetHisOrderByID(order_id)
  33945. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33946. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33947. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33948. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  33949. if count > 0 {
  33950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  33951. return
  33952. }
  33953. if config.IsOpen == 1 { //对接了医保,走医保流程
  33954. var res2 ResultSix
  33955. var res3 GZResultSix
  33956. var resSix10265 ResultSix10265
  33957. if miConfig.MdtrtareaAdmvs == "421300" {
  33958. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33959. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33960. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33961. resp3, requestErr3 := http.Get(api3)
  33962. if requestErr3 != nil {
  33963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33964. return
  33965. }
  33966. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33967. if ioErr3 != nil {
  33968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33970. return
  33971. }
  33972. var respJSON3 map[string]interface{}
  33973. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33976. return
  33977. }
  33978. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33979. userJSONBytes3, _ := json.Marshal(respJSON3)
  33980. fmt.Println("log")
  33981. fmt.Println(string(userJSONBytes3))
  33982. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33983. utils.ErrorLog("解析失败:%v", err)
  33984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33985. return
  33986. }
  33987. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33988. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33989. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33990. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33991. resp3, requestErr3 := http.Get(api3)
  33992. if requestErr3 != nil {
  33993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33994. return
  33995. }
  33996. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33997. if ioErr3 != nil {
  33998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34000. return
  34001. }
  34002. var respJSON3 map[string]interface{}
  34003. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34006. return
  34007. }
  34008. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34009. userJSONBytes3, _ := json.Marshal(respJSON3)
  34010. fmt.Println("log")
  34011. fmt.Println(string(userJSONBytes3))
  34012. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34013. utils.ErrorLog("解析失败:%v", err)
  34014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34015. return
  34016. }
  34017. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34018. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34019. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34020. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34021. resp3, requestErr3 := http.Get(api3)
  34022. if requestErr3 != nil {
  34023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34024. return
  34025. }
  34026. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34027. if ioErr3 != nil {
  34028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34030. return
  34031. }
  34032. var respJSON3 map[string]interface{}
  34033. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34036. return
  34037. }
  34038. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34039. userJSONBytes3, _ := json.Marshal(respJSON3)
  34040. fmt.Println("log")
  34041. fmt.Println(string(userJSONBytes3))
  34042. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34043. utils.ErrorLog("解析失败:%v", err)
  34044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34045. return
  34046. }
  34047. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34048. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34049. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34050. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34051. resp3, requestErr3 := http.Get(api3)
  34052. if requestErr3 != nil {
  34053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34054. return
  34055. }
  34056. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34057. if ioErr3 != nil {
  34058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34060. return
  34061. }
  34062. var respJSON3 map[string]interface{}
  34063. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34066. return
  34067. }
  34068. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34069. userJSONBytes3, _ := json.Marshal(respJSON3)
  34070. fmt.Println("log")
  34071. fmt.Println(string(userJSONBytes3))
  34072. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34073. utils.ErrorLog("解析失败:%v", err)
  34074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34075. return
  34076. }
  34077. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34078. var api3 string
  34079. if miConfig.MdtrtareaAdmvs == "320830" {
  34080. api3 = miConfig.AppSecret + "jsyb/2202?psn_no=" + his.PsnNo +
  34081. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34082. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34083. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34084. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34085. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34086. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34087. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34088. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34089. } else {
  34090. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34091. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34092. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34093. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34094. }
  34095. resp3, requestErr3 := http.Get(api3)
  34096. if requestErr3 != nil {
  34097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34098. return
  34099. }
  34100. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34101. if ioErr3 != nil {
  34102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34104. return
  34105. }
  34106. var respJSON3 map[string]interface{}
  34107. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34110. return
  34111. }
  34112. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34113. userJSONBytes3, _ := json.Marshal(respJSON3)
  34114. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34115. utils.ErrorLog("解析失败:%v", err)
  34116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34117. return
  34118. }
  34119. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34120. res2.Output = resSix10265.Output
  34121. res2.ErrMsg = resSix10265.ErrMsg
  34122. res2.Cainfo = resSix10265.Cainfo
  34123. res2.WarnMsg = resSix10265.WarnMsg
  34124. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34125. res2.Infcode = infocode
  34126. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34127. var api3 string
  34128. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  34129. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34130. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34131. resp3, requestErr3 := http.Get(api3)
  34132. if requestErr3 != nil {
  34133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34134. return
  34135. }
  34136. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34137. if ioErr3 != nil {
  34138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34140. return
  34141. }
  34142. var respJSON3 map[string]interface{}
  34143. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34146. return
  34147. }
  34148. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34149. userJSONBytes3, _ := json.Marshal(respJSON3)
  34150. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34151. utils.ErrorLog("解析失败:%v", err)
  34152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34153. return
  34154. }
  34155. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34156. res2.Output = resSix10265.Output
  34157. res2.ErrMsg = resSix10265.ErrMsg
  34158. res2.Cainfo = resSix10265.Cainfo
  34159. res2.WarnMsg = resSix10265.WarnMsg
  34160. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34161. res2.Infcode = infocode
  34162. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34163. 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)
  34164. var dat map[string]interface{}
  34165. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34166. fmt.Println(dat)
  34167. } else {
  34168. fmt.Println(err)
  34169. }
  34170. saveLog(result, request, "2202", "退号")
  34171. userJSONBytes, _ := json.Marshal(dat)
  34172. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34173. utils.ErrorLog("解析失败:%v", err)
  34174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34175. return
  34176. }
  34177. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34178. 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, "")
  34179. var dat map[string]interface{}
  34180. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34181. fmt.Println(dat)
  34182. } else {
  34183. fmt.Println(err)
  34184. }
  34185. saveLog(result, request, "2202", "退号")
  34186. userJSONBytes, _ := json.Marshal(dat)
  34187. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34188. utils.ErrorLog("解析失败:%v", err)
  34189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34190. return
  34191. }
  34192. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34193. 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, "")
  34194. var dat map[string]interface{}
  34195. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34196. fmt.Println(dat)
  34197. } else {
  34198. fmt.Println(err)
  34199. }
  34200. saveLog(result, request, "2202", "退号")
  34201. userJSONBytes, _ := json.Marshal(dat)
  34202. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34203. utils.ErrorLog("解析失败:%v", err)
  34204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34205. return
  34206. }
  34207. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34208. 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, "")
  34209. var dat map[string]interface{}
  34210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34211. fmt.Println(dat)
  34212. } else {
  34213. fmt.Println(err)
  34214. }
  34215. saveLog(result, request, "2202", "退号")
  34216. userJSONBytes, _ := json.Marshal(dat)
  34217. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34218. utils.ErrorLog("解析失败:%v", err)
  34219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34220. return
  34221. }
  34222. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34223. var api3 string
  34224. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34225. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34226. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34227. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34228. resp3, requestErr3 := http.Get(api3)
  34229. if requestErr3 != nil {
  34230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34231. return
  34232. }
  34233. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34234. if ioErr3 != nil {
  34235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34237. return
  34238. }
  34239. var respJSON3 map[string]interface{}
  34240. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34243. return
  34244. }
  34245. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34246. if status == "0" {
  34247. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34248. c.ServeSuccessJSON(map[string]interface{}{
  34249. "failed_code": -10,
  34250. "msg": err_msg,
  34251. })
  34252. return
  34253. }
  34254. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34255. userJSONBytes3, _ := json.Marshal(respJSON3)
  34256. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34257. utils.ErrorLog("解析失败:%v", err)
  34258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34259. return
  34260. }
  34261. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34262. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34263. var api3 string
  34264. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34265. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34266. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34267. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34268. resp3, requestErr3 := http.Get(api3)
  34269. if requestErr3 != nil {
  34270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34271. return
  34272. }
  34273. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34274. if ioErr3 != nil {
  34275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34277. return
  34278. }
  34279. var respJSON3 map[string]interface{}
  34280. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34283. return
  34284. }
  34285. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34286. if status == "0" {
  34287. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34288. c.ServeSuccessJSON(map[string]interface{}{
  34289. "failed_code": -10,
  34290. "msg": err_msg,
  34291. })
  34292. return
  34293. }
  34294. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34295. userJSONBytes3, _ := json.Marshal(respJSON3)
  34296. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34297. utils.ErrorLog("解析失败:%v", err)
  34298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34299. return
  34300. }
  34301. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34302. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34303. 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, "")
  34304. var dat map[string]interface{}
  34305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34306. fmt.Println(dat)
  34307. } else {
  34308. fmt.Println(err)
  34309. }
  34310. saveLog(result, request, "2202", "退号")
  34311. userJSONBytes, _ := json.Marshal(dat)
  34312. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34313. utils.ErrorLog("解析失败:%v", err)
  34314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34315. return
  34316. }
  34317. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34318. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  34319. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34320. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34321. resp3, requestErr3 := http.Get(api3)
  34322. if requestErr3 != nil {
  34323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34324. return
  34325. }
  34326. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34327. if ioErr3 != nil {
  34328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34330. return
  34331. }
  34332. var respJSON3 map[string]interface{}
  34333. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34336. return
  34337. }
  34338. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34339. userJSONBytes3, _ := json.Marshal(respJSON3)
  34340. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34341. utils.ErrorLog("解析失败:%v", err)
  34342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34343. return
  34344. }
  34345. } else {
  34346. var api3 string
  34347. if miConfig.Code == "H15049901371" {
  34348. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  34349. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34350. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34351. } else {
  34352. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  34353. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34354. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34355. }
  34356. resp3, requestErr3 := http.Get(api3)
  34357. if requestErr3 != nil {
  34358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34359. return
  34360. }
  34361. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34362. if ioErr3 != nil {
  34363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34365. return
  34366. }
  34367. var respJSON3 map[string]interface{}
  34368. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34371. return
  34372. }
  34373. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34374. userJSONBytes3, _ := json.Marshal(respJSON3)
  34375. if miConfig.Code == "H15049901371" {
  34376. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34377. utils.ErrorLog("解析失败:%v", err)
  34378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34379. return
  34380. }
  34381. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34382. res2.Output = resSix10265.Output
  34383. res2.ErrMsg = resSix10265.ErrMsg
  34384. res2.Cainfo = resSix10265.Cainfo
  34385. res2.WarnMsg = resSix10265.WarnMsg
  34386. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34387. res2.Infcode = infocode
  34388. } else {
  34389. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34390. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  34391. utils.ErrorLog("解析失败:%v", err)
  34392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34393. return
  34394. }
  34395. res2.Infcode = res3.Infcode
  34396. } else {
  34397. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34398. utils.ErrorLog("解析失败:%v", err)
  34399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34400. return
  34401. }
  34402. }
  34403. }
  34404. }
  34405. if res2.Infcode == -1 {
  34406. c.ServeSuccessJSON(map[string]interface{}{
  34407. "failed_code": -10,
  34408. "msg": res2.ErrMsg,
  34409. })
  34410. return
  34411. }
  34412. if res2.Infcode == 0 {
  34413. if err == nil {
  34414. c.ServeSuccessJSON(map[string]interface{}{
  34415. "msg": "退号成功",
  34416. })
  34417. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  34418. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  34419. } else {
  34420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34421. return
  34422. }
  34423. }
  34424. } else {
  34425. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  34426. //if err == nil {
  34427. // c.ServeSuccessJSON(map[string]interface{}{
  34428. // "msg": "退费成功",
  34429. // })
  34430. //} else {
  34431. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34432. // return
  34433. //}
  34434. }
  34435. }
  34436. func (c *HisApiController) RefundDetail() {
  34437. order_id, _ := c.GetInt64("order_id")
  34438. admin_user_id, _ := c.GetInt64("admin_user_id")
  34439. //his_patient_id, _ := c.GetInt64("his_patient_id")
  34440. number := c.GetString("number")
  34441. record_time := c.GetString("record_time")
  34442. patient_id, _ := c.GetInt64("patient_id")
  34443. //med_type, _ := c.GetInt64("med_type")
  34444. timeLayout := "2006-01-02"
  34445. loc, _ := time.LoadLocation("Local")
  34446. adminUser := c.GetAdminUserInfo()
  34447. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34448. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34449. fmt.Println(err)
  34450. if err != nil {
  34451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34452. return
  34453. }
  34454. recordDateTime := theTime.Unix()
  34455. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  34456. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34457. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34458. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34459. var order models.HisOrder
  34460. order, _ = service.GetHisOrderByID(order_id)
  34461. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34462. if config.IsOpen == 1 { //对接了医保,走医保流程
  34463. var res2 ResultSix
  34464. if miConfig.MdtrtareaAdmvs == "421300" {
  34465. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34466. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34467. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34468. resp3, requestErr3 := http.Get(api3)
  34469. if requestErr3 != nil {
  34470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34471. return
  34472. }
  34473. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34474. if ioErr3 != nil {
  34475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34477. return
  34478. }
  34479. var respJSON3 map[string]interface{}
  34480. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34483. return
  34484. }
  34485. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34486. userJSONBytes3, _ := json.Marshal(respJSON3)
  34487. fmt.Println("log")
  34488. fmt.Println(string(userJSONBytes3))
  34489. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34490. utils.ErrorLog("解析失败:%v", err)
  34491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34492. return
  34493. }
  34494. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34495. if err == nil {
  34496. c.ServeSuccessJSON(map[string]interface{}{
  34497. "msg": "撤销明细成功",
  34498. })
  34499. return
  34500. } else {
  34501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34502. return
  34503. }
  34504. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34505. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34506. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34507. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34508. resp3, requestErr3 := http.Get(api3)
  34509. if requestErr3 != nil {
  34510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34511. return
  34512. }
  34513. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34514. if ioErr3 != nil {
  34515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34517. return
  34518. }
  34519. var respJSON3 map[string]interface{}
  34520. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34523. return
  34524. }
  34525. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34526. userJSONBytes3, _ := json.Marshal(respJSON3)
  34527. fmt.Println("log")
  34528. fmt.Println(string(userJSONBytes3))
  34529. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34530. utils.ErrorLog("解析失败:%v", err)
  34531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34532. return
  34533. }
  34534. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34535. if err == nil {
  34536. c.ServeSuccessJSON(map[string]interface{}{
  34537. "msg": "撤销明细成功",
  34538. })
  34539. return
  34540. } else {
  34541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34542. return
  34543. }
  34544. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34545. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34546. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34547. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34548. resp3, requestErr3 := http.Get(api3)
  34549. if requestErr3 != nil {
  34550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34551. return
  34552. }
  34553. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34554. if ioErr3 != nil {
  34555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34557. return
  34558. }
  34559. var respJSON3 map[string]interface{}
  34560. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34563. return
  34564. }
  34565. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34566. userJSONBytes3, _ := json.Marshal(respJSON3)
  34567. fmt.Println("log")
  34568. fmt.Println(string(userJSONBytes3))
  34569. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34570. utils.ErrorLog("解析失败:%v", err)
  34571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34572. return
  34573. }
  34574. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34575. if err == nil {
  34576. c.ServeSuccessJSON(map[string]interface{}{
  34577. "msg": "撤销明细成功",
  34578. })
  34579. return
  34580. } else {
  34581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34582. return
  34583. }
  34584. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34585. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34586. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34587. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34588. resp3, requestErr3 := http.Get(api3)
  34589. if requestErr3 != nil {
  34590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34591. return
  34592. }
  34593. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34594. if ioErr3 != nil {
  34595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34597. return
  34598. }
  34599. var respJSON3 map[string]interface{}
  34600. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34603. return
  34604. }
  34605. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34606. userJSONBytes3, _ := json.Marshal(respJSON3)
  34607. fmt.Println("log")
  34608. fmt.Println(string(userJSONBytes3))
  34609. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34610. utils.ErrorLog("解析失败:%v", err)
  34611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34612. return
  34613. }
  34614. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34615. if err == nil {
  34616. c.ServeSuccessJSON(map[string]interface{}{
  34617. "msg": "撤销明细成功",
  34618. })
  34619. return
  34620. } else {
  34621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34622. return
  34623. }
  34624. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34625. var resSix10265 ResultSix10265
  34626. var api3 string
  34627. if miConfig.MdtrtareaAdmvs == "320830" {
  34628. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  34629. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34630. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34631. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34632. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34633. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34634. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34635. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34636. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34637. } else {
  34638. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34639. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34640. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34641. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34642. }
  34643. resp3, requestErr3 := http.Get(api3)
  34644. utils.ErrorLog("接口: %v", requestErr3)
  34645. if requestErr3 != nil {
  34646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34647. return
  34648. }
  34649. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34650. if ioErr3 != nil {
  34651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34653. return
  34654. }
  34655. var respJSON3 map[string]interface{}
  34656. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34659. return
  34660. }
  34661. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34662. userJSONBytes3, _ := json.Marshal(respJSON3)
  34663. fmt.Println("log")
  34664. fmt.Println(string(userJSONBytes3))
  34665. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34666. utils.ErrorLog("解析失败:%v", err)
  34667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34668. return
  34669. }
  34670. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34671. res2.Output = resSix10265.Output
  34672. res2.ErrMsg = resSix10265.ErrMsg
  34673. res2.Cainfo = resSix10265.Cainfo
  34674. res2.WarnMsg = resSix10265.WarnMsg
  34675. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34676. res2.Infcode = infocode
  34677. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34678. if err == nil {
  34679. c.ServeSuccessJSON(map[string]interface{}{
  34680. "msg": "撤销明细成功",
  34681. })
  34682. return
  34683. } else {
  34684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34685. return
  34686. }
  34687. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34688. var api3 string
  34689. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34690. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34691. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34692. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34693. resp3, requestErr3 := http.Get(api3)
  34694. utils.ErrorLog("接口: %v", requestErr3)
  34695. if requestErr3 != nil {
  34696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34697. return
  34698. }
  34699. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34700. if ioErr3 != nil {
  34701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34703. return
  34704. }
  34705. var respJSON3 map[string]interface{}
  34706. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34709. return
  34710. }
  34711. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34712. if status == "0" {
  34713. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34714. c.ServeSuccessJSON(map[string]interface{}{
  34715. "failed_code": -10,
  34716. "msg": err_msg,
  34717. })
  34718. return
  34719. }
  34720. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34721. userJSONBytes3, _ := json.Marshal(respJSON3)
  34722. fmt.Println("log")
  34723. fmt.Println(string(userJSONBytes3))
  34724. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34725. utils.ErrorLog("解析失败:%v", err)
  34726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34727. return
  34728. }
  34729. fmt.Println(res2.Infcode)
  34730. if res2.Infcode == -1 {
  34731. c.ServeSuccessJSON(map[string]interface{}{
  34732. "failed_code": -10,
  34733. "msg": res2.ErrMsg,
  34734. })
  34735. return
  34736. }
  34737. if res2.Infcode == 0 {
  34738. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34739. if err == nil {
  34740. c.ServeSuccessJSON(map[string]interface{}{
  34741. "msg": "撤销明细成功",
  34742. })
  34743. return
  34744. } else {
  34745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34746. return
  34747. }
  34748. } else {
  34749. c.ServeSuccessJSON(map[string]interface{}{
  34750. "failed_code": -10,
  34751. "msg": res2.ErrMsg,
  34752. })
  34753. }
  34754. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34755. if err == nil {
  34756. c.ServeSuccessJSON(map[string]interface{}{
  34757. "msg": "撤销明细成功",
  34758. })
  34759. return
  34760. } else {
  34761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34762. return
  34763. }
  34764. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34765. var api3 string
  34766. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34767. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34768. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34769. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34770. resp3, requestErr3 := http.Get(api3)
  34771. utils.ErrorLog("接口: %v", requestErr3)
  34772. if requestErr3 != nil {
  34773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34774. return
  34775. }
  34776. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34777. if ioErr3 != nil {
  34778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34780. return
  34781. }
  34782. var respJSON3 map[string]interface{}
  34783. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34786. return
  34787. }
  34788. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34789. if status == "0" {
  34790. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34791. c.ServeSuccessJSON(map[string]interface{}{
  34792. "failed_code": -10,
  34793. "msg": err_msg,
  34794. })
  34795. return
  34796. }
  34797. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34798. userJSONBytes3, _ := json.Marshal(respJSON3)
  34799. fmt.Println("log")
  34800. fmt.Println(string(userJSONBytes3))
  34801. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34802. utils.ErrorLog("解析失败:%v", err)
  34803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34804. return
  34805. }
  34806. fmt.Println(res2.Infcode)
  34807. if res2.Infcode == -1 {
  34808. c.ServeSuccessJSON(map[string]interface{}{
  34809. "failed_code": -10,
  34810. "msg": res2.ErrMsg,
  34811. })
  34812. return
  34813. }
  34814. if res2.Infcode == 0 {
  34815. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34816. if err == nil {
  34817. c.ServeSuccessJSON(map[string]interface{}{
  34818. "msg": "撤销明细成功",
  34819. })
  34820. return
  34821. } else {
  34822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34823. return
  34824. }
  34825. } else {
  34826. c.ServeSuccessJSON(map[string]interface{}{
  34827. "failed_code": -10,
  34828. "msg": res2.ErrMsg,
  34829. })
  34830. }
  34831. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34832. if err == nil {
  34833. c.ServeSuccessJSON(map[string]interface{}{
  34834. "msg": "撤销明细成功",
  34835. })
  34836. return
  34837. } else {
  34838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34839. return
  34840. }
  34841. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34842. var resSix10265 ResultSix10265
  34843. new_chrg_bchno := order.Number
  34844. if adminUser.CurrentOrgId == 10265 {
  34845. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  34846. new_chrg_bchno = "0000"
  34847. }
  34848. }
  34849. var api3 string
  34850. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  34851. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34852. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34853. resp3, requestErr3 := http.Get(api3)
  34854. if requestErr3 != nil {
  34855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34856. return
  34857. }
  34858. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34859. if ioErr3 != nil {
  34860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34862. return
  34863. }
  34864. var respJSON3 map[string]interface{}
  34865. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34868. return
  34869. }
  34870. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34871. userJSONBytes3, _ := json.Marshal(respJSON3)
  34872. fmt.Println("log")
  34873. fmt.Println(string(userJSONBytes3))
  34874. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34875. utils.ErrorLog("解析失败:%v", err)
  34876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34877. return
  34878. }
  34879. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34880. res2.Output = resSix10265.Output
  34881. res2.ErrMsg = resSix10265.ErrMsg
  34882. res2.Cainfo = resSix10265.Cainfo
  34883. res2.WarnMsg = resSix10265.WarnMsg
  34884. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34885. res2.Infcode = infocode
  34886. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34887. if err == nil {
  34888. c.ServeSuccessJSON(map[string]interface{}{
  34889. "msg": "撤销明细成功",
  34890. })
  34891. return
  34892. } else {
  34893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34894. return
  34895. }
  34896. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34897. 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)
  34898. var dat map[string]interface{}
  34899. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34900. fmt.Println(dat)
  34901. } else {
  34902. fmt.Println(err)
  34903. }
  34904. saveLog(result2, src_request, "2205", "撤销明细")
  34905. userJSONBytes, _ := json.Marshal(dat)
  34906. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34907. utils.ErrorLog("解析失败:%v", err)
  34908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34909. return
  34910. }
  34911. if res2.Infcode == 0 {
  34912. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34913. if err == nil {
  34914. c.ServeSuccessJSON(map[string]interface{}{
  34915. "msg": "撤销明细成功",
  34916. })
  34917. return
  34918. } else {
  34919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34920. return
  34921. }
  34922. } else {
  34923. c.ServeSuccessJSON(map[string]interface{}{
  34924. "failed_code": -10,
  34925. "msg": res2.ErrMsg,
  34926. })
  34927. }
  34928. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34929. 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, "")
  34930. var dat map[string]interface{}
  34931. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34932. fmt.Println(dat)
  34933. } else {
  34934. fmt.Println(err)
  34935. }
  34936. saveLog(result2, src_request, "2205", "撤销明细")
  34937. userJSONBytes, _ := json.Marshal(dat)
  34938. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34939. utils.ErrorLog("解析失败:%v", err)
  34940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34941. return
  34942. }
  34943. if res2.Infcode == 0 {
  34944. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34945. if err == nil {
  34946. c.ServeSuccessJSON(map[string]interface{}{
  34947. "msg": "撤销明细成功",
  34948. })
  34949. return
  34950. } else {
  34951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34952. return
  34953. }
  34954. } else {
  34955. c.ServeSuccessJSON(map[string]interface{}{
  34956. "failed_code": -10,
  34957. "msg": res2.ErrMsg,
  34958. })
  34959. }
  34960. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34961. 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, "")
  34962. var dat map[string]interface{}
  34963. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34964. fmt.Println(dat)
  34965. } else {
  34966. fmt.Println(err)
  34967. }
  34968. saveLog(result2, src_request, "2205", "撤销明细")
  34969. userJSONBytes, _ := json.Marshal(dat)
  34970. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34971. utils.ErrorLog("解析失败:%v", err)
  34972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34973. return
  34974. }
  34975. if res2.Infcode == 0 {
  34976. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34977. if err == nil {
  34978. c.ServeSuccessJSON(map[string]interface{}{
  34979. "msg": "撤销明细成功",
  34980. })
  34981. return
  34982. } else {
  34983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34984. return
  34985. }
  34986. } else {
  34987. c.ServeSuccessJSON(map[string]interface{}{
  34988. "failed_code": -10,
  34989. "msg": res2.ErrMsg,
  34990. })
  34991. }
  34992. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34993. 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, "")
  34994. var dat map[string]interface{}
  34995. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34996. fmt.Println(dat)
  34997. } else {
  34998. fmt.Println(err)
  34999. }
  35000. saveLog(result2, src_request, "2205", "撤销明细")
  35001. userJSONBytes, _ := json.Marshal(dat)
  35002. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35003. utils.ErrorLog("解析失败:%v", err)
  35004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35005. return
  35006. }
  35007. if res2.Infcode == 0 {
  35008. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35009. if err == nil {
  35010. c.ServeSuccessJSON(map[string]interface{}{
  35011. "msg": "撤销明细成功",
  35012. })
  35013. return
  35014. } else {
  35015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35016. return
  35017. }
  35018. } else {
  35019. c.ServeSuccessJSON(map[string]interface{}{
  35020. "failed_code": -10,
  35021. "msg": res2.ErrMsg,
  35022. })
  35023. }
  35024. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35025. 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, "")
  35026. var dat map[string]interface{}
  35027. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35028. fmt.Println(dat)
  35029. } else {
  35030. fmt.Println(err)
  35031. }
  35032. saveLog(result2, src_request, "2205", "撤销明细")
  35033. userJSONBytes, _ := json.Marshal(dat)
  35034. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35035. utils.ErrorLog("解析失败:%v", err)
  35036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35037. return
  35038. }
  35039. if res2.Infcode == 0 {
  35040. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35041. if err == nil {
  35042. c.ServeSuccessJSON(map[string]interface{}{
  35043. "msg": "撤销明细成功",
  35044. })
  35045. return
  35046. } else {
  35047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35048. return
  35049. }
  35050. } else {
  35051. c.ServeSuccessJSON(map[string]interface{}{
  35052. "failed_code": -10,
  35053. "msg": res2.ErrMsg,
  35054. })
  35055. }
  35056. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35057. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  35058. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35059. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35060. resp2, requestErr2 := http.Get(api2)
  35061. if requestErr2 != nil {
  35062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35063. return
  35064. }
  35065. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35066. if ioErr2 != nil {
  35067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35069. return
  35070. }
  35071. var respJSON2 map[string]interface{}
  35072. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35075. return
  35076. }
  35077. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35078. userJSONBytes3, _ := json.Marshal(respJSON2)
  35079. fmt.Println("log")
  35080. fmt.Println(string(userJSONBytes3))
  35081. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35082. utils.ErrorLog("解析失败:%v", err)
  35083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35084. return
  35085. }
  35086. if res2.Infcode == 0 {
  35087. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35088. if err == nil {
  35089. c.ServeSuccessJSON(map[string]interface{}{
  35090. "msg": "撤销明细成功",
  35091. })
  35092. return
  35093. } else {
  35094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35095. return
  35096. }
  35097. } else {
  35098. c.ServeSuccessJSON(map[string]interface{}{
  35099. "failed_code": -10,
  35100. "msg": res2.ErrMsg,
  35101. })
  35102. }
  35103. } else {
  35104. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  35105. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35106. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35107. resp2, requestErr2 := http.Get(api2)
  35108. if requestErr2 != nil {
  35109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35110. return
  35111. }
  35112. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35113. if ioErr2 != nil {
  35114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35116. return
  35117. }
  35118. var respJSON2 map[string]interface{}
  35119. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35122. return
  35123. }
  35124. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35125. userJSONBytes3, _ := json.Marshal(respJSON2)
  35126. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35127. utils.ErrorLog("解析失败:%v", err)
  35128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35129. return
  35130. }
  35131. if res2.Infcode == -1 {
  35132. c.ServeSuccessJSON(map[string]interface{}{
  35133. "failed_code": -10,
  35134. "msg": res2.ErrMsg,
  35135. })
  35136. return
  35137. } else {
  35138. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35139. if err == nil {
  35140. c.ServeSuccessJSON(map[string]interface{}{
  35141. "msg": "撤销明细成功",
  35142. })
  35143. return
  35144. } else {
  35145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35146. return
  35147. }
  35148. }
  35149. }
  35150. } else {
  35151. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35152. if err == nil {
  35153. c.ServeSuccessJSON(map[string]interface{}{
  35154. "msg": "退费成功",
  35155. })
  35156. } else {
  35157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35158. return
  35159. }
  35160. }
  35161. }
  35162. // 对账
  35163. func (c *HisApiController) GetCheckAccount() {
  35164. start_time := c.GetString("start_time")
  35165. end_time := c.GetString("end_time")
  35166. insutype := c.GetString("insutype")
  35167. clr_type := c.GetString("clr_type")
  35168. clr_org := c.GetString("clr_optins")
  35169. admin_user_id, _ := c.GetInt64("admin_user_id")
  35170. adminUser := c.GetAdminUserInfo()
  35171. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35172. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35173. if len(clr_org) == 0 {
  35174. clr_org = miConfig.InsuplcAdmdvs
  35175. }
  35176. timeLayout := "2006-01-02"
  35177. loc, _ := time.LoadLocation("Local")
  35178. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35179. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35180. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35181. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35182. fixmedins_setl_cnt := int64(len(orders))
  35183. var medfee_sumamt float64
  35184. var acct_pay float64
  35185. var fund_pay_sumamt float64
  35186. for _, item := range orders {
  35187. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35188. acct_pay = acct_pay + item.AcctPay
  35189. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  35190. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  35191. } else {
  35192. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35193. }
  35194. }
  35195. var user_name string
  35196. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35197. if role.ID == 0 {
  35198. user_name = "xxx"
  35199. } else {
  35200. user_name = role.UserName
  35201. }
  35202. var res ResultEight
  35203. var res10188 ResultEightFor10188
  35204. if config.IsOpen == 1 {
  35205. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  35206. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  35207. "insutype=" + insutype +
  35208. "&clr_type=" + clr_type +
  35209. "&setl_optins=" + clr_org +
  35210. "&stmt_begndate=" + start_time +
  35211. "&stm_enddate=" + end_time +
  35212. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35213. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35214. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35215. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35216. "&fixmedins_code=" + miConfig.Code +
  35217. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35218. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35219. "&secret_key=" + miConfig.SecretKey +
  35220. "&org_name=" + miConfig.OrgName +
  35221. "&doctor=" + user_name +
  35222. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35223. fmt.Println(api)
  35224. resp, requestErr := http.Get(api)
  35225. if requestErr != nil {
  35226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35227. return
  35228. }
  35229. body, ioErr := ioutil.ReadAll(resp.Body)
  35230. fmt.Println(body)
  35231. if ioErr != nil {
  35232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35234. return
  35235. }
  35236. var respJSON map[string]interface{}
  35237. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35240. return
  35241. }
  35242. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35243. userJSONBytes, _ := json.Marshal(respJSON)
  35244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35245. utils.ErrorLog("解析失败:%v", err)
  35246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35247. return
  35248. }
  35249. res.InfRefmsgid = res10188.InfRefmsgid
  35250. res.Output = res10188.Output
  35251. res.ErrMsg = res10188.ErrMsg
  35252. res.Cainfo = res10188.Cainfo
  35253. res.WarnMsg = res10188.WarnMsg
  35254. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35255. res.Infcode = infocode
  35256. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35257. if clr_type != "9903" {
  35258. clr_type = "99" // 就诊 ID(来自2201接口返回)
  35259. }
  35260. if clr_type == "9903" {
  35261. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  35262. }
  35263. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  35264. "insutype=" + insutype +
  35265. "&clr_type=" + clr_type +
  35266. "&setl_optins=" + clr_org +
  35267. "&stmt_begndate=" + start_time +
  35268. "&stm_enddate=" + end_time +
  35269. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35270. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35271. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35272. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35273. "&fixmedins_code=" + miConfig.Code +
  35274. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35275. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35276. "&secret_key=" + miConfig.SecretKey +
  35277. "&org_name=" + miConfig.OrgName +
  35278. "&doctor=" + user_name
  35279. resp, requestErr := http.Get(api)
  35280. if requestErr != nil {
  35281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35282. return
  35283. }
  35284. body, ioErr := ioutil.ReadAll(resp.Body)
  35285. if ioErr != nil {
  35286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35288. return
  35289. }
  35290. var respJSON map[string]interface{}
  35291. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35294. return
  35295. }
  35296. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35297. result, _ := json.Marshal(respJSON)
  35298. fmt.Println("log")
  35299. fmt.Println(string(result))
  35300. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  35301. utils.ErrorLog("解析失败:%v", err)
  35302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35303. return
  35304. }
  35305. res.InfRefmsgid = res10188.InfRefmsgid
  35306. res.Output = res10188.Output
  35307. res.ErrMsg = res10188.ErrMsg
  35308. res.Cainfo = res10188.Cainfo
  35309. res.WarnMsg = res10188.WarnMsg
  35310. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35311. res.Infcode = infocode
  35312. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35313. var baseParams models.BaseParams
  35314. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35315. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35316. baseParams.SecretKey = miConfig.SecretKey
  35317. baseParams.OrgName = miConfig.OrgName
  35318. baseParams.FixmedinsCode = miConfig.Code
  35319. baseParams.EncKey = miConfig.EncKey
  35320. baseParams.AppSecret = miConfig.AppSecret
  35321. baseParams.SignKey = miConfig.SignKey
  35322. baseParams.AppID = miConfig.Code
  35323. baseParams.Doctor = role.UserName
  35324. baseParams.RequestUrl = miConfig.Url
  35325. businessParams := models.BusinessParams{
  35326. Insutype: insutype,
  35327. ClrType: clr_type,
  35328. SetlOptins: clr_org,
  35329. StmtBegndate: start_time,
  35330. StmtEnddate: end_time,
  35331. MedfeeSumamt: medfee_sumamt,
  35332. FundPaySumamt: fund_pay_sumamt,
  35333. AcctPay: acct_pay,
  35334. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35335. }
  35336. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35337. fmt.Println(requestLog)
  35338. fmt.Println(result)
  35339. fmt.Println(err_msg)
  35340. var dat map[string]interface{}
  35341. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35342. fmt.Println(dat)
  35343. } else {
  35344. fmt.Println(err)
  35345. }
  35346. userJSONBytes, _ := json.Marshal(dat)
  35347. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35348. utils.ErrorLog("解析失败:%v", err)
  35349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35350. return
  35351. }
  35352. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35353. var baseParams models.BaseParams
  35354. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35355. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35356. baseParams.SecretKey = miConfig.SecretKey
  35357. baseParams.OrgName = miConfig.OrgName
  35358. baseParams.FixmedinsCode = miConfig.Code
  35359. baseParams.EncKey = miConfig.EncKey
  35360. baseParams.AppSecret = miConfig.AppSecret
  35361. baseParams.SignKey = miConfig.SignKey
  35362. baseParams.AppID = miConfig.Code
  35363. baseParams.Doctor = role.UserName
  35364. baseParams.RequestUrl = miConfig.Url
  35365. baseParams.AccessKey = miConfig.AccessKey
  35366. businessParams := models.BusinessParams{
  35367. Insutype: insutype,
  35368. ClrType: clr_type,
  35369. SetlOptins: "430822",
  35370. StmtBegndate: start_time,
  35371. StmtEnddate: end_time,
  35372. MedfeeSumamt: medfee_sumamt,
  35373. FundPaySumamt: fund_pay_sumamt,
  35374. AcctPay: acct_pay,
  35375. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35376. }
  35377. 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)
  35378. fmt.Println(requestLog)
  35379. fmt.Println(result)
  35380. var dat map[string]interface{}
  35381. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35382. fmt.Println(dat)
  35383. } else {
  35384. fmt.Println(err)
  35385. }
  35386. userJSONBytes, _ := json.Marshal(dat)
  35387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35388. utils.ErrorLog("解析失败:%v", err)
  35389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35390. return
  35391. }
  35392. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35393. var baseParams models.BaseParams
  35394. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35395. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35396. baseParams.SecretKey = miConfig.SecretKey
  35397. baseParams.OrgName = miConfig.OrgName
  35398. baseParams.FixmedinsCode = miConfig.Code
  35399. baseParams.EncKey = miConfig.EncKey
  35400. baseParams.AppSecret = miConfig.AppSecret
  35401. baseParams.SignKey = miConfig.SignKey
  35402. baseParams.AppID = miConfig.Code
  35403. baseParams.Doctor = role.UserName
  35404. baseParams.RequestUrl = miConfig.Url
  35405. businessParams := models.BusinessParams{
  35406. Insutype: insutype,
  35407. ClrType: clr_type,
  35408. SetlOptins: clr_org,
  35409. StmtBegndate: start_time,
  35410. StmtEnddate: end_time,
  35411. MedfeeSumamt: medfee_sumamt,
  35412. FundPaySumamt: fund_pay_sumamt,
  35413. AcctPay: acct_pay,
  35414. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35415. }
  35416. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35417. fmt.Println(requestLog)
  35418. fmt.Println(result)
  35419. fmt.Println(err_msg)
  35420. var dat map[string]interface{}
  35421. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35422. fmt.Println(dat)
  35423. } else {
  35424. fmt.Println(err)
  35425. }
  35426. userJSONBytes, _ := json.Marshal(dat)
  35427. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35428. utils.ErrorLog("解析失败:%v", err)
  35429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35430. return
  35431. }
  35432. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35433. if len(clr_type) == 0 {
  35434. clr_type = "11"
  35435. }
  35436. api := miConfig.Url + "gdyb/ten?" +
  35437. "insutype=" + insutype +
  35438. "&clr_type=" + clr_type +
  35439. "&setl_optins=" + clr_org +
  35440. "&stmt_begndate=" + start_time +
  35441. "&stm_enddate=" + end_time +
  35442. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35443. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35444. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35445. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35446. "&fixmedins_code=" + miConfig.Code +
  35447. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35448. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35449. "&secret_key=" + miConfig.SecretKey +
  35450. "&org_name=" + miConfig.OrgName +
  35451. "&doctor=" + user_name
  35452. fmt.Println(api)
  35453. resp, requestErr := http.Get(api)
  35454. if requestErr != nil {
  35455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35456. return
  35457. }
  35458. body, ioErr := ioutil.ReadAll(resp.Body)
  35459. fmt.Println(body)
  35460. if ioErr != nil {
  35461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35463. return
  35464. }
  35465. var respJSON map[string]interface{}
  35466. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35469. return
  35470. }
  35471. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35472. userJSONBytes, _ := json.Marshal(respJSON)
  35473. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35474. utils.ErrorLog("解析失败:%v", err)
  35475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35476. return
  35477. }
  35478. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35479. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35480. //fixmedins_setl_cnt := int64(len(orders_two))
  35481. //var medfee_sumamt float64
  35482. //var acct_pay float64
  35483. //var fund_pay_sumamt float64
  35484. //for _, item := range orders_two {
  35485. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35486. // acct_pay = acct_pay + item.AcctPay
  35487. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35488. //}
  35489. var baseParams models.BaseParams
  35490. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35491. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35492. baseParams.SecretKey = miConfig.SecretKey
  35493. baseParams.OrgName = miConfig.OrgName
  35494. baseParams.FixmedinsCode = miConfig.Code
  35495. baseParams.EncKey = miConfig.EncKey
  35496. baseParams.AppSecret = miConfig.AppSecret
  35497. baseParams.SignKey = miConfig.SignKey
  35498. baseParams.AppID = miConfig.Code
  35499. baseParams.Doctor = role.UserName
  35500. baseParams.RequestUrl = miConfig.Url
  35501. if clr_type == "9903" {
  35502. clr_type = "9901"
  35503. }
  35504. businessParams := models.BusinessParams{
  35505. Insutype: insutype,
  35506. ClrType: clr_type,
  35507. SetlOptins: "360302",
  35508. StmtBegndate: start_time,
  35509. StmtEnddate: end_time,
  35510. MedfeeSumamt: 0,
  35511. FundPaySumamt: 0,
  35512. AcctPay: 0,
  35513. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35514. }
  35515. 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))
  35516. fmt.Println(requestLog)
  35517. fmt.Println(result)
  35518. var dat map[string]interface{}
  35519. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35520. fmt.Println(dat)
  35521. } else {
  35522. fmt.Println(err)
  35523. }
  35524. userJSONBytes, _ := json.Marshal(dat)
  35525. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35526. utils.ErrorLog("解析失败:%v", err)
  35527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35528. return
  35529. }
  35530. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35531. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35532. //fixmedins_setl_cnt := int64(len(orders_two))
  35533. //var medfee_sumamt float64
  35534. //var acct_pay float64
  35535. //var fund_pay_sumamt float64
  35536. //for _, item := range orders_two {
  35537. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35538. // acct_pay = acct_pay + item.AcctPay
  35539. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35540. //}
  35541. var baseParams models.BaseParams
  35542. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35543. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35544. baseParams.SecretKey = miConfig.SecretKey
  35545. baseParams.OrgName = miConfig.OrgName
  35546. baseParams.FixmedinsCode = miConfig.Code
  35547. baseParams.EncKey = miConfig.EncKey
  35548. baseParams.AppSecret = miConfig.AppSecret
  35549. baseParams.SignKey = miConfig.SignKey
  35550. baseParams.AppID = miConfig.Code
  35551. baseParams.Doctor = role.UserName
  35552. baseParams.RequestUrl = miConfig.Url
  35553. if clr_type == "9903" {
  35554. clr_type = "9994"
  35555. }
  35556. businessParams := models.BusinessParams{
  35557. Insutype: insutype,
  35558. ClrType: clr_type,
  35559. SetlOptins: "361025",
  35560. StmtBegndate: start_time,
  35561. StmtEnddate: end_time,
  35562. MedfeeSumamt: 0,
  35563. FundPaySumamt: 0,
  35564. AcctPay: 0,
  35565. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35566. }
  35567. 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))
  35568. fmt.Println(requestLog)
  35569. fmt.Println(result)
  35570. var dat map[string]interface{}
  35571. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35572. fmt.Println(dat)
  35573. } else {
  35574. fmt.Println(err)
  35575. }
  35576. userJSONBytes, _ := json.Marshal(dat)
  35577. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35578. utils.ErrorLog("解析失败:%v", err)
  35579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35580. return
  35581. }
  35582. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35583. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35584. //fixmedins_setl_cnt := int64(len(orders_two))
  35585. //var medfee_sumamt float64
  35586. //var acct_pay float64
  35587. //var fund_pay_sumamt float64
  35588. //for _, item := range orders_two {
  35589. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35590. // acct_pay = acct_pay + item.AcctPay
  35591. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35592. //}
  35593. var baseParams models.BaseParams
  35594. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35595. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35596. baseParams.SecretKey = miConfig.SecretKey
  35597. baseParams.OrgName = miConfig.OrgName
  35598. baseParams.FixmedinsCode = miConfig.Code
  35599. baseParams.EncKey = miConfig.EncKey
  35600. baseParams.AppSecret = miConfig.AppSecret
  35601. baseParams.SignKey = miConfig.SignKey
  35602. baseParams.AppID = miConfig.Code
  35603. baseParams.Doctor = role.UserName
  35604. baseParams.RequestUrl = miConfig.Url
  35605. if clr_type == "9903" {
  35606. clr_type = "9994"
  35607. }
  35608. businessParams := models.BusinessParams{
  35609. Insutype: insutype,
  35610. ClrType: clr_type,
  35611. SetlOptins: "360100",
  35612. StmtBegndate: start_time,
  35613. StmtEnddate: end_time,
  35614. MedfeeSumamt: 0,
  35615. FundPaySumamt: 0,
  35616. AcctPay: 0,
  35617. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35618. }
  35619. 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))
  35620. fmt.Println(requestLog)
  35621. fmt.Println(result)
  35622. var dat map[string]interface{}
  35623. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35624. fmt.Println(dat)
  35625. } else {
  35626. fmt.Println(err)
  35627. }
  35628. userJSONBytes, _ := json.Marshal(dat)
  35629. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35630. utils.ErrorLog("解析失败:%v", err)
  35631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35632. return
  35633. }
  35634. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35635. var api string
  35636. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35637. "&clr_type=" + clr_type +
  35638. "&setl_optins=" + clr_org +
  35639. "&stmt_begndate=" + start_time +
  35640. "&stm_enddate=" + end_time +
  35641. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35642. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35643. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35644. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35645. "&fixmedins_code=" + miConfig.Code +
  35646. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35647. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35648. "&secret_key=" + miConfig.SecretKey +
  35649. "&org_name=" + miConfig.OrgName +
  35650. "&doctor=" + user_name + "&url=" + miConfig.Url
  35651. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35652. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35653. resp, requestErr := http.Get(api)
  35654. if requestErr != nil {
  35655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35656. return
  35657. }
  35658. body, ioErr := ioutil.ReadAll(resp.Body)
  35659. if ioErr != nil {
  35660. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35662. return
  35663. }
  35664. var respJSON map[string]interface{}
  35665. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35668. return
  35669. }
  35670. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35671. if status == "0" {
  35672. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35673. c.ServeSuccessJSON(map[string]interface{}{
  35674. "failed_code": -10,
  35675. "msg": err_msg,
  35676. })
  35677. return
  35678. }
  35679. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35680. userJSONBytes, _ := json.Marshal(respJSON)
  35681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35682. utils.ErrorLog("解析失败:%v", err)
  35683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35684. return
  35685. }
  35686. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35687. var api string
  35688. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35689. "&clr_type=" + clr_type +
  35690. "&setl_optins=" + clr_org +
  35691. "&stmt_begndate=" + start_time +
  35692. "&stm_enddate=" + end_time +
  35693. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35694. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35695. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35696. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35697. "&fixmedins_code=" + miConfig.Code +
  35698. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35699. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35700. "&secret_key=" + miConfig.SecretKey +
  35701. "&org_name=" + miConfig.OrgName +
  35702. "&doctor=" + user_name + "&url=" + miConfig.Url
  35703. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35704. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35705. resp, requestErr := http.Get(api)
  35706. if requestErr != nil {
  35707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35708. return
  35709. }
  35710. body, ioErr := ioutil.ReadAll(resp.Body)
  35711. if ioErr != nil {
  35712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35714. return
  35715. }
  35716. var respJSON map[string]interface{}
  35717. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35720. return
  35721. }
  35722. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35723. if status == "0" {
  35724. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35725. c.ServeSuccessJSON(map[string]interface{}{
  35726. "failed_code": -10,
  35727. "msg": err_msg,
  35728. })
  35729. return
  35730. }
  35731. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35732. userJSONBytes, _ := json.Marshal(respJSON)
  35733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35734. utils.ErrorLog("解析失败:%v", err)
  35735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35736. return
  35737. }
  35738. } else {
  35739. if len(clr_type) == 0 {
  35740. clr_type = "11"
  35741. }
  35742. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35743. "insutype=" + insutype +
  35744. "&clr_type=" + clr_type +
  35745. "&setl_optins=" + clr_org +
  35746. "&stmt_begndate=" + start_time +
  35747. "&stm_enddate=" + end_time +
  35748. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35749. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35750. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35751. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35752. "&fixmedins_code=" + miConfig.Code +
  35753. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35754. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35755. "&secret_key=" + miConfig.SecretKey +
  35756. "&org_name=" + miConfig.OrgName +
  35757. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35758. fmt.Println(api)
  35759. resp, requestErr := http.Get(api)
  35760. if requestErr != nil {
  35761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35762. return
  35763. }
  35764. body, ioErr := ioutil.ReadAll(resp.Body)
  35765. fmt.Println(body)
  35766. if ioErr != nil {
  35767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35769. return
  35770. }
  35771. var respJSON map[string]interface{}
  35772. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35775. return
  35776. }
  35777. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35778. userJSONBytes, _ := json.Marshal(respJSON)
  35779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35780. utils.ErrorLog("解析失败:%v", err)
  35781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35782. return
  35783. }
  35784. }
  35785. if res.Infcode == 0 {
  35786. if res.Output.Stmtinfo.StmtRslt == "0" {
  35787. micc := &models.MedicalInsuranceCostCompare{
  35788. StartTime: startime.Unix(),
  35789. EndTime: endtime.Unix(),
  35790. Insutype: insutype,
  35791. CheckType: 1,
  35792. Num: fixmedins_setl_cnt,
  35793. Mtime: time.Now().Unix(),
  35794. Status: 1,
  35795. UserOrgId: adminUser.CurrentOrgId,
  35796. CostTotal: medfee_sumamt,
  35797. FuncTotal: fund_pay_sumamt,
  35798. PsnPay: acct_pay,
  35799. Creator: admin_user_id,
  35800. Ctime: time.Now().Unix(),
  35801. ClrType: clr_type,
  35802. }
  35803. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  35804. if err == nil {
  35805. c.ServeSuccessJSON(map[string]interface{}{
  35806. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35807. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35808. })
  35809. } else {
  35810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35811. }
  35812. } else {
  35813. c.ServeSuccessJSON(map[string]interface{}{
  35814. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35815. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35816. })
  35817. }
  35818. } else {
  35819. c.ServeSuccessJSON(map[string]interface{}{
  35820. "failed_code": -10,
  35821. "msg": res.ErrMsg,
  35822. })
  35823. }
  35824. }
  35825. }
  35826. func (c *HisApiController) Check310() {
  35827. adminUser := c.GetAdminUserInfo()
  35828. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35829. var user_name string
  35830. user_name = "高慧裕"
  35831. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35832. "insutype=" + "310" +
  35833. "&clr_type=" + "" +
  35834. "&setl_optins=" + "441202" +
  35835. "&stmt_begndate=" + "2022-03-01" +
  35836. "&stm_enddate=" + "2022-03-31" +
  35837. "&medfee_sumamt=" + "194930.12" +
  35838. "&fund_pay_sumamt=" + "188741.46" +
  35839. "&acct_pay=" + "0" +
  35840. "&fixmedins_setl_cnt=" + "452" +
  35841. "&fixmedins_code=" + miConfig.Code +
  35842. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35843. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35844. "&secret_key=" + miConfig.SecretKey +
  35845. "&org_name=" + miConfig.OrgName +
  35846. "&doctor=" + user_name
  35847. fmt.Println(api)
  35848. resp, requestErr := http.Get(api)
  35849. if requestErr != nil {
  35850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35851. return
  35852. }
  35853. body, ioErr := ioutil.ReadAll(resp.Body)
  35854. fmt.Println(body)
  35855. if ioErr != nil {
  35856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35858. return
  35859. }
  35860. var respJSON map[string]interface{}
  35861. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35864. return
  35865. }
  35866. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35867. userJSONBytes, _ := json.Marshal(respJSON)
  35868. var res ResultEight
  35869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35870. utils.ErrorLog("解析失败:%v", err)
  35871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35872. return
  35873. }
  35874. }
  35875. func (c *HisApiController) Check390() {
  35876. adminUser := c.GetAdminUserInfo()
  35877. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35878. var user_name string
  35879. user_name = "高慧裕"
  35880. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35881. "insutype=" + "390" +
  35882. "&clr_type=" + "" +
  35883. "&setl_optins=" + "441202" +
  35884. "&stmt_begndate=" + "2022-03-01" +
  35885. "&stm_enddate=" + "2022-03-31" +
  35886. "&medfee_sumamt=" + "1068448.89" +
  35887. "&fund_pay_sumamt=" + "1014677.62" +
  35888. "&acct_pay=" + "0" +
  35889. "&fixmedins_setl_cnt=" + "1950" +
  35890. "&fixmedins_code=" + miConfig.Code +
  35891. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35892. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35893. "&secret_key=" + miConfig.SecretKey +
  35894. "&org_name=" + miConfig.OrgName +
  35895. "&doctor=" + user_name
  35896. fmt.Println(api)
  35897. resp, requestErr := http.Get(api)
  35898. if requestErr != nil {
  35899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35900. return
  35901. }
  35902. body, ioErr := ioutil.ReadAll(resp.Body)
  35903. fmt.Println(body)
  35904. if ioErr != nil {
  35905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35907. return
  35908. }
  35909. var respJSON map[string]interface{}
  35910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35913. return
  35914. }
  35915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35916. userJSONBytes, _ := json.Marshal(respJSON)
  35917. var res ResultEight
  35918. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35919. utils.ErrorLog("解析失败:%v", err)
  35920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35921. return
  35922. }
  35923. }
  35924. // 对账明细
  35925. func (c *HisApiController) GetCheckDetailAccount() {
  35926. start_time := c.GetString("start_time")
  35927. end_time := c.GetString("end_time")
  35928. admin_user_id, _ := c.GetInt64("admin_user_id")
  35929. adminUser := c.GetAdminUserInfo()
  35930. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35931. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35932. timeLayout := "2006-01-02"
  35933. loc, _ := time.LoadLocation("Local")
  35934. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35935. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35936. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35937. rand.Seed(time.Now().UnixNano())
  35938. num := rand.Intn(30000)
  35939. Mkdir(miConfig.OrgName)
  35940. file := strconv.FormatInt(int64(num), 10)
  35941. file_name := file + ".txt"
  35942. zip_name := file + ".zip"
  35943. zip_path := miConfig.OrgName + "/" + zip_name
  35944. file_path := miConfig.OrgName + "/" + file_name
  35945. decimal.DivisionPrecision = 2
  35946. var medfee_sumamt float64
  35947. var psn_cash_pay float64
  35948. var fund_pay_sumamt float64
  35949. fixmedins_setl_cnt := int64(len(orders))
  35950. for _, item := range orders {
  35951. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35952. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  35953. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35954. }
  35955. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  35956. defer f.Close()
  35957. if err != nil {
  35958. fmt.Println(err.Error())
  35959. } else {
  35960. for _, item := range orders {
  35961. var refd_setl_flag string
  35962. if item.OrderStatus == 2 {
  35963. refd_setl_flag = "0"
  35964. var str string
  35965. str = item.SetlId + " " +
  35966. item.MdtrtId + " " +
  35967. item.PsnNo + " " +
  35968. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35969. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35970. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  35971. _, err = f.Write([]byte(str))
  35972. }
  35973. if item.OrderStatus == 3 {
  35974. var str string
  35975. str = item.SetlId + " " +
  35976. item.MdtrtId + " " +
  35977. item.PsnNo + " " +
  35978. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35979. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35980. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  35981. _, err = f.Write([]byte(str))
  35982. var str2 string
  35983. str2 = item.SetlId + " " +
  35984. item.MdtrtId + " " +
  35985. item.PsnNo + " " +
  35986. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  35987. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  35988. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  35989. _, err = f.Write([]byte(str2))
  35990. }
  35991. }
  35992. }
  35993. Zip(file_path, zip_path)
  35994. fmt.Println(ReadFile(zip_path))
  35995. fmt.Println(string(ReadFile(zip_path)))
  35996. if config.IsOpen == 1 {
  35997. var user_name string
  35998. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35999. if role.ID == 0 {
  36000. user_name = "管理员"
  36001. } else {
  36002. user_name = role.UserName
  36003. }
  36004. baseParams := models.BaseParams{
  36005. SecretKey: miConfig.SecretKey,
  36006. FixmedinsCode: miConfig.Code,
  36007. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36008. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36009. OrgName: miConfig.OrgName,
  36010. Doctor: user_name,
  36011. }
  36012. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  36013. var dat map[string]interface{}
  36014. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36015. fmt.Println(dat)
  36016. } else {
  36017. fmt.Println(err)
  36018. }
  36019. userJSONBytes, _ := json.Marshal(dat)
  36020. var res ResultNine
  36021. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36022. utils.ErrorLog("解析失败:%v", err)
  36023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36024. return
  36025. }
  36026. if res.Infcode == 0 {
  36027. fileNo := res.Output.FileQuryNo
  36028. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  36029. "file_qury_no=" + fileNo +
  36030. "&setl_optins=" + "定点医保中心" +
  36031. "&stmt_begndate=" + start_time +
  36032. "&stm_enddate=" + end_time +
  36033. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36034. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36035. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  36036. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  36037. "&fixmedins_code=" + miConfig.Code +
  36038. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36039. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36040. "&secret_key=" + miConfig.SecretKey +
  36041. "&org_name=" + miConfig.OrgName +
  36042. "&doctor=" + user_name
  36043. resp, requestErr := http.Get(api)
  36044. if requestErr != nil {
  36045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36046. return
  36047. }
  36048. body, ioErr := ioutil.ReadAll(resp.Body)
  36049. if ioErr != nil {
  36050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36052. return
  36053. }
  36054. var respJSON map[string]interface{}
  36055. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36058. return
  36059. }
  36060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36061. userJSONBytes, _ := json.Marshal(respJSON)
  36062. var res ResultTen
  36063. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36064. utils.ErrorLog("解析失败:%v", err)
  36065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36066. return
  36067. }
  36068. if res.Infcode == 0 {
  36069. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  36070. micc := &models.MedicalInsuranceCostCompare{
  36071. StartTime: startime.Unix(),
  36072. EndTime: endtime.Unix(),
  36073. Insutype: "0",
  36074. CheckType: 2,
  36075. Num: fixmedins_setl_cnt,
  36076. Mtime: time.Now().Unix(),
  36077. Status: 1,
  36078. UserOrgId: adminUser.CurrentOrgId,
  36079. CostTotal: medfee_sumamt,
  36080. FuncTotal: fund_pay_sumamt,
  36081. PsnPay: psn_cash_pay,
  36082. Creator: admin_user_id,
  36083. Ctime: time.Now().Unix(),
  36084. }
  36085. service.CreateMedicalInsuranceCostCompareRecord(micc)
  36086. c.ServeSuccessJSON(map[string]interface{}{
  36087. "msg": "明细对账成功",
  36088. })
  36089. }
  36090. } else {
  36091. }
  36092. }
  36093. }
  36094. type CustomOrderInfo struct {
  36095. Name string
  36096. Spec string
  36097. Unit string
  36098. Count float64
  36099. Price float64
  36100. Total float64
  36101. }
  36102. func (c *HisApiController) GetBatchSettleAccounts() {
  36103. admin_user_id, _ := c.GetInt64("admin_user_id")
  36104. order_ids := c.GetString("order_ids")
  36105. order_ids_arr := strings.Split(order_ids, ",")
  36106. data3 := []map[string]interface{}{}
  36107. for _, item := range order_ids_arr {
  36108. id, _ := strconv.ParseInt(item, 10, 64)
  36109. order_id := id
  36110. adminUser := c.GetAdminUserInfo()
  36111. order, _ := service.GetHisOrderByID(order_id)
  36112. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36113. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36114. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36115. orderInfos = append(orderInfos, orderInfos_two...)
  36116. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36117. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36118. var diagnosis_ids []string
  36119. if his.ID > 0 {
  36120. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36121. } else {
  36122. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36123. }
  36124. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36125. var dia_config []*models.HisXtDiagnoseConfig
  36126. var name string
  36127. for _, item := range diagnosis_ids {
  36128. id, _ := strconv.ParseInt(item, 10, 64)
  36129. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36130. dia_config = append(dia_config, &diagnosisConfig)
  36131. if len(name) == 0 {
  36132. name = diagnosisConfig.ClassName
  36133. }
  36134. //} else {
  36135. // name = name + "," + diagnosisConfig.ClassName
  36136. //}
  36137. }
  36138. var bedCostTotal float64 = 0 //床位总费
  36139. var bedCostSelfTotal float64 = 0 //床位自费
  36140. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36141. var bedSelfTotal float64 = 0 //床位部分项目自费
  36142. var bedInscpTotal float64 = 0 //床位部分项目自费
  36143. var operationCostTotal float64 = 0 //手术费
  36144. var operationCostSelfTotal float64 = 0 //手术费
  36145. var operationCostPartSelfTotal float64 = 0 //手术费
  36146. var operationSelfTotal float64 = 0 //床位部分项目自费
  36147. var operationInscpTotal float64 = 0 //床位部分项目自费
  36148. var otherCostTotal float64 = 0 //其他费用
  36149. var otherCostSelfTotal float64 = 0 //其他费用
  36150. var otherCostPartSelfTotal float64 = 0 //其他费用
  36151. var otherSelfTotal float64 = 0 //床位部分项目自费
  36152. var otherInscpTotal float64 = 0 //床位部分项目自费
  36153. var materialCostTotal float64 = 0 //材料费
  36154. var materialCostSelfTotal float64 = 0 //材料费
  36155. var materialCostPartSelfTotal float64 = 0 //材料费
  36156. var materialSelfTotal float64 = 0 //床位部分项目自费
  36157. var materialInscpTotal float64 = 0 //床位部分项目自费
  36158. var westernMedicineCostTotal float64 = 0 //西药费
  36159. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36160. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36161. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36162. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36163. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36164. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36165. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36166. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36167. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36168. var checkCostTotal float64 = 0 //检查费
  36169. var checkCostSelfTotal float64 = 0 //检查费
  36170. var checkCostPartSelfTotal float64 = 0 //检查费
  36171. var checkSelfTotal float64 = 0 //床位部分项目自费
  36172. var checkInscpTotal float64 = 0 //床位部分项目自费
  36173. var laboratoryCostTotal float64 = 0 //化验费
  36174. var laboratoryCostSelfTotal float64 = 0 //化验费
  36175. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36176. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36177. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36178. var treatCostTotal float64 = 0 //治疗费用
  36179. var treatCostSelfTotal float64 = 0 //治疗费用
  36180. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36181. var treatSelfTotal float64 = 0 //床位部分项目自费
  36182. var treatInscpTotal float64 = 0 //床位部分项目自费
  36183. decimal.DivisionPrecision = 2
  36184. for _, item := range orderInfos {
  36185. if item.MedChrgitmType == "01" { //床位费
  36186. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36187. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36188. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36189. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36190. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36191. }
  36192. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36193. if item.MedChrgitmType == "03" { //检查费
  36194. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36195. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36196. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36197. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36198. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36199. }
  36200. } else {
  36201. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36202. fmt.Println("------------")
  36203. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36204. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36205. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36206. }
  36207. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36208. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36209. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36210. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36211. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36212. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36213. }
  36214. }
  36215. if item.MedChrgitmType == "04" { //化验费
  36216. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36217. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36218. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36219. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36220. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36221. }
  36222. if item.MedChrgitmType == "05" { //治疗费
  36223. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36224. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36225. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36226. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36227. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36228. }
  36229. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36230. fmt.Println("------------")
  36231. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36232. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36233. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36234. }
  36235. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36236. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36237. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36238. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36239. }
  36240. //if item.MedChrgitmType == "06" { //手术费
  36241. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36242. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36243. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36244. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36245. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36246. //
  36247. //}
  36248. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36249. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36250. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36251. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36252. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36253. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36254. }
  36255. if item.MedChrgitmType == "09" { //西药费
  36256. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36257. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36258. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36259. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36260. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36261. }
  36262. if item.MedChrgitmType == "11" { //中成费
  36263. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36264. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36265. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36266. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36267. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36268. }
  36269. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  36270. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36271. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36272. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36273. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36274. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36275. }
  36276. }
  36277. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36278. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36279. var user_name string
  36280. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36281. if role.ID == 0 {
  36282. user_name = "管理员"
  36283. } else {
  36284. user_name = role.UserName
  36285. }
  36286. baseParams := models.BaseParams{
  36287. SecretKey: miConfig.SecretKey,
  36288. FixmedinsCode: miConfig.Code,
  36289. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36290. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36291. OrgName: miConfig.OrgName,
  36292. Doctor: user_name,
  36293. RequestUrl: miConfig.Url,
  36294. AccessKey: miConfig.AccessKey,
  36295. }
  36296. businessParams := models.BusinessParams{
  36297. PsnNo: order.PsnNo,
  36298. MdtrtId: order.MdtrtId,
  36299. SetlId: order.SetlId,
  36300. }
  36301. var res ResultEleven
  36302. var resEleven10265 ResultEleven10265
  36303. if config.IsOpen == 1 {
  36304. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36305. result := service.Gdyb5203(baseParams, businessParams)
  36306. service.Gdyb5204(baseParams, businessParams)
  36307. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36308. var dat map[string]interface{}
  36309. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36310. fmt.Println(dat)
  36311. } else {
  36312. fmt.Println(err)
  36313. }
  36314. userJSONBytes, _ := json.Marshal(dat)
  36315. if miConfig.Code == "H15049901371" {
  36316. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36317. utils.ErrorLog("解析失败:%v", err)
  36318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36319. return
  36320. }
  36321. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36322. res.Output = resEleven10265.Output
  36323. res.ErrMsg = resEleven10265.ErrMsg
  36324. res.Cainfo = resEleven10265.Cainfo
  36325. res.WarnMsg = resEleven10265.WarnMsg
  36326. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36327. res.Infcode = infocode
  36328. } else {
  36329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36330. utils.ErrorLog("解析失败:%v", err)
  36331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36332. return
  36333. }
  36334. }
  36335. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36336. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36337. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36338. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36339. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36340. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36341. var doctor_name string
  36342. if roles.ID == 0 {
  36343. doctor_name = "管理员"
  36344. } else {
  36345. doctor_name = roles.UserName
  36346. }
  36347. yiliao_leibie := ""
  36348. switch order.MedType {
  36349. case "11":
  36350. yiliao_leibie = "普通门诊"
  36351. break
  36352. case "12":
  36353. yiliao_leibie = "门诊挂号"
  36354. break
  36355. case "13":
  36356. yiliao_leibie = "急诊"
  36357. break
  36358. case "14":
  36359. yiliao_leibie = "门诊特殊病"
  36360. break
  36361. case "15":
  36362. yiliao_leibie = "门诊统筹"
  36363. break
  36364. case "16":
  36365. yiliao_leibie = "门诊慢性病"
  36366. break
  36367. case "21":
  36368. yiliao_leibie = "普通住院"
  36369. break
  36370. }
  36371. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36372. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  36373. if res.Infcode == 0 {
  36374. data2 := map[string]interface{}{
  36375. "diagnosis": name,
  36376. "order_infos": orderInfos,
  36377. "number": order.MdtrtId,
  36378. "date": order.SettleAccountsDate,
  36379. "charge_admin": charge_admin,
  36380. "printor_admin": printor_admin,
  36381. "info": res.Output.Setlinfo,
  36382. "order": order,
  36383. "bedCostTotal": bedCostTotal,
  36384. "bedCostSelfTotal": bedCostSelfTotal,
  36385. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36386. "bedSelfTotal": bedSelfTotal,
  36387. "bedInscpTotal": bedInscpTotal,
  36388. "operationCostTotal": operationCostTotal,
  36389. "operationCostSelfTotal": operationCostSelfTotal,
  36390. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36391. "operationSelfTotal": operationSelfTotal,
  36392. "operationInscpTotal": operationInscpTotal,
  36393. "otherCostTotal": otherCostTotal,
  36394. "otherCostSelfTotal": otherCostSelfTotal,
  36395. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36396. "otherSelfTotal": otherSelfTotal,
  36397. "otherInscpTotal": otherInscpTotal,
  36398. "materialCostTotal": materialCostTotal,
  36399. "materialCostSelfTotal": materialCostSelfTotal,
  36400. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36401. "materialSelfTotal": materialSelfTotal,
  36402. "materialInscpTotal": materialInscpTotal,
  36403. "westernMedicineCostTotal": westernMedicineCostTotal,
  36404. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36405. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36406. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36407. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36408. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36409. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36410. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36411. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36412. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36413. "checkCostTotal": checkCostTotal,
  36414. "checkCostSelfTotal": checkCostSelfTotal,
  36415. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36416. "checkSelfTotal": checkSelfTotal,
  36417. "checkInscpTotal": checkInscpTotal,
  36418. "laboratoryCostTotal": laboratoryCostTotal,
  36419. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36420. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36421. "laboratorySelfTotal": laboratorySelfTotal,
  36422. "laboratoryInscpTotal": laboratoryInscpTotal,
  36423. "treatCostTotal": treatCostTotal,
  36424. "treatCostSelfTotal": treatCostSelfTotal,
  36425. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36426. "treatSelfTotal": treatSelfTotal,
  36427. "treatInscpTotal": treatInscpTotal,
  36428. "doctor_info": doctor_info,
  36429. "doctor_code": adminRole_two.DoctorCode,
  36430. "doctor_name": doctor_name,
  36431. "health_card_no": order.PsnNo,
  36432. "department": departments.Name,
  36433. "yiliao_leibie": yiliao_leibie,
  36434. "after_money": order.AccountPrice,
  36435. "patient": patient,
  36436. "org_name": miConfig.OrgName,
  36437. "org_code": miConfig.Code,
  36438. "order_number": order.Number,
  36439. "his_hospital": his_hospital,
  36440. "his": his,
  36441. "dia_config": dia_config,
  36442. "psn_cash_pay": order.PsnCashPay,
  36443. //"check_order_info": cus_slice,
  36444. }
  36445. data3 = append(data3, data2)
  36446. }
  36447. }
  36448. }
  36449. c.ServeSuccessJSON(map[string]interface{}{
  36450. "infos": data3,
  36451. })
  36452. }
  36453. func (c *HisApiController) GetSettleAccounts() {
  36454. //id, _ := c.GetInt64("id")
  36455. //record_time := c.GetString("record_time")
  36456. order_id, _ := c.GetInt64("order_id")
  36457. admin_user_id, _ := c.GetInt64("admin_user_id")
  36458. //timeLayout := "2006-01-02"
  36459. //loc, _ := time.LoadLocation("Local")
  36460. //
  36461. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36462. //if err != nil {
  36463. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36464. // return
  36465. //}Hbyb5203
  36466. //recordDateTime := theTime.Unix()
  36467. adminUser := c.GetAdminUserInfo()
  36468. order, _ := service.GetHisOrderByID(order_id)
  36469. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36470. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36471. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36472. orderInfos = append(orderInfos, orderInfos_two...)
  36473. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36474. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36475. var diagnosis_ids []string
  36476. if his.ID > 0 {
  36477. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36478. } else {
  36479. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36480. }
  36481. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36482. var dia_config []*models.HisXtDiagnoseConfig
  36483. var name string
  36484. for _, item := range diagnosis_ids {
  36485. id, _ := strconv.ParseInt(item, 10, 64)
  36486. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36487. dia_config = append(dia_config, &diagnosisConfig)
  36488. if len(name) == 0 {
  36489. name = diagnosisConfig.ClassName
  36490. } else {
  36491. name = name + "," + diagnosisConfig.ClassName
  36492. }
  36493. }
  36494. if patient.UserOrgId == 10215 {
  36495. name = "慢性肾功能不全(血透治疗)"
  36496. }
  36497. var bedCostTotal float64 = 0 //床位总费
  36498. var bedCostSelfTotal float64 = 0 //床位自费
  36499. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36500. var bedSelfTotal float64 = 0 //床位部分项目自费
  36501. var bedInscpTotal float64 = 0 //床位部分项目自费
  36502. var operationCostTotal float64 = 0 //手术费
  36503. var operationCostSelfTotal float64 = 0 //手术费
  36504. var operationCostPartSelfTotal float64 = 0 //手术费
  36505. var operationSelfTotal float64 = 0 //床位部分项目自费
  36506. var operationInscpTotal float64 = 0 //床位部分项目自费
  36507. var otherCostTotal float64 = 0 //其他费用
  36508. var otherCostSelfTotal float64 = 0 //其他费用
  36509. var otherCostPartSelfTotal float64 = 0 //其他费用
  36510. var otherSelfTotal float64 = 0 //床位部分项目自费
  36511. var otherInscpTotal float64 = 0 //床位部分项目自费
  36512. var materialCostTotal float64 = 0 //材料费
  36513. var materialCostSelfTotal float64 = 0 //材料费
  36514. var materialCostPartSelfTotal float64 = 0 //材料费
  36515. var materialSelfTotal float64 = 0 //床位部分项目自费
  36516. var materialInscpTotal float64 = 0 //床位部分项目自费
  36517. var westernMedicineCostTotal float64 = 0 //西药费
  36518. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36519. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36520. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36521. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36522. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36523. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36524. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36525. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36526. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36527. var checkCostTotal float64 = 0 //检查费
  36528. var checkCostSelfTotal float64 = 0 //检查费
  36529. var checkCostPartSelfTotal float64 = 0 //检查费
  36530. var checkSelfTotal float64 = 0 //床位部分项目自费
  36531. var checkInscpTotal float64 = 0 //床位部分项目自费
  36532. var laboratoryCostTotal float64 = 0 //化验费
  36533. var laboratoryCostSelfTotal float64 = 0 //化验费
  36534. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36535. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36536. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36537. var treatCostTotal float64 = 0 //治疗费用
  36538. var treatCostSelfTotal float64 = 0 //治疗费用
  36539. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36540. var treatSelfTotal float64 = 0 //床位部分项目自费
  36541. var treatInscpTotal float64 = 0 //床位部分项目自费
  36542. var zcCostTotal float64 = 0 //治疗费用
  36543. var zcCostSelfTotal float64 = 0 //治疗费用
  36544. var zcCostPartSelfTotal float64 = 0 //治疗费用
  36545. var zcSelfTotal float64 = 0 //床位部分项目自费
  36546. var zcInscpTotal float64 = 0 //床位部分项目自费
  36547. var huliCostTotal float64 = 0 //治疗费用
  36548. var huliCostSelfTotal float64 = 0 //治疗费用
  36549. var huliCostPartSelfTotal float64 = 0 //治疗费用
  36550. var huliSelfTotal float64 = 0 //床位部分项目自费
  36551. var huliInscpTotal float64 = 0 //床位部分项目自费
  36552. decimal.DivisionPrecision = 2
  36553. for _, item := range orderInfos {
  36554. if item.MedChrgitmType == "01" { //床位费
  36555. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36556. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36557. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36558. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36559. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36560. }
  36561. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36562. if item.MedChrgitmType == "03" { //检查费
  36563. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36564. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36565. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36566. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36567. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36568. }
  36569. } else {
  36570. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36571. fmt.Println("------------")
  36572. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36573. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36574. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36575. }
  36576. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36577. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36578. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36579. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36580. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36581. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36582. }
  36583. }
  36584. if item.MedChrgitmType == "04" { //化验费
  36585. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36586. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36587. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36588. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36589. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36590. }
  36591. if item.MedChrgitmType == "05" { //治疗费
  36592. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36593. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36594. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36595. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36596. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36597. }
  36598. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36599. fmt.Println("------------")
  36600. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36601. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36602. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36603. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36604. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36605. }
  36606. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36607. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36608. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36609. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36610. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36611. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36612. }
  36613. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36614. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36615. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36616. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36617. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36618. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36619. }
  36620. if item.MedChrgitmType == "09" { //西药费
  36621. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36622. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36623. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36624. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36625. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36626. }
  36627. if item.MedChrgitmType == "11" { //中成费
  36628. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36629. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36630. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36631. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36632. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36633. }
  36634. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  36635. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36636. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36637. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36638. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36639. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36640. }
  36641. if item.MedChrgitmType == "02" { //其他费
  36642. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36643. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36644. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36645. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36646. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36647. }
  36648. if item.MedChrgitmType == "07" { //其他费
  36649. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36650. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36651. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36652. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36653. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36654. }
  36655. }
  36656. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36657. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36658. var user_name string
  36659. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36660. if role.ID == 0 {
  36661. user_name = "管理员"
  36662. } else {
  36663. user_name = role.UserName
  36664. }
  36665. baseParams := models.BaseParams{
  36666. SecretKey: miConfig.SecretKey,
  36667. FixmedinsCode: miConfig.Code,
  36668. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36669. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36670. OrgName: miConfig.OrgName,
  36671. Doctor: user_name,
  36672. RequestUrl: miConfig.Url,
  36673. AccessKey: miConfig.AccessKey,
  36674. }
  36675. businessParams := models.BusinessParams{
  36676. PsnNo: order.PsnNo,
  36677. MdtrtId: order.MdtrtId,
  36678. SetlId: order.SetlId,
  36679. }
  36680. var res ResultEleven
  36681. var resah ResultElevenah
  36682. var resEleven10265 ResultEleven10265
  36683. if config.IsOpen == 1 {
  36684. if miConfig.MdtrtareaAdmvs == "421300" {
  36685. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36686. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36687. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36688. resp, requestErr := http.Get(api)
  36689. if requestErr != nil {
  36690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36691. return
  36692. }
  36693. body, ioErr := ioutil.ReadAll(resp.Body)
  36694. if ioErr != nil {
  36695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36697. return
  36698. }
  36699. var respJSON map[string]interface{}
  36700. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36703. return
  36704. }
  36705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36706. result, _ := json.Marshal(respJSON)
  36707. fmt.Println("log")
  36708. fmt.Println(string(result))
  36709. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36710. utils.ErrorLog("解析失败:%v", err)
  36711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36712. return
  36713. }
  36714. } else if miConfig.MdtrtareaAdmvs == "420200" {
  36715. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36716. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36717. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36718. resp, requestErr := http.Get(api)
  36719. if requestErr != nil {
  36720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36721. return
  36722. }
  36723. body, ioErr := ioutil.ReadAll(resp.Body)
  36724. if ioErr != nil {
  36725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36727. return
  36728. }
  36729. var respJSON map[string]interface{}
  36730. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36733. return
  36734. }
  36735. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36736. result, _ := json.Marshal(respJSON)
  36737. fmt.Println("log")
  36738. fmt.Println(string(result))
  36739. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36740. utils.ErrorLog("解析失败:%v", err)
  36741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36742. return
  36743. }
  36744. } else if miConfig.MdtrtareaAdmvs == "420902" {
  36745. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36746. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36747. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36748. resp, requestErr := http.Get(api)
  36749. if requestErr != nil {
  36750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36751. return
  36752. }
  36753. body, ioErr := ioutil.ReadAll(resp.Body)
  36754. if ioErr != nil {
  36755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36757. return
  36758. }
  36759. var respJSON map[string]interface{}
  36760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36763. return
  36764. }
  36765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36766. result, _ := json.Marshal(respJSON)
  36767. fmt.Println("log")
  36768. fmt.Println(string(result))
  36769. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36770. utils.ErrorLog("解析失败:%v", err)
  36771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36772. return
  36773. }
  36774. } else if miConfig.MdtrtareaAdmvs == "421182" {
  36775. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36776. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36777. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  36778. resp, requestErr := http.Get(api)
  36779. if requestErr != nil {
  36780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36781. return
  36782. }
  36783. body, ioErr := ioutil.ReadAll(resp.Body)
  36784. if ioErr != nil {
  36785. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36787. return
  36788. }
  36789. var respJSON map[string]interface{}
  36790. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36793. return
  36794. }
  36795. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36796. result, _ := json.Marshal(respJSON)
  36797. fmt.Println("log")
  36798. fmt.Println(string(result))
  36799. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36800. utils.ErrorLog("解析失败:%v", err)
  36801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36802. return
  36803. }
  36804. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  36805. var api string
  36806. if miConfig.MdtrtareaAdmvs == "320830" {
  36807. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36808. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36809. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36810. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36811. } else if miConfig.MdtrtareaAdmvs == "320921" {
  36812. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36813. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36814. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36815. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36816. } else {
  36817. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36818. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36819. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36820. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36821. }
  36822. resp, requestErr := http.Get(api)
  36823. if requestErr != nil {
  36824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36825. return
  36826. }
  36827. body, ioErr := ioutil.ReadAll(resp.Body)
  36828. if ioErr != nil {
  36829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36831. return
  36832. }
  36833. var respJSON map[string]interface{}
  36834. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36837. return
  36838. }
  36839. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36840. result, _ := json.Marshal(respJSON)
  36841. fmt.Println("log")
  36842. fmt.Println(string(result))
  36843. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  36844. utils.ErrorLog("解析失败:%v", err)
  36845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36846. return
  36847. }
  36848. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36849. res.Output = resEleven10265.Output
  36850. res.ErrMsg = resEleven10265.ErrMsg
  36851. res.Cainfo = resEleven10265.Cainfo
  36852. res.WarnMsg = resEleven10265.WarnMsg
  36853. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36854. res.Infcode = infocode
  36855. } else if miConfig.MdtrtareaAdmvs == "350500" {
  36856. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  36857. saveLog(result, requestLog, "5203", "结算单")
  36858. var dat map[string]interface{}
  36859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36860. fmt.Println(dat)
  36861. } else {
  36862. fmt.Println(err)
  36863. }
  36864. userJSONBytes, _ := json.Marshal(dat)
  36865. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36866. utils.ErrorLog("解析失败:%v", err)
  36867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36868. return
  36869. }
  36870. } else if miConfig.MdtrtareaAdmvs == "360302" {
  36871. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36872. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36873. saveLog(result, requestLog, "5203", "结算单")
  36874. var dat map[string]interface{}
  36875. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36876. fmt.Println(dat)
  36877. } else {
  36878. fmt.Println(err)
  36879. }
  36880. userJSONBytes, _ := json.Marshal(dat)
  36881. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36882. utils.ErrorLog("解析失败:%v", err)
  36883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36884. return
  36885. }
  36886. } else if miConfig.MdtrtareaAdmvs == "361025" {
  36887. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36888. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36889. saveLog(result, requestLog, "5203", "结算单")
  36890. var dat map[string]interface{}
  36891. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36892. fmt.Println(dat)
  36893. } else {
  36894. fmt.Println(err)
  36895. }
  36896. userJSONBytes, _ := json.Marshal(dat)
  36897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36898. utils.ErrorLog("解析失败:%v", err)
  36899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36900. return
  36901. }
  36902. } else if miConfig.MdtrtareaAdmvs == "360100" {
  36903. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36904. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36905. saveLog(result, requestLog, "5203", "结算单")
  36906. var dat map[string]interface{}
  36907. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36908. fmt.Println(dat)
  36909. } else {
  36910. fmt.Println(err)
  36911. }
  36912. userJSONBytes, _ := json.Marshal(dat)
  36913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36914. utils.ErrorLog("解析失败:%v", err)
  36915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36916. return
  36917. }
  36918. } else if miConfig.MdtrtareaAdmvs == "341203" {
  36919. var api string
  36920. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36921. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36922. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36923. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36924. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36925. resp, requestErr := http.Get(api)
  36926. if requestErr != nil {
  36927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36928. return
  36929. }
  36930. body, ioErr := ioutil.ReadAll(resp.Body)
  36931. if ioErr != nil {
  36932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36934. return
  36935. }
  36936. var respJSON map[string]interface{}
  36937. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36940. return
  36941. }
  36942. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36943. if status == "0" {
  36944. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36945. c.ServeSuccessJSON(map[string]interface{}{
  36946. "failed_code": -10,
  36947. "msg": err_msg,
  36948. })
  36949. return
  36950. }
  36951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36952. result, _ := json.Marshal(respJSON)
  36953. fmt.Println("log")
  36954. fmt.Println(string(result))
  36955. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  36956. utils.ErrorLog("解析失败:%v", err)
  36957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36958. return
  36959. }
  36960. res.InfRefmsgid = resah.InfRefmsgid
  36961. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36962. // 创建对应的Time类型
  36963. t := time.UnixMilli(timestamp)
  36964. // 格式化成指定的日期字符串
  36965. str := t.Format("2006-01-02 15:04:05")
  36966. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36967. // 创建对应的Time类型
  36968. t3 := time.UnixMilli(timestamp2)
  36969. // 格式化成指定的日期字符串
  36970. str2 := t3.Format("2006-01-02 15:04:05")
  36971. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  36972. // 创建对应的Time类型
  36973. t4 := time.UnixMilli(timestamp3)
  36974. // 格式化成指定的日期字符串
  36975. str3 := t4.Format("2006-01-02 15:04:05")
  36976. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  36977. // 创建对应的Time类型
  36978. t5 := time.UnixMilli(timestamp4)
  36979. // 格式化成指定的日期字符串
  36980. str5 := t5.Format("2006-01-02 15:04:05")
  36981. res.Output.Setlinfo.Brdy = str2
  36982. res.Output.Setlinfo.SetlTime = str
  36983. res.Output.Setlinfo.Begndate = str3
  36984. res.Output.Setlinfo.Enddate = str5
  36985. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  36986. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  36987. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  36988. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  36989. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36990. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36991. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  36992. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  36993. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36994. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  36995. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  36996. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  36997. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  36998. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  36999. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37000. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37001. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37002. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37003. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37004. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37005. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37006. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37007. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37008. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37009. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37010. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37011. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37012. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37013. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37014. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37015. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37016. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37017. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37018. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37019. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37020. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37021. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37022. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37023. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37024. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37025. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37026. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37027. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37028. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37029. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37030. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37031. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37032. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37033. //res.Output.Setldetail = resah.Output.Setldetail
  37034. res.ErrMsg = resah.ErrMsg
  37035. res.Cainfo = resah.Cainfo
  37036. res.WarnMsg = resah.WarnMsg
  37037. } else if miConfig.MdtrtareaAdmvs == "340699" {
  37038. var api string
  37039. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37040. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37041. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37042. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37043. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37044. resp, requestErr := http.Get(api)
  37045. if requestErr != nil {
  37046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37047. return
  37048. }
  37049. body, ioErr := ioutil.ReadAll(resp.Body)
  37050. if ioErr != nil {
  37051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37053. return
  37054. }
  37055. var respJSON map[string]interface{}
  37056. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37059. return
  37060. }
  37061. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37062. if status == "0" {
  37063. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37064. c.ServeSuccessJSON(map[string]interface{}{
  37065. "failed_code": -10,
  37066. "msg": err_msg,
  37067. })
  37068. return
  37069. }
  37070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37071. result, _ := json.Marshal(respJSON)
  37072. fmt.Println("log")
  37073. fmt.Println(string(result))
  37074. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37075. utils.ErrorLog("解析失败:%v", err)
  37076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37077. return
  37078. }
  37079. res.InfRefmsgid = resah.InfRefmsgid
  37080. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37081. // 创建对应的Time类型
  37082. t := time.UnixMilli(timestamp)
  37083. // 格式化成指定的日期字符串
  37084. str := t.Format("2006-01-02 15:04:05")
  37085. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37086. // 创建对应的Time类型
  37087. t3 := time.UnixMilli(timestamp2)
  37088. // 格式化成指定的日期字符串
  37089. str2 := t3.Format("2006-01-02 15:04:05")
  37090. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37091. // 创建对应的Time类型
  37092. t4 := time.UnixMilli(timestamp3)
  37093. // 格式化成指定的日期字符串
  37094. str3 := t4.Format("2006-01-02 15:04:05")
  37095. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37096. // 创建对应的Time类型
  37097. t5 := time.UnixMilli(timestamp4)
  37098. // 格式化成指定的日期字符串
  37099. str5 := t5.Format("2006-01-02 15:04:05")
  37100. res.Output.Setlinfo.Brdy = str2
  37101. res.Output.Setlinfo.SetlTime = str
  37102. res.Output.Setlinfo.Begndate = str3
  37103. res.Output.Setlinfo.Enddate = str5
  37104. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37105. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37106. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37107. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37108. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37109. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37110. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37111. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37112. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37113. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37114. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37115. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37116. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37117. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37118. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37119. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37120. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37121. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37122. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37123. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37124. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37125. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37126. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37127. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37128. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37129. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37130. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37131. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37132. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37133. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37134. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37135. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37136. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37137. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37138. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37139. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37140. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37141. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37142. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37143. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37144. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37145. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37146. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37147. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37148. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37149. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37150. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37151. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37152. //res.Output.Setldetail = resah.Output.Setldetail
  37153. res.ErrMsg = resah.ErrMsg
  37154. res.Cainfo = resah.Cainfo
  37155. res.WarnMsg = resah.WarnMsg
  37156. } else if miConfig.MdtrtareaAdmvs == "430800" {
  37157. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  37158. saveLog(result, requestLog, "5203", "结算单")
  37159. var dat map[string]interface{}
  37160. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37161. fmt.Println(dat)
  37162. } else {
  37163. fmt.Println(err)
  37164. }
  37165. userJSONBytes, _ := json.Marshal(dat)
  37166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37167. utils.ErrorLog("解析失败:%v", err)
  37168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37169. return
  37170. }
  37171. } else if miConfig.MdtrtareaAdmvs == "150499" {
  37172. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37173. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37174. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37175. resp, requestErr := http.Get(api)
  37176. if requestErr != nil {
  37177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37178. return
  37179. }
  37180. body, ioErr := ioutil.ReadAll(resp.Body)
  37181. if ioErr != nil {
  37182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37184. return
  37185. }
  37186. var respJSON map[string]interface{}
  37187. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37190. return
  37191. }
  37192. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37193. result, _ := json.Marshal(respJSON)
  37194. fmt.Println("log")
  37195. fmt.Println(string(result))
  37196. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37197. utils.ErrorLog("解析失败:%v", err)
  37198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37199. return
  37200. }
  37201. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37202. res.Output = resEleven10265.Output
  37203. res.ErrMsg = resEleven10265.ErrMsg
  37204. res.Cainfo = resEleven10265.Cainfo
  37205. res.WarnMsg = resEleven10265.WarnMsg
  37206. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37207. res.Infcode = infocode
  37208. } else if miConfig.MdtrtareaAdmvs == "441799" {
  37209. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37210. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37211. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37212. resp, requestErr := http.Get(api)
  37213. if requestErr != nil {
  37214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37215. return
  37216. }
  37217. body, ioErr := ioutil.ReadAll(resp.Body)
  37218. if ioErr != nil {
  37219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37221. return
  37222. }
  37223. var respJSON map[string]interface{}
  37224. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37227. return
  37228. }
  37229. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37230. result, _ := json.Marshal(respJSON)
  37231. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37232. utils.ErrorLog("解析失败:%v", err)
  37233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37234. return
  37235. }
  37236. } else if miConfig.MdtrtareaAdmvs == "450721" {
  37237. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  37238. //return
  37239. } else {
  37240. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  37241. if len(his.InsuplcAdmdvs) == 0 {
  37242. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  37243. } else {
  37244. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37245. }
  37246. result := service.Gdyb5203(baseParams, businessParams)
  37247. //service.Gdyb5204(baseParams, businessParams)
  37248. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  37249. var dat map[string]interface{}
  37250. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37251. fmt.Println(dat)
  37252. } else {
  37253. fmt.Println(err)
  37254. }
  37255. userJSONBytes, _ := json.Marshal(dat)
  37256. if miConfig.Code == "H15049901371" {
  37257. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  37258. utils.ErrorLog("解析失败:%v", err)
  37259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37260. return
  37261. }
  37262. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37263. res.Output = resEleven10265.Output
  37264. res.ErrMsg = resEleven10265.ErrMsg
  37265. res.Cainfo = resEleven10265.Cainfo
  37266. res.WarnMsg = resEleven10265.WarnMsg
  37267. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37268. res.Infcode = infocode
  37269. } else {
  37270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37271. utils.ErrorLog("解析失败:%v", err)
  37272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37273. return
  37274. }
  37275. }
  37276. }
  37277. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37278. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  37279. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  37280. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  37281. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  37282. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37283. var doctor_name string
  37284. if roles.ID == 0 {
  37285. doctor_name = "管理员"
  37286. } else {
  37287. doctor_name = roles.UserName
  37288. }
  37289. yiliao_leibie := ""
  37290. switch order.MedType {
  37291. case "11":
  37292. yiliao_leibie = "普通门诊"
  37293. break
  37294. case "12":
  37295. yiliao_leibie = "门诊挂号"
  37296. break
  37297. case "13":
  37298. yiliao_leibie = "急诊"
  37299. break
  37300. case "14":
  37301. yiliao_leibie = "门诊特殊病"
  37302. break
  37303. case "15":
  37304. yiliao_leibie = "门诊统筹"
  37305. break
  37306. case "16":
  37307. yiliao_leibie = "门诊慢性病"
  37308. break
  37309. case "21":
  37310. yiliao_leibie = "普通住院"
  37311. break
  37312. }
  37313. //var rf []CustomFundPay
  37314. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  37315. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37316. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  37317. if res.Infcode == 0 {
  37318. 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 {
  37319. c.ServeSuccessJSON(map[string]interface{}{
  37320. "diagnosis": name,
  37321. "order_infos": orderInfos,
  37322. "number": order.MdtrtId,
  37323. "date": order.SettleAccountsDate,
  37324. "charge_admin": charge_admin,
  37325. "printor_admin": printor_admin,
  37326. "info": res.Output.Setlinfo,
  37327. "order": order,
  37328. "bedCostTotal": bedCostTotal,
  37329. "bedCostSelfTotal": bedCostSelfTotal,
  37330. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37331. "bedSelfTotal": bedSelfTotal,
  37332. "bedInscpTotal": bedInscpTotal,
  37333. "operationCostTotal": operationCostTotal,
  37334. "operationCostSelfTotal": operationCostSelfTotal,
  37335. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37336. "operationSelfTotal": operationSelfTotal,
  37337. "operationInscpTotal": operationInscpTotal,
  37338. "otherCostTotal": otherCostTotal,
  37339. "otherCostSelfTotal": otherCostSelfTotal,
  37340. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37341. "otherSelfTotal": otherSelfTotal,
  37342. "otherInscpTotal": otherInscpTotal,
  37343. "materialCostTotal": materialCostTotal,
  37344. "materialCostSelfTotal": materialCostSelfTotal,
  37345. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37346. "materialSelfTotal": materialSelfTotal,
  37347. "materialInscpTotal": materialInscpTotal,
  37348. "westernMedicineCostTotal": westernMedicineCostTotal,
  37349. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37350. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37351. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37352. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37353. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37354. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37355. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37356. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37357. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37358. "checkCostTotal": checkCostTotal,
  37359. "checkCostSelfTotal": checkCostSelfTotal,
  37360. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37361. "checkSelfTotal": checkSelfTotal,
  37362. "checkInscpTotal": checkInscpTotal,
  37363. "laboratoryCostTotal": laboratoryCostTotal,
  37364. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37365. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37366. "laboratorySelfTotal": laboratorySelfTotal,
  37367. "laboratoryInscpTotal": laboratoryInscpTotal,
  37368. "treatCostTotal": treatCostTotal,
  37369. "treatCostSelfTotal": treatCostSelfTotal,
  37370. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37371. "treatSelfTotal": treatSelfTotal,
  37372. "treatInscpTotal": treatInscpTotal,
  37373. "doctor_info": doctor_info,
  37374. "doctor_code": adminRole_two.DoctorCode,
  37375. "doctor_name": doctor_name,
  37376. "health_card_no": order.PsnNo,
  37377. "department": departments.Name,
  37378. "yiliao_leibie": yiliao_leibie,
  37379. "after_money": order.AccountPrice,
  37380. "patient": patient,
  37381. "org_name": miConfig.OrgName,
  37382. "org_code": miConfig.Code,
  37383. "order_number": order.Number,
  37384. "his_hospital": his_hospital,
  37385. "his": his,
  37386. "dia_config": dia_config,
  37387. "psn_cash_pay": order.PsnCashPay,
  37388. "zcCostTotal": zcCostTotal,
  37389. "zcCostSelfTotal": zcCostSelfTotal,
  37390. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37391. "zcSelfTotal": zcSelfTotal,
  37392. "zcInscpTotal": zcInscpTotal,
  37393. "huliCostTotal": huliCostTotal,
  37394. "huliCostSelfTotal": huliCostSelfTotal,
  37395. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37396. "huliSelfTotal": huliSelfTotal,
  37397. "huliInscpTotal": huliInscpTotal,
  37398. //"funds": rf,
  37399. //"check_order_info": cus_slice,
  37400. })
  37401. } else {
  37402. c.ServeSuccessJSON(map[string]interface{}{
  37403. "diagnosis": name,
  37404. "order_infos": orderInfos,
  37405. "number": order.MdtrtId,
  37406. "date": order.SettleAccountsDate,
  37407. "charge_admin": charge_admin,
  37408. "printor_admin": printor_admin,
  37409. "info": order,
  37410. "order": order,
  37411. "bedCostTotal": bedCostTotal,
  37412. "bedCostSelfTotal": bedCostSelfTotal,
  37413. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37414. "bedSelfTotal": bedSelfTotal,
  37415. "bedInscpTotal": bedInscpTotal,
  37416. "operationCostTotal": operationCostTotal,
  37417. "operationCostSelfTotal": operationCostSelfTotal,
  37418. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37419. "operationSelfTotal": operationSelfTotal,
  37420. "operationInscpTotal": operationInscpTotal,
  37421. "otherCostTotal": otherCostTotal,
  37422. "otherCostSelfTotal": otherCostSelfTotal,
  37423. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37424. "otherSelfTotal": otherSelfTotal,
  37425. "otherInscpTotal": otherInscpTotal,
  37426. "materialCostTotal": materialCostTotal,
  37427. "materialCostSelfTotal": materialCostSelfTotal,
  37428. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37429. "materialSelfTotal": materialSelfTotal,
  37430. "materialInscpTotal": materialInscpTotal,
  37431. "westernMedicineCostTotal": westernMedicineCostTotal,
  37432. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37433. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37434. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37435. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37436. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37437. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37438. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37439. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37440. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37441. "checkCostTotal": checkCostTotal,
  37442. "checkCostSelfTotal": checkCostSelfTotal,
  37443. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37444. "checkSelfTotal": checkSelfTotal,
  37445. "checkInscpTotal": checkInscpTotal,
  37446. "laboratoryCostTotal": laboratoryCostTotal,
  37447. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37448. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37449. "laboratorySelfTotal": laboratorySelfTotal,
  37450. "laboratoryInscpTotal": laboratoryInscpTotal,
  37451. "treatCostTotal": treatCostTotal,
  37452. "treatCostSelfTotal": treatCostSelfTotal,
  37453. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37454. "treatSelfTotal": treatSelfTotal,
  37455. "treatInscpTotal": treatInscpTotal,
  37456. "doctor_info": doctor_info,
  37457. "doctor_code": adminRole_two.DoctorCode,
  37458. "doctor_name": doctor_name,
  37459. "health_card_no": order.PsnNo,
  37460. "department": departments.Name,
  37461. "yiliao_leibie": yiliao_leibie,
  37462. "after_money": order.AccountPrice,
  37463. "patient": patient,
  37464. "org_name": miConfig.OrgName,
  37465. "org_code": miConfig.Code,
  37466. "order_number": order.Number,
  37467. "his_hospital": his_hospital,
  37468. "his": his,
  37469. "dia_config": dia_config,
  37470. "psn_cash_pay": order.PsnCashPay,
  37471. "zcCostTotal": zcCostTotal,
  37472. "zcCostSelfTotal": zcCostSelfTotal,
  37473. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37474. "zcSelfTotal": zcSelfTotal,
  37475. "zcInscpTotal": zcInscpTotal,
  37476. "huliCostTotal": huliCostTotal,
  37477. "huliCostSelfTotal": huliCostSelfTotal,
  37478. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37479. "huliSelfTotal": huliSelfTotal,
  37480. "huliInscpTotal": huliInscpTotal,
  37481. //"funds": rf,
  37482. //"check_order_info": cus_slice,
  37483. })
  37484. }
  37485. }
  37486. }
  37487. }
  37488. //func (c *HisApiController) CheckTreatment() {
  37489. // patient_id, _ := c.GetInt64("patient_id")
  37490. // id_card_no := c.GetString("id_card_no")
  37491. // insutype := c.GetString("insutype")
  37492. // med_type := c.GetString("med_type")
  37493. // admin_user_id, _ := c.GetInt64("admin_user_id")
  37494. //
  37495. // adminUser := c.GetAdminUserInfo()
  37496. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37497. //
  37498. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37499. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37500. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37501. //
  37502. // if miConfig.MdtrtareaAdmvs == "421300" {
  37503. // var res ResultTwo
  37504. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  37505. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37506. // "&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)
  37507. // resp, requestErr := http.Get(api)
  37508. // if requestErr != nil {
  37509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37510. // return
  37511. // }
  37512. //
  37513. // body, ioErr := ioutil.ReadAll(resp.Body)
  37514. // if ioErr != nil {
  37515. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37516. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37517. // return
  37518. // }
  37519. // var respJSON map[string]interface{}
  37520. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37521. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37523. // return
  37524. // }
  37525. //
  37526. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37527. // result, _ := json.Marshal(respJSON)
  37528. //
  37529. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37530. // utils.ErrorLog("解析失败:%v", err)
  37531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37532. // return
  37533. // }
  37534. //
  37535. // if res.Infcode == 0 {
  37536. //
  37537. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  37538. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37539. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  37540. // resp, requestErr := http.Get(api)
  37541. // if requestErr != nil {
  37542. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37543. // return
  37544. // }
  37545. //
  37546. // body, ioErr := ioutil.ReadAll(resp.Body)
  37547. // if ioErr != nil {
  37548. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37550. // return
  37551. // }
  37552. // var respJSON map[string]interface{}
  37553. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37554. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37556. // return
  37557. // }
  37558. // var res Result2001
  37559. //
  37560. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37561. // result2, _ := json.Marshal(respJSON)
  37562. //
  37563. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  37564. // utils.ErrorLog("解析失败:%v", err)
  37565. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37566. // return
  37567. // }
  37568. //
  37569. // if res.Infcode == 0 {
  37570. // c.ServeSuccessJSON(map[string]interface{}{
  37571. // "msg": res.Output.Trtinfo,
  37572. // })
  37573. // }
  37574. //
  37575. // } else {
  37576. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37577. // return
  37578. // }
  37579. //
  37580. // } else {
  37581. //
  37582. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37583. // var dat map[string]interface{}
  37584. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37585. // fmt.Println(dat)
  37586. // } else {
  37587. // fmt.Println(err)
  37588. // }
  37589. // userJSONBytes, _ := json.Marshal(dat)
  37590. // var res ResultTwo
  37591. // var res10265 ResultTwo10265
  37592. // if miConfig.Code == "H15049901371" {
  37593. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37594. // utils.ErrorLog("解析失败:%v", err)
  37595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37596. // return
  37597. // }
  37598. // res.ErrMsg = res10265.ErrMsg
  37599. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37600. // res.Infcode = infocode
  37601. // res.Output = res10265.Output
  37602. // res.InfRefmsgid = res10265.InfRefmsgid
  37603. // } else {
  37604. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37605. // utils.ErrorLog("解析失败:%v", err)
  37606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37607. // return
  37608. // }
  37609. // }
  37610. //
  37611. // var user_name string
  37612. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  37613. // if role.ID == 0 {
  37614. // user_name = "xxx"
  37615. // } else {
  37616. // user_name = role.UserName
  37617. // }
  37618. //
  37619. // baseParams := models.BaseParams{
  37620. // SecretKey: miConfig.SecretKey,
  37621. // FixmedinsCode: miConfig.Code,
  37622. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37623. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37624. // OrgName: miConfig.OrgName,
  37625. // Doctor: user_name,
  37626. // }
  37627. //
  37628. // if config.IsOpen == 1 {
  37629. // if miConfig.Code == "H15049901371" {
  37630. // if med_type == "14" {
  37631. // if insutype == "390" {
  37632. // med_type = "9933"
  37633. // } else if insutype == "310" {
  37634. // med_type = "990502"
  37635. // }
  37636. // } else if med_type == "11" {
  37637. // med_type = "11"
  37638. // }
  37639. // }
  37640. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  37641. // var dat map[string]interface{}
  37642. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37643. // fmt.Println(dat)
  37644. // } else {
  37645. // fmt.Println(err)
  37646. // }
  37647. // var res Result2001
  37648. // var res10265 Result2001Org10265
  37649. // if miConfig.Code == "H15049901371" {
  37650. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37651. // utils.ErrorLog("解析失败:%v", err)
  37652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37653. // return
  37654. // }
  37655. // res.ErrMsg = res10265.ErrMsg
  37656. // res.Output = res10265.Output
  37657. // res.InfRefmsgid = res10265.InfRefmsgid
  37658. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37659. // res.Infcode = infocode
  37660. // } else {
  37661. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37662. // utils.ErrorLog("解析失败:%v", err)
  37663. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37664. // return
  37665. // }
  37666. // }
  37667. // if res.Infcode == 0 {
  37668. // c.ServeSuccessJSON(map[string]interface{}{
  37669. // "msg": res.Output.Trtinfo,
  37670. // })
  37671. // }
  37672. // }
  37673. // }
  37674. //}
  37675. //func (c *HisApiController) PutRecord() {
  37676. // id, _ := c.GetInt64("id")
  37677. // record_time := c.GetString("record_time")
  37678. // timeLayout := "2006-01-02"
  37679. // loc, _ := time.LoadLocation("Local")
  37680. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37681. // if err != nil {
  37682. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37683. // return
  37684. // }
  37685. // recordDateTime := theTime.Unix()
  37686. //
  37687. // adminInfo := c.GetAdminUserInfo()
  37688. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  37689. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37690. //
  37691. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37692. //
  37693. // fmt.Println(miConfig.SecretKey)
  37694. //
  37695. // if patient == nil {
  37696. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37697. // return
  37698. // }
  37699. // if len(patient.IdCardNo) == 0 {
  37700. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  37701. // return
  37702. // }
  37703. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  37704. // if config.IsOpen == 1 {
  37705. // 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
  37706. // resp, requestErr := http.Get(api)
  37707. // if requestErr != nil {
  37708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37709. // return
  37710. // }
  37711. // defer resp.Body.Close()
  37712. // body, ioErr := ioutil.ReadAll(resp.Body)
  37713. // if ioErr != nil {
  37714. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37715. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37716. // return
  37717. // }
  37718. // var respJSON map[string]interface{}
  37719. //
  37720. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37721. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37723. // return
  37724. // }
  37725. //
  37726. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37727. // userJSONBytes, _ := json.Marshal(userJSON)
  37728. // var res ResultTwo
  37729. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37730. // utils.ErrorLog("解析失败:%v", err)
  37731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37732. // return
  37733. // }
  37734. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37735. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37736. // infoStr := string(Iinfos)
  37737. // idetinfoStr := string(Idetinfos)
  37738. //
  37739. // if res.Infcode == 0 {
  37740. // his := models.VMHisPatient{
  37741. // Status: 1,
  37742. // Ctime: time.Now().Unix(),
  37743. // Mtime: time.Now().Unix(),
  37744. // PsnNo: res.Output.Baseinfo.PsnNo,
  37745. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  37746. // Certno: res.Output.Baseinfo.Certno,
  37747. // PsnName: res.Output.Baseinfo.PsnName,
  37748. // Gend: res.Output.Baseinfo.Gend,
  37749. // Naty: res.Output.Baseinfo.Naty,
  37750. // Brdy: res.Output.Baseinfo.Brdy,
  37751. // Age: res.Output.Baseinfo.Age,
  37752. // Iinfo: infoStr,
  37753. // Idetinfo: idetinfoStr,
  37754. // PatientId: patient.ID,
  37755. // RecordDate: theTime.Unix(),
  37756. // UserOrgId: adminInfo.CurrentOrgId,
  37757. // AdminUserId: adminInfo.AdminUser.Id,
  37758. // IsReturn: 1,
  37759. // }
  37760. //
  37761. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  37762. // //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")
  37763. // //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")
  37764. //
  37765. // //var dat map[string]interface{}
  37766. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37767. // // fmt.Println(dat)
  37768. // //} else {
  37769. // // fmt.Println(err)
  37770. // //}
  37771. //
  37772. // var dat2 map[string]interface{}
  37773. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37774. // fmt.Println(dat2)
  37775. // } else {
  37776. // fmt.Println(err)
  37777. // }
  37778. //
  37779. // } else {
  37780. // adminUser := c.GetAdminUserInfo()
  37781. // errlog := &models.HisOrderError{
  37782. // UserOrgId: adminUser.CurrentOrgId,
  37783. // Ctime: time.Now().Unix(),
  37784. // Mtime: time.Now().Unix(),
  37785. // ErrMsg: res.ErrMsg,
  37786. // Status: 1,
  37787. // PatientId: id,
  37788. // RecordTime: recordDateTime,
  37789. // Stage: 1,
  37790. // }
  37791. // service.CreateErrMsgLog(errlog)
  37792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  37793. // return
  37794. // }
  37795. // }
  37796. //
  37797. //}
  37798. //func (c *HisApiController) GetUploadDiag() {
  37799. // id, _ := c.GetInt64("id")
  37800. // record_time := c.GetString("record_time")
  37801. //
  37802. // diagnosis_id, _ := c.GetInt64("diagnosis")
  37803. // sick_type, _ := c.GetInt64("sick_type")
  37804. // reg_type, _ := c.GetInt64("reg_type")
  37805. //
  37806. // timeLayout := "2006-01-02"
  37807. // loc, _ := time.LoadLocation("Local")
  37808. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37809. // if err != nil {
  37810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37811. // return
  37812. // }
  37813. //
  37814. // var patientPrescription models.HisPrescriptionInfo
  37815. // recordDateTime := theTime.Unix()
  37816. // adminInfo := c.GetAdminUserInfo()
  37817. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37818. //
  37819. // if patientPrescription.ID == 0 {
  37820. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37821. // }
  37822. //
  37823. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37824. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  37825. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37826. // sickConfig, _ := service.FindSickById(sick_type)
  37827. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37828. //
  37829. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  37830. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  37831. // "&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 +
  37832. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  37833. // resp2, requestErr2 := http.Get(api2)
  37834. // if requestErr2 != nil {
  37835. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37836. // return
  37837. // }
  37838. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  37839. // if ioErr2 != nil {
  37840. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  37841. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37842. // return
  37843. // }
  37844. // var respJSON2 map[string]interface{}
  37845. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  37846. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37847. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37848. // return
  37849. // }
  37850. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37851. // userJSONBytes2, _ := json.Marshal(respJSON2)
  37852. //
  37853. // var res2 ResultSix
  37854. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37855. // utils.ErrorLog("解析失败:%v", err)
  37856. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37857. // return
  37858. // }
  37859. // if res2.Infcode != 0 {
  37860. // adminUser := c.GetAdminUserInfo()
  37861. // errlog := &models.HisOrderError{
  37862. // UserOrgId: adminUser.CurrentOrgId,
  37863. // Ctime: time.Now().Unix(),
  37864. // Mtime: time.Now().Unix(),
  37865. // ErrMsg: res2.ErrMsg,
  37866. // Status: 1,
  37867. // PatientId: id,
  37868. // RecordTime: recordDateTime,
  37869. // Stage: 3,
  37870. // }
  37871. // service.CreateErrMsgLog(errlog)
  37872. //
  37873. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  37874. // return
  37875. // }
  37876. //
  37877. // c.ServeSuccessJSON(map[string]interface{}{
  37878. // "msg": "上传成功",
  37879. // })
  37880. //
  37881. //}
  37882. type QueryResult struct {
  37883. ID int64
  37884. Name string
  37885. Code string
  37886. List_type_code string
  37887. }
  37888. func (c *HisApiController) GetCheckCode() {
  37889. ids_str := c.GetString("ids")
  37890. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  37891. ids_arr := strings.Split(ids_str, ",")
  37892. var queryResult []QueryResult
  37893. ids := make([]int64, 0)
  37894. for _, item := range ids_arr {
  37895. id, _ := strconv.ParseInt(item, 10, 64)
  37896. ids = append(ids, id)
  37897. }
  37898. if record_type == 1 {
  37899. drugs, _ := service.GetBatchDrugList(ids)
  37900. for _, item := range drugs {
  37901. result := QueryResult{
  37902. ID: item.ID,
  37903. Name: item.DrugName,
  37904. Code: item.MedicalInsuranceNumber,
  37905. List_type_code: "101",
  37906. }
  37907. queryResult = append(queryResult, result)
  37908. }
  37909. } else if record_type == 2 {
  37910. goods, _ := service.GetBatchGoodInformationList(ids)
  37911. fmt.Println(goods)
  37912. for _, item := range goods {
  37913. result := QueryResult{
  37914. ID: item.ID,
  37915. Name: item.GoodName,
  37916. Code: item.SocialSecurityDirectoryCode,
  37917. List_type_code: "301",
  37918. }
  37919. queryResult = append(queryResult, result)
  37920. }
  37921. } else if record_type == 3 {
  37922. projects, _ := service.GetBathchMyPorjecgList(ids)
  37923. for _, item := range projects {
  37924. result := QueryResult{
  37925. ID: item.ID,
  37926. Name: item.ProjectName,
  37927. Code: item.MedicalCode,
  37928. List_type_code: "201",
  37929. }
  37930. queryResult = append(queryResult, result)
  37931. }
  37932. }
  37933. admin_user_id, _ := c.GetInt64("admin_user_id")
  37934. adminUser := c.GetAdminUserInfo()
  37935. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37936. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37937. var user_name string
  37938. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37939. if role.ID == 0 {
  37940. user_name = "管理员"
  37941. } else {
  37942. user_name = role.UserName
  37943. }
  37944. baseParams := models.BaseParams{
  37945. SecretKey: miConfig.SecretKey,
  37946. FixmedinsCode: miConfig.Code,
  37947. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37948. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37949. OrgName: miConfig.OrgName,
  37950. Doctor: user_name,
  37951. }
  37952. var result string
  37953. if miConfig.MdtrtareaAdmvs == "430800" {
  37954. for _, item := range queryResult {
  37955. if record_type == 1 {
  37956. 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)
  37957. } else if record_type == 2 {
  37958. fmt.Println(item.Code)
  37959. 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)
  37960. } else if record_type == 3 {
  37961. 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)
  37962. }
  37963. var dat map[string]interface{}
  37964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37965. fmt.Println(dat)
  37966. } else {
  37967. fmt.Println(err)
  37968. }
  37969. userJSONBytes, _ := json.Marshal(dat)
  37970. var res ResultSix
  37971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37972. utils.ErrorLog("解析失败:%v", err)
  37973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37974. return
  37975. }
  37976. if res.Infcode == 0 {
  37977. if record_type == 1 {
  37978. service.UpdateBaseDrugById(item.ID)
  37979. } else if record_type == 2 {
  37980. service.UpdateGoodInformaitonByDetail(item.ID)
  37981. } else if record_type == 3 {
  37982. service.UpdateProjectById(item.ID)
  37983. }
  37984. c.ServeSuccessJSON(map[string]interface{}{
  37985. "failed_code": 0,
  37986. "msg": "目录对照成功",
  37987. })
  37988. } else {
  37989. c.ServeSuccessJSON(map[string]interface{}{
  37990. "failed_code": -10,
  37991. "msg": res.ErrMsg,
  37992. })
  37993. }
  37994. }
  37995. } else {
  37996. for _, item := range queryResult {
  37997. var result string
  37998. if record_type == 1 {
  37999. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38000. } else if record_type == 2 {
  38001. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38002. } else if record_type == 3 {
  38003. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38004. }
  38005. var dat map[string]interface{}
  38006. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38007. fmt.Println(dat)
  38008. } else {
  38009. fmt.Println(err)
  38010. }
  38011. userJSONBytes, _ := json.Marshal(dat)
  38012. var res ResultSix
  38013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38014. utils.ErrorLog("解析失败:%v", err)
  38015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38016. return
  38017. }
  38018. if res.Infcode == 0 {
  38019. if record_type == 1 {
  38020. service.UpdateBaseDrugById(item.ID)
  38021. } else if record_type == 2 {
  38022. service.UpdateGoodInformaitonByDetail(item.ID)
  38023. } else if record_type == 3 {
  38024. service.UpdateProjectById(item.ID)
  38025. }
  38026. c.ServeSuccessJSON(map[string]interface{}{
  38027. "failed_code": 0,
  38028. "msg": "目录对照成功",
  38029. })
  38030. } else {
  38031. c.ServeSuccessJSON(map[string]interface{}{
  38032. "failed_code": -10,
  38033. "msg": res.ErrMsg,
  38034. })
  38035. }
  38036. }
  38037. }
  38038. }
  38039. func (c *HisApiController) UnCheckCode() {
  38040. ids_str := c.GetString("ids")
  38041. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38042. admin_user_id, _ := c.GetInt64("admin_user_id")
  38043. ids_arr := strings.Split(ids_str, ",")
  38044. var queryResult []QueryResult
  38045. ids := make([]int64, 0)
  38046. for _, item := range ids_arr {
  38047. id, _ := strconv.ParseInt(item, 10, 64)
  38048. ids = append(ids, id)
  38049. }
  38050. if record_type == 1 {
  38051. drugs, _ := service.GetBatchDrugList(ids)
  38052. for _, item := range drugs {
  38053. result := QueryResult{
  38054. ID: item.ID,
  38055. Name: item.DrugName,
  38056. Code: item.MedicalInsuranceNumber,
  38057. List_type_code: "101",
  38058. }
  38059. queryResult = append(queryResult, result)
  38060. }
  38061. } else if record_type == 2 {
  38062. goods, _ := service.GetBatchGoodInformationList(ids)
  38063. for _, item := range goods {
  38064. result := QueryResult{
  38065. ID: item.ID,
  38066. Name: item.GoodName,
  38067. Code: item.SocialSecurityDirectoryCode,
  38068. List_type_code: "301",
  38069. }
  38070. queryResult = append(queryResult, result)
  38071. }
  38072. } else if record_type == 3 {
  38073. projects, _ := service.GetBathchMyPorjecgList(ids)
  38074. for _, item := range projects {
  38075. result := QueryResult{
  38076. ID: item.ID,
  38077. Name: item.ProjectName,
  38078. Code: item.MedicalCode,
  38079. List_type_code: "201",
  38080. }
  38081. queryResult = append(queryResult, result)
  38082. }
  38083. }
  38084. adminUser := c.GetAdminUserInfo()
  38085. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38086. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38087. var user_name string
  38088. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38089. if role.ID == 0 {
  38090. user_name = "xxx"
  38091. } else {
  38092. user_name = role.UserName
  38093. }
  38094. baseParams := &models.BaseParams{
  38095. SecretKey: miConfig.SecretKey,
  38096. FixmedinsCode: miConfig.Code,
  38097. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38098. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38099. OrgName: miConfig.OrgName,
  38100. Doctor: user_name,
  38101. }
  38102. if config.IsOpen == 1 {
  38103. if miConfig.MdtrtareaAdmvs == "430800" {
  38104. for _, item := range queryResult {
  38105. var result string
  38106. if record_type == 1 {
  38107. 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)
  38108. } else if record_type == 2 {
  38109. fmt.Println(item.Code)
  38110. 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)
  38111. } else if record_type == 3 {
  38112. 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)
  38113. }
  38114. var dat map[string]interface{}
  38115. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38116. fmt.Println(dat)
  38117. } else {
  38118. fmt.Println(err)
  38119. }
  38120. userJSONBytes, _ := json.Marshal(dat)
  38121. var res ResultSix
  38122. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38123. utils.ErrorLog("解析失败:%v", err)
  38124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38125. return
  38126. }
  38127. if res.Infcode == 0 {
  38128. if record_type == 1 {
  38129. service.UpdateBaseDrugById(item.ID)
  38130. } else if record_type == 2 {
  38131. service.UpdateGoodInformaitonByDetail(item.ID)
  38132. } else if record_type == 3 {
  38133. service.UpdateProjectById(item.ID)
  38134. }
  38135. c.ServeSuccessJSON(map[string]interface{}{
  38136. "failed_code": 0,
  38137. "msg": "目录对照成功",
  38138. })
  38139. } else {
  38140. c.ServeSuccessJSON(map[string]interface{}{
  38141. "failed_code": -10,
  38142. "msg": res.ErrMsg,
  38143. })
  38144. }
  38145. }
  38146. } else {
  38147. for _, item := range queryResult {
  38148. var result string
  38149. if record_type == 1 {
  38150. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38151. } else if record_type == 2 {
  38152. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38153. } else if record_type == 3 {
  38154. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38155. }
  38156. var dat2 map[string]interface{}
  38157. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  38158. fmt.Println(dat2)
  38159. } else {
  38160. fmt.Println(err)
  38161. }
  38162. userJSONBytes, _ := json.Marshal(dat2)
  38163. var res ResultSix
  38164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38165. utils.ErrorLog("解析失败:%v", err)
  38166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38167. return
  38168. }
  38169. if res.Infcode == 0 {
  38170. if record_type == 1 {
  38171. service.UpdateDrugByIdDetail(item.ID)
  38172. } else if record_type == 2 {
  38173. service.UpdateGoodInfoById(item.ID)
  38174. } else if record_type == 3 {
  38175. service.UpdateMyProjectById(item.ID)
  38176. }
  38177. c.ServeSuccessJSON(map[string]interface{}{
  38178. "failed_code": 0,
  38179. "msg": "撤销目录对照成功",
  38180. })
  38181. } else {
  38182. c.ServeSuccessJSON(map[string]interface{}{
  38183. "failed_code": -10,
  38184. "msg": res.ErrMsg,
  38185. })
  38186. }
  38187. }
  38188. }
  38189. }
  38190. }
  38191. func (c *HisApiController) GetPatientInfo() {
  38192. id_card_no := c.GetString("id_card_no")
  38193. admin_user_id, _ := c.GetInt64("admin_user_id")
  38194. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  38195. if patient.ID == 0 {
  38196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38197. return
  38198. }
  38199. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  38200. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38201. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  38202. var res ResultTwo
  38203. var res10265 ResultTwo10265
  38204. if config.IsOpen == 1 {
  38205. if miConfig.MdtrtareaAdmvs == "150499" {
  38206. //请求内网数据
  38207. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  38208. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38209. "&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
  38210. resp, requestErr := http.Get(api)
  38211. if requestErr != nil {
  38212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38213. return
  38214. }
  38215. body, ioErr := ioutil.ReadAll(resp.Body)
  38216. if ioErr != nil {
  38217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38219. return
  38220. }
  38221. var respJSON map[string]interface{}
  38222. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38225. return
  38226. }
  38227. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38228. result_byte, _ := json.Marshal(respJSON)
  38229. result := string(result_byte)
  38230. var dat map[string]interface{}
  38231. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38232. fmt.Println(dat)
  38233. } else {
  38234. fmt.Println(err)
  38235. }
  38236. userJSONBytes, _ := json.Marshal(dat)
  38237. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38238. utils.ErrorLog("解析失败:%v", err)
  38239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38240. return
  38241. }
  38242. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38243. res.Infcode = Infcode
  38244. res.ErrMsg = res10265.ErrMsg
  38245. res.Output = res10265.Output
  38246. res.InfRefmsgid = res10265.InfRefmsgid
  38247. res.RespondTime = res10265.RespondTime
  38248. res.WarnInfo = res10265.WarnInfo
  38249. } else {
  38250. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  38251. var dat map[string]interface{}
  38252. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38253. fmt.Println(dat)
  38254. } else {
  38255. fmt.Println(err)
  38256. }
  38257. userJSONBytes, _ := json.Marshal(dat)
  38258. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38259. utils.ErrorLog("解析失败:%v", err)
  38260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38261. return
  38262. }
  38263. }
  38264. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38265. // utils.ErrorLog("解析失败:%v", err)
  38266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38267. // return
  38268. //}
  38269. for index, item := range res.Output.Iinfo {
  38270. if item.PsnInsuStas == "2" {
  38271. fmt.Println("--------")
  38272. res.Output.Iinfo[index].Insutype = "300"
  38273. res.Output.Iinfo[index].PsnInsuStas = "1"
  38274. }
  38275. }
  38276. fmt.Println(res.Output.Iinfo)
  38277. if res.Infcode != 0 {
  38278. c.ServeSuccessJSON(map[string]interface{}{
  38279. "failed_code": -10,
  38280. "msg": res.ErrMsg,
  38281. })
  38282. } else {
  38283. c.ServeSuccessJSON(map[string]interface{}{
  38284. "failed_code": 0,
  38285. "info": res,
  38286. })
  38287. }
  38288. }
  38289. }
  38290. func (c *HisApiController) PsnPutOnRecord() {
  38291. record_type, _ := c.GetInt64("type")
  38292. patient_id, _ := c.GetInt64("patient_id")
  38293. admin_user_id, _ := c.GetInt64("admin_user_id")
  38294. start_time := c.GetString("start_time")
  38295. end_time := c.GetString("end_time")
  38296. adminUser := c.GetAdminUserInfo()
  38297. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38298. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38299. var patients []*models.Patients
  38300. if record_type == 1 { //全部备案
  38301. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  38302. patients = append(patients, patient...)
  38303. } else { //单个备案
  38304. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38305. patients = append(patients, patient)
  38306. }
  38307. var user_name string
  38308. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38309. if role.ID == 0 {
  38310. user_name = "xxx"
  38311. } else {
  38312. user_name = role.UserName
  38313. }
  38314. if config.IsOpen == 1 {
  38315. for _, item := range patients {
  38316. 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
  38317. resp, requestErr := http.Get(api)
  38318. if requestErr != nil {
  38319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38320. return
  38321. }
  38322. defer resp.Body.Close()
  38323. body, ioErr := ioutil.ReadAll(resp.Body)
  38324. if ioErr != nil {
  38325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38327. return
  38328. }
  38329. var respJSON map[string]interface{}
  38330. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38333. return
  38334. }
  38335. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38336. userJSONBytes, _ := json.Marshal(userJSON)
  38337. var res ResultTwo
  38338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38339. utils.ErrorLog("解析失败:%v", err)
  38340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38341. return
  38342. }
  38343. if res.Infcode == 0 {
  38344. 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)
  38345. var dat map[string]interface{}
  38346. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38347. fmt.Println(dat)
  38348. } else {
  38349. fmt.Println(err)
  38350. }
  38351. userJSONBytes, _ := json.Marshal(dat)
  38352. var res2 ResultThirteen
  38353. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38354. utils.ErrorLog("解析失败:%v", err)
  38355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38356. return
  38357. }
  38358. if res2.Infcode == 0 {
  38359. psnResult := &models.GdybPsnRecord{
  38360. UserOrgId: adminUser.CurrentOrgId,
  38361. PatientId: item.ID,
  38362. PsnNo: res.Output.Baseinfo.PsnNo,
  38363. Ctime: time.Now().Unix(),
  38364. Mtime: time.Now().Unix(),
  38365. Status: 1,
  38366. IsCancel: 1,
  38367. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38368. }
  38369. service.CreatePsnRecord(psnResult)
  38370. } else {
  38371. c.ServeSuccessJSON(map[string]interface{}{
  38372. "failed_code": -10,
  38373. "msg": res2.ErrMsg,
  38374. })
  38375. return
  38376. }
  38377. }
  38378. }
  38379. }
  38380. }
  38381. func (c *HisApiController) PsnUnPutOnRecord() {
  38382. id, _ := c.GetInt64("id")
  38383. //record_type, _ := c.GetInt64("type")
  38384. admin_user_id, _ := c.GetInt64("admin_user_id")
  38385. adminUser := c.GetAdminUserInfo()
  38386. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38387. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38388. var user_name string
  38389. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38390. if role.ID == 0 {
  38391. user_name = "xxx"
  38392. } else {
  38393. user_name = role.UserName
  38394. }
  38395. psn_record, _ := service.GetPsnRecordById(id)
  38396. if psn_record.ID == 0 {
  38397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38398. return
  38399. }
  38400. if config.IsOpen == 1 {
  38401. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38402. var dat map[string]interface{}
  38403. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38404. fmt.Println(dat)
  38405. } else {
  38406. fmt.Println(err)
  38407. }
  38408. userJSONBytes, _ := json.Marshal(dat)
  38409. var res ResultFourteen
  38410. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38411. utils.ErrorLog("解析失败:%v", err)
  38412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38413. return
  38414. }
  38415. if res.Infcode == 0 {
  38416. psn_record.IsCancel = 2
  38417. service.CreatePsnRecord(&psn_record)
  38418. } else {
  38419. c.ServeSuccessJSON(map[string]interface{}{
  38420. "failed_code": -10,
  38421. "msg": res.ErrMsg,
  38422. })
  38423. return
  38424. }
  38425. }
  38426. }
  38427. func (c *HisApiController) PsnPutNCDSOnRecord() {
  38428. patient_id, _ := c.GetInt64("patient_id")
  38429. insutype_two := c.GetString("insutype")
  38430. psn_no := c.GetString("psn_no")
  38431. doctor_id, _ := c.GetInt64("doctor_id")
  38432. sick_id, _ := c.GetInt64("sick_id")
  38433. department_id, _ := c.GetInt64("department_id")
  38434. start_time := c.GetString("start_time")
  38435. end_time := c.GetString("end_time")
  38436. check_time := c.GetString("check_time")
  38437. hospital_code := c.GetString("hospital_code")
  38438. hospital_name := c.GetString("hospital_name")
  38439. adminUser := c.GetAdminUserInfo()
  38440. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38441. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38442. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38443. sick, _ := service.FindSickById(sick_id)
  38444. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38445. if len(hospital_code) == 0 {
  38446. hospital_code = miConfig.Code
  38447. }
  38448. if len(hospital_name) == 0 {
  38449. hospital_name = miConfig.OrgName
  38450. }
  38451. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38452. var res ResultTwo
  38453. var res10265 ResultTwo10265
  38454. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38455. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  38456. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  38457. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38458. "&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
  38459. resp, requestErr := http.Get(api)
  38460. if requestErr != nil {
  38461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38462. return
  38463. }
  38464. body, ioErr := ioutil.ReadAll(resp.Body)
  38465. if ioErr != nil {
  38466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38468. return
  38469. }
  38470. var respJSON map[string]interface{}
  38471. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38474. return
  38475. }
  38476. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38477. result, _ := json.Marshal(respJSON)
  38478. fmt.Println("log")
  38479. fmt.Println(string(result))
  38480. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38481. utils.ErrorLog("解析失败:%v", err)
  38482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38483. return
  38484. }
  38485. res.ErrMsg = res10265.ErrMsg
  38486. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38487. res.Infcode = infocode
  38488. res.Output = res10265.Output
  38489. res.InfRefmsgid = res10265.InfRefmsgid
  38490. } else {
  38491. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38492. if miConfig.Code == "H15049901371" {
  38493. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38494. utils.ErrorLog("解析失败:%v", err)
  38495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38496. return
  38497. }
  38498. res.ErrMsg = res10265.ErrMsg
  38499. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38500. res.Infcode = infocode
  38501. res.Output = res10265.Output
  38502. res.InfRefmsgid = res10265.InfRefmsgid
  38503. } else {
  38504. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38505. utils.ErrorLog("解析失败:%v", err)
  38506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38507. return
  38508. }
  38509. }
  38510. }
  38511. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38512. infoStr := string(Iinfos)
  38513. var rf []*ResultFive
  38514. json.Unmarshal([]byte(infoStr), &rf)
  38515. var insuplc_admdvs string
  38516. var insutype string
  38517. var is390 int = 0
  38518. var is310 int = 0
  38519. var insutypes []*ResultFive
  38520. for _, item := range rf {
  38521. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38522. insutypes = append(insutypes, item)
  38523. }
  38524. }
  38525. if len(insutypes) == 1 {
  38526. insutype = insutypes[0].Insutype
  38527. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38528. } else {
  38529. for _, i := range insutypes {
  38530. if i.Insutype == "390" {
  38531. is390 = 1
  38532. }
  38533. if i.Insutype == "310" {
  38534. is310 = 1
  38535. }
  38536. }
  38537. }
  38538. if is390 == 1 {
  38539. insutype = "390"
  38540. }
  38541. if is310 == 1 {
  38542. insutype = "310"
  38543. }
  38544. if len(insutypes) == 2 {
  38545. insutype = insutype_two
  38546. }
  38547. if len(insutypes) == 0 {
  38548. insutype = "310"
  38549. }
  38550. insutype = insutype_two
  38551. fmt.Println(insutype)
  38552. for _, item := range rf {
  38553. fmt.Println(item.Insutype)
  38554. fmt.Println(insutype)
  38555. if item.Insutype == insutype {
  38556. fmt.Println(item.Insutype)
  38557. fmt.Println(insutype)
  38558. insuplc_admdvs = item.InsuplcAdmdvs
  38559. }
  38560. }
  38561. fmt.Println(insuplc_admdvs)
  38562. var res2 ResultThirteen
  38563. var res10265_2 ResultThirteen10265
  38564. if config.IsOpen == 1 {
  38565. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38566. } else {
  38567. if miConfig.MdtrtareaAdmvs == "150499" {
  38568. //
  38569. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  38570. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38571. // "&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
  38572. //resp, requestErr := http.Get(api)
  38573. //if requestErr != nil {
  38574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38575. // return
  38576. //}
  38577. //
  38578. //body, ioErr := ioutil.ReadAll(resp.Body)
  38579. //if ioErr != nil {
  38580. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38581. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38582. // return
  38583. //}
  38584. //var respJSON map[string]interface{}
  38585. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38586. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38588. // return
  38589. //}
  38590. //
  38591. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38592. //result, _ := json.Marshal(respJSON)
  38593. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  38594. // utils.ErrorLog("解析失败:%v", err)
  38595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38596. // return
  38597. //}
  38598. //infocode = resThree.Infcode
  38599. //result, _ := json.Marshal(respJSON)
  38600. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  38601. // utils.ErrorLog("解析失败:%v", err)
  38602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38603. // return
  38604. //}
  38605. //
  38606. //resThree.ErrMsg = resThree10265.ErrMsg
  38607. //
  38608. //resThree.Output = resThree10265.Output
  38609. //
  38610. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  38611. //
  38612. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  38613. //
  38614. } else {
  38615. 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)
  38616. var dat map[string]interface{}
  38617. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38618. fmt.Println(dat)
  38619. } else {
  38620. fmt.Println(err)
  38621. }
  38622. userJSONBytes, _ := json.Marshal(dat)
  38623. if miConfig.Code == "H15049901371" {
  38624. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  38625. utils.ErrorLog("解析失败:%v", err)
  38626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38627. return
  38628. }
  38629. res2.ErrMsg = res10265_2.ErrMsg
  38630. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  38631. res2.Infcode = infocode
  38632. res2.Output = res10265_2.Output
  38633. res2.InfRefmsgid = res10265_2.InfRefmsgid
  38634. } else {
  38635. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38636. utils.ErrorLog("解析失败:%v", err)
  38637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38638. return
  38639. }
  38640. }
  38641. }
  38642. }
  38643. if res2.Infcode == 0 {
  38644. psnResult := &models.GdybPsnNcdsRecord{
  38645. UserOrgId: adminUser.CurrentOrgId,
  38646. PatientId: patient.ID,
  38647. PsnNo: psn_no,
  38648. DoctorId: doctor.AdminUserId,
  38649. DepartmentId: department_id,
  38650. SickType: sick_id,
  38651. Insutype: insutype,
  38652. Ctime: time.Now().Unix(),
  38653. Mtime: time.Now().Unix(),
  38654. Status: 1,
  38655. IsCancel: 1,
  38656. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38657. }
  38658. service.CreatePsnNCDSRecord(psnResult)
  38659. c.ServeSuccessJSON(map[string]interface{}{
  38660. "failed_code": 0,
  38661. "msg": "备案成功",
  38662. "result": psnResult,
  38663. })
  38664. } else {
  38665. c.ServeSuccessJSON(map[string]interface{}{
  38666. "failed_code": -10,
  38667. "msg": res2.ErrMsg,
  38668. })
  38669. return
  38670. }
  38671. }
  38672. }
  38673. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  38674. id, _ := c.GetInt64("id")
  38675. admin_user_id, _ := c.GetInt64("admin_user_id")
  38676. adminUser := c.GetAdminUserInfo()
  38677. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38678. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38679. //config, _ := service.Ge(adminUser.CurrentOrgId)
  38680. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  38681. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38682. //var user_name string
  38683. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38684. //if role.ID == 0 {
  38685. // user_name = "xxx"
  38686. //} else {
  38687. // user_name = role.UserName
  38688. //}
  38689. psn_record, _ := service.GetPsnNCDSRecordById(id)
  38690. if psn_record.ID == 0 {
  38691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38692. return
  38693. }
  38694. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38695. var res ResultTwo
  38696. var res10265 ResultTwo10265
  38697. if miConfig.Code == "H15049901371" {
  38698. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38699. utils.ErrorLog("解析失败:%v", err)
  38700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38701. return
  38702. }
  38703. res.ErrMsg = res10265.ErrMsg
  38704. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38705. res.Infcode = infocode
  38706. res.Output = res10265.Output
  38707. res.InfRefmsgid = res10265.InfRefmsgid
  38708. } else {
  38709. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38710. utils.ErrorLog("解析失败:%v", err)
  38711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38712. return
  38713. }
  38714. }
  38715. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38716. infoStr := string(Iinfos)
  38717. var rf []*ResultFive
  38718. json.Unmarshal([]byte(infoStr), &rf)
  38719. var insuplc_admdvs string
  38720. var insutype string
  38721. var is390 int = 0
  38722. var is310 int = 0
  38723. var insutypes []*ResultFive
  38724. for _, item := range rf {
  38725. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38726. insutypes = append(insutypes, item)
  38727. }
  38728. }
  38729. if len(insutypes) == 1 {
  38730. insutype = insutypes[0].Insutype
  38731. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38732. } else {
  38733. for _, i := range insutypes {
  38734. if i.Insutype == "390" {
  38735. is390 = 1
  38736. }
  38737. if i.Insutype == "310" {
  38738. is310 = 1
  38739. }
  38740. }
  38741. }
  38742. if is390 == 1 {
  38743. insutype = "390"
  38744. }
  38745. if is310 == 1 {
  38746. insutype = "310"
  38747. }
  38748. if len(insutypes) == 0 {
  38749. insutype = "310"
  38750. }
  38751. insutype = psn_record.Insutype
  38752. for _, item := range rf {
  38753. if item.Insutype == insutype {
  38754. insuplc_admdvs = item.InsuplcAdmdvs
  38755. }
  38756. }
  38757. if config.IsOpen == 1 {
  38758. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38759. var dat map[string]interface{}
  38760. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38761. fmt.Println(dat)
  38762. } else {
  38763. fmt.Println(err)
  38764. }
  38765. userJSONBytes, _ := json.Marshal(dat)
  38766. var res ResultFourteen
  38767. var res10265 ResultFourteen10265
  38768. if miConfig.Code == "H15049901371" {
  38769. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38770. utils.ErrorLog("解析失败:%v", err)
  38771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38772. return
  38773. }
  38774. res.ErrMsg = res10265.ErrMsg
  38775. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38776. res.Infcode = infocode
  38777. res.Output = res10265.Output
  38778. res.InfRefmsgid = res10265.InfRefmsgid
  38779. } else {
  38780. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38781. utils.ErrorLog("解析失败:%v", err)
  38782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38783. return
  38784. }
  38785. }
  38786. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38787. // utils.ErrorLog("解析失败:%v", err)
  38788. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38789. // return
  38790. //}
  38791. if res.Infcode == 0 {
  38792. psn_record.IsCancel = 2
  38793. service.CreatePsnNCDSRecord(&psn_record)
  38794. c.ServeSuccessJSON(map[string]interface{}{
  38795. "failed_code": 0,
  38796. "msg": "撤销备案成功",
  38797. })
  38798. } else {
  38799. c.ServeSuccessJSON(map[string]interface{}{
  38800. "failed_code": -10,
  38801. "msg": res.ErrMsg,
  38802. })
  38803. return
  38804. }
  38805. }
  38806. }
  38807. func (c *HisApiController) TestTest() {
  38808. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  38809. fmt.Println(patient.Iinfo)
  38810. }
  38811. type CustomData struct {
  38812. MsgId string
  38813. PsnNo string
  38814. Info string
  38815. }
  38816. func (c *HisApiController) ReversalData() {
  38817. var customData []*CustomData
  38818. custom := &CustomData{
  38819. MsgId: "H44022900158202103301714472004",
  38820. PsnNo: "44020000001101329945",
  38821. Info: "2207",
  38822. }
  38823. customData = append(customData, custom)
  38824. custom1 := &CustomData{
  38825. MsgId: "H4402290015820210330172057803",
  38826. PsnNo: "44020000001101161813",
  38827. Info: "2207",
  38828. }
  38829. customData = append(customData, custom1)
  38830. custom2 := &CustomData{
  38831. MsgId: "H44022900158202103301705198813",
  38832. PsnNo: "44190000133097375417",
  38833. Info: "2207",
  38834. }
  38835. customData = append(customData, custom2)
  38836. custom3 := &CustomData{
  38837. MsgId: "H44022900158202103301715524756",
  38838. PsnNo: "44020000001100187221",
  38839. Info: "2207",
  38840. }
  38841. customData = append(customData, custom3)
  38842. custom4 := &CustomData{
  38843. MsgId: "H44022900158202103301730376224",
  38844. PsnNo: "44020000001101959155",
  38845. Info: "2207",
  38846. }
  38847. customData = append(customData, custom4)
  38848. custom5 := &CustomData{
  38849. MsgId: "H44022900158202103301748008725",
  38850. PsnNo: "44020000001104246641",
  38851. Info: "2207",
  38852. }
  38853. customData = append(customData, custom5)
  38854. custom6 := &CustomData{
  38855. MsgId: "H44022900158202103301718096755",
  38856. PsnNo: "44020000001102211860",
  38857. Info: "2207",
  38858. }
  38859. customData = append(customData, custom6)
  38860. custom7 := &CustomData{
  38861. MsgId: "H44022900158202103301736551640",
  38862. PsnNo: "44020000001102687718",
  38863. Info: "2207",
  38864. }
  38865. customData = append(customData, custom7)
  38866. custom8 := &CustomData{
  38867. MsgId: "H44022900158202103301743097676",
  38868. PsnNo: "44020000001102127785",
  38869. Info: "2207",
  38870. }
  38871. customData = append(customData, custom8)
  38872. custom9 := &CustomData{
  38873. MsgId: "H44022900158202103301712304203",
  38874. PsnNo: "44020000001101518097",
  38875. Info: "2207",
  38876. }
  38877. customData = append(customData, custom9)
  38878. custom10 := &CustomData{
  38879. MsgId: "H44022900158202103301738448785",
  38880. PsnNo: "44020000001100500813",
  38881. Info: "2207",
  38882. }
  38883. customData = append(customData, custom10)
  38884. custom11 := &CustomData{
  38885. MsgId: "H44022900158202103301732455843",
  38886. PsnNo: "44020000001102690557",
  38887. Info: "2207",
  38888. }
  38889. customData = append(customData, custom11)
  38890. custom12 := &CustomData{
  38891. MsgId: "H44022900158202103301745421708",
  38892. PsnNo: "44020000001102211928",
  38893. Info: "2207",
  38894. }
  38895. customData = append(customData, custom12)
  38896. custom1212 := &CustomData{
  38897. MsgId: "H440229001582021033017351627",
  38898. PsnNo: "44020000001102481733",
  38899. Info: "2207",
  38900. }
  38901. customData = append(customData, custom1212)
  38902. custom13 := &CustomData{
  38903. MsgId: "H44022900158202103301740327951",
  38904. PsnNo: "44020000001103174866",
  38905. Info: "2207",
  38906. }
  38907. customData = append(customData, custom13)
  38908. custom14 := &CustomData{
  38909. MsgId: "H4402290015820210330174922668",
  38910. PsnNo: "44020000001102927272",
  38911. Info: "2207",
  38912. }
  38913. customData = append(customData, custom14)
  38914. custom15 := &CustomData{
  38915. MsgId: "H44022900158202103301752362273",
  38916. PsnNo: "44020000001102942890",
  38917. Info: "2207",
  38918. }
  38919. customData = append(customData, custom15)
  38920. custom16 := &CustomData{
  38921. MsgId: "H44022900158202103301751082917",
  38922. PsnNo: "44020000001101662162",
  38923. Info: "2207",
  38924. }
  38925. customData = append(customData, custom16)
  38926. custom17 := &CustomData{
  38927. MsgId: "H44022900158202103301754147728",
  38928. PsnNo: "44020000000229014511",
  38929. Info: "2207",
  38930. }
  38931. customData = append(customData, custom17)
  38932. adminUser := c.GetAdminUserInfo()
  38933. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38934. for _, item := range customData {
  38935. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  38936. fmt.Println(result)
  38937. }
  38938. }
  38939. func (c *HisApiController) GetAllopatry() {
  38940. year := c.GetString("year")
  38941. month := c.GetString("month")
  38942. admin_user_id, _ := c.GetInt64("admin_user_id")
  38943. adminUser := c.GetAdminUserInfo()
  38944. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38945. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38946. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38947. var dat map[string]interface{}
  38948. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38949. fmt.Println(dat)
  38950. } else {
  38951. fmt.Println(err)
  38952. }
  38953. userJSONBytes, _ := json.Marshal(dat)
  38954. var res models.Result9001
  38955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38956. utils.ErrorLog("解析失败:%v", err)
  38957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38958. return
  38959. }
  38960. fmt.Println(res.Output.Signinoutb)
  38961. fmt.Println(res.Output.Signinoutb.SignNo)
  38962. fmt.Println(string(userJSONBytes))
  38963. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  38964. var dat3 map[string]interface{}
  38965. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  38966. fmt.Println(dat3)
  38967. } else {
  38968. fmt.Println(err)
  38969. }
  38970. userJSONBytes3, _ := json.Marshal(dat3)
  38971. var res3 models.Result3260
  38972. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  38973. utils.ErrorLog("解析失败:%v", err)
  38974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38975. return
  38976. }
  38977. var curpage int
  38978. var pagesize int = 100
  38979. var start int = 1
  38980. //var stop int
  38981. //pagecount := 10
  38982. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  38983. var res22 []models.Result3260
  38984. for curpage = 1; curpage <= pagecount; curpage++ {
  38985. if curpage == 1 {
  38986. start = 0
  38987. } else {
  38988. start = (curpage-1)*pagesize + 1
  38989. }
  38990. fmt.Println(start)
  38991. //stop = curpage * pagesize
  38992. //if stop > int(res3.Output.Totalrow) {
  38993. // stop =int(res3.Output.Totalrow)
  38994. //}
  38995. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  38996. var dat2 map[string]interface{}
  38997. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38998. fmt.Println(dat)
  38999. } else {
  39000. fmt.Println(err)
  39001. }
  39002. userJSONBytes2, _ := json.Marshal(dat2)
  39003. var res2 models.Result3260
  39004. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39005. utils.ErrorLog("解析失败:%v", err)
  39006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39007. return
  39008. }
  39009. if res2.Infcode == 0 {
  39010. res22 = append(res22, res2)
  39011. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39012. //var dat2 map[string]interface{}
  39013. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39014. // fmt.Println(dat)
  39015. //} else {
  39016. // fmt.Println(err)
  39017. //}
  39018. //c.ServeSuccessJSON(map[string]interface{}{
  39019. // "list": res2.Output.Data,
  39020. //})
  39021. //continue
  39022. }
  39023. }
  39024. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39025. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39026. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  39027. //var dat2 map[string]interface{}
  39028. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39029. // fmt.Println(dat)
  39030. //} else {
  39031. // fmt.Println(err)
  39032. //}
  39033. //userJSONBytes2, _ := json.Marshal(dat2)
  39034. //var res2 models.Result3260
  39035. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39036. // utils.ErrorLog("解析失败:%v", err)
  39037. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39038. // return
  39039. //}
  39040. //if res2.Infcode == 0 {
  39041. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39042. // var dat2 map[string]interface{}
  39043. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39044. // fmt.Println(dat)
  39045. // } else {
  39046. // fmt.Println(err)
  39047. // }
  39048. // c.ServeSuccessJSON(map[string]interface{}{
  39049. // "list": res2.Output.Data,
  39050. // })
  39051. //}
  39052. }
  39053. func (c *HisApiController) ComfirmAllopatry() {
  39054. year := c.GetString("year")
  39055. month := c.GetString("month")
  39056. admin_user_id, _ := c.GetInt64("admin_user_id")
  39057. adminUser := c.GetAdminUserInfo()
  39058. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39059. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39060. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39061. var dat map[string]interface{}
  39062. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39063. fmt.Println(dat)
  39064. } else {
  39065. fmt.Println(err)
  39066. }
  39067. userJSONBytes, _ := json.Marshal(dat)
  39068. var res models.Result9001
  39069. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39070. utils.ErrorLog("解析失败:%v", err)
  39071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39072. return
  39073. }
  39074. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39075. var dat2 map[string]interface{}
  39076. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39077. fmt.Println(dat)
  39078. } else {
  39079. fmt.Println(err)
  39080. }
  39081. userJSONBytes2, _ := json.Marshal(dat2)
  39082. var res2 models.Result3260
  39083. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39084. utils.ErrorLog("解析失败:%v", err)
  39085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39086. return
  39087. }
  39088. //if res2.Infcode == 0 {
  39089. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39090. // var dat map[string]interface{}
  39091. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39092. // fmt.Println(dat)
  39093. // } else {
  39094. // fmt.Println(err)
  39095. // }
  39096. // userJSONBytes, _ := json.Marshal(dat)
  39097. // var res3 models.Result3261
  39098. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  39099. // utils.ErrorLog("解析失败:%v", err)
  39100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39101. // return
  39102. // }
  39103. //
  39104. // if res3.Infcode == 0 {
  39105. // record := &models.HisYidiClearRecord{
  39106. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39107. // Ctime: time.Now().Unix(),
  39108. // Mtime: time.Now().Unix(),
  39109. // Status: 1,
  39110. // MsgId: msgId,
  39111. // }
  39112. // service.SaveClearRecord(record)
  39113. // c.ServeSuccessJSON(map[string]interface{}{
  39114. // "msg": "提取成功",
  39115. // })
  39116. // }
  39117. //}
  39118. }
  39119. func (c *HisApiController) RefundAllopatry() {
  39120. year := c.GetString("year")
  39121. month := c.GetString("month")
  39122. //id, _ := c.GetInt64("id")
  39123. admin_user_id, _ := c.GetInt64("admin_user_id")
  39124. adminUser := c.GetAdminUserInfo()
  39125. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39126. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39127. //record, _ := service.GetClearRecordById(id)
  39128. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39129. var dat map[string]interface{}
  39130. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  39131. fmt.Println(dat)
  39132. } else {
  39133. fmt.Println(err)
  39134. }
  39135. userJSONBytes, _ := json.Marshal(dat)
  39136. var res models.Result9001
  39137. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39138. utils.ErrorLog("解析失败:%v", err)
  39139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39140. return
  39141. }
  39142. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  39143. var dat2 map[string]interface{}
  39144. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  39145. fmt.Println(dat)
  39146. } else {
  39147. fmt.Println(err)
  39148. }
  39149. userJSONBytes2, _ := json.Marshal(dat2)
  39150. var empty ResultFourteen
  39151. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  39152. utils.ErrorLog("解析失败:%v", err)
  39153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39154. return
  39155. }
  39156. if empty.Infcode == 0 {
  39157. c.ServeSuccessJSON(map[string]interface{}{
  39158. "msg": "撤销成功",
  39159. })
  39160. return
  39161. }
  39162. }
  39163. func (c *HisApiController) ReversalOtherData() {
  39164. var customData []*CustomData
  39165. custom := &CustomData{
  39166. MsgId: "H44022900158202103301714472004",
  39167. PsnNo: "44020000001101329945",
  39168. Info: "2208",
  39169. }
  39170. customData = append(customData, custom)
  39171. custom1 := &CustomData{
  39172. MsgId: "H4402290015820210330172057803",
  39173. PsnNo: "44020000001101161813",
  39174. Info: "2208",
  39175. }
  39176. customData = append(customData, custom1)
  39177. custom2 := &CustomData{
  39178. MsgId: "H44022900158202103301705198813",
  39179. PsnNo: "44190000133097375417",
  39180. Info: "2208",
  39181. }
  39182. customData = append(customData, custom2)
  39183. custom3 := &CustomData{
  39184. MsgId: "H44022900158202103301715524756",
  39185. PsnNo: "44020000001100187221",
  39186. Info: "2208",
  39187. }
  39188. customData = append(customData, custom3)
  39189. custom4 := &CustomData{
  39190. MsgId: "H44022900158202103301730376224",
  39191. PsnNo: "44020000001101959155",
  39192. Info: "2208",
  39193. }
  39194. customData = append(customData, custom4)
  39195. custom5 := &CustomData{
  39196. MsgId: "H44022900158202103301748008725",
  39197. PsnNo: "44020000001104246641",
  39198. Info: "2208",
  39199. }
  39200. customData = append(customData, custom5)
  39201. custom6 := &CustomData{
  39202. MsgId: "H44022900158202103301718096755",
  39203. PsnNo: "44020000001102211860",
  39204. Info: "2208",
  39205. }
  39206. customData = append(customData, custom6)
  39207. custom7 := &CustomData{
  39208. MsgId: "H44022900158202103301736551640",
  39209. PsnNo: "44020000001102687718",
  39210. Info: "2208",
  39211. }
  39212. customData = append(customData, custom7)
  39213. custom8 := &CustomData{
  39214. MsgId: "H44022900158202103301743097676",
  39215. PsnNo: "44020000001102127785",
  39216. Info: "2208",
  39217. }
  39218. customData = append(customData, custom8)
  39219. custom9 := &CustomData{
  39220. MsgId: "H44022900158202103301712304203",
  39221. PsnNo: "44020000001101518097",
  39222. Info: "2208",
  39223. }
  39224. customData = append(customData, custom9)
  39225. custom10 := &CustomData{
  39226. MsgId: "H44022900158202103301738448785",
  39227. PsnNo: "44020000001100500813",
  39228. Info: "2208",
  39229. }
  39230. customData = append(customData, custom10)
  39231. custom11 := &CustomData{
  39232. MsgId: "H44022900158202103301732455843",
  39233. PsnNo: "44020000001102690557",
  39234. Info: "2208",
  39235. }
  39236. customData = append(customData, custom11)
  39237. custom12 := &CustomData{
  39238. MsgId: "H44022900158202103301745421708",
  39239. PsnNo: "44020000001102211928",
  39240. Info: "2208",
  39241. }
  39242. customData = append(customData, custom12)
  39243. custom1212 := &CustomData{
  39244. MsgId: "H440229001582021033017351627",
  39245. PsnNo: "44020000001102481733",
  39246. Info: "2208",
  39247. }
  39248. customData = append(customData, custom1212)
  39249. custom13 := &CustomData{
  39250. MsgId: "H44022900158202103301740327951",
  39251. PsnNo: "44020000001103174866",
  39252. Info: "2208",
  39253. }
  39254. customData = append(customData, custom13)
  39255. custom14 := &CustomData{
  39256. MsgId: "H4402290015820210330174922668",
  39257. PsnNo: "44020000001102927272",
  39258. Info: "2208",
  39259. }
  39260. customData = append(customData, custom14)
  39261. custom15 := &CustomData{
  39262. MsgId: "H44022900158202103301752362273",
  39263. PsnNo: "44020000001102942890",
  39264. Info: "2208",
  39265. }
  39266. customData = append(customData, custom15)
  39267. custom16 := &CustomData{
  39268. MsgId: "H44022900158202103301751082917",
  39269. PsnNo: "44020000001101662162",
  39270. Info: "2208",
  39271. }
  39272. customData = append(customData, custom16)
  39273. custom17 := &CustomData{
  39274. MsgId: "H44022900158202103301754147728",
  39275. PsnNo: "44020000000229014511",
  39276. Info: "2208",
  39277. }
  39278. customData = append(customData, custom17)
  39279. adminUser := c.GetAdminUserInfo()
  39280. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39281. for _, item := range customData {
  39282. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39283. fmt.Println(result)
  39284. }
  39285. }
  39286. func PathExists(path string) (bool, error) {
  39287. _, err := os.Stat(path)
  39288. if err == nil {
  39289. return true, nil
  39290. }
  39291. if os.IsNotExist(err) {
  39292. return false, nil
  39293. }
  39294. return false, err
  39295. }
  39296. // 创建文件夹
  39297. func Mkdir(dir string) {
  39298. // 创建文件夹
  39299. exist, err := PathExists(dir)
  39300. if err != nil {
  39301. fmt.Println(err.Error())
  39302. } else {
  39303. if exist {
  39304. fmt.Println(dir + "文件夹已存在!")
  39305. } else {
  39306. // 文件夹名称,权限
  39307. err := os.Mkdir(dir, os.ModePerm)
  39308. if err != nil {
  39309. fmt.Println(dir+"文件夹创建失败:", err.Error())
  39310. } else {
  39311. fmt.Println(dir + "文件夹创建成功!")
  39312. }
  39313. }
  39314. }
  39315. }
  39316. // 压缩文件
  39317. func Zip(srcFile string, destZip string) error {
  39318. zipfile, err := os.Create(destZip)
  39319. if err != nil {
  39320. return err
  39321. }
  39322. defer zipfile.Close()
  39323. archive := zip.NewWriter(zipfile)
  39324. defer archive.Close()
  39325. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  39326. if err != nil {
  39327. return err
  39328. }
  39329. header, err := zip.FileInfoHeader(info)
  39330. if err != nil {
  39331. return err
  39332. }
  39333. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  39334. // header.Name = path
  39335. if info.IsDir() {
  39336. header.Name += "/"
  39337. } else {
  39338. header.Method = zip.Deflate
  39339. }
  39340. writer, err := archive.CreateHeader(header)
  39341. if err != nil {
  39342. return err
  39343. }
  39344. if !info.IsDir() {
  39345. file, err := os.Open(path)
  39346. if err != nil {
  39347. return err
  39348. }
  39349. defer file.Close()
  39350. _, err = io.Copy(writer, file)
  39351. }
  39352. return err
  39353. })
  39354. return err
  39355. }
  39356. func ReadFile(filePath string) []byte {
  39357. f, err := os.Open(filePath)
  39358. if err != nil {
  39359. fmt.Println("read file fail", err)
  39360. return nil
  39361. }
  39362. defer f.Close()
  39363. fd, err := ioutil.ReadAll(f)
  39364. if err != nil {
  39365. fmt.Println("read to fd fail", err)
  39366. return nil
  39367. }
  39368. return fd
  39369. }
  39370. func saveLogq(result string, request string, infno string, desc string) {
  39371. dir := "日志"
  39372. utils.Mkdir(dir)
  39373. month := time.Unix(1557042972, 0).Format("1")
  39374. year := time.Now().Format("2006")
  39375. month = time.Now().Format("01")
  39376. day := time.Now().Format("02")
  39377. hour := time.Now().Format("15")
  39378. min := time.Now().Format("04")
  39379. sec := time.Now().Format("05")
  39380. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39381. file := year + month + day + "_log"
  39382. file_name := file + ".txt"
  39383. file_path := "日志" + "/" + file_name
  39384. exist, _ := utils.PathExists(file_path)
  39385. if exist { //存在
  39386. fmt.Println("存在")
  39387. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39388. if err != nil {
  39389. fmt.Println("read fail")
  39390. }
  39391. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39392. n, _ := f.Seek(0, 2)
  39393. _, err = f.WriteAt([]byte(content), n)
  39394. } else { //不存在
  39395. fmt.Println("文件不存在,创建文件")
  39396. f, err := os.Create("日志" + "/" + file_name)
  39397. defer f.Close()
  39398. if err != nil {
  39399. } else {
  39400. _, err = f.Write([]byte("记录日志"))
  39401. }
  39402. }
  39403. }
  39404. func saveLog(result string, request string, infno string, desc string) {
  39405. org_id, _ := beego.AppConfig.Int64("org_id")
  39406. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39407. dir := miConfig.OrgName + "日志"
  39408. utils.Mkdir(dir)
  39409. month := time.Unix(1557042972, 0).Format("1")
  39410. year := time.Now().Format("2006")
  39411. month = time.Now().Format("01")
  39412. day := time.Now().Format("02")
  39413. hour := time.Now().Format("15")
  39414. min := time.Now().Format("04")
  39415. sec := time.Now().Format("05")
  39416. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39417. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  39418. file_name := file + ".txt"
  39419. file_path := miConfig.OrgName + "日志" + "/" + file_name
  39420. exist, _ := utils.PathExists(file_path)
  39421. if exist { //存在
  39422. fmt.Println("存在")
  39423. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39424. if err != nil {
  39425. fmt.Println("read fail")
  39426. }
  39427. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39428. n, _ := f.Seek(0, 2)
  39429. _, err = f.WriteAt([]byte(content), n)
  39430. } else { //不存在
  39431. fmt.Println("文件不存在,创建文件")
  39432. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  39433. defer f.Close()
  39434. if err != nil {
  39435. } else {
  39436. _, err = f.Write([]byte("记录日志"))
  39437. }
  39438. }
  39439. }
  39440. type Charset string
  39441. const (
  39442. UTF8 = Charset("UTF-8")
  39443. GB18030 = Charset("GB18030")
  39444. )
  39445. func ConvertToString(src string, srcCode string, tagCode string) string {
  39446. srcCoder := mahonia.NewDecoder(srcCode)
  39447. srcResult := srcCoder.ConvertString(src)
  39448. tagCoder := mahonia.NewDecoder(tagCode)
  39449. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  39450. result := string(cdata)
  39451. return result
  39452. }
  39453. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  39454. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39455. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39456. var token string
  39457. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39458. var api string
  39459. if miConfig.MdtrtareaAdmvs == "320830" {
  39460. api = miConfig.AppSecret + "jsyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39461. "&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
  39462. fmt.Println(api)
  39463. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39464. 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 +
  39465. "&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
  39466. fmt.Println(api)
  39467. } else {
  39468. 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 +
  39469. "&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
  39470. }
  39471. resp, requestErr := http.Get(api)
  39472. if requestErr != nil {
  39473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39474. return ""
  39475. }
  39476. body, ioErr := ioutil.ReadAll(resp.Body)
  39477. if ioErr != nil {
  39478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39480. return ""
  39481. }
  39482. var respJSON map[string]interface{}
  39483. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39486. return ""
  39487. }
  39488. var status string
  39489. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39490. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39491. var res ResultTwo //1101结果
  39492. var res10265 ResultTwo10265 //1101结果
  39493. if status == "0" { //读卡成功
  39494. var card_info string //卡信息
  39495. var busi_card_info string
  39496. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39497. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39498. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39499. fmt.Println(card_info)
  39500. fmt.Println(busi_card_info)
  39501. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39502. result, _ := json.Marshal(respJSON)
  39503. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39504. utils.ErrorLog("解析失败:%v", err)
  39505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39506. return ""
  39507. }
  39508. res.ErrMsg = res10265.ErrMsg
  39509. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39510. res.Infcode = infocode
  39511. res.Output = res10265.Output
  39512. res.InfRefmsgid = res10265.InfRefmsgid
  39513. if res.Infcode == 0 {
  39514. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39515. if err == gorm.ErrRecordNotFound {
  39516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39517. return ""
  39518. } else if err != nil {
  39519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39520. return ""
  39521. } else {
  39522. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39523. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39524. infoStr := string(Iinfos)
  39525. idetinfoStr := string(Idetinfos)
  39526. psn := &models.HisPsn{
  39527. PsnNo: res.Output.Baseinfo.PsnNo,
  39528. PatientId: patient.ID,
  39529. Certno: res.Output.Baseinfo.Certno,
  39530. Gend: res.Output.Baseinfo.Gend,
  39531. Naty: res.Output.Baseinfo.Naty,
  39532. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39533. PsnName: res.Output.Baseinfo.PsnName,
  39534. Idetinfo: idetinfoStr,
  39535. Insuinfo: infoStr,
  39536. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39537. CardInfo: card_info,
  39538. VerifyNumber: token,
  39539. }
  39540. service.CreateHisPsn(psn)
  39541. return token
  39542. }
  39543. }
  39544. } else {
  39545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39546. return ""
  39547. }
  39548. } else { //读卡失败
  39549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39550. return ""
  39551. }
  39552. return token
  39553. }
  39554. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  39555. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39556. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39557. var token string
  39558. var api string
  39559. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39560. "&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
  39561. fmt.Println(api)
  39562. resp, requestErr := http.Get(api)
  39563. if requestErr != nil {
  39564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39565. return ""
  39566. }
  39567. body, ioErr := ioutil.ReadAll(resp.Body)
  39568. if ioErr != nil {
  39569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39571. return ""
  39572. }
  39573. var respJSON map[string]interface{}
  39574. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39577. return ""
  39578. }
  39579. var status string
  39580. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39581. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39582. var res ResultTwo //1101结果
  39583. if status == "1" { //读卡成功
  39584. var card_info string //卡信息
  39585. var busi_card_info string
  39586. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39587. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39588. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39589. fmt.Println(card_info)
  39590. fmt.Println(busi_card_info)
  39591. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39592. result, _ := json.Marshal(respJSON)
  39593. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39594. utils.ErrorLog("解析失败:%v", err)
  39595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39596. return ""
  39597. }
  39598. if res.Infcode == 0 {
  39599. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39600. if err == gorm.ErrRecordNotFound {
  39601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39602. return ""
  39603. } else if err != nil {
  39604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39605. return ""
  39606. } else {
  39607. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39608. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39609. infoStr := string(Iinfos)
  39610. idetinfoStr := string(Idetinfos)
  39611. psn := &models.HisPsn{
  39612. PsnNo: res.Output.Baseinfo.PsnNo,
  39613. PatientId: patient.ID,
  39614. Certno: res.Output.Baseinfo.Certno,
  39615. Gend: res.Output.Baseinfo.Gend,
  39616. Naty: res.Output.Baseinfo.Naty,
  39617. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39618. PsnName: res.Output.Baseinfo.PsnName,
  39619. Idetinfo: idetinfoStr,
  39620. Insuinfo: infoStr,
  39621. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39622. CardInfo: card_info,
  39623. VerifyNumber: token,
  39624. }
  39625. service.CreateHisPsn(psn)
  39626. return token
  39627. }
  39628. }
  39629. } else {
  39630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39631. return ""
  39632. }
  39633. return token
  39634. }
  39635. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  39636. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39637. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39638. var token string
  39639. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39640. var api string
  39641. if miConfig.MdtrtareaAdmvs == "320830" {
  39642. api = miConfig.AppSecret + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39643. "&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
  39644. fmt.Println(api)
  39645. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39646. 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 +
  39647. "&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
  39648. fmt.Println(api)
  39649. } else {
  39650. 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 +
  39651. "&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
  39652. }
  39653. resp, requestErr := http.Get(api)
  39654. if requestErr != nil {
  39655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39656. return ""
  39657. }
  39658. body, ioErr := ioutil.ReadAll(resp.Body)
  39659. if ioErr != nil {
  39660. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39662. return ""
  39663. }
  39664. var respJSON map[string]interface{}
  39665. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39668. return ""
  39669. }
  39670. var status string
  39671. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39672. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39673. var res ResultTwo //1101结果
  39674. var res10265 ResultTwo10265 //1101结果
  39675. if status == "0" { //读卡成功
  39676. var card_info string //卡信息
  39677. var busi_card_info string
  39678. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39679. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39680. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39681. fmt.Println(card_info)
  39682. fmt.Println(busi_card_info)
  39683. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39684. result, _ := json.Marshal(respJSON)
  39685. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39686. utils.ErrorLog("解析失败:%v", err)
  39687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39688. return ""
  39689. }
  39690. res.ErrMsg = res10265.ErrMsg
  39691. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39692. res.Infcode = infocode
  39693. res.Output = res10265.Output
  39694. res.InfRefmsgid = res10265.InfRefmsgid
  39695. if res.Infcode == 0 {
  39696. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39697. if err == gorm.ErrRecordNotFound {
  39698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39699. return ""
  39700. } else if err != nil {
  39701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39702. return ""
  39703. } else {
  39704. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39705. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39706. infoStr := string(Iinfos)
  39707. idetinfoStr := string(Idetinfos)
  39708. psn := &models.HisPsn{
  39709. PsnNo: res.Output.Baseinfo.PsnNo,
  39710. PatientId: patient.ID,
  39711. Certno: res.Output.Baseinfo.Certno,
  39712. Gend: res.Output.Baseinfo.Gend,
  39713. Naty: res.Output.Baseinfo.Naty,
  39714. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39715. PsnName: res.Output.Baseinfo.PsnName,
  39716. Idetinfo: idetinfoStr,
  39717. Insuinfo: infoStr,
  39718. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39719. CardInfo: card_info,
  39720. VerifyNumber: token,
  39721. }
  39722. service.CreateHisPsn(psn)
  39723. return token
  39724. }
  39725. }
  39726. } else {
  39727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39728. return ""
  39729. }
  39730. } else { //读卡失败
  39731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39732. return ""
  39733. }
  39734. return token
  39735. }
  39736. func DeleteExtraSpaceTwo(s string) string {
  39737. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39738. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39739. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39740. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39741. s2 := make([]byte, len(s1)) //定义字符数组切片
  39742. copy(s2, s1) //将字符串复制到切片
  39743. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39744. for len(spc_index) > 0 { //找到适配项
  39745. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39746. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39747. }
  39748. return string(s2)
  39749. }
  39750. func Remove0000(s string) string {
  39751. str := make([]rune, 0, len(s))
  39752. for _, v := range []rune(s) {
  39753. if v == 0 {
  39754. continue
  39755. }
  39756. str = append(str, v)
  39757. }
  39758. return string(str)
  39759. }
  39760. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  39761. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  39762. readCard := DllDef.MustFindProc("EcQuery")
  39763. pCardInfo := make([]byte, 8192)
  39764. pBusiCardInfo := make([]byte, 8192)
  39765. data := make(map[string]interface{})
  39766. //pData := make(map[string]interface{})
  39767. inputData := make(map[string]interface{})
  39768. inputData["orgId"] = code
  39769. inputData["businessType"] = "01101"
  39770. inputData["operatorId"] = operator_id
  39771. inputData["operatorName"] = operator_name
  39772. inputData["officeId"] = "001"
  39773. inputData["officeName"] = "血透室"
  39774. //
  39775. data["data"] = inputData
  39776. data["transType"] = "ec.query"
  39777. data["orgId"] = code
  39778. bytesData, _ := json.Marshal(data)
  39779. pCardInfo = bytesData
  39780. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  39781. fmt.Println(ret2)
  39782. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  39783. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  39784. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  39785. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  39786. if ret2 != 0 {
  39787. return "", ""
  39788. }
  39789. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  39790. }
  39791. func DeleteExtraSpace(s string) string {
  39792. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39793. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39794. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39795. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39796. s2 := make([]byte, len(s1)) //定义字符数组切片
  39797. copy(s2, s1) //将字符串复制到切片
  39798. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39799. for len(spc_index) > 0 { //找到适配项
  39800. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39801. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39802. }
  39803. return string(s2)
  39804. }
  39805. // 对账
  39806. func (c *HisApiController) Post3202() {
  39807. start_time := c.GetString("start_time")
  39808. end_time := c.GetString("end_time")
  39809. //insutype := c.GetString("insutype")
  39810. clr_type := c.GetString("clr_type")
  39811. clr_org := c.GetString("clr_optins")
  39812. admin_user_id, _ := c.GetInt64("admin_user_id")
  39813. adminUser := c.GetAdminUserInfo()
  39814. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39815. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39816. if len(clr_org) == 0 {
  39817. clr_org = miConfig.MdtrtareaAdmvs
  39818. }
  39819. timeLayout := "2006-01-02"
  39820. loc, _ := time.LoadLocation("Local")
  39821. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39822. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39823. var orders []*models.HisOrder
  39824. if clr_org == "421300" {
  39825. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39826. } else if clr_org == "420902" {
  39827. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39828. } else {
  39829. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39830. }
  39831. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39832. //fixmedins_setl_cnt := int64(len(orders))
  39833. var medfee_sumamt float64
  39834. var acct_pay float64
  39835. var fund_pay_sumamt float64
  39836. for _, item := range orders {
  39837. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39838. acct_pay = acct_pay + item.AcctPay
  39839. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39840. }
  39841. //var medfee_sumamt_two float64
  39842. //var acct_pay_two float64
  39843. //var fund_pay_sumamt_two float64
  39844. //for _, item := range orders_two {
  39845. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39846. // acct_pay_two = acct_pay_two + item.AcctPay
  39847. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39848. //}
  39849. //var user_name string
  39850. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39851. //if role.ID == 0 {
  39852. // user_name = "xxx"
  39853. //} else {
  39854. // user_name = role.UserName
  39855. //}
  39856. var res ResultSix
  39857. if config.IsOpen == 1 {
  39858. var bps []*models.BusinessParamsTwo
  39859. var bp models.BusinessParamsTwo
  39860. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39861. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39862. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39863. bp.MedfeeSumamt = medfee_sumamt_str
  39864. bp.AcctPay = acct_pay_str
  39865. bp.FundPaySumamt = fund_pay_sumamt_str
  39866. bp.Insutype = ""
  39867. bp.StmtBegndate = start_time
  39868. bp.ClrType = clr_type
  39869. bp.SetlOptins = clr_org
  39870. bp.StmtEnddate = end_time
  39871. bps = append(bps, &bp)
  39872. data := make(map[string]interface{})
  39873. data["bps"] = bps
  39874. data["org_name"] = miConfig.OrgName
  39875. data["doctor"] = role.UserName
  39876. data["fixmedins_code"] = miConfig.Code
  39877. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39878. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39879. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39880. if miConfig.MdtrtareaAdmvs == "421300" {
  39881. client := &http.Client{}
  39882. bytesData, _ := json.Marshal(data)
  39883. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39884. resp, _ := client.Do(req)
  39885. defer resp.Body.Close()
  39886. body, ioErr := ioutil.ReadAll(resp.Body)
  39887. if ioErr != nil {
  39888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39890. return
  39891. }
  39892. var respJSON map[string]interface{}
  39893. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39896. return
  39897. }
  39898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39899. userJSONBytes, _ := json.Marshal(respJSON)
  39900. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39901. utils.ErrorLog("解析失败:%v", err)
  39902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39903. return
  39904. }
  39905. }
  39906. if miConfig.MdtrtareaAdmvs == "420200" {
  39907. client := &http.Client{}
  39908. bytesData, _ := json.Marshal(data)
  39909. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39910. resp, _ := client.Do(req)
  39911. defer resp.Body.Close()
  39912. body, ioErr := ioutil.ReadAll(resp.Body)
  39913. if ioErr != nil {
  39914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39916. return
  39917. }
  39918. var respJSON map[string]interface{}
  39919. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39922. return
  39923. }
  39924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39925. userJSONBytes, _ := json.Marshal(respJSON)
  39926. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39927. utils.ErrorLog("解析失败:%v", err)
  39928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39929. return
  39930. }
  39931. }
  39932. if miConfig.MdtrtareaAdmvs == "421182" {
  39933. client := &http.Client{}
  39934. bytesData, _ := json.Marshal(data)
  39935. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39936. resp, _ := client.Do(req)
  39937. defer resp.Body.Close()
  39938. body, ioErr := ioutil.ReadAll(resp.Body)
  39939. if ioErr != nil {
  39940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39942. return
  39943. }
  39944. var respJSON map[string]interface{}
  39945. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39948. return
  39949. }
  39950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39951. userJSONBytes, _ := json.Marshal(respJSON)
  39952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39953. utils.ErrorLog("解析失败:%v", err)
  39954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39955. return
  39956. }
  39957. }
  39958. if miConfig.MdtrtareaAdmvs == "420902" {
  39959. client := &http.Client{}
  39960. bytesData, _ := json.Marshal(data)
  39961. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39962. resp, _ := client.Do(req)
  39963. defer resp.Body.Close()
  39964. body, ioErr := ioutil.ReadAll(resp.Body)
  39965. if ioErr != nil {
  39966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39968. return
  39969. }
  39970. var respJSON map[string]interface{}
  39971. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39974. return
  39975. }
  39976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39977. userJSONBytes, _ := json.Marshal(respJSON)
  39978. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39979. utils.ErrorLog("解析失败:%v", err)
  39980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39981. return
  39982. }
  39983. }
  39984. if res.Infcode == 0 {
  39985. c.ServeSuccessJSON(map[string]interface{}{
  39986. "msg": "发起成功",
  39987. })
  39988. } else {
  39989. c.ServeSuccessJSON(map[string]interface{}{
  39990. "failed_code": -10,
  39991. "msg": res.ErrMsg,
  39992. })
  39993. }
  39994. }
  39995. }
  39996. func (c *HisApiController) Post3204a() {
  39997. start_time := c.GetString("start_time")
  39998. end_time := c.GetString("end_time")
  39999. //insutype := c.GetString("insutype")
  40000. clr_type := c.GetString("clr_type")
  40001. clr_org := c.GetString("clr_optins")
  40002. admin_user_id, _ := c.GetInt64("admin_user_id")
  40003. adminUser := c.GetAdminUserInfo()
  40004. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40005. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40006. if len(clr_org) == 0 {
  40007. clr_org = miConfig.MdtrtareaAdmvs
  40008. }
  40009. timeLayout := "2006-01-02"
  40010. loc, _ := time.LoadLocation("Local")
  40011. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40012. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40013. var orders []*models.HisOrder
  40014. if clr_org == "421300" {
  40015. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40016. } else if clr_org == "420902" {
  40017. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40018. } else {
  40019. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40020. }
  40021. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40022. //fixmedins_setl_cnt := int64(len(orders))
  40023. var medfee_sumamt float64
  40024. var acct_pay float64
  40025. var fund_pay_sumamt float64
  40026. for _, item := range orders {
  40027. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40028. acct_pay = acct_pay + item.AcctPay
  40029. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40030. }
  40031. //var medfee_sumamt_two float64
  40032. //var acct_pay_two float64
  40033. //var fund_pay_sumamt_two float64
  40034. //for _, item := range orders_two {
  40035. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40036. // acct_pay_two = acct_pay_two + item.AcctPay
  40037. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40038. //}
  40039. //var user_name string
  40040. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40041. //if role.ID == 0 {
  40042. // user_name = "xxx"
  40043. //} else {
  40044. // user_name = role.UserName
  40045. //}
  40046. var res ResultSix
  40047. if config.IsOpen == 1 {
  40048. var bps []*models.BusinessParamsTwo
  40049. var bp models.BusinessParamsTwo
  40050. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40051. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40052. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40053. bp.MedfeeSumamt = medfee_sumamt_str
  40054. bp.AcctPay = acct_pay_str
  40055. bp.FundPaySumamt = fund_pay_sumamt_str
  40056. bp.Insutype = ""
  40057. bp.StmtBegndate = start_time
  40058. bp.ClrType = clr_type
  40059. bp.SetlOptins = clr_org
  40060. bp.StmtEnddate = end_time
  40061. bps = append(bps, &bp)
  40062. data := make(map[string]interface{})
  40063. data["bps"] = bps
  40064. data["org_name"] = miConfig.OrgName
  40065. data["doctor"] = role.UserName
  40066. data["fixmedins_code"] = miConfig.Code
  40067. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40068. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40069. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40070. if miConfig.MdtrtareaAdmvs == "421300" {
  40071. client := &http.Client{}
  40072. bytesData, _ := json.Marshal(data)
  40073. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40074. resp, _ := client.Do(req)
  40075. defer resp.Body.Close()
  40076. body, ioErr := ioutil.ReadAll(resp.Body)
  40077. if ioErr != nil {
  40078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40080. return
  40081. }
  40082. var respJSON map[string]interface{}
  40083. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40086. return
  40087. }
  40088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40089. userJSONBytes, _ := json.Marshal(respJSON)
  40090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40091. utils.ErrorLog("解析失败:%v", err)
  40092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40093. return
  40094. }
  40095. }
  40096. if miConfig.MdtrtareaAdmvs == "420200" {
  40097. client := &http.Client{}
  40098. bytesData, _ := json.Marshal(data)
  40099. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40100. resp, _ := client.Do(req)
  40101. defer resp.Body.Close()
  40102. body, ioErr := ioutil.ReadAll(resp.Body)
  40103. if ioErr != nil {
  40104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40106. return
  40107. }
  40108. var respJSON map[string]interface{}
  40109. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40112. return
  40113. }
  40114. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40115. userJSONBytes, _ := json.Marshal(respJSON)
  40116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40117. utils.ErrorLog("解析失败:%v", err)
  40118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40119. return
  40120. }
  40121. }
  40122. if miConfig.MdtrtareaAdmvs == "421182" {
  40123. client := &http.Client{}
  40124. bytesData, _ := json.Marshal(data)
  40125. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40126. resp, _ := client.Do(req)
  40127. defer resp.Body.Close()
  40128. body, ioErr := ioutil.ReadAll(resp.Body)
  40129. if ioErr != nil {
  40130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40132. return
  40133. }
  40134. var respJSON map[string]interface{}
  40135. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40138. return
  40139. }
  40140. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40141. userJSONBytes, _ := json.Marshal(respJSON)
  40142. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40143. utils.ErrorLog("解析失败:%v", err)
  40144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40145. return
  40146. }
  40147. }
  40148. if miConfig.MdtrtareaAdmvs == "420902" {
  40149. client := &http.Client{}
  40150. bytesData, _ := json.Marshal(data)
  40151. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40152. resp, _ := client.Do(req)
  40153. defer resp.Body.Close()
  40154. body, ioErr := ioutil.ReadAll(resp.Body)
  40155. if ioErr != nil {
  40156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40158. return
  40159. }
  40160. var respJSON map[string]interface{}
  40161. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40164. return
  40165. }
  40166. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40167. userJSONBytes, _ := json.Marshal(respJSON)
  40168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40169. utils.ErrorLog("解析失败:%v", err)
  40170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40171. return
  40172. }
  40173. }
  40174. if res.Infcode == 0 {
  40175. c.ServeSuccessJSON(map[string]interface{}{
  40176. "msg": "撤销成功",
  40177. })
  40178. } else {
  40179. c.ServeSuccessJSON(map[string]interface{}{
  40180. "failed_code": -10,
  40181. "msg": res.ErrMsg,
  40182. })
  40183. }
  40184. }
  40185. }
  40186. func (c *HisApiController) Post3204() {
  40187. admin_user_id, _ := c.GetInt64("admin_user_id")
  40188. id := c.GetString("id")
  40189. adminUser := c.GetAdminUserInfo()
  40190. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40191. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40192. //clr_org := miConfig.MdtrtareaAdmvs
  40193. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40194. var res ResultSix
  40195. if config.IsOpen == 1 {
  40196. data := make(map[string]interface{})
  40197. data["id"] = id
  40198. data["org_name"] = miConfig.OrgName
  40199. data["doctor"] = role.UserName
  40200. data["fixmedins_code"] = miConfig.Code
  40201. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40202. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40203. client := &http.Client{}
  40204. bytesData, _ := json.Marshal(data)
  40205. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  40206. resp, _ := client.Do(req)
  40207. defer resp.Body.Close()
  40208. body, ioErr := ioutil.ReadAll(resp.Body)
  40209. if ioErr != nil {
  40210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40212. return
  40213. }
  40214. var respJSON map[string]interface{}
  40215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40218. return
  40219. }
  40220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40221. userJSONBytes, _ := json.Marshal(respJSON)
  40222. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40223. utils.ErrorLog("解析失败:%v", err)
  40224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40225. return
  40226. }
  40227. if res.Infcode == 0 {
  40228. c.ServeSuccessJSON(map[string]interface{}{
  40229. "msg": "发起成功",
  40230. })
  40231. } else {
  40232. c.ServeSuccessJSON(map[string]interface{}{
  40233. "failed_code": -10,
  40234. "msg": res.ErrMsg,
  40235. })
  40236. }
  40237. }
  40238. }
  40239. func (c *HisApiController) Post8404() {
  40240. admin_user_id, _ := c.GetInt64("admin_user_id")
  40241. month := c.GetString("month")
  40242. adminUser := c.GetAdminUserInfo()
  40243. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40244. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40245. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40246. var res ResultSix
  40247. if config.IsOpen == 1 {
  40248. data := make(map[string]interface{})
  40249. data["month"] = month
  40250. data["org_name"] = miConfig.OrgName
  40251. data["doctor"] = role.UserName
  40252. data["fixmedins_code"] = miConfig.Code
  40253. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40254. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40255. client := &http.Client{}
  40256. bytesData, _ := json.Marshal(data)
  40257. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  40258. resp, _ := client.Do(req)
  40259. defer resp.Body.Close()
  40260. body, ioErr := ioutil.ReadAll(resp.Body)
  40261. if ioErr != nil {
  40262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40264. return
  40265. }
  40266. var respJSON map[string]interface{}
  40267. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40270. return
  40271. }
  40272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40273. userJSONBytes, _ := json.Marshal(respJSON)
  40274. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40275. utils.ErrorLog("解析失败:%v", err)
  40276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40277. return
  40278. }
  40279. if res.Infcode == 0 {
  40280. c.ServeSuccessJSON(map[string]interface{}{
  40281. "msg": "查询成功",
  40282. })
  40283. } else {
  40284. c.ServeSuccessJSON(map[string]interface{}{
  40285. "failed_code": -10,
  40286. "msg": res.ErrMsg,
  40287. })
  40288. }
  40289. }
  40290. }
  40291. func (c *HisApiController) Post3202b() {
  40292. start_time := c.GetString("start_time")
  40293. end_time := c.GetString("end_time")
  40294. //insutype := c.GetString("insutype")
  40295. clr_type := c.GetString("clr_type")
  40296. clr_org := c.GetString("clr_optins")
  40297. admin_user_id, _ := c.GetInt64("admin_user_id")
  40298. adminUser := c.GetAdminUserInfo()
  40299. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40300. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40301. if len(clr_org) == 0 {
  40302. clr_org = miConfig.MdtrtareaAdmvs
  40303. }
  40304. timeLayout := "2006-01-02"
  40305. loc, _ := time.LoadLocation("Local")
  40306. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40307. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40308. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40309. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40310. //fixmedins_setl_cnt := int64(len(orders))
  40311. var medfee_sumamt float64
  40312. var acct_pay float64
  40313. var fund_pay_sumamt float64
  40314. for _, item := range orders {
  40315. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40316. acct_pay = acct_pay + item.AcctPay
  40317. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40318. }
  40319. //var medfee_sumamt_two float64
  40320. //var acct_pay_two float64
  40321. //var fund_pay_sumamt_two float64
  40322. //for _, item := range orders_two {
  40323. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40324. // acct_pay_two = acct_pay_two + item.AcctPay
  40325. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40326. //}
  40327. //var user_name string
  40328. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40329. //if role.ID == 0 {
  40330. // user_name = "xxx"
  40331. //} else {
  40332. // user_name = role.UserName
  40333. //}
  40334. var res ResultSix
  40335. if config.IsOpen == 1 {
  40336. var bps []*models.BusinessParamsTwo
  40337. var bp models.BusinessParamsTwo
  40338. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40339. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40340. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40341. bp.MedfeeSumamt = medfee_sumamt_str
  40342. bp.AcctPay = acct_pay_str
  40343. bp.FundPaySumamt = fund_pay_sumamt_str
  40344. bp.Insutype = "390"
  40345. bp.StmtBegndate = start_time
  40346. bp.ClrType = clr_type
  40347. bp.SetlOptins = clr_org
  40348. bp.StmtEnddate = end_time
  40349. bps = append(bps, &bp)
  40350. data := make(map[string]interface{})
  40351. data["bps"] = bps
  40352. data["org_name"] = miConfig.OrgName
  40353. data["doctor"] = role.UserName
  40354. data["fixmedins_code"] = miConfig.Code
  40355. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40356. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40357. if miConfig.MdtrtareaAdmvs == "421300" {
  40358. client := &http.Client{}
  40359. bytesData, _ := json.Marshal(data)
  40360. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40361. resp, _ := client.Do(req)
  40362. defer resp.Body.Close()
  40363. body, ioErr := ioutil.ReadAll(resp.Body)
  40364. if ioErr != nil {
  40365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40367. return
  40368. }
  40369. var respJSON map[string]interface{}
  40370. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40373. return
  40374. }
  40375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40376. userJSONBytes, _ := json.Marshal(respJSON)
  40377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40378. utils.ErrorLog("解析失败:%v", err)
  40379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40380. return
  40381. }
  40382. }
  40383. if miConfig.MdtrtareaAdmvs == "420200" {
  40384. client := &http.Client{}
  40385. bytesData, _ := json.Marshal(data)
  40386. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40387. resp, _ := client.Do(req)
  40388. defer resp.Body.Close()
  40389. body, ioErr := ioutil.ReadAll(resp.Body)
  40390. if ioErr != nil {
  40391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40393. return
  40394. }
  40395. var respJSON map[string]interface{}
  40396. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40399. return
  40400. }
  40401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40402. userJSONBytes, _ := json.Marshal(respJSON)
  40403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40404. utils.ErrorLog("解析失败:%v", err)
  40405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40406. return
  40407. }
  40408. }
  40409. if miConfig.MdtrtareaAdmvs == "421182" {
  40410. client := &http.Client{}
  40411. bytesData, _ := json.Marshal(data)
  40412. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  40413. resp, _ := client.Do(req)
  40414. defer resp.Body.Close()
  40415. body, ioErr := ioutil.ReadAll(resp.Body)
  40416. if ioErr != nil {
  40417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40419. return
  40420. }
  40421. var respJSON map[string]interface{}
  40422. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40425. return
  40426. }
  40427. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40428. userJSONBytes, _ := json.Marshal(respJSON)
  40429. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40430. utils.ErrorLog("解析失败:%v", err)
  40431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40432. return
  40433. }
  40434. }
  40435. if res.Infcode == 0 {
  40436. c.ServeSuccessJSON(map[string]interface{}{
  40437. "msg": "发起成功",
  40438. })
  40439. } else {
  40440. c.ServeSuccessJSON(map[string]interface{}{
  40441. "failed_code": -10,
  40442. "msg": res.ErrMsg,
  40443. })
  40444. }
  40445. }
  40446. }
  40447. func (c *HisApiController) Post1608() {
  40448. start_time := c.GetString("start_time")
  40449. end_time := c.GetString("end_time")
  40450. admin_user_id, _ := c.GetInt64("admin_user_id")
  40451. adminUser := c.GetAdminUserInfo()
  40452. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40453. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40454. timeLayout := "2006-01-02"
  40455. loc, _ := time.LoadLocation("Local")
  40456. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40457. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40458. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40459. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40460. fixmedins_setl_cnt := int64(len(orders))
  40461. var medfee_sumamt float64
  40462. var func_smamt float64
  40463. for _, item := range orders {
  40464. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40465. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  40466. }
  40467. times := strings.Split(start_time, "-")
  40468. time_tows := strings.Split(end_time, "-")
  40469. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40470. var res ResultSix
  40471. if config.IsOpen == 1 {
  40472. //var bps []*models.BusinessParamsTwo
  40473. //var bp models.BusinessParamsTwo
  40474. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40475. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  40476. data := make(map[string]interface{})
  40477. data["org_name"] = miConfig.OrgName
  40478. data["doctor"] = role.UserName
  40479. data["func_smamt"] = func_smamt_str
  40480. data["fixmedins_code"] = miConfig.Code
  40481. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40482. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40483. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  40484. data["medfee_sumamt"] = medfee_sumamt_str
  40485. data["start_time"] = times[0] + times[1] + times[2]
  40486. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  40487. if miConfig.MdtrtareaAdmvs == "421300" {
  40488. client := &http.Client{}
  40489. bytesData, _ := json.Marshal(data)
  40490. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40491. resp, _ := client.Do(req)
  40492. defer resp.Body.Close()
  40493. body, ioErr := ioutil.ReadAll(resp.Body)
  40494. if ioErr != nil {
  40495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40497. return
  40498. }
  40499. var respJSON map[string]interface{}
  40500. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40503. return
  40504. }
  40505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40506. userJSONBytes, _ := json.Marshal(respJSON)
  40507. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40508. utils.ErrorLog("解析失败:%v", err)
  40509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40510. return
  40511. }
  40512. }
  40513. if miConfig.MdtrtareaAdmvs == "420200" {
  40514. client := &http.Client{}
  40515. bytesData, _ := json.Marshal(data)
  40516. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40517. resp, _ := client.Do(req)
  40518. defer resp.Body.Close()
  40519. body, ioErr := ioutil.ReadAll(resp.Body)
  40520. if ioErr != nil {
  40521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40523. return
  40524. }
  40525. var respJSON map[string]interface{}
  40526. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40529. return
  40530. }
  40531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40532. userJSONBytes, _ := json.Marshal(respJSON)
  40533. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40534. utils.ErrorLog("解析失败:%v", err)
  40535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40536. return
  40537. }
  40538. }
  40539. if miConfig.MdtrtareaAdmvs == "421182" {
  40540. client := &http.Client{}
  40541. bytesData, _ := json.Marshal(data)
  40542. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  40543. resp, _ := client.Do(req)
  40544. defer resp.Body.Close()
  40545. body, ioErr := ioutil.ReadAll(resp.Body)
  40546. if ioErr != nil {
  40547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40549. return
  40550. }
  40551. var respJSON map[string]interface{}
  40552. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40555. return
  40556. }
  40557. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40558. userJSONBytes, _ := json.Marshal(respJSON)
  40559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40560. utils.ErrorLog("解析失败:%v", err)
  40561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40562. return
  40563. }
  40564. }
  40565. if res.Infcode == 0 {
  40566. c.ServeSuccessJSON(map[string]interface{}{
  40567. "msg": "发起成功",
  40568. })
  40569. } else {
  40570. c.ServeSuccessJSON(map[string]interface{}{
  40571. "failed_code": -10,
  40572. "msg": res.ErrMsg,
  40573. })
  40574. }
  40575. }
  40576. }
  40577. // 5.11.1.1【5262】结算信息按时间段查询
  40578. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40579. admin_user_id, _ := c.GetInt64("admin_user_id")
  40580. adminUser := c.GetAdminUserInfo()
  40581. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40582. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40583. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40584. var res Result5262
  40585. if config.IsOpen == 1 {
  40586. if miConfig.MdtrtareaAdmvs == "421300" {
  40587. data := make(map[string]interface{})
  40588. data["bps"] = bp
  40589. data["org_name"] = miConfig.OrgName
  40590. data["doctor"] = role.UserName
  40591. data["fixmedins_code"] = miConfig.Code
  40592. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40593. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40594. data["page"] = strconv.FormatInt(page, 10)
  40595. data["limit"] = strconv.FormatInt(limit, 10)
  40596. fmt.Println(data)
  40597. client := &http.Client{}
  40598. bytesData, _ := json.Marshal(data)
  40599. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40600. resp, _ := client.Do(req)
  40601. defer resp.Body.Close()
  40602. body, ioErr := ioutil.ReadAll(resp.Body)
  40603. if ioErr != nil {
  40604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40606. return
  40607. }
  40608. var respJSON map[string]interface{}
  40609. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40612. return
  40613. }
  40614. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40615. userJSONBytes, _ := json.Marshal(respJSON)
  40616. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40617. utils.ErrorLog("解析失败:%v", err)
  40618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40619. return
  40620. }
  40621. }
  40622. if miConfig.MdtrtareaAdmvs == "420200" {
  40623. data := make(map[string]interface{})
  40624. data["bps"] = bp
  40625. data["org_name"] = miConfig.OrgName
  40626. data["doctor"] = role.UserName
  40627. data["fixmedins_code"] = miConfig.Code
  40628. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40629. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40630. data["page"] = strconv.FormatInt(page, 10)
  40631. data["limit"] = strconv.FormatInt(limit, 10)
  40632. fmt.Println(data)
  40633. client := &http.Client{}
  40634. bytesData, _ := json.Marshal(data)
  40635. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40636. resp, _ := client.Do(req)
  40637. defer resp.Body.Close()
  40638. body, ioErr := ioutil.ReadAll(resp.Body)
  40639. if ioErr != nil {
  40640. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40642. return
  40643. }
  40644. var respJSON map[string]interface{}
  40645. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40648. return
  40649. }
  40650. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40651. userJSONBytes, _ := json.Marshal(respJSON)
  40652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40653. utils.ErrorLog("解析失败:%v", err)
  40654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40655. return
  40656. }
  40657. }
  40658. if miConfig.MdtrtareaAdmvs == "421182" {
  40659. data := make(map[string]interface{})
  40660. data["bps"] = bp
  40661. data["org_name"] = miConfig.OrgName
  40662. data["doctor"] = role.UserName
  40663. data["fixmedins_code"] = miConfig.Code
  40664. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40665. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40666. data["page"] = strconv.FormatInt(page, 10)
  40667. data["limit"] = strconv.FormatInt(limit, 10)
  40668. fmt.Println(data)
  40669. client := &http.Client{}
  40670. bytesData, _ := json.Marshal(data)
  40671. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40672. resp, _ := client.Do(req)
  40673. defer resp.Body.Close()
  40674. body, ioErr := ioutil.ReadAll(resp.Body)
  40675. if ioErr != nil {
  40676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40678. return
  40679. }
  40680. var respJSON map[string]interface{}
  40681. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40684. return
  40685. }
  40686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40687. userJSONBytes, _ := json.Marshal(respJSON)
  40688. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40689. utils.ErrorLog("解析失败:%v", err)
  40690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40691. return
  40692. }
  40693. }
  40694. if miConfig.MdtrtareaAdmvs == "420902" {
  40695. data := make(map[string]interface{})
  40696. data["bps"] = bp
  40697. data["org_name"] = miConfig.OrgName
  40698. data["doctor"] = role.UserName
  40699. data["fixmedins_code"] = miConfig.Code
  40700. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40701. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40702. data["page"] = strconv.FormatInt(page, 10)
  40703. data["limit"] = strconv.FormatInt(limit, 10)
  40704. fmt.Println(data)
  40705. client := &http.Client{}
  40706. bytesData, _ := json.Marshal(data)
  40707. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40708. resp, _ := client.Do(req)
  40709. defer resp.Body.Close()
  40710. body, ioErr := ioutil.ReadAll(resp.Body)
  40711. if ioErr != nil {
  40712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40714. return
  40715. }
  40716. var respJSON map[string]interface{}
  40717. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40720. return
  40721. }
  40722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40723. userJSONBytes, _ := json.Marshal(respJSON)
  40724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40725. utils.ErrorLog("解析失败:%v", err)
  40726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40727. return
  40728. }
  40729. }
  40730. if res.Infcode == 0 {
  40731. c.ServeSuccessJSON(map[string]interface{}{
  40732. "order": res.Output.Result,
  40733. "total": res.Output.PageInfo.RecordCounts,
  40734. })
  40735. } else {
  40736. c.ServeSuccessJSON(map[string]interface{}{
  40737. "failed_code": -10,
  40738. "msg": res.ErrMsg,
  40739. })
  40740. }
  40741. }
  40742. }
  40743. // 5.11.1.2【5267】异地结算信息时间段查询
  40744. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40745. admin_user_id, _ := c.GetInt64("admin_user_id")
  40746. adminUser := c.GetAdminUserInfo()
  40747. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40748. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40749. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40750. var res Result5267
  40751. if config.IsOpen == 1 {
  40752. if miConfig.MdtrtareaAdmvs == "421300" {
  40753. data := make(map[string]interface{})
  40754. data["bps"] = bp
  40755. data["org_name"] = miConfig.OrgName
  40756. data["doctor"] = role.UserName
  40757. data["fixmedins_code"] = miConfig.Code
  40758. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40759. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40760. data["page"] = page
  40761. data["limit"] = limit
  40762. fmt.Println(data)
  40763. client := &http.Client{}
  40764. bytesData, _ := json.Marshal(data)
  40765. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40766. resp, _ := client.Do(req)
  40767. defer resp.Body.Close()
  40768. body, ioErr := ioutil.ReadAll(resp.Body)
  40769. if ioErr != nil {
  40770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40772. return
  40773. }
  40774. var respJSON map[string]interface{}
  40775. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40778. return
  40779. }
  40780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40781. userJSONBytes, _ := json.Marshal(respJSON)
  40782. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40783. utils.ErrorLog("解析失败:%v", err)
  40784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40785. return
  40786. }
  40787. }
  40788. if miConfig.MdtrtareaAdmvs == "420200" {
  40789. data := make(map[string]interface{})
  40790. data["bps"] = bp
  40791. data["org_name"] = miConfig.OrgName
  40792. data["doctor"] = role.UserName
  40793. data["fixmedins_code"] = miConfig.Code
  40794. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40795. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40796. data["page"] = page
  40797. data["limit"] = limit
  40798. fmt.Println(data)
  40799. client := &http.Client{}
  40800. bytesData, _ := json.Marshal(data)
  40801. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40802. resp, _ := client.Do(req)
  40803. defer resp.Body.Close()
  40804. body, ioErr := ioutil.ReadAll(resp.Body)
  40805. if ioErr != nil {
  40806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40808. return
  40809. }
  40810. var respJSON map[string]interface{}
  40811. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40814. return
  40815. }
  40816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40817. userJSONBytes, _ := json.Marshal(respJSON)
  40818. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40819. utils.ErrorLog("解析失败:%v", err)
  40820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40821. return
  40822. }
  40823. }
  40824. if miConfig.MdtrtareaAdmvs == "421182" {
  40825. data := make(map[string]interface{})
  40826. data["bps"] = bp
  40827. data["org_name"] = miConfig.OrgName
  40828. data["doctor"] = role.UserName
  40829. data["fixmedins_code"] = miConfig.Code
  40830. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40831. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40832. data["page"] = page
  40833. data["limit"] = limit
  40834. fmt.Println(data)
  40835. client := &http.Client{}
  40836. bytesData, _ := json.Marshal(data)
  40837. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  40838. resp, _ := client.Do(req)
  40839. defer resp.Body.Close()
  40840. body, ioErr := ioutil.ReadAll(resp.Body)
  40841. if ioErr != nil {
  40842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40844. return
  40845. }
  40846. var respJSON map[string]interface{}
  40847. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40850. return
  40851. }
  40852. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40853. userJSONBytes, _ := json.Marshal(respJSON)
  40854. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40855. utils.ErrorLog("解析失败:%v", err)
  40856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40857. return
  40858. }
  40859. }
  40860. if res.Infcode == 0 {
  40861. c.ServeSuccessJSON(map[string]interface{}{
  40862. "order": res.Output.Result,
  40863. "total": res.Output.PageInfo.RecordCounts,
  40864. })
  40865. } else {
  40866. c.ServeSuccessJSON(map[string]interface{}{
  40867. "failed_code": -10,
  40868. "msg": res.ErrMsg,
  40869. })
  40870. }
  40871. }
  40872. }
  40873. func (c *HisApiController) Post3501() {
  40874. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40875. data := make(map[string]interface{})
  40876. var struct3501s []models.Struct3501
  40877. var struct3501 models.Struct3501
  40878. struct3501.OrgName = miConfig.OrgName
  40879. struct3501.AccessKey = miConfig.AccessKey
  40880. struct3501.RequestUrl = miConfig.Url
  40881. struct3501.SecretKey = miConfig.SecretKey
  40882. struct3501.ManuDate = "2022-08-17"
  40883. struct3501.FixmedinsBchno = ""
  40884. struct3501.ManuLotnum = ""
  40885. struct3501.RxFlag = "0"
  40886. struct3501.ExpyEnd = "2022-08-17"
  40887. struct3501.Invdate = "2022-08-17"
  40888. struct3501.InvCnt = "20.25"
  40889. struct3501.Memo = ""
  40890. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40891. struct3501.FixmedinsHilistId = miConfig.Code
  40892. struct3501.FixmedinsHilistName = miConfig.OrgName
  40893. struct3501s = append(struct3501s, struct3501)
  40894. data["struct_3501s"] = struct3501s
  40895. client := &http.Client{}
  40896. bytesData, _ := json.Marshal(data)
  40897. var req *http.Request
  40898. if miConfig.MdtrtareaAdmvs == "320830" {
  40899. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  40900. } else if miConfig.MdtrtareaAdmvs == "320921" {
  40901. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40902. } else {
  40903. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40904. }
  40905. resp, _ := client.Do(req)
  40906. defer resp.Body.Close()
  40907. body, ioErr := ioutil.ReadAll(resp.Body)
  40908. if ioErr != nil {
  40909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40911. return
  40912. }
  40913. var respJSON map[string]interface{}
  40914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40917. return
  40918. }
  40919. var res ResultSix
  40920. var resSix10265 ResultSix10265 //1101结果
  40921. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40922. result, _ := json.Marshal(respJSON)
  40923. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40924. utils.ErrorLog("解析失败:%v", err)
  40925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40926. return
  40927. }
  40928. res.InfRefmsgid = resSix10265.InfRefmsgid
  40929. res.Output = resSix10265.Output
  40930. res.ErrMsg = resSix10265.ErrMsg
  40931. res.Cainfo = resSix10265.Cainfo
  40932. res.WarnMsg = resSix10265.WarnMsg
  40933. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40934. res.Infcode = infocode
  40935. if infocode == 0 {
  40936. c.ServeSuccessJSON(map[string]interface{}{
  40937. "msg": "上传成功",
  40938. })
  40939. return
  40940. } else {
  40941. c.ServeSuccessJSON(map[string]interface{}{
  40942. "failed_code": -10,
  40943. "msg": res.ErrMsg,
  40944. })
  40945. return
  40946. }
  40947. }
  40948. func (c *HisApiController) Post3502() {
  40949. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40950. data := make(map[string]interface{})
  40951. var struct3502s []models.Struct3502
  40952. var struct3502 models.Struct3502
  40953. struct3502.OrgName = miConfig.OrgName
  40954. struct3502.AccessKey = miConfig.AccessKey
  40955. struct3502.RequestUrl = miConfig.Url
  40956. struct3502.SecretKey = miConfig.SecretKey
  40957. struct3502.ManuDate = "2022-08-15"
  40958. struct3502.FixmedinsBchno = ""
  40959. struct3502.ManuLotnum = ""
  40960. struct3502.RxFlag = "0"
  40961. struct3502.ExpyEnd = "2022-08-15"
  40962. struct3502.Invdate = "2022-08-15"
  40963. struct3502.InvCnt = "20.25"
  40964. struct3502.Memo = ""
  40965. struct3502.MedListCodg = "XB01ABD056B002020200517"
  40966. struct3502.FixmedinsHilistId = miConfig.Code
  40967. struct3502.FixmedinsHilistName = miConfig.OrgName
  40968. struct3502s = append(struct3502s, struct3502)
  40969. data["struct_3502s"] = struct3502s
  40970. client := &http.Client{}
  40971. bytesData, _ := json.Marshal(data)
  40972. var req *http.Request
  40973. if miConfig.MdtrtareaAdmvs == "320830" {
  40974. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  40975. } else if miConfig.MdtrtareaAdmvs == "320921" {
  40976. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40977. } else {
  40978. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40979. }
  40980. resp, _ := client.Do(req)
  40981. defer resp.Body.Close()
  40982. body, ioErr := ioutil.ReadAll(resp.Body)
  40983. if ioErr != nil {
  40984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40986. return
  40987. }
  40988. var respJSON map[string]interface{}
  40989. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40992. return
  40993. }
  40994. var res ResultSix
  40995. var resSix10265 ResultSix10265 //1101结果
  40996. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40997. result, _ := json.Marshal(respJSON)
  40998. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40999. utils.ErrorLog("解析失败:%v", err)
  41000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41001. return
  41002. }
  41003. res.InfRefmsgid = resSix10265.InfRefmsgid
  41004. res.Output = resSix10265.Output
  41005. res.ErrMsg = resSix10265.ErrMsg
  41006. res.Cainfo = resSix10265.Cainfo
  41007. res.WarnMsg = resSix10265.WarnMsg
  41008. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41009. res.Infcode = infocode
  41010. if infocode == 0 {
  41011. c.ServeSuccessJSON(map[string]interface{}{
  41012. "msg": "上传成功",
  41013. })
  41014. return
  41015. } else {
  41016. c.ServeSuccessJSON(map[string]interface{}{
  41017. "failed_code": -10,
  41018. "msg": res.ErrMsg,
  41019. })
  41020. return
  41021. }
  41022. }
  41023. func (c *HisApiController) Post3503() {
  41024. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41025. data := make(map[string]interface{})
  41026. var struct3501s []models.Struct3501
  41027. var struct3501 models.Struct3501
  41028. struct3501.OrgName = miConfig.OrgName
  41029. struct3501.AccessKey = miConfig.AccessKey
  41030. struct3501.RequestUrl = miConfig.Url
  41031. struct3501.SecretKey = miConfig.SecretKey
  41032. struct3501.ManuDate = "2022-08-15"
  41033. struct3501.FixmedinsBchno = ""
  41034. struct3501.ManuLotnum = ""
  41035. struct3501.RxFlag = "0"
  41036. struct3501.ExpyEnd = "2022-08-15"
  41037. struct3501.Invdate = "2022-08-15"
  41038. struct3501.InvCnt = "20.25"
  41039. struct3501.Memo = ""
  41040. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41041. struct3501.FixmedinsHilistId = miConfig.Code
  41042. struct3501.FixmedinsHilistName = miConfig.OrgName
  41043. struct3501s = append(struct3501s, struct3501)
  41044. data["struct_3501s"] = struct3501s
  41045. client := &http.Client{}
  41046. bytesData, _ := json.Marshal(data)
  41047. var req *http.Request
  41048. if miConfig.MdtrtareaAdmvs == "320921" {
  41049. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41050. } else {
  41051. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41052. }
  41053. resp, _ := client.Do(req)
  41054. defer resp.Body.Close()
  41055. body, ioErr := ioutil.ReadAll(resp.Body)
  41056. if ioErr != nil {
  41057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41059. return
  41060. }
  41061. var respJSON map[string]interface{}
  41062. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41065. return
  41066. }
  41067. var res ResultSix
  41068. var resSix10265 ResultSix10265 //1101结果
  41069. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41070. result, _ := json.Marshal(respJSON)
  41071. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41072. utils.ErrorLog("解析失败:%v", err)
  41073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41074. return
  41075. }
  41076. res.InfRefmsgid = resSix10265.InfRefmsgid
  41077. res.Output = resSix10265.Output
  41078. res.ErrMsg = resSix10265.ErrMsg
  41079. res.Cainfo = resSix10265.Cainfo
  41080. res.WarnMsg = resSix10265.WarnMsg
  41081. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41082. res.Infcode = infocode
  41083. if infocode == 0 {
  41084. c.ServeSuccessJSON(map[string]interface{}{
  41085. "msg": "上传成功",
  41086. })
  41087. return
  41088. } else {
  41089. c.ServeSuccessJSON(map[string]interface{}{
  41090. "failed_code": -10,
  41091. "msg": res.ErrMsg,
  41092. })
  41093. return
  41094. }
  41095. }
  41096. func (c *HisApiController) Post3504() {
  41097. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41098. data := make(map[string]interface{})
  41099. var struct3501s []models.Struct3501
  41100. var struct3501 models.Struct3501
  41101. struct3501.OrgName = miConfig.OrgName
  41102. struct3501.AccessKey = miConfig.AccessKey
  41103. struct3501.RequestUrl = miConfig.Url
  41104. struct3501.SecretKey = miConfig.SecretKey
  41105. struct3501.ManuDate = "2022-08-15"
  41106. struct3501.FixmedinsBchno = ""
  41107. struct3501.ManuLotnum = ""
  41108. struct3501.RxFlag = "0"
  41109. struct3501.ExpyEnd = "2022-08-15"
  41110. struct3501.Invdate = "2022-08-15"
  41111. struct3501.InvCnt = "20.25"
  41112. struct3501.Memo = ""
  41113. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41114. struct3501.FixmedinsHilistId = miConfig.Code
  41115. struct3501.FixmedinsHilistName = miConfig.OrgName
  41116. struct3501s = append(struct3501s, struct3501)
  41117. data["struct_3501s"] = struct3501s
  41118. client := &http.Client{}
  41119. bytesData, _ := json.Marshal(data)
  41120. var req *http.Request
  41121. if miConfig.MdtrtareaAdmvs == "320921" {
  41122. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41123. } else {
  41124. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41125. }
  41126. resp, _ := client.Do(req)
  41127. defer resp.Body.Close()
  41128. body, ioErr := ioutil.ReadAll(resp.Body)
  41129. if ioErr != nil {
  41130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41132. return
  41133. }
  41134. var respJSON map[string]interface{}
  41135. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41138. return
  41139. }
  41140. var res ResultSix
  41141. var resSix10265 ResultSix10265 //1101结果
  41142. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41143. result, _ := json.Marshal(respJSON)
  41144. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41145. utils.ErrorLog("解析失败:%v", err)
  41146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41147. return
  41148. }
  41149. res.InfRefmsgid = resSix10265.InfRefmsgid
  41150. res.Output = resSix10265.Output
  41151. res.ErrMsg = resSix10265.ErrMsg
  41152. res.Cainfo = resSix10265.Cainfo
  41153. res.WarnMsg = resSix10265.WarnMsg
  41154. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41155. res.Infcode = infocode
  41156. if infocode == 0 {
  41157. c.ServeSuccessJSON(map[string]interface{}{
  41158. "msg": "上传成功",
  41159. })
  41160. return
  41161. } else {
  41162. c.ServeSuccessJSON(map[string]interface{}{
  41163. "failed_code": -10,
  41164. "msg": res.ErrMsg,
  41165. })
  41166. return
  41167. }
  41168. }
  41169. func (c *HisApiController) Post3505() {
  41170. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41171. data := make(map[string]interface{})
  41172. var struct3501s []models.Struct3501
  41173. var struct3501 models.Struct3501
  41174. struct3501.OrgName = miConfig.OrgName
  41175. struct3501.AccessKey = miConfig.AccessKey
  41176. struct3501.RequestUrl = miConfig.Url
  41177. struct3501.SecretKey = miConfig.SecretKey
  41178. struct3501.ManuDate = "2022-08-15"
  41179. struct3501.FixmedinsBchno = ""
  41180. struct3501.ManuLotnum = ""
  41181. struct3501.RxFlag = "0"
  41182. struct3501.ExpyEnd = "2022-08-15"
  41183. struct3501.Invdate = "2022-08-15"
  41184. struct3501.InvCnt = "20.25"
  41185. struct3501.Memo = ""
  41186. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41187. struct3501.FixmedinsHilistId = miConfig.Code
  41188. struct3501.FixmedinsHilistName = miConfig.OrgName
  41189. struct3501s = append(struct3501s, struct3501)
  41190. data["struct_3501s"] = struct3501s
  41191. client := &http.Client{}
  41192. bytesData, _ := json.Marshal(data)
  41193. var req *http.Request
  41194. if miConfig.MdtrtareaAdmvs == "320921" {
  41195. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41196. } else {
  41197. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41198. }
  41199. resp, _ := client.Do(req)
  41200. defer resp.Body.Close()
  41201. body, ioErr := ioutil.ReadAll(resp.Body)
  41202. if ioErr != nil {
  41203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41205. return
  41206. }
  41207. var respJSON map[string]interface{}
  41208. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41211. return
  41212. }
  41213. var res ResultSix
  41214. var resSix10265 ResultSix10265 //1101结果
  41215. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41216. result, _ := json.Marshal(respJSON)
  41217. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41218. utils.ErrorLog("解析失败:%v", err)
  41219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41220. return
  41221. }
  41222. res.InfRefmsgid = resSix10265.InfRefmsgid
  41223. res.Output = resSix10265.Output
  41224. res.ErrMsg = resSix10265.ErrMsg
  41225. res.Cainfo = resSix10265.Cainfo
  41226. res.WarnMsg = resSix10265.WarnMsg
  41227. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41228. res.Infcode = infocode
  41229. if infocode == 0 {
  41230. c.ServeSuccessJSON(map[string]interface{}{
  41231. "msg": "上传成功",
  41232. })
  41233. return
  41234. } else {
  41235. c.ServeSuccessJSON(map[string]interface{}{
  41236. "failed_code": -10,
  41237. "msg": res.ErrMsg,
  41238. })
  41239. return
  41240. }
  41241. }
  41242. func (c *HisApiController) Post3506() {
  41243. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41244. data := make(map[string]interface{})
  41245. var struct3501s []models.Struct3501
  41246. var struct3501 models.Struct3501
  41247. struct3501.OrgName = miConfig.OrgName
  41248. struct3501.AccessKey = miConfig.AccessKey
  41249. struct3501.RequestUrl = miConfig.Url
  41250. struct3501.SecretKey = miConfig.SecretKey
  41251. struct3501.ManuDate = "2022-08-15"
  41252. struct3501.FixmedinsBchno = ""
  41253. struct3501.ManuLotnum = ""
  41254. struct3501.RxFlag = "0"
  41255. struct3501.ExpyEnd = "2022-08-15"
  41256. struct3501.Invdate = "2022-08-15"
  41257. struct3501.InvCnt = "20.25"
  41258. struct3501.Memo = ""
  41259. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41260. struct3501.FixmedinsHilistId = miConfig.Code
  41261. struct3501.FixmedinsHilistName = miConfig.OrgName
  41262. struct3501s = append(struct3501s, struct3501)
  41263. data["struct_3501s"] = struct3501s
  41264. client := &http.Client{}
  41265. bytesData, _ := json.Marshal(data)
  41266. var req *http.Request
  41267. if miConfig.MdtrtareaAdmvs == "320921" {
  41268. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41269. } else {
  41270. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41271. }
  41272. resp, _ := client.Do(req)
  41273. defer resp.Body.Close()
  41274. body, ioErr := ioutil.ReadAll(resp.Body)
  41275. if ioErr != nil {
  41276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41278. return
  41279. }
  41280. var respJSON map[string]interface{}
  41281. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41284. return
  41285. }
  41286. var res ResultSix
  41287. var resSix10265 ResultSix10265 //1101结果
  41288. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41289. result, _ := json.Marshal(respJSON)
  41290. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41291. utils.ErrorLog("解析失败:%v", err)
  41292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41293. return
  41294. }
  41295. res.InfRefmsgid = resSix10265.InfRefmsgid
  41296. res.Output = resSix10265.Output
  41297. res.ErrMsg = resSix10265.ErrMsg
  41298. res.Cainfo = resSix10265.Cainfo
  41299. res.WarnMsg = resSix10265.WarnMsg
  41300. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41301. res.Infcode = infocode
  41302. if infocode == 0 {
  41303. c.ServeSuccessJSON(map[string]interface{}{
  41304. "msg": "上传成功",
  41305. })
  41306. return
  41307. } else {
  41308. c.ServeSuccessJSON(map[string]interface{}{
  41309. "failed_code": -10,
  41310. "msg": res.ErrMsg,
  41311. })
  41312. return
  41313. }
  41314. }
  41315. func (c *HisApiController) Post3507() {
  41316. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41317. data := make(map[string]interface{})
  41318. var struct3501s []models.Struct3501
  41319. var struct3501 models.Struct3501
  41320. struct3501.OrgName = miConfig.OrgName
  41321. struct3501.AccessKey = miConfig.AccessKey
  41322. struct3501.RequestUrl = miConfig.Url
  41323. struct3501.SecretKey = miConfig.SecretKey
  41324. struct3501.ManuDate = "2022-08-15"
  41325. struct3501.FixmedinsBchno = ""
  41326. struct3501.ManuLotnum = ""
  41327. struct3501.RxFlag = "0"
  41328. struct3501.ExpyEnd = "2022-08-15"
  41329. struct3501.Invdate = "2022-08-15"
  41330. struct3501.InvCnt = "20.25"
  41331. struct3501.Memo = ""
  41332. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41333. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  41334. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  41335. struct3501s = append(struct3501s, struct3501)
  41336. data["struct_3501s"] = struct3501s
  41337. client := &http.Client{}
  41338. bytesData, _ := json.Marshal(data)
  41339. var req *http.Request
  41340. if miConfig.MdtrtareaAdmvs == "320921" {
  41341. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41342. } else {
  41343. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41344. }
  41345. resp, _ := client.Do(req)
  41346. defer resp.Body.Close()
  41347. body, ioErr := ioutil.ReadAll(resp.Body)
  41348. if ioErr != nil {
  41349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41351. return
  41352. }
  41353. var respJSON map[string]interface{}
  41354. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41357. return
  41358. }
  41359. var res ResultSix
  41360. var resSix10265 ResultSix10265 //1101结果
  41361. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41362. result, _ := json.Marshal(respJSON)
  41363. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41364. utils.ErrorLog("解析失败:%v", err)
  41365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41366. return
  41367. }
  41368. res.InfRefmsgid = resSix10265.InfRefmsgid
  41369. res.Output = resSix10265.Output
  41370. res.ErrMsg = resSix10265.ErrMsg
  41371. res.Cainfo = resSix10265.Cainfo
  41372. res.WarnMsg = resSix10265.WarnMsg
  41373. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41374. res.Infcode = infocode
  41375. if infocode == 0 {
  41376. c.ServeSuccessJSON(map[string]interface{}{
  41377. "msg": "上传成功",
  41378. })
  41379. return
  41380. } else {
  41381. c.ServeSuccessJSON(map[string]interface{}{
  41382. "failed_code": -10,
  41383. "msg": res.ErrMsg,
  41384. })
  41385. return
  41386. }
  41387. }
  41388. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41389. // WebSocket服务器地址
  41390. serverURL := "ws://127.0.0.1:8899"
  41391. // 解析WebSocket服务器地址
  41392. u, err := url.Parse(serverURL)
  41393. if err != nil {
  41394. }
  41395. // 建立WebSocket连接
  41396. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41397. if err != nil {
  41398. }
  41399. defer conn.Close()
  41400. input2 := make(map[string]interface{})
  41401. input := make(map[string]interface{})
  41402. inputData := make(map[string]interface{})
  41403. inputData["orgId"] = code
  41404. inputData["businessType"] = "01101"
  41405. inputData["operatorId"] = operator_id
  41406. inputData["operatorName"] = operator_name
  41407. inputData["officeId"] = "001"
  41408. inputData["officeName"] = "血透室"
  41409. inputData["deviceType"] = ""
  41410. input["data"] = inputData
  41411. input["orgId"] = code
  41412. input["transType"] = "ec.query"
  41413. //if md == ""
  41414. if md[:4] == "4403" {
  41415. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41416. } else if md[:4] == "4401" {
  41417. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41418. } else {
  41419. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41420. }
  41421. input2["indata"] = input
  41422. fmt.Println(input2)
  41423. bytesData, _ := json.Marshal(input2)
  41424. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41425. if err != nil {
  41426. fmt.Println(err)
  41427. }
  41428. // 接收消息
  41429. _, receivedMessage, err := conn.ReadMessage()
  41430. if err != nil {
  41431. fmt.Println(err)
  41432. }
  41433. return "", string(receivedMessage)
  41434. }
  41435. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  41436. // WebSocket服务器地址
  41437. serverURL := "ws://127.0.0.1:8899"
  41438. // 解析WebSocket服务器地址
  41439. u, err := url.Parse(serverURL)
  41440. if err != nil {
  41441. }
  41442. // 建立WebSocket连接
  41443. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41444. if err != nil {
  41445. }
  41446. defer conn.Close()
  41447. input2 := make(map[string]interface{})
  41448. input := make(map[string]interface{})
  41449. inputData := make(map[string]interface{})
  41450. inputData["orgId"] = code
  41451. inputData["businessType"] = "01101"
  41452. inputData["operatorId"] = operator_id
  41453. inputData["operatorName"] = operator_name
  41454. inputData["officeId"] = "001"
  41455. inputData["officeName"] = "血透室"
  41456. inputData["deviceType"] = ""
  41457. input["data"] = inputData
  41458. input["orgId"] = code
  41459. input["transType"] = "ec.query"
  41460. //if md == ""
  41461. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41462. input2["indata"] = input
  41463. fmt.Println(input2)
  41464. bytesData, _ := json.Marshal(input2)
  41465. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41466. if err != nil {
  41467. fmt.Println(err)
  41468. }
  41469. // 接收消息
  41470. _, receivedMessage, err := conn.ReadMessage()
  41471. if err != nil {
  41472. fmt.Println(err)
  41473. }
  41474. return "", string(receivedMessage)
  41475. }
  41476. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  41477. // WebSocket服务器地址
  41478. serverURL := "ws://127.0.0.1:8899"
  41479. // 解析WebSocket服务器地址
  41480. u, err := url.Parse(serverURL)
  41481. if err != nil {
  41482. }
  41483. // 建立WebSocket连接
  41484. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41485. if err != nil {
  41486. }
  41487. defer conn.Close()
  41488. input2 := make(map[string]interface{})
  41489. input := make(map[string]interface{})
  41490. inputData := make(map[string]interface{})
  41491. inputData["orgId"] = code
  41492. inputData["businessType"] = "01301"
  41493. inputData["operatorId"] = operator_id
  41494. inputData["operatorName"] = operator_name
  41495. inputData["officeId"] = "001"
  41496. inputData["officeName"] = "血透室"
  41497. inputData["deviceType"] = ""
  41498. input["data"] = inputData
  41499. input["orgId"] = code
  41500. input["transType"] = "ec.query"
  41501. //if md == ""
  41502. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41503. input2["indata"] = input
  41504. fmt.Println(input2)
  41505. bytesData, _ := json.Marshal(input2)
  41506. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41507. if err != nil {
  41508. fmt.Println(err)
  41509. }
  41510. // 接收消息
  41511. _, receivedMessage, err := conn.ReadMessage()
  41512. if err != nil {
  41513. fmt.Println(err)
  41514. }
  41515. return "", string(receivedMessage)
  41516. }
  41517. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  41518. // WebSocket服务器地址
  41519. serverURL := "ws://127.0.0.1:8899"
  41520. // 解析WebSocket服务器地址
  41521. u, err := url.Parse(serverURL)
  41522. if err != nil {
  41523. }
  41524. // 建立WebSocket连接
  41525. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41526. if err != nil {
  41527. }
  41528. defer conn.Close()
  41529. input2 := make(map[string]interface{})
  41530. input := make(map[string]interface{})
  41531. inputData := make(map[string]interface{})
  41532. inputData["orgId"] = code
  41533. inputData["businessType"] = "01103"
  41534. inputData["operatorId"] = operator_id
  41535. inputData["operatorName"] = operator_name
  41536. inputData["officeId"] = "001"
  41537. inputData["officeName"] = "血透室"
  41538. inputData["deviceType"] = ""
  41539. input["data"] = inputData
  41540. input["orgId"] = code
  41541. input["transType"] = "ec.query"
  41542. //if md ==
  41543. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  41544. input2["indata"] = input
  41545. fmt.Println(input2)
  41546. bytesData, _ := json.Marshal(input2)
  41547. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41548. if err != nil {
  41549. fmt.Println(err)
  41550. }
  41551. // 接收消息
  41552. _, receivedMessage, err := conn.ReadMessage()
  41553. if err != nil {
  41554. fmt.Println(err)
  41555. }
  41556. return "", string(receivedMessage)
  41557. }
  41558. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41559. // WebSocket服务器地址
  41560. serverURL := "ws://127.0.0.1:8899"
  41561. // 解析WebSocket服务器地址
  41562. u, err := url.Parse(serverURL)
  41563. if err != nil {
  41564. }
  41565. // 建立WebSocket连接
  41566. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41567. if err != nil {
  41568. }
  41569. defer conn.Close()
  41570. input2 := make(map[string]interface{})
  41571. input := make(map[string]interface{})
  41572. inputData := make(map[string]interface{})
  41573. inputData["orgId"] = code
  41574. inputData["businessType"] = "01101"
  41575. inputData["operatorId"] = operator_id
  41576. inputData["operatorName"] = operator_name
  41577. inputData["officeId"] = "001"
  41578. inputData["officeName"] = "血透室"
  41579. inputData["deviceType"] = ""
  41580. input["data"] = inputData
  41581. input["orgId"] = code
  41582. input["transType"] = "ec.query"
  41583. //if md == ""
  41584. if md[:4] == "4403" {
  41585. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41586. } else if md[:4] == "4401" {
  41587. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41588. } else {
  41589. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41590. }
  41591. input2["indata"] = input
  41592. fmt.Println(input2)
  41593. bytesData, _ := json.Marshal(input2)
  41594. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41595. if err != nil {
  41596. fmt.Println(err)
  41597. }
  41598. // 接收消息
  41599. _, receivedMessage, err := conn.ReadMessage()
  41600. if err != nil {
  41601. fmt.Println(err)
  41602. }
  41603. return "", string(receivedMessage)
  41604. }
  41605. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  41606. // WebSocket服务器地址
  41607. serverURL := "ws://127.0.0.1:8899"
  41608. // 解析WebSocket服务器地址
  41609. u, err := url.Parse(serverURL)
  41610. if err != nil {
  41611. }
  41612. // 建立WebSocket连接
  41613. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41614. if err != nil {
  41615. }
  41616. defer conn.Close()
  41617. input2 := make(map[string]interface{})
  41618. input := make(map[string]interface{})
  41619. inputData := make(map[string]interface{})
  41620. inputData["orgId"] = code
  41621. inputData["businessType"] = "01301"
  41622. inputData["operatorId"] = operator_id
  41623. inputData["operatorName"] = operator_name
  41624. inputData["officeId"] = "001"
  41625. inputData["officeName"] = "血透室"
  41626. inputData["deviceType"] = ""
  41627. input["data"] = inputData
  41628. input["orgId"] = code
  41629. input["transType"] = "ec.query"
  41630. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41631. input2["indata"] = input
  41632. bytesData, _ := json.Marshal(input2)
  41633. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41634. if err != nil {
  41635. fmt.Println(err)
  41636. }
  41637. // 接收消息
  41638. _, receivedMessage, err := conn.ReadMessage()
  41639. if err != nil {
  41640. fmt.Println(err)
  41641. }
  41642. return "", string(receivedMessage)
  41643. }
  41644. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  41645. newArr = make([]string, 0)
  41646. for i := 0; i < len(arr); i++ {
  41647. repeat := false
  41648. for j := i + 1; j < len(arr); j++ {
  41649. if arr[i] == arr[j] {
  41650. repeat = true
  41651. break
  41652. }
  41653. }
  41654. if !repeat {
  41655. newArr = append(newArr, arr[i])
  41656. }
  41657. }
  41658. return
  41659. }
  41660. func getBirthdateAndAge(idNumber string) (string, int, error) {
  41661. if len(idNumber) != 18 {
  41662. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  41663. }
  41664. // 提取出生日期
  41665. year, err := strconv.Atoi(idNumber[6:10])
  41666. if err != nil {
  41667. return "", 0, err
  41668. }
  41669. month, err := strconv.Atoi(idNumber[10:12])
  41670. if err != nil {
  41671. return "", 0, err
  41672. }
  41673. day, err := strconv.Atoi(idNumber[12:14])
  41674. if err != nil {
  41675. return "", 0, err
  41676. }
  41677. // 格式化生日字符串
  41678. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  41679. birthdateFormatted := birthdate.Format("2006-01-02")
  41680. // 计算年龄
  41681. today := time.Now()
  41682. age := today.Year() - birthdate.Year()
  41683. if today.YearDay() < birthdate.YearDay() {
  41684. age--
  41685. }
  41686. return birthdateFormatted, age, nil
  41687. }
  41688. // 从身份证号码中提取出生年月日
  41689. func getBirthDateFromIDCard(idCard string) (string, error) {
  41690. // 身份证号码长度应为18位
  41691. if len(idCard) != 18 {
  41692. return "", fmt.Errorf("身份证号码长度应为18位")
  41693. }
  41694. // 提取出生日期部分 (YYYYMMDD)
  41695. birthDateStr := idCard[6:14]
  41696. // 解析出生日期
  41697. birthDate, err := time.Parse("20060102", birthDateStr)
  41698. if err != nil {
  41699. return "", fmt.Errorf("解析出生日期失败: %v", err)
  41700. }
  41701. // 格式化出生日期为 YYYY-MM-DD
  41702. formattedDate := birthDate.Format("2006-01-02")
  41703. return formattedDate, nil
  41704. }