his_api_controller.go 1.6MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989
  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/3260", &HisApiController{}, "get:Get3260")
  116. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  117. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  118. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  119. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  120. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  121. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  122. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  123. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  124. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  125. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  126. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  127. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  128. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  129. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  130. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  131. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  132. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  133. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  134. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  135. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  136. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  137. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  138. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  139. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  140. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  141. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  142. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  143. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  144. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  145. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  146. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  147. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  148. //库盘和变更
  149. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  150. //删除库盘和变更
  151. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  152. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  153. //药品变更
  154. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  155. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  156. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  157. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  158. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  159. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  160. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  161. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  162. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  163. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  164. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  165. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  166. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  167. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  168. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  169. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  170. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  171. }
  172. func (c *HisApiController) Get3201() {
  173. adminUser := c.GetAdminUserInfo()
  174. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  175. 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)
  176. var response Response
  177. if err := json.Unmarshal([]byte(result), &response); err != nil {
  178. fmt.Println("Error decoding JSON:", err)
  179. return
  180. }
  181. }
  182. func (c *HisApiController) TestNet() {
  183. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  184. //return
  185. c.ServeSuccessJSON(map[string]interface{}{
  186. "msg": "成功",
  187. })
  188. }
  189. func (c *HisApiController) Get3508() {
  190. admin_user_id, _ := c.GetInt64("admin_user_id")
  191. drug_id, _ := c.GetInt64("id")
  192. start_time := c.GetString("start_time")
  193. end_time := c.GetString("end_time")
  194. adminUser := c.GetAdminUserInfo()
  195. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  196. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  197. drug, _ := service.GetDrugByID(drug_id)
  198. var struct3508 models.Struct3508
  199. struct3508.OrgName = miConfig.OrgName
  200. struct3508.FixmedinsCode = miConfig.Code
  201. struct3508.AccessKey = miConfig.AccessKey
  202. struct3508.Opter = curRoles.UserName
  203. struct3508.RequestUrl = miConfig.Url
  204. struct3508.Url = miConfig.Url
  205. struct3508.AppId = miConfig.Cainfo
  206. struct3508.AppSecret = miConfig.AppSecret
  207. struct3508.Enckey = miConfig.EncKey
  208. struct3508.SignKey = miConfig.SignKey
  209. struct3508.SecretKey = miConfig.SecretKey
  210. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  211. struct3508.Begndate = start_time
  212. struct3508.Enddate = end_time
  213. result1, result2, _ := service.FJyb3508(struct3508)
  214. saveLog(result1, result2, "3508", "3508")
  215. var res models.Result3508
  216. var respJSON2 map[string]interface{}
  217. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. userJSONBytes2, _ := json.Marshal(respJSON2)
  223. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  224. utils.ErrorLog("解析失败:%v", err)
  225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  226. return
  227. }
  228. if res.Infcode == -1 {
  229. c.ServeSuccessJSON(map[string]interface{}{
  230. "failed_code": -10,
  231. "msg": res.ErrMsg,
  232. })
  233. } else {
  234. c.ServeSuccessJSON(map[string]interface{}{
  235. "info": res.Output,
  236. })
  237. }
  238. }
  239. func (c *HisApiController) Get3509() {
  240. admin_user_id, _ := c.GetInt64("admin_user_id")
  241. drug_id, _ := c.GetInt64("id")
  242. start_time := c.GetString("start_time")
  243. end_time := c.GetString("end_time")
  244. adminUser := c.GetAdminUserInfo()
  245. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  246. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  247. drug, _ := service.GetDrugByID(drug_id)
  248. var struct3508 models.Struct3509
  249. struct3508.OrgName = miConfig.OrgName
  250. struct3508.FixmedinsCode = miConfig.Code
  251. struct3508.AccessKey = miConfig.AccessKey
  252. struct3508.Opter = curRoles.UserName
  253. struct3508.RequestUrl = miConfig.Url
  254. struct3508.Url = miConfig.Url
  255. struct3508.AppId = miConfig.Cainfo
  256. struct3508.AppSecret = miConfig.AppSecret
  257. struct3508.Enckey = miConfig.EncKey
  258. struct3508.SignKey = miConfig.SignKey
  259. struct3508.SecretKey = miConfig.SecretKey
  260. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  261. struct3508.Begndate = start_time
  262. struct3508.Enddate = end_time
  263. result1, result2, _ := service.FJyb3509(struct3508)
  264. saveLog(result1, result2, "3509", "3509")
  265. var res models.Result3509
  266. var respJSON2 map[string]interface{}
  267. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  270. return
  271. }
  272. userJSONBytes2, _ := json.Marshal(respJSON2)
  273. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  274. utils.ErrorLog("解析失败:%v", err)
  275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  276. return
  277. }
  278. if res.Infcode == -1 {
  279. c.ServeSuccessJSON(map[string]interface{}{
  280. "failed_code": -10,
  281. "msg": res.ErrMsg,
  282. })
  283. } else {
  284. c.ServeSuccessJSON(map[string]interface{}{
  285. "info": res.Output,
  286. })
  287. }
  288. }
  289. func (c *HisApiController) Get3510() {
  290. admin_user_id, _ := c.GetInt64("admin_user_id")
  291. drug_id, _ := c.GetInt64("id")
  292. start_time := c.GetString("start_time")
  293. end_time := c.GetString("end_time")
  294. adminUser := c.GetAdminUserInfo()
  295. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  296. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  297. drug, _ := service.GetDrugByID(drug_id)
  298. var struct3508 models.Struct3510
  299. struct3508.FixmedinsCode = miConfig.Code
  300. struct3508.OrgName = miConfig.OrgName
  301. struct3508.AccessKey = miConfig.AccessKey
  302. struct3508.Opter = curRoles.UserName
  303. struct3508.RequestUrl = miConfig.Url
  304. struct3508.Url = miConfig.Url
  305. struct3508.AppId = miConfig.Cainfo
  306. struct3508.AppSecret = miConfig.AppSecret
  307. struct3508.Enckey = miConfig.EncKey
  308. struct3508.SignKey = miConfig.SignKey
  309. struct3508.SecretKey = miConfig.SecretKey
  310. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  311. struct3508.Begndate = start_time
  312. struct3508.Enddate = end_time
  313. result1, result2, _ := service.FJyb3510(struct3508)
  314. saveLog(result1, result2, "3510", "3510")
  315. var res models.Result3510
  316. var respJSON2 map[string]interface{}
  317. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  320. return
  321. }
  322. userJSONBytes2, _ := json.Marshal(respJSON2)
  323. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  324. utils.ErrorLog("解析失败:%v", err)
  325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  326. return
  327. }
  328. if res.Infcode == -1 {
  329. c.ServeSuccessJSON(map[string]interface{}{
  330. "failed_code": -10,
  331. "msg": res.ErrMsg,
  332. })
  333. } else {
  334. c.ServeSuccessJSON(map[string]interface{}{
  335. "info": res.Output,
  336. })
  337. }
  338. }
  339. func (c *HisApiController) Get3511() {
  340. admin_user_id, _ := c.GetInt64("admin_user_id")
  341. drug_id, _ := c.GetInt64("id")
  342. start_time := c.GetString("start_time")
  343. end_time := c.GetString("end_time")
  344. adminUser := c.GetAdminUserInfo()
  345. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  346. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  347. drug, _ := service.GetDrugByID(drug_id)
  348. var struct3508 models.Struct3511
  349. struct3508.FixmedinsCode = miConfig.Code
  350. struct3508.OrgName = miConfig.OrgName
  351. struct3508.AccessKey = miConfig.AccessKey
  352. struct3508.Opter = curRoles.UserName
  353. struct3508.RequestUrl = miConfig.Url
  354. struct3508.Url = miConfig.Url
  355. struct3508.AppId = miConfig.Cainfo
  356. struct3508.AppSecret = miConfig.AppSecret
  357. struct3508.Enckey = miConfig.EncKey
  358. struct3508.SignKey = miConfig.SignKey
  359. struct3508.SecretKey = miConfig.SecretKey
  360. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  361. struct3508.Begndate = start_time
  362. struct3508.Enddate = end_time
  363. result1, result2, _ := service.FJyb3511(struct3508)
  364. saveLog(result1, result2, "3511", "3511")
  365. var res models.Result3511
  366. var respJSON2 map[string]interface{}
  367. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  370. return
  371. }
  372. userJSONBytes2, _ := json.Marshal(respJSON2)
  373. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  374. utils.ErrorLog("解析失败:%v", err)
  375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  376. return
  377. }
  378. if res.Infcode == -1 {
  379. c.ServeSuccessJSON(map[string]interface{}{
  380. "failed_code": -10,
  381. "msg": res.ErrMsg,
  382. })
  383. } else {
  384. c.ServeSuccessJSON(map[string]interface{}{
  385. "info": res.Output,
  386. })
  387. }
  388. }
  389. func (c *HisApiController) Get3512() {
  390. admin_user_id, _ := c.GetInt64("admin_user_id")
  391. drug_id, _ := c.GetInt64("id")
  392. start_time := c.GetString("start_time")
  393. end_time := c.GetString("end_time")
  394. adminUser := c.GetAdminUserInfo()
  395. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  396. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  397. drug, _ := service.GetDrugByID(drug_id)
  398. var struct3508 models.Struct3512
  399. struct3508.FixmedinsCode = miConfig.Code
  400. struct3508.OrgName = miConfig.OrgName
  401. struct3508.AccessKey = miConfig.AccessKey
  402. struct3508.Opter = curRoles.UserName
  403. struct3508.RequestUrl = miConfig.Url
  404. struct3508.Url = miConfig.Url
  405. struct3508.AppId = miConfig.Cainfo
  406. struct3508.AppSecret = miConfig.AppSecret
  407. struct3508.Enckey = miConfig.EncKey
  408. struct3508.SignKey = miConfig.SignKey
  409. struct3508.SecretKey = miConfig.SecretKey
  410. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  411. struct3508.Begndate = start_time
  412. struct3508.Enddate = end_time
  413. result1, result2, _ := service.FJyb3512(struct3508)
  414. saveLog(result1, result2, "3512", "3512")
  415. var res models.Result3512
  416. var respJSON2 map[string]interface{}
  417. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  420. return
  421. }
  422. userJSONBytes2, _ := json.Marshal(respJSON2)
  423. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  424. utils.ErrorLog("解析失败:%v", err)
  425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  426. return
  427. }
  428. if res.Infcode == -1 {
  429. c.ServeSuccessJSON(map[string]interface{}{
  430. "failed_code": -10,
  431. "msg": res.ErrMsg,
  432. })
  433. } else {
  434. c.ServeSuccessJSON(map[string]interface{}{
  435. "info": res.Output,
  436. })
  437. }
  438. }
  439. func (c *HisApiController) Get3513() {
  440. admin_user_id, _ := c.GetInt64("admin_user_id")
  441. drug_id, _ := c.GetInt64("id")
  442. start_time := c.GetString("start_time")
  443. end_time := c.GetString("end_time")
  444. adminUser := c.GetAdminUserInfo()
  445. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  446. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  447. drug, _ := service.GetDrugByID(drug_id)
  448. var struct3508 models.Struct3513
  449. struct3508.FixmedinsCode = miConfig.Code
  450. struct3508.OrgName = miConfig.OrgName
  451. struct3508.AccessKey = miConfig.AccessKey
  452. struct3508.Opter = curRoles.UserName
  453. struct3508.RequestUrl = miConfig.Url
  454. struct3508.Url = miConfig.Url
  455. struct3508.AppId = miConfig.Cainfo
  456. struct3508.AppSecret = miConfig.AppSecret
  457. struct3508.Enckey = miConfig.EncKey
  458. struct3508.SignKey = miConfig.SignKey
  459. struct3508.SecretKey = miConfig.SecretKey
  460. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  461. struct3508.Begndate = start_time
  462. struct3508.Enddate = end_time
  463. result1, result2, _ := service.FJyb3513(struct3508)
  464. saveLog(result1, result2, "3513", "3513")
  465. var res models.Result3513
  466. var respJSON2 map[string]interface{}
  467. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  470. return
  471. }
  472. userJSONBytes2, _ := json.Marshal(respJSON2)
  473. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  474. utils.ErrorLog("解析失败:%v", err)
  475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  476. return
  477. }
  478. if res.Infcode == -1 {
  479. c.ServeSuccessJSON(map[string]interface{}{
  480. "failed_code": -10,
  481. "msg": res.ErrMsg,
  482. })
  483. } else {
  484. c.ServeSuccessJSON(map[string]interface{}{
  485. "info": res.Output,
  486. })
  487. }
  488. }
  489. func (c *HisApiController) Get35081() {
  490. admin_user_id, _ := c.GetInt64("admin_user_id")
  491. drug_id, _ := c.GetInt64("id")
  492. //start_time := c.GetString("start_time")
  493. //end_time := c.GetString("end_time")
  494. page, _ := c.GetInt("page")
  495. adminUser := c.GetAdminUserInfo()
  496. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  497. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  498. drug, _ := service.GetDrugByID(drug_id)
  499. var struct3508 models.Struct35081
  500. struct3508.FixmedinsCode = miConfig.Code
  501. struct3508.OrgName = miConfig.OrgName
  502. struct3508.AccessKey = miConfig.AccessKey
  503. struct3508.Opter = curRoles.UserName
  504. struct3508.RequestUrl = miConfig.Url
  505. struct3508.Url = miConfig.Url
  506. struct3508.AppId = miConfig.Cainfo
  507. struct3508.AppSecret = miConfig.AppSecret
  508. struct3508.Enckey = miConfig.EncKey
  509. struct3508.SignKey = miConfig.SignKey
  510. struct3508.SecretKey = miConfig.SecretKey
  511. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  512. struct3508.PageNum = page
  513. struct3508.PageSize = 10
  514. result1, result2, _ := service.FJyb35081(struct3508)
  515. saveLog(result1, result2, "35081", "35081")
  516. var res models.Result35081
  517. var respJSON2 map[string]interface{}
  518. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  521. return
  522. }
  523. userJSONBytes2, _ := json.Marshal(respJSON2)
  524. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  525. utils.ErrorLog("解析失败:%v", err)
  526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  527. return
  528. }
  529. if res.Infcode == -1 {
  530. c.ServeSuccessJSON(map[string]interface{}{
  531. "failed_code": -10,
  532. "msg": res.ErrMsg,
  533. })
  534. } else {
  535. c.ServeSuccessJSON(map[string]interface{}{
  536. "info": res.Output,
  537. })
  538. }
  539. }
  540. func (c *HisApiController) Get35082() {
  541. admin_user_id, _ := c.GetInt64("admin_user_id")
  542. drug_id, _ := c.GetInt64("id")
  543. //start_time := c.GetString("start_time")
  544. //end_time := c.GetString("end_time")
  545. page, _ := c.GetInt("page")
  546. adminUser := c.GetAdminUserInfo()
  547. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  548. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  549. drug, _ := service.GetDrugByID(drug_id)
  550. var struct3508 models.Struct35082
  551. struct3508.FixmedinsCode = miConfig.Code
  552. struct3508.OrgName = miConfig.OrgName
  553. struct3508.AccessKey = miConfig.AccessKey
  554. struct3508.Opter = curRoles.UserName
  555. struct3508.RequestUrl = miConfig.Url
  556. struct3508.Url = miConfig.Url
  557. struct3508.AppId = miConfig.Cainfo
  558. struct3508.AppSecret = miConfig.AppSecret
  559. struct3508.Enckey = miConfig.EncKey
  560. struct3508.SignKey = miConfig.SignKey
  561. struct3508.SecretKey = miConfig.SecretKey
  562. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  563. struct3508.PageNum = page
  564. struct3508.PageSize = 10
  565. result1, result2, _ := service.FJyb35082(struct3508)
  566. saveLog(result1, result2, "35082", "35082")
  567. var res models.Result35082
  568. var respJSON2 map[string]interface{}
  569. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  572. return
  573. }
  574. userJSONBytes2, _ := json.Marshal(respJSON2)
  575. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  576. utils.ErrorLog("解析失败:%v", err)
  577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  578. return
  579. }
  580. if res.Infcode == -1 {
  581. c.ServeSuccessJSON(map[string]interface{}{
  582. "failed_code": -10,
  583. "msg": res.ErrMsg,
  584. })
  585. } else {
  586. c.ServeSuccessJSON(map[string]interface{}{
  587. "info": res.Output,
  588. })
  589. }
  590. }
  591. func (c *HisApiController) FJ3501AND3502() {
  592. ids := c.GetString("ids")
  593. admin_user_id, _ := c.GetInt64("admin_user_id")
  594. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  595. id_arr := strings.Split(ids, ",")
  596. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  597. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  598. //库盘
  599. var errs []string
  600. for _, drug := range drugs {
  601. if drug.IsPc == 0 {
  602. var res2 ResultSix
  603. var res3 ResultSix
  604. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  605. var struct3501 models.Struct3501
  606. struct3501.Code = miConfig.Code
  607. struct3501.OrgName = miConfig.OrgName
  608. struct3501.AccessKey = miConfig.AccessKey
  609. struct3501.Opter = roles.UserName
  610. struct3501.RequestUrl = miConfig.Url
  611. struct3501.Url = miConfig.Url
  612. struct3501.AppId = miConfig.Cainfo
  613. struct3501.AppSecret = miConfig.AppSecret
  614. struct3501.Enckey = miConfig.EncKey
  615. struct3501.SignKey = miConfig.SignKey
  616. struct3501.SecretKey = miConfig.SecretKey
  617. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  618. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  619. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  620. struct3501.RxFlag = "1"
  621. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  622. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  623. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  624. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  625. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  626. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  627. struct3501.FixmedinsBchno = number
  628. struct3501.DrugTracCodg = drug.DrugCode
  629. memo := make(map[string]interface{})
  630. memo["pric"] = drug.Price
  631. bytesData, _ := json.Marshal(memo)
  632. struct3501.Memo = string(bytesData)
  633. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  634. result1, result2, _ := service.FJyb3501(struct3501)
  635. saveLog(result1, result2, "3501", "3501")
  636. //saveLog(result, requestLog, "2201", "挂号")
  637. var respJSON2 map[string]interface{}
  638. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  641. return
  642. }
  643. userJSONBytes2, _ := json.Marshal(respJSON2)
  644. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  645. utils.ErrorLog("解析失败:%v", err)
  646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  647. return
  648. }
  649. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  650. data := make(map[string]interface{})
  651. data["struct_3501s"] = struct3501
  652. client := &http.Client{}
  653. bytesData, _ := json.Marshal(data)
  654. var req *http.Request
  655. if miConfig.MdtrtareaAdmvs == "320921" {
  656. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  657. } else {
  658. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  659. }
  660. resp, _ := client.Do(req)
  661. defer resp.Body.Close()
  662. body, ioErr := ioutil.ReadAll(resp.Body)
  663. if ioErr != nil {
  664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  665. }
  666. var respJSON map[string]interface{}
  667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. var resSix10265 ResultSix10265 //1101结果
  673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  674. result, _ := json.Marshal(respJSON)
  675. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  676. utils.ErrorLog("解析失败:%v", err)
  677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  678. return
  679. }
  680. res2.InfRefmsgid = resSix10265.InfRefmsgid
  681. res2.Output = resSix10265.Output
  682. res2.ErrMsg = resSix10265.ErrMsg
  683. res2.Cainfo = resSix10265.Cainfo
  684. res2.WarnMsg = resSix10265.WarnMsg
  685. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  686. res2.Infcode = infocode
  687. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  688. data := make(map[string]interface{})
  689. data["struct_3501s"] = struct3501
  690. client := &http.Client{}
  691. bytesData, _ := json.Marshal(data)
  692. var req *http.Request
  693. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  694. resp, _ := client.Do(req)
  695. defer resp.Body.Close()
  696. body, ioErr := ioutil.ReadAll(resp.Body)
  697. if ioErr != nil {
  698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  699. }
  700. var respJSON map[string]interface{}
  701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. var resSix10265 ResultSix10265 //1101结果
  707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  708. result, _ := json.Marshal(respJSON)
  709. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  710. utils.ErrorLog("解析失败:%v", err)
  711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  712. return
  713. }
  714. res2.InfRefmsgid = resSix10265.InfRefmsgid
  715. res2.Output = resSix10265.Output
  716. res2.ErrMsg = resSix10265.ErrMsg
  717. res2.Cainfo = resSix10265.Cainfo
  718. res2.WarnMsg = resSix10265.WarnMsg
  719. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  720. res2.Infcode = infocode
  721. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  722. data := make(map[string]interface{})
  723. data["struct_3501s"] = struct3501
  724. client := &http.Client{}
  725. bytesData, _ := json.Marshal(data)
  726. var req *http.Request
  727. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  728. resp, _ := client.Do(req)
  729. defer resp.Body.Close()
  730. body, ioErr := ioutil.ReadAll(resp.Body)
  731. if ioErr != nil {
  732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  733. }
  734. var respJSON map[string]interface{}
  735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  738. return
  739. }
  740. var resSix10265 ResultSix10265 //1101结果
  741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  742. result, _ := json.Marshal(respJSON)
  743. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  744. utils.ErrorLog("解析失败:%v", err)
  745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  746. return
  747. }
  748. res2.InfRefmsgid = resSix10265.InfRefmsgid
  749. res2.Output = resSix10265.Output
  750. res2.ErrMsg = resSix10265.ErrMsg
  751. res2.Cainfo = resSix10265.Cainfo
  752. res2.WarnMsg = resSix10265.WarnMsg
  753. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  754. res2.Infcode = infocode
  755. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  756. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  757. saveLog(result1, result2, "3501", "3501")
  758. //saveLog(result, requestLog, "2201", "挂号")
  759. var respJSON2 map[string]interface{}
  760. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  763. return
  764. }
  765. userJSONBytes2, _ := json.Marshal(respJSON2)
  766. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  767. utils.ErrorLog("解析失败:%v", err)
  768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  769. return
  770. }
  771. }
  772. if res2.Infcode != -1 {
  773. drug.IsPc = 1
  774. drug.Bchno = number
  775. drug.PcDate = time.Now().Unix()
  776. err := service.SaveW(drug)
  777. if err == nil {
  778. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  779. var struct3502 models.Struct3502
  780. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  781. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  782. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  783. struct3502.FixmedinsCode = miConfig.Code
  784. struct3502.Code = miConfig.Code
  785. struct3502.RxFlag = "0"
  786. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  787. struct3502.OrgName = miConfig.OrgName
  788. struct3502.Opter = roles.UserName
  789. struct3502.AccessKey = miConfig.AccessKey
  790. struct3502.RequestUrl = miConfig.Url
  791. struct3502.SecretKey = miConfig.SecretKey
  792. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  793. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  794. struct3502.Url = miConfig.Url
  795. struct3502.AppId = miConfig.Cainfo
  796. struct3502.AppSecret = miConfig.AppSecret
  797. struct3502.Enckey = miConfig.EncKey
  798. struct3502.SignKey = miConfig.SignKey
  799. struct3502.SecretKey = miConfig.SecretKey
  800. struct3502.DrugTracCodg = drug.DrugCode
  801. struct3502.Memo = ""
  802. struct3502.InvChgType = "108"
  803. struct3502.FixmedinsBchno = bg_number
  804. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  805. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  806. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  807. result11, result22, _ := service.FJyb3502(struct3502)
  808. saveLog(result11, result22, "3502", "3502")
  809. var respJSON3 map[string]interface{}
  810. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  813. return
  814. }
  815. userJSONBytes3, _ := json.Marshal(respJSON3)
  816. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  817. utils.ErrorLog("解析失败:%v", err)
  818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  819. return
  820. }
  821. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  822. data := make(map[string]interface{})
  823. data["struct_3502s"] = struct3502
  824. client := &http.Client{}
  825. bytesData, _ := json.Marshal(data)
  826. var req *http.Request
  827. if miConfig.MdtrtareaAdmvs == "320921" {
  828. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  829. } else {
  830. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  831. }
  832. resp, _ := client.Do(req)
  833. defer resp.Body.Close()
  834. body, ioErr := ioutil.ReadAll(resp.Body)
  835. if ioErr != nil {
  836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  837. }
  838. var respJSON map[string]interface{}
  839. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  842. return
  843. }
  844. var resSix10265 ResultSix10265 //1101结果
  845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  846. result, _ := json.Marshal(respJSON)
  847. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  848. utils.ErrorLog("解析失败:%v", err)
  849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  850. return
  851. }
  852. res3.InfRefmsgid = resSix10265.InfRefmsgid
  853. res3.Output = resSix10265.Output
  854. res3.ErrMsg = resSix10265.ErrMsg
  855. res3.Cainfo = resSix10265.Cainfo
  856. res3.WarnMsg = resSix10265.WarnMsg
  857. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  858. res3.Infcode = infocode
  859. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  860. data := make(map[string]interface{})
  861. data["struct_3502s"] = struct3502
  862. client := &http.Client{}
  863. bytesData, _ := json.Marshal(data)
  864. var req *http.Request
  865. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  866. resp, _ := client.Do(req)
  867. defer resp.Body.Close()
  868. body, ioErr := ioutil.ReadAll(resp.Body)
  869. if ioErr != nil {
  870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  871. }
  872. var respJSON map[string]interface{}
  873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  876. return
  877. }
  878. var resSix10265 ResultSix10265 //1101结果
  879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  880. result, _ := json.Marshal(respJSON)
  881. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  882. utils.ErrorLog("解析失败:%v", err)
  883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  884. return
  885. }
  886. res3.InfRefmsgid = resSix10265.InfRefmsgid
  887. res3.Output = resSix10265.Output
  888. res3.ErrMsg = resSix10265.ErrMsg
  889. res3.Cainfo = resSix10265.Cainfo
  890. res3.WarnMsg = resSix10265.WarnMsg
  891. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  892. res3.Infcode = infocode
  893. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  894. data := make(map[string]interface{})
  895. data["struct_3501s"] = struct3501
  896. client := &http.Client{}
  897. bytesData, _ := json.Marshal(data)
  898. var req *http.Request
  899. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  900. resp, _ := client.Do(req)
  901. defer resp.Body.Close()
  902. body, ioErr := ioutil.ReadAll(resp.Body)
  903. if ioErr != nil {
  904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  905. }
  906. var respJSON map[string]interface{}
  907. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  910. return
  911. }
  912. var resSix10265 ResultSix10265 //1101结果
  913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  914. result, _ := json.Marshal(respJSON)
  915. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  916. utils.ErrorLog("解析失败:%v", err)
  917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  918. return
  919. }
  920. res2.InfRefmsgid = resSix10265.InfRefmsgid
  921. res2.Output = resSix10265.Output
  922. res2.ErrMsg = resSix10265.ErrMsg
  923. res2.Cainfo = resSix10265.Cainfo
  924. res2.WarnMsg = resSix10265.WarnMsg
  925. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  926. res2.Infcode = infocode
  927. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  928. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  929. saveLog(result11, result22, "3502", "3502")
  930. var respJSON3 map[string]interface{}
  931. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  934. return
  935. }
  936. userJSONBytes3, _ := json.Marshal(respJSON3)
  937. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  938. utils.ErrorLog("解析失败:%v", err)
  939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  940. return
  941. }
  942. }
  943. if res3.Infcode == -1 {
  944. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": res3.ErrMsg,
  948. })
  949. } else {
  950. drug.IsBg = 1
  951. drug.BgBchno = bg_number
  952. service.SaveW(drug)
  953. }
  954. }
  955. } else {
  956. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  957. }
  958. }
  959. //变更
  960. }
  961. if len(errs) == 0 {
  962. c.ServeSuccessJSON(map[string]interface{}{
  963. "msg": "盘存变更成功",
  964. })
  965. } else {
  966. c.ServeSuccessJSON(map[string]interface{}{
  967. "failed_code": -10,
  968. "msg": errs,
  969. })
  970. }
  971. }
  972. func (c *HisApiController) DeletePCandBG() {
  973. ids := c.GetString("ids")
  974. id_arr := strings.Split(ids, ",")
  975. admin_user_id, _ := c.GetInt64("admin_user_id")
  976. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  977. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  978. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  979. var err []string
  980. for _, item := range drugs {
  981. if item.IsPc == 1 && item.IsBg == 1 {
  982. var res FJ3507Result
  983. var res2 FJ3507Result
  984. var struct3507 models.Struct3507
  985. struct3507.FixmedinsBchno = item.Bchno
  986. struct3507.InvDataType = "1"
  987. struct3507.Opter = roles.UserName
  988. struct3507.OrgName = miConfig.OrgName
  989. struct3507.AccessKey = miConfig.AccessKey
  990. struct3507.RequestUrl = miConfig.Url
  991. struct3507.FixmedinsCode = miConfig.Code
  992. struct3507.Code = miConfig.Code
  993. struct3507.SecretKey = miConfig.SecretKey
  994. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  995. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  996. struct3507.Url = miConfig.Url
  997. struct3507.AppId = miConfig.Cainfo
  998. struct3507.AppSecret = miConfig.AppSecret
  999. struct3507.Enckey = miConfig.EncKey
  1000. struct3507.SignKey = miConfig.SignKey
  1001. struct3507.SecretKey = miConfig.SecretKey
  1002. if miConfig.MdtrtareaAdmvs == "350500" {
  1003. result, result1, _ := service.FJyb3507(struct3507)
  1004. saveLog(result, result1, "3507", "3507")
  1005. var respJSON2 map[string]interface{}
  1006. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1009. return
  1010. }
  1011. userJSONBytes2, _ := json.Marshal(respJSON2)
  1012. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1013. utils.ErrorLog("解析失败:%v", err)
  1014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1015. return
  1016. }
  1017. } else {
  1018. data := make(map[string]interface{})
  1019. data["struct_3507s"] = struct3507
  1020. client := &http.Client{}
  1021. bytesData, _ := json.Marshal(data)
  1022. var req *http.Request
  1023. if miConfig.MdtrtareaAdmvs == "320921" {
  1024. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1025. } else {
  1026. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1027. }
  1028. resp, _ := client.Do(req)
  1029. defer resp.Body.Close()
  1030. body, ioErr := ioutil.ReadAll(resp.Body)
  1031. if ioErr != nil {
  1032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1033. }
  1034. var respJSON map[string]interface{}
  1035. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. return
  1039. }
  1040. var resSix10265 ResultSix10265 //1101结果
  1041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1042. result, _ := json.Marshal(respJSON)
  1043. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1044. utils.ErrorLog("解析失败:%v", err)
  1045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1046. return
  1047. }
  1048. res.InfRefmsgid = resSix10265.InfRefmsgid
  1049. //res.Output = resSix10265.Output
  1050. res.ErrMsg = resSix10265.ErrMsg
  1051. res.Cainfo = resSix10265.Cainfo
  1052. res.WarnMsg = resSix10265.WarnMsg
  1053. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1054. res.Infcode = infocode
  1055. }
  1056. if res.Infcode == 0 {
  1057. item.IsPc = 0
  1058. err2 := service.SaveW(item)
  1059. if err2 == nil {
  1060. var struct3507_2 models.Struct3507
  1061. struct3507_2.OrgName = miConfig.OrgName
  1062. struct3507_2.AccessKey = miConfig.AccessKey
  1063. struct3507_2.RequestUrl = miConfig.Url
  1064. struct3507_2.Opter = roles.UserName
  1065. struct3507_2.FixmedinsCode = miConfig.Code
  1066. struct3507_2.Code = miConfig.Code
  1067. struct3507_2.SecretKey = miConfig.SecretKey
  1068. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1069. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1070. struct3507_2.Url = miConfig.Url
  1071. struct3507_2.AppId = miConfig.Cainfo
  1072. struct3507_2.AppSecret = miConfig.AppSecret
  1073. struct3507_2.Enckey = miConfig.EncKey
  1074. struct3507_2.SignKey = miConfig.SignKey
  1075. struct3507_2.SecretKey = miConfig.SecretKey
  1076. struct3507_2.FixmedinsBchno = item.BgBchno
  1077. struct3507_2.InvDataType = "2"
  1078. if miConfig.MdtrtareaAdmvs == "350500" {
  1079. result11, result22, _ := service.FJyb3507(struct3507_2)
  1080. saveLog(result11, result22, "3507", "3507")
  1081. var respJSON3 map[string]interface{}
  1082. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1085. return
  1086. }
  1087. userJSONBytes3, _ := json.Marshal(respJSON3)
  1088. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1089. utils.ErrorLog("解析失败:%v", err)
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. } else {
  1094. data := make(map[string]interface{})
  1095. data["struct_3507s"] = struct3507_2
  1096. client := &http.Client{}
  1097. bytesData, _ := json.Marshal(data)
  1098. var req *http.Request
  1099. if miConfig.MdtrtareaAdmvs == "320921" {
  1100. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1101. } else {
  1102. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1103. }
  1104. resp, _ := client.Do(req)
  1105. defer resp.Body.Close()
  1106. body, ioErr := ioutil.ReadAll(resp.Body)
  1107. if ioErr != nil {
  1108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1109. }
  1110. var respJSON map[string]interface{}
  1111. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1114. return
  1115. }
  1116. var resSix10265 ResultSix10265 //1101结果
  1117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1118. result, _ := json.Marshal(respJSON)
  1119. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1120. utils.ErrorLog("解析失败:%v", err)
  1121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1122. return
  1123. }
  1124. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1125. //res2.Output = resSix10265.Output
  1126. res2.ErrMsg = resSix10265.ErrMsg
  1127. res2.Cainfo = resSix10265.Cainfo
  1128. res2.WarnMsg = resSix10265.WarnMsg
  1129. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1130. res2.Infcode = infocode
  1131. }
  1132. if res2.Infcode != -1 {
  1133. item.IsBg = 0
  1134. item.Bchno = ""
  1135. item.BgBchno = ""
  1136. item.PcDate = 0
  1137. service.SaveW(item)
  1138. } else {
  1139. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1140. }
  1141. }
  1142. } else {
  1143. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1144. }
  1145. }
  1146. if item.IsPc == 1 && item.IsBg == 0 {
  1147. var res FJ3507Result
  1148. var struct3507 models.Struct3507
  1149. struct3507.FixmedinsBchno = item.Bchno
  1150. struct3507.InvDataType = "1"
  1151. struct3507.Opter = roles.UserName
  1152. struct3507.FixmedinsCode = miConfig.Code
  1153. struct3507.Code = miConfig.Code
  1154. struct3507.OrgName = miConfig.OrgName
  1155. struct3507.AccessKey = miConfig.AccessKey
  1156. struct3507.RequestUrl = miConfig.Url
  1157. struct3507.SecretKey = miConfig.SecretKey
  1158. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1159. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1160. struct3507.Url = miConfig.Url
  1161. struct3507.AppId = miConfig.Cainfo
  1162. struct3507.AppSecret = miConfig.AppSecret
  1163. struct3507.Enckey = miConfig.EncKey
  1164. struct3507.SignKey = miConfig.SignKey
  1165. struct3507.SecretKey = miConfig.SecretKey
  1166. //result, result1, _ := service.FJyb3507(struct3507)
  1167. //saveLog(result, result1, "3507", "3507")
  1168. if miConfig.MdtrtareaAdmvs == "350500" {
  1169. result, result1, _ := service.FJyb3507(struct3507)
  1170. saveLog(result, result1, "3507", "3507")
  1171. var respJSON2 map[string]interface{}
  1172. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1175. return
  1176. }
  1177. userJSONBytes2, _ := json.Marshal(respJSON2)
  1178. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1179. utils.ErrorLog("解析失败:%v", err)
  1180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1181. return
  1182. }
  1183. } else {
  1184. data := make(map[string]interface{})
  1185. data["struct_3507s"] = struct3507
  1186. client := &http.Client{}
  1187. bytesData, _ := json.Marshal(data)
  1188. var req *http.Request
  1189. if miConfig.MdtrtareaAdmvs == "320921" {
  1190. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1191. } else {
  1192. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1193. }
  1194. resp, _ := client.Do(req)
  1195. defer resp.Body.Close()
  1196. body, ioErr := ioutil.ReadAll(resp.Body)
  1197. if ioErr != nil {
  1198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1199. }
  1200. var respJSON map[string]interface{}
  1201. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1204. return
  1205. }
  1206. var resSix10265 ResultSix10265 //1101结果
  1207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1208. result, _ := json.Marshal(respJSON)
  1209. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1210. utils.ErrorLog("解析失败:%v", err)
  1211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1212. return
  1213. }
  1214. res.InfRefmsgid = resSix10265.InfRefmsgid
  1215. //res.Output = resSix10265.Output
  1216. res.ErrMsg = resSix10265.ErrMsg
  1217. res.Cainfo = resSix10265.Cainfo
  1218. res.WarnMsg = resSix10265.WarnMsg
  1219. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1220. res.Infcode = infocode
  1221. }
  1222. if res.Infcode == 0 {
  1223. item.IsPc = 0
  1224. item.Bchno = ""
  1225. item.BgBchno = ""
  1226. item.PcDate = 0
  1227. service.SaveW(item)
  1228. } else {
  1229. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1230. }
  1231. }
  1232. if item.IsPc == 0 && item.IsBg == 1 {
  1233. var res FJ3507Result
  1234. var struct3507 models.Struct3507
  1235. struct3507.FixmedinsBchno = item.BgBchno
  1236. struct3507.InvDataType = "2"
  1237. struct3507.Opter = roles.UserName
  1238. struct3507.FixmedinsCode = miConfig.Code
  1239. struct3507.OrgName = miConfig.OrgName
  1240. struct3507.AccessKey = miConfig.AccessKey
  1241. struct3507.RequestUrl = miConfig.Url
  1242. struct3507.SecretKey = miConfig.SecretKey
  1243. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1244. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1245. struct3507.Url = miConfig.Url
  1246. struct3507.AppId = miConfig.Cainfo
  1247. struct3507.AppSecret = miConfig.AppSecret
  1248. struct3507.Enckey = miConfig.EncKey
  1249. struct3507.SignKey = miConfig.SignKey
  1250. struct3507.SecretKey = miConfig.SecretKey
  1251. //result, result1, _ := service.FJyb3507(struct3507)
  1252. //saveLog(result, result1, "3507", "3507")
  1253. if miConfig.MdtrtareaAdmvs == "350500" {
  1254. result, result1, _ := service.FJyb3507(struct3507)
  1255. saveLog(result, result1, "3507", "3507")
  1256. var respJSON2 map[string]interface{}
  1257. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1260. return
  1261. }
  1262. userJSONBytes2, _ := json.Marshal(respJSON2)
  1263. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1264. utils.ErrorLog("解析失败:%v", err)
  1265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1266. return
  1267. }
  1268. } else {
  1269. data := make(map[string]interface{})
  1270. data["struct_3507s"] = struct3507
  1271. client := &http.Client{}
  1272. bytesData, _ := json.Marshal(data)
  1273. var req *http.Request
  1274. if miConfig.MdtrtareaAdmvs == "320921" {
  1275. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1276. } else {
  1277. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1278. }
  1279. resp, _ := client.Do(req)
  1280. defer resp.Body.Close()
  1281. body, ioErr := ioutil.ReadAll(resp.Body)
  1282. if ioErr != nil {
  1283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1284. }
  1285. var respJSON map[string]interface{}
  1286. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1289. return
  1290. }
  1291. var resSix10265 ResultSix10265 //1101结果
  1292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1293. result, _ := json.Marshal(respJSON)
  1294. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1295. utils.ErrorLog("解析失败:%v", err)
  1296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1297. return
  1298. }
  1299. res.InfRefmsgid = resSix10265.InfRefmsgid
  1300. //res.Output = resSix10265.Output
  1301. res.ErrMsg = resSix10265.ErrMsg
  1302. res.Cainfo = resSix10265.Cainfo
  1303. res.WarnMsg = resSix10265.WarnMsg
  1304. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1305. res.Infcode = infocode
  1306. }
  1307. if res.Infcode == 0 {
  1308. item.IsBg = 0
  1309. item.Bchno = ""
  1310. item.BgBchno = ""
  1311. item.PcDate = 0
  1312. service.SaveW(item)
  1313. } else {
  1314. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1315. }
  1316. }
  1317. }
  1318. if len(err) == 0 {
  1319. c.ServeSuccessJSON(map[string]interface{}{
  1320. "msg": "删除盘存变更成功",
  1321. })
  1322. } else {
  1323. c.ServeSuccessJSON(map[string]interface{}{
  1324. "failed_code": -10,
  1325. "msg": err,
  1326. })
  1327. }
  1328. }
  1329. func (c *HisApiController) DeleteXSandBG() {
  1330. ids := c.GetString("ids")
  1331. id_arr := strings.Split(ids, ",")
  1332. admin_user_id, _ := c.GetInt64("admin_user_id")
  1333. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1334. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1335. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1336. var err []string
  1337. for _, item := range flows {
  1338. if item.IsSale == 1 && item.IsChange == 1 {
  1339. var res FJ3507Result
  1340. var res2 FJ3507Result
  1341. var struct3507 models.Struct3507
  1342. struct3507.FixmedinsBchno = item.Bchno
  1343. struct3507.InvDataType = "4"
  1344. struct3507.Opter = roles.UserName
  1345. struct3507.OrgName = miConfig.OrgName
  1346. struct3507.AccessKey = miConfig.AccessKey
  1347. struct3507.RequestUrl = miConfig.Url
  1348. struct3507.FixmedinsCode = miConfig.Code
  1349. struct3507.SecretKey = miConfig.SecretKey
  1350. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1351. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1352. struct3507.Url = miConfig.Url
  1353. struct3507.AppId = miConfig.Cainfo
  1354. struct3507.AppSecret = miConfig.AppSecret
  1355. struct3507.Enckey = miConfig.EncKey
  1356. struct3507.SignKey = miConfig.SignKey
  1357. struct3507.SecretKey = miConfig.SecretKey
  1358. //result, result1, _ := service.FJyb3507(struct3507)
  1359. //saveLog(result, result1, "3507", "3507")
  1360. if miConfig.MdtrtareaAdmvs == "350500" {
  1361. result, result1, _ := service.FJyb3507(struct3507)
  1362. saveLog(result, result1, "3507", "3507")
  1363. var respJSON2 map[string]interface{}
  1364. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1367. return
  1368. }
  1369. userJSONBytes2, _ := json.Marshal(respJSON2)
  1370. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1371. utils.ErrorLog("解析失败:%v", err)
  1372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1373. return
  1374. }
  1375. } else {
  1376. data := make(map[string]interface{})
  1377. data["struct_3507s"] = struct3507
  1378. client := &http.Client{}
  1379. bytesData, _ := json.Marshal(data)
  1380. var req *http.Request
  1381. if miConfig.MdtrtareaAdmvs == "320921" {
  1382. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1383. } else {
  1384. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1385. }
  1386. resp, _ := client.Do(req)
  1387. defer resp.Body.Close()
  1388. body, ioErr := ioutil.ReadAll(resp.Body)
  1389. if ioErr != nil {
  1390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1391. }
  1392. var respJSON map[string]interface{}
  1393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1396. return
  1397. }
  1398. var resSix10265 ResultSix10265 //1101结果
  1399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1400. result, _ := json.Marshal(respJSON)
  1401. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1402. utils.ErrorLog("解析失败:%v", err)
  1403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1404. return
  1405. }
  1406. res.InfRefmsgid = resSix10265.InfRefmsgid
  1407. //res.Output = resSix10265.Output
  1408. res.ErrMsg = resSix10265.ErrMsg
  1409. res.Cainfo = resSix10265.Cainfo
  1410. res.WarnMsg = resSix10265.WarnMsg
  1411. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1412. res.Infcode = infocode
  1413. }
  1414. if res.Infcode == 0 {
  1415. item.IsSale = 0
  1416. item.SaleDate = ""
  1417. item.Bchno = ""
  1418. err2 := service.SaveDF(item)
  1419. if err2 == nil {
  1420. var struct3507_2 models.Struct3507
  1421. struct3507_2.OrgName = miConfig.OrgName
  1422. struct3507_2.AccessKey = miConfig.AccessKey
  1423. struct3507_2.RequestUrl = miConfig.Url
  1424. struct3507_2.Opter = roles.UserName
  1425. struct3507_2.FixmedinsCode = miConfig.Code
  1426. struct3507_2.Code = miConfig.Code
  1427. struct3507_2.SecretKey = miConfig.SecretKey
  1428. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1429. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1430. struct3507_2.Url = miConfig.Url
  1431. struct3507_2.AppId = miConfig.Cainfo
  1432. struct3507_2.AppSecret = miConfig.AppSecret
  1433. struct3507_2.Enckey = miConfig.EncKey
  1434. struct3507_2.SignKey = miConfig.SignKey
  1435. struct3507_2.SecretKey = miConfig.SecretKey
  1436. struct3507_2.FixmedinsBchno = item.BgBchno
  1437. struct3507_2.InvDataType = "2"
  1438. if miConfig.MdtrtareaAdmvs == "350500" {
  1439. result11, result22, _ := service.FJyb3507(struct3507_2)
  1440. saveLog(result11, result22, "3507", "3507")
  1441. var respJSON3 map[string]interface{}
  1442. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1445. return
  1446. }
  1447. userJSONBytes3, _ := json.Marshal(respJSON3)
  1448. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1449. utils.ErrorLog("解析失败:%v", err)
  1450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1451. return
  1452. }
  1453. } else {
  1454. data := make(map[string]interface{})
  1455. data["struct_3507s"] = struct3507_2
  1456. client := &http.Client{}
  1457. bytesData, _ := json.Marshal(data)
  1458. var req *http.Request
  1459. if miConfig.MdtrtareaAdmvs == "320921" {
  1460. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1461. } else {
  1462. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1463. }
  1464. resp, _ := client.Do(req)
  1465. defer resp.Body.Close()
  1466. body, ioErr := ioutil.ReadAll(resp.Body)
  1467. if ioErr != nil {
  1468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1469. }
  1470. var respJSON map[string]interface{}
  1471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1474. return
  1475. }
  1476. var resSix10265 ResultSix10265 //1101结果
  1477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1478. result, _ := json.Marshal(respJSON)
  1479. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1480. utils.ErrorLog("解析失败:%v", err)
  1481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1482. return
  1483. }
  1484. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1485. //res.Output = resSix10265.Output
  1486. res2.ErrMsg = resSix10265.ErrMsg
  1487. res2.Cainfo = resSix10265.Cainfo
  1488. res2.WarnMsg = resSix10265.WarnMsg
  1489. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1490. res2.Infcode = infocode
  1491. }
  1492. if res2.Infcode == 0 {
  1493. item.IsChange = 0
  1494. item.BgBchno = ""
  1495. service.SaveDF2(item)
  1496. } else {
  1497. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1498. }
  1499. }
  1500. } else {
  1501. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1502. }
  1503. }
  1504. if item.IsSale == 2 && item.IsChange == 1 {
  1505. var res FJ3507Result
  1506. var res2 FJ3507Result
  1507. var struct3507 models.Struct3507
  1508. struct3507.FixmedinsBchno = item.Bchno
  1509. struct3507.InvDataType = "4"
  1510. struct3507.Opter = roles.UserName
  1511. struct3507.OrgName = miConfig.OrgName
  1512. struct3507.AccessKey = miConfig.AccessKey
  1513. struct3507.RequestUrl = miConfig.Url
  1514. struct3507.FixmedinsCode = miConfig.Code
  1515. struct3507.Code = miConfig.Code
  1516. struct3507.SecretKey = miConfig.SecretKey
  1517. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1518. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1519. struct3507.Url = miConfig.Url
  1520. struct3507.AppId = miConfig.Cainfo
  1521. struct3507.AppSecret = miConfig.AppSecret
  1522. struct3507.Enckey = miConfig.EncKey
  1523. struct3507.SignKey = miConfig.SignKey
  1524. struct3507.SecretKey = miConfig.SecretKey
  1525. //result, result1, _ := service.FJyb3507(struct3507)
  1526. //saveLog(result, result1, "3507", "3507")
  1527. //
  1528. //var respJSON2 map[string]interface{}
  1529. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1530. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1532. // return
  1533. //}
  1534. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1535. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1536. // utils.ErrorLog("解析失败:%v", err)
  1537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1538. // return
  1539. //}
  1540. if miConfig.MdtrtareaAdmvs == "350500" {
  1541. result, result1, _ := service.FJyb3507(struct3507)
  1542. saveLog(result, result1, "3507", "3507")
  1543. var respJSON2 map[string]interface{}
  1544. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1547. return
  1548. }
  1549. userJSONBytes2, _ := json.Marshal(respJSON2)
  1550. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1551. utils.ErrorLog("解析失败:%v", err)
  1552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1553. return
  1554. }
  1555. } else {
  1556. data := make(map[string]interface{})
  1557. data["struct_3507s"] = struct3507
  1558. client := &http.Client{}
  1559. bytesData, _ := json.Marshal(data)
  1560. var req *http.Request
  1561. if miConfig.MdtrtareaAdmvs == "320921" {
  1562. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1563. } else {
  1564. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1565. }
  1566. resp, _ := client.Do(req)
  1567. defer resp.Body.Close()
  1568. body, ioErr := ioutil.ReadAll(resp.Body)
  1569. if ioErr != nil {
  1570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1571. }
  1572. var respJSON map[string]interface{}
  1573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1576. return
  1577. }
  1578. var resSix10265 ResultSix10265 //1101结果
  1579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1580. result, _ := json.Marshal(respJSON)
  1581. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1582. utils.ErrorLog("解析失败:%v", err)
  1583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1584. return
  1585. }
  1586. res.InfRefmsgid = resSix10265.InfRefmsgid
  1587. //res.Output = resSix10265.Output
  1588. res.ErrMsg = resSix10265.ErrMsg
  1589. res.Cainfo = resSix10265.Cainfo
  1590. res.WarnMsg = resSix10265.WarnMsg
  1591. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1592. res.Infcode = infocode
  1593. }
  1594. if res.Infcode == 0 {
  1595. item.IsSale = 0
  1596. item.SaleDate = ""
  1597. item.Bchno = ""
  1598. err2 := service.SaveDF(item)
  1599. if err2 == nil {
  1600. var struct3507_2 models.Struct3507
  1601. struct3507_2.OrgName = miConfig.OrgName
  1602. struct3507_2.AccessKey = miConfig.AccessKey
  1603. struct3507_2.RequestUrl = miConfig.Url
  1604. struct3507_2.Opter = roles.UserName
  1605. struct3507_2.FixmedinsCode = miConfig.Code
  1606. struct3507_2.Code = miConfig.Code
  1607. struct3507_2.SecretKey = miConfig.SecretKey
  1608. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1609. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1610. struct3507_2.Url = miConfig.Url
  1611. struct3507_2.AppId = miConfig.Cainfo
  1612. struct3507_2.AppSecret = miConfig.AppSecret
  1613. struct3507_2.Enckey = miConfig.EncKey
  1614. struct3507_2.SignKey = miConfig.SignKey
  1615. struct3507_2.SecretKey = miConfig.SecretKey
  1616. struct3507_2.FixmedinsBchno = item.BgBchno
  1617. struct3507_2.InvDataType = "2"
  1618. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1619. //saveLog(result11, result22, "3507", "3507")
  1620. //var respJSON3 map[string]interface{}
  1621. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1622. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1624. // return
  1625. //}
  1626. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1627. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1628. // utils.ErrorLog("解析失败:%v", err)
  1629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1630. // return
  1631. //}
  1632. if miConfig.MdtrtareaAdmvs == "350500" {
  1633. result11, result22, _ := service.FJyb3507(struct3507_2)
  1634. saveLog(result11, result22, "3507", "3507")
  1635. var respJSON3 map[string]interface{}
  1636. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1639. return
  1640. }
  1641. userJSONBytes3, _ := json.Marshal(respJSON3)
  1642. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1643. utils.ErrorLog("解析失败:%v", err)
  1644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1645. return
  1646. }
  1647. } else {
  1648. data := make(map[string]interface{})
  1649. data["struct_3507s"] = struct3507_2
  1650. client := &http.Client{}
  1651. bytesData, _ := json.Marshal(data)
  1652. var req *http.Request
  1653. if miConfig.MdtrtareaAdmvs == "320921" {
  1654. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1655. } else {
  1656. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1657. }
  1658. resp, _ := client.Do(req)
  1659. defer resp.Body.Close()
  1660. body, ioErr := ioutil.ReadAll(resp.Body)
  1661. if ioErr != nil {
  1662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1663. }
  1664. var respJSON map[string]interface{}
  1665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1668. return
  1669. }
  1670. var resSix10265 ResultSix10265 //1101结果
  1671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1672. result, _ := json.Marshal(respJSON)
  1673. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1674. utils.ErrorLog("解析失败:%v", err)
  1675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1676. return
  1677. }
  1678. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1679. //res.Output = resSix10265.Output
  1680. res2.ErrMsg = resSix10265.ErrMsg
  1681. res2.Cainfo = resSix10265.Cainfo
  1682. res2.WarnMsg = resSix10265.WarnMsg
  1683. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1684. res2.Infcode = infocode
  1685. }
  1686. if res2.Infcode == 0 {
  1687. item.IsChange = 0
  1688. item.BgBchno = ""
  1689. service.SaveDF2(item)
  1690. } else {
  1691. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1692. }
  1693. }
  1694. } else {
  1695. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1696. }
  1697. }
  1698. if item.IsSale == 1 && item.IsChange == 0 {
  1699. var res FJ3507Result
  1700. var struct3507 models.Struct3507
  1701. struct3507.FixmedinsBchno = item.Bchno
  1702. struct3507.InvDataType = "4"
  1703. struct3507.Opter = roles.UserName
  1704. struct3507.FixmedinsCode = miConfig.Code
  1705. struct3507.Code = miConfig.Code
  1706. struct3507.OrgName = miConfig.OrgName
  1707. struct3507.AccessKey = miConfig.AccessKey
  1708. struct3507.RequestUrl = miConfig.Url
  1709. struct3507.SecretKey = miConfig.SecretKey
  1710. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1711. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1712. struct3507.Url = miConfig.Url
  1713. struct3507.AppId = miConfig.Cainfo
  1714. struct3507.AppSecret = miConfig.AppSecret
  1715. struct3507.Enckey = miConfig.EncKey
  1716. struct3507.SignKey = miConfig.SignKey
  1717. struct3507.SecretKey = miConfig.SecretKey
  1718. //result, result1, _ := service.FJyb3507(struct3507)
  1719. //saveLog(result, result1, "3507", "3507")
  1720. //
  1721. //var respJSON3 map[string]interface{}
  1722. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1723. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1724. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1725. // return
  1726. //}
  1727. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1728. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1729. // utils.ErrorLog("解析失败:%v", err)
  1730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1731. // return
  1732. //}
  1733. if miConfig.MdtrtareaAdmvs == "350500" {
  1734. result, result1, _ := service.FJyb3507(struct3507)
  1735. saveLog(result, result1, "3507", "3507")
  1736. var respJSON2 map[string]interface{}
  1737. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1740. return
  1741. }
  1742. userJSONBytes2, _ := json.Marshal(respJSON2)
  1743. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1744. utils.ErrorLog("解析失败:%v", err)
  1745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1746. return
  1747. }
  1748. } else {
  1749. data := make(map[string]interface{})
  1750. data["struct_3507s"] = struct3507
  1751. client := &http.Client{}
  1752. bytesData, _ := json.Marshal(data)
  1753. var req *http.Request
  1754. if miConfig.MdtrtareaAdmvs == "320921" {
  1755. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1756. } else {
  1757. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1758. }
  1759. resp, _ := client.Do(req)
  1760. defer resp.Body.Close()
  1761. body, ioErr := ioutil.ReadAll(resp.Body)
  1762. if ioErr != nil {
  1763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1764. }
  1765. var respJSON map[string]interface{}
  1766. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1769. return
  1770. }
  1771. var resSix10265 ResultSix10265 //1101结果
  1772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1773. result, _ := json.Marshal(respJSON)
  1774. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1775. utils.ErrorLog("解析失败:%v", err)
  1776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1777. return
  1778. }
  1779. res.InfRefmsgid = resSix10265.InfRefmsgid
  1780. //res.Output = resSix10265.Output
  1781. res.ErrMsg = resSix10265.ErrMsg
  1782. res.Cainfo = resSix10265.Cainfo
  1783. res.WarnMsg = resSix10265.WarnMsg
  1784. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1785. res.Infcode = infocode
  1786. }
  1787. if res.Infcode == 0 {
  1788. item.IsSale = 0
  1789. item.SaleDate = ""
  1790. service.SaveDF(item)
  1791. } else {
  1792. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1793. }
  1794. }
  1795. if item.IsSale == 2 && item.IsChange == 0 {
  1796. var res FJ3507Result
  1797. var struct3507 models.Struct3507
  1798. struct3507.FixmedinsBchno = item.Bchno
  1799. struct3507.InvDataType = "4"
  1800. struct3507.Opter = roles.UserName
  1801. struct3507.FixmedinsCode = miConfig.Code
  1802. struct3507.Code = miConfig.Code
  1803. struct3507.OrgName = miConfig.OrgName
  1804. struct3507.AccessKey = miConfig.AccessKey
  1805. struct3507.RequestUrl = miConfig.Url
  1806. struct3507.SecretKey = miConfig.SecretKey
  1807. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1808. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1809. struct3507.Url = miConfig.Url
  1810. struct3507.AppId = miConfig.Cainfo
  1811. struct3507.AppSecret = miConfig.AppSecret
  1812. struct3507.Enckey = miConfig.EncKey
  1813. struct3507.SignKey = miConfig.SignKey
  1814. struct3507.SecretKey = miConfig.SecretKey
  1815. //result, result1, _ := service.FJyb3507(struct3507)
  1816. //saveLog(result, result1, "3507", "3507")
  1817. //
  1818. //var respJSON3 map[string]interface{}
  1819. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1820. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1822. // return
  1823. //}
  1824. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1825. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1826. // utils.ErrorLog("解析失败:%v", err)
  1827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1828. // return
  1829. //}
  1830. if miConfig.MdtrtareaAdmvs == "350500" {
  1831. result, result1, _ := service.FJyb3507(struct3507)
  1832. saveLog(result, result1, "3507", "3507")
  1833. var respJSON2 map[string]interface{}
  1834. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1837. return
  1838. }
  1839. userJSONBytes2, _ := json.Marshal(respJSON2)
  1840. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1841. utils.ErrorLog("解析失败:%v", err)
  1842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1843. return
  1844. }
  1845. } else {
  1846. data := make(map[string]interface{})
  1847. data["struct_3507s"] = struct3507
  1848. client := &http.Client{}
  1849. bytesData, _ := json.Marshal(data)
  1850. var req *http.Request
  1851. if miConfig.MdtrtareaAdmvs == "320921" {
  1852. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1853. } else {
  1854. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1855. }
  1856. resp, _ := client.Do(req)
  1857. defer resp.Body.Close()
  1858. body, ioErr := ioutil.ReadAll(resp.Body)
  1859. if ioErr != nil {
  1860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1861. }
  1862. var respJSON map[string]interface{}
  1863. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1866. return
  1867. }
  1868. var resSix10265 ResultSix10265 //1101结果
  1869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1870. result, _ := json.Marshal(respJSON)
  1871. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1872. utils.ErrorLog("解析失败:%v", err)
  1873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1874. return
  1875. }
  1876. res.InfRefmsgid = resSix10265.InfRefmsgid
  1877. //res.Output = resSix10265.Output
  1878. res.ErrMsg = resSix10265.ErrMsg
  1879. res.Cainfo = resSix10265.Cainfo
  1880. res.WarnMsg = resSix10265.WarnMsg
  1881. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1882. res.Infcode = infocode
  1883. }
  1884. if res.Infcode == 0 {
  1885. item.IsSale = 0
  1886. item.SaleDate = ""
  1887. item.Bchno = ""
  1888. service.SaveDF(item)
  1889. } else {
  1890. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1891. }
  1892. }
  1893. if item.IsSale == 0 && item.IsChange == 1 {
  1894. var res FJ3507Result
  1895. var struct3507 models.Struct3507
  1896. struct3507.FixmedinsBchno = item.BgBchno
  1897. struct3507.InvDataType = "2"
  1898. struct3507.Opter = roles.UserName
  1899. struct3507.FixmedinsCode = miConfig.Code
  1900. struct3507.Code = miConfig.Code
  1901. struct3507.OrgName = miConfig.OrgName
  1902. struct3507.AccessKey = miConfig.AccessKey
  1903. struct3507.RequestUrl = miConfig.Url
  1904. struct3507.SecretKey = miConfig.SecretKey
  1905. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1906. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1907. struct3507.Url = miConfig.Url
  1908. struct3507.AppId = miConfig.Cainfo
  1909. struct3507.AppSecret = miConfig.AppSecret
  1910. struct3507.Enckey = miConfig.EncKey
  1911. struct3507.SignKey = miConfig.SignKey
  1912. struct3507.SecretKey = miConfig.SecretKey
  1913. //result, result1, _ := service.FJyb3507(struct3507)
  1914. //saveLog(result, result1, "3507", "3507")
  1915. //
  1916. //var respJSON3 map[string]interface{}
  1917. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1918. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1920. // return
  1921. //}
  1922. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1923. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1924. // utils.ErrorLog("解析失败:%v", err)
  1925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. // return
  1927. //}
  1928. if miConfig.MdtrtareaAdmvs == "350500" {
  1929. result, result1, _ := service.FJyb3507(struct3507)
  1930. saveLog(result, result1, "3507", "3507")
  1931. var respJSON2 map[string]interface{}
  1932. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1935. return
  1936. }
  1937. userJSONBytes2, _ := json.Marshal(respJSON2)
  1938. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1939. utils.ErrorLog("解析失败:%v", err)
  1940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1941. return
  1942. }
  1943. } else {
  1944. data := make(map[string]interface{})
  1945. data["struct_3507s"] = struct3507
  1946. client := &http.Client{}
  1947. bytesData, _ := json.Marshal(data)
  1948. var req *http.Request
  1949. if miConfig.MdtrtareaAdmvs == "320921" {
  1950. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1951. } else {
  1952. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1953. }
  1954. resp, _ := client.Do(req)
  1955. defer resp.Body.Close()
  1956. body, ioErr := ioutil.ReadAll(resp.Body)
  1957. if ioErr != nil {
  1958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1959. }
  1960. var respJSON map[string]interface{}
  1961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1964. return
  1965. }
  1966. var resSix10265 ResultSix10265 //1101结果
  1967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1968. result, _ := json.Marshal(respJSON)
  1969. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1970. utils.ErrorLog("解析失败:%v", err)
  1971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1972. return
  1973. }
  1974. res.InfRefmsgid = resSix10265.InfRefmsgid
  1975. //res.Output = resSix10265.Output
  1976. res.ErrMsg = resSix10265.ErrMsg
  1977. res.Cainfo = resSix10265.Cainfo
  1978. res.WarnMsg = resSix10265.WarnMsg
  1979. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1980. res.Infcode = infocode
  1981. }
  1982. if res.Infcode == 0 {
  1983. item.IsChange = 0
  1984. item.BgBchno = ""
  1985. service.SaveDF2(item)
  1986. } else {
  1987. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1988. }
  1989. }
  1990. }
  1991. if len(err) == 0 {
  1992. c.ServeSuccessJSON(map[string]interface{}{
  1993. "msg": "删除销售变更成功",
  1994. })
  1995. } else {
  1996. c.ServeSuccessJSON(map[string]interface{}{
  1997. "failed_code": -10,
  1998. "msg": err,
  1999. })
  2000. }
  2001. }
  2002. //func (c *HisApiController) BatchFJ3501AND3502() {
  2003. // //ids := c.GetString("ids")
  2004. // start_time := c.GetString("start_time")
  2005. // end_time := c.GetString("end_time")
  2006. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2007. //
  2008. //
  2009. // timeLayout := "2006-01-02"
  2010. // loc, _ := time.LoadLocation("Local")
  2011. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2012. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2013. //
  2014. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2015. // //id_arr := strings.Split(ids, ",")
  2016. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2017. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2018. // //库盘
  2019. // var errs []string
  2020. // for _, drug := range drugs {
  2021. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2022. // var res2 ResultSix
  2023. // var res3 ResultSix
  2024. //
  2025. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2026. // var struct3501 models.Struct3501
  2027. // struct3501.Code = miConfig.Code
  2028. // struct3501.OrgName = miConfig.OrgName
  2029. // struct3501.AccessKey = miConfig.AccessKey
  2030. // struct3501.Opter = roles.UserName
  2031. // struct3501.RequestUrl = miConfig.Url
  2032. // struct3501.Url = miConfig.Url
  2033. // struct3501.AppId = miConfig.Cainfo
  2034. // struct3501.AppSecret = miConfig.AppSecret
  2035. // struct3501.Enckey = miConfig.EncKey
  2036. // struct3501.SignKey = miConfig.SignKey
  2037. // struct3501.SecretKey = miConfig.SecretKey
  2038. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2039. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2040. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2041. // struct3501.RxFlag = "1"
  2042. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2043. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2044. //
  2045. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2046. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2047. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2048. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2049. // struct3501.FixmedinsBchno = number
  2050. // struct3501.DrugTracCodg = drug.DrugCode
  2051. // memo := make(map[string]interface{})
  2052. // memo["pric"] = drug.Price
  2053. // bytesData, _ := json.Marshal(memo)
  2054. // struct3501.Memo = string(bytesData)
  2055. //
  2056. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2057. //
  2058. // result1, result2, _ := service.FJyb3501(struct3501)
  2059. // saveLog(result1, result2, "3501", "3501")
  2060. // //saveLog(result, requestLog, "2201", "挂号")
  2061. //
  2062. // var respJSON2 map[string]interface{}
  2063. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2064. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2066. // return
  2067. // }
  2068. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2069. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2070. // utils.ErrorLog("解析失败:%v", err)
  2071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2072. // return
  2073. // }
  2074. //
  2075. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2076. // data := make(map[string]interface{})
  2077. // data["struct_3501s"] = struct3501
  2078. // client := &http.Client{}
  2079. // bytesData, _ := json.Marshal(data)
  2080. // var req *http.Request
  2081. // if miConfig.MdtrtareaAdmvs == "320921" {
  2082. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2083. // } else {
  2084. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2085. // }
  2086. //
  2087. // resp, _ := client.Do(req)
  2088. // defer resp.Body.Close()
  2089. // body, ioErr := ioutil.ReadAll(resp.Body)
  2090. // if ioErr != nil {
  2091. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2092. // }
  2093. // var respJSON map[string]interface{}
  2094. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2095. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2097. // return
  2098. // }
  2099. // var resSix10265 ResultSix10265 //1101结果
  2100. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2101. // result, _ := json.Marshal(respJSON)
  2102. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2103. // utils.ErrorLog("解析失败:%v", err)
  2104. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2105. // return
  2106. // }
  2107. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2108. // res2.Output = resSix10265.Output
  2109. // res2.ErrMsg = resSix10265.ErrMsg
  2110. // res2.Cainfo = resSix10265.Cainfo
  2111. // res2.WarnMsg = resSix10265.WarnMsg
  2112. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2113. // res2.Infcode = infocode
  2114. //
  2115. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2116. // data := make(map[string]interface{})
  2117. // data["struct_3501s"] = struct3501
  2118. // client := &http.Client{}
  2119. // bytesData, _ := json.Marshal(data)
  2120. // var req *http.Request
  2121. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2122. // resp, _ := client.Do(req)
  2123. // defer resp.Body.Close()
  2124. // body, ioErr := ioutil.ReadAll(resp.Body)
  2125. // if ioErr != nil {
  2126. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2127. // }
  2128. // var respJSON map[string]interface{}
  2129. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2130. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2132. // return
  2133. // }
  2134. // var resSix10265 ResultSix10265 //1101结果
  2135. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2136. // result, _ := json.Marshal(respJSON)
  2137. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2138. // utils.ErrorLog("解析失败:%v", err)
  2139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2140. // return
  2141. // }
  2142. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2143. // res2.Output = resSix10265.Output
  2144. // res2.ErrMsg = resSix10265.ErrMsg
  2145. // res2.Cainfo = resSix10265.Cainfo
  2146. // res2.WarnMsg = resSix10265.WarnMsg
  2147. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2148. // res2.Infcode = infocode
  2149. //
  2150. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2151. // data := make(map[string]interface{})
  2152. // data["struct_3501s"] = struct3501
  2153. // client := &http.Client{}
  2154. // bytesData, _ := json.Marshal(data)
  2155. // var req *http.Request
  2156. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2157. // resp, _ := client.Do(req)
  2158. // defer resp.Body.Close()
  2159. // body, ioErr := ioutil.ReadAll(resp.Body)
  2160. // if ioErr != nil {
  2161. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2162. // }
  2163. // var respJSON map[string]interface{}
  2164. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2165. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2167. // return
  2168. // }
  2169. // var resSix10265 ResultSix10265 //1101结果
  2170. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2171. // result, _ := json.Marshal(respJSON)
  2172. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2173. // utils.ErrorLog("解析失败:%v", err)
  2174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2175. // return
  2176. // }
  2177. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2178. // res2.Output = resSix10265.Output
  2179. // res2.ErrMsg = resSix10265.ErrMsg
  2180. // res2.Cainfo = resSix10265.Cainfo
  2181. // res2.WarnMsg = resSix10265.WarnMsg
  2182. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2183. // res2.Infcode = infocode
  2184. //
  2185. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2186. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2187. // saveLog(result1, result2, "3501", "3501")
  2188. // //saveLog(result, requestLog, "2201", "挂号")
  2189. //
  2190. // var respJSON2 map[string]interface{}
  2191. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2192. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2194. // return
  2195. // }
  2196. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2197. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2198. // utils.ErrorLog("解析失败:%v", err)
  2199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2200. // return
  2201. // }
  2202. //
  2203. // }
  2204. //
  2205. // if res2.Infcode != -1 {
  2206. // drug.IsPc = 1
  2207. // drug.Bchno = number
  2208. // drug.PcDate = time.Now().Unix()
  2209. // err := service.SaveW(drug)
  2210. // if err == nil {
  2211. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2212. // var struct3502 models.Struct3502
  2213. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2214. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2215. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2216. // struct3502.FixmedinsCode = miConfig.Code
  2217. // struct3502.Code = miConfig.Code
  2218. //
  2219. // struct3502.RxFlag = "0"
  2220. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2221. // struct3502.OrgName = miConfig.OrgName
  2222. // struct3502.Opter = roles.UserName
  2223. // struct3502.AccessKey = miConfig.AccessKey
  2224. // struct3502.RequestUrl = miConfig.Url
  2225. // struct3502.SecretKey = miConfig.SecretKey
  2226. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2227. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2228. // struct3502.Url = miConfig.Url
  2229. // struct3502.AppId = miConfig.Cainfo
  2230. // struct3502.AppSecret = miConfig.AppSecret
  2231. // struct3502.Enckey = miConfig.EncKey
  2232. // struct3502.SignKey = miConfig.SignKey
  2233. // struct3502.SecretKey = miConfig.SecretKey
  2234. // struct3502.DrugTracCodg = drug.DrugCode
  2235. //
  2236. // struct3502.Memo = ""
  2237. // struct3502.InvChgType = "108"
  2238. // struct3502.FixmedinsBchno = bg_number
  2239. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2240. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2241. //
  2242. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2243. // result11, result22, _ := service.FJyb3502(struct3502)
  2244. // saveLog(result11, result22, "3502", "3502")
  2245. //
  2246. // var respJSON3 map[string]interface{}
  2247. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2248. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2250. // return
  2251. // }
  2252. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2253. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2254. // utils.ErrorLog("解析失败:%v", err)
  2255. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2256. // return
  2257. // }
  2258. //
  2259. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2260. // data := make(map[string]interface{})
  2261. // data["struct_3502s"] = struct3502
  2262. // client := &http.Client{}
  2263. // bytesData, _ := json.Marshal(data)
  2264. // var req *http.Request
  2265. // if miConfig.MdtrtareaAdmvs == "320921" {
  2266. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2267. // } else {
  2268. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2269. // }
  2270. //
  2271. // resp, _ := client.Do(req)
  2272. // defer resp.Body.Close()
  2273. // body, ioErr := ioutil.ReadAll(resp.Body)
  2274. // if ioErr != nil {
  2275. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2276. // }
  2277. // var respJSON map[string]interface{}
  2278. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2279. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2281. // return
  2282. // }
  2283. // var resSix10265 ResultSix10265 //1101结果
  2284. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2285. // result, _ := json.Marshal(respJSON)
  2286. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2287. // utils.ErrorLog("解析失败:%v", err)
  2288. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2289. // return
  2290. // }
  2291. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2292. // res3.Output = resSix10265.Output
  2293. // res3.ErrMsg = resSix10265.ErrMsg
  2294. // res3.Cainfo = resSix10265.Cainfo
  2295. // res3.WarnMsg = resSix10265.WarnMsg
  2296. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2297. // res3.Infcode = infocode
  2298. //
  2299. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2300. //
  2301. // data := make(map[string]interface{})
  2302. // data["struct_3502s"] = struct3502
  2303. // client := &http.Client{}
  2304. // bytesData, _ := json.Marshal(data)
  2305. // var req *http.Request
  2306. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2307. // resp, _ := client.Do(req)
  2308. // defer resp.Body.Close()
  2309. // body, ioErr := ioutil.ReadAll(resp.Body)
  2310. // if ioErr != nil {
  2311. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2312. // }
  2313. // var respJSON map[string]interface{}
  2314. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2315. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2316. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2317. // return
  2318. // }
  2319. // var resSix10265 ResultSix10265 //1101结果
  2320. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2321. // result, _ := json.Marshal(respJSON)
  2322. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2323. // utils.ErrorLog("解析失败:%v", err)
  2324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2325. // return
  2326. // }
  2327. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2328. // res3.Output = resSix10265.Output
  2329. // res3.ErrMsg = resSix10265.ErrMsg
  2330. // res3.Cainfo = resSix10265.Cainfo
  2331. // res3.WarnMsg = resSix10265.WarnMsg
  2332. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2333. // res3.Infcode = infocode
  2334. //
  2335. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2336. //
  2337. // data := make(map[string]interface{})
  2338. // data["struct_3501s"] = struct3501
  2339. // client := &http.Client{}
  2340. // bytesData, _ := json.Marshal(data)
  2341. // var req *http.Request
  2342. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2343. // resp, _ := client.Do(req)
  2344. // defer resp.Body.Close()
  2345. // body, ioErr := ioutil.ReadAll(resp.Body)
  2346. // if ioErr != nil {
  2347. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2348. // }
  2349. // var respJSON map[string]interface{}
  2350. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2351. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2353. // return
  2354. // }
  2355. // var resSix10265 ResultSix10265 //1101结果
  2356. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2357. // result, _ := json.Marshal(respJSON)
  2358. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2359. // utils.ErrorLog("解析失败:%v", err)
  2360. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2361. // return
  2362. // }
  2363. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2364. // res2.Output = resSix10265.Output
  2365. // res2.ErrMsg = resSix10265.ErrMsg
  2366. // res2.Cainfo = resSix10265.Cainfo
  2367. // res2.WarnMsg = resSix10265.WarnMsg
  2368. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2369. // res2.Infcode = infocode
  2370. //
  2371. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2372. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2373. // saveLog(result11, result22, "3502", "3502")
  2374. //
  2375. // var respJSON3 map[string]interface{}
  2376. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2377. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2379. // return
  2380. // }
  2381. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2382. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2383. // utils.ErrorLog("解析失败:%v", err)
  2384. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2385. // return
  2386. // }
  2387. // }
  2388. // if res3.Infcode == -1 {
  2389. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2390. // c.ServeSuccessJSON(map[string]interface{}{
  2391. // "failed_code": -10,
  2392. // "msg": res3.ErrMsg,
  2393. // })
  2394. // } else {
  2395. // drug.IsBg = 1
  2396. // drug.BgBchno = bg_number
  2397. // service.SaveW(drug)
  2398. // }
  2399. // }
  2400. // } else {
  2401. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2402. // }
  2403. // }
  2404. // //变更
  2405. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2406. // var res3 ResultSix
  2407. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2408. //
  2409. // var struct3502 models.Struct3502
  2410. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2411. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2412. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2413. // struct3502.FixmedinsCode = miConfig.Code
  2414. // struct3502.Code = miConfig.Code
  2415. //
  2416. // struct3502.Opter = roles.UserName
  2417. // struct3502.RxFlag = "0"
  2418. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2419. // struct3502.OrgName = miConfig.OrgName
  2420. // struct3502.AccessKey = miConfig.AccessKey
  2421. // struct3502.RequestUrl = miConfig.Url
  2422. // struct3502.SecretKey = miConfig.SecretKey
  2423. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2424. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2425. // struct3502.InvChgType = "108"
  2426. // struct3502.DrugTracCodg = drug.DrugCode
  2427. //
  2428. // struct3502.Url = miConfig.Url
  2429. // struct3502.AppId = miConfig.Cainfo
  2430. // struct3502.AppSecret = miConfig.AppSecret
  2431. // struct3502.Enckey = miConfig.EncKey
  2432. // struct3502.SignKey = miConfig.SignKey
  2433. // struct3502.SecretKey = miConfig.SecretKey
  2434. //
  2435. // struct3502.FixmedinsBchno = bg_number
  2436. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2437. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2438. //
  2439. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2440. // result1, result2, _ := service.FJyb3502(struct3502)
  2441. // saveLog(result1, result2, "3502", "3502")
  2442. // var respJSON3 map[string]interface{}
  2443. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2444. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2446. // return
  2447. // }
  2448. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2449. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2450. // utils.ErrorLog("解析失败:%v", err)
  2451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2452. // return
  2453. // }
  2454. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2455. // data := make(map[string]interface{})
  2456. // data["struct_3502s"] = struct3502
  2457. // client := &http.Client{}
  2458. // bytesData, _ := json.Marshal(data)
  2459. // var req *http.Request
  2460. // if miConfig.MdtrtareaAdmvs == "320921" {
  2461. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2462. // } else {
  2463. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2464. // }
  2465. // resp, _ := client.Do(req)
  2466. // defer resp.Body.Close()
  2467. // body, ioErr := ioutil.ReadAll(resp.Body)
  2468. // if ioErr != nil {
  2469. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2470. // }
  2471. // var respJSON map[string]interface{}
  2472. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2473. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2475. // return
  2476. // }
  2477. // var resSix10265 ResultSix10265 //1101结果
  2478. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2479. // result, _ := json.Marshal(respJSON)
  2480. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2481. // utils.ErrorLog("解析失败:%v", err)
  2482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2483. // return
  2484. // }
  2485. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2486. // res3.Output = resSix10265.Output
  2487. // res3.ErrMsg = resSix10265.ErrMsg
  2488. // res3.Cainfo = resSix10265.Cainfo
  2489. // res3.WarnMsg = resSix10265.WarnMsg
  2490. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2491. // res3.Infcode = infocode
  2492. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2493. //
  2494. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2495. //
  2496. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2497. //
  2498. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2499. //
  2500. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2501. // saveLog(result1, result2, "3501", "3501")
  2502. // //saveLog(result, requestLog, "2201", "挂号")
  2503. //
  2504. // var respJSON2 map[string]interface{}
  2505. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2506. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2508. // return
  2509. // }
  2510. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2511. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2512. // utils.ErrorLog("解析失败:%v", err)
  2513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2514. // return
  2515. // }
  2516. //
  2517. // }
  2518. // if res3.Infcode == -1 {
  2519. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2520. // } else {
  2521. // drug.IsBg = 1
  2522. // drug.BgBchno = bg_number
  2523. // service.SaveW(drug)
  2524. // }
  2525. // }
  2526. // }
  2527. //
  2528. // if len(errs) == 0 {
  2529. // c.ServeSuccessJSON(map[string]interface{}{
  2530. // "msg": "盘存变更成功",
  2531. // })
  2532. // } else {
  2533. // c.ServeSuccessJSON(map[string]interface{}{
  2534. // "failed_code": -10,
  2535. // "msg": errs,
  2536. // })
  2537. // }
  2538. //}
  2539. func (c *HisApiController) DeleteXSandBGTwo() {
  2540. patient_id, _ := c.GetInt64("patient_id")
  2541. admin_user_id, _ := c.GetInt64("admin_user_id")
  2542. times := c.GetString("time", "")
  2543. timeLayout := "2006-01-02"
  2544. loc, _ := time.LoadLocation("Local")
  2545. var stime, etime int64
  2546. if times == "" {
  2547. stime, etime = GetNowTime()
  2548. } else {
  2549. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2550. stime = stmp.Unix()
  2551. etime = stime + 86399
  2552. }
  2553. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2554. var flows []*models.DrugFlow
  2555. for _, item := range advicelist {
  2556. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2557. flows = append(flows, flow...)
  2558. }
  2559. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2560. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2561. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2562. var err []string
  2563. for _, item := range flows {
  2564. if item.IsSale == 1 {
  2565. var res FJ3507Result
  2566. var struct3507 models.Struct3507
  2567. struct3507.FixmedinsBchno = item.Bchno
  2568. struct3507.InvDataType = "4"
  2569. struct3507.Opter = roles.UserName
  2570. struct3507.OrgName = miConfig.OrgName
  2571. struct3507.AccessKey = miConfig.AccessKey
  2572. struct3507.RequestUrl = miConfig.Url
  2573. struct3507.FixmedinsCode = miConfig.Code
  2574. struct3507.SecretKey = miConfig.SecretKey
  2575. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2576. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2577. struct3507.Url = miConfig.Url
  2578. struct3507.AppId = miConfig.Cainfo
  2579. struct3507.AppSecret = miConfig.AppSecret
  2580. struct3507.Enckey = miConfig.EncKey
  2581. struct3507.SignKey = miConfig.SignKey
  2582. struct3507.SecretKey = miConfig.SecretKey
  2583. if miConfig.MdtrtareaAdmvs == "350500" {
  2584. result, result1, _ := service.FJyb3507(struct3507)
  2585. saveLog(result, result1, "3507", "3507")
  2586. var respJSON2 map[string]interface{}
  2587. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2590. return
  2591. }
  2592. userJSONBytes2, _ := json.Marshal(respJSON2)
  2593. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2594. utils.ErrorLog("解析失败:%v", err)
  2595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2596. return
  2597. }
  2598. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2599. data := make(map[string]interface{})
  2600. data["struct_3507s"] = struct3507
  2601. client := &http.Client{}
  2602. bytesData, _ := json.Marshal(data)
  2603. var req *http.Request
  2604. if miConfig.MdtrtareaAdmvs == "320921" {
  2605. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2606. } else {
  2607. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2608. }
  2609. resp, _ := client.Do(req)
  2610. defer resp.Body.Close()
  2611. body, ioErr := ioutil.ReadAll(resp.Body)
  2612. if ioErr != nil {
  2613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2614. }
  2615. var respJSON map[string]interface{}
  2616. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2619. return
  2620. }
  2621. var resSix10265 ResultSix10265 //1101结果
  2622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2623. result, _ := json.Marshal(respJSON)
  2624. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2625. utils.ErrorLog("解析失败:%v", err)
  2626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2627. return
  2628. }
  2629. res.InfRefmsgid = resSix10265.InfRefmsgid
  2630. //res.Output = resSix10265.Output
  2631. res.ErrMsg = resSix10265.ErrMsg
  2632. res.Cainfo = resSix10265.Cainfo
  2633. res.WarnMsg = resSix10265.WarnMsg
  2634. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2635. res.Infcode = infocode
  2636. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2637. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2638. saveLog(result2, result1, "3507", "3507")
  2639. var respJSON2 map[string]interface{}
  2640. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2643. return
  2644. }
  2645. userJSONBytes2, _ := json.Marshal(respJSON2)
  2646. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2647. utils.ErrorLog("解析失败:%v", err)
  2648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2649. return
  2650. }
  2651. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2652. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2653. saveLog(result2, result1, "3507", "3507")
  2654. var respJSON2 map[string]interface{}
  2655. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2658. return
  2659. }
  2660. userJSONBytes2, _ := json.Marshal(respJSON2)
  2661. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2662. utils.ErrorLog("解析失败:%v", err)
  2663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2664. return
  2665. }
  2666. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2667. result1, result2 := service.Jxyb3507(struct3507)
  2668. saveLog(result2, result1, "3507", "3507")
  2669. var respJSON2 map[string]interface{}
  2670. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2673. return
  2674. }
  2675. userJSONBytes2, _ := json.Marshal(respJSON2)
  2676. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2677. utils.ErrorLog("解析失败:%v", err)
  2678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2679. return
  2680. }
  2681. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2682. result1, result2 := service.AHyb3507(struct3507)
  2683. saveLog(result2, result1, "3507", "3507")
  2684. var respJSON2 map[string]interface{}
  2685. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2688. return
  2689. }
  2690. userJSONBytes2, _ := json.Marshal(respJSON2)
  2691. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2692. utils.ErrorLog("解析失败:%v", err)
  2693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2694. return
  2695. }
  2696. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2697. data := make(map[string]interface{})
  2698. data["struct_3507s"] = struct3507
  2699. client := &http.Client{}
  2700. bytesData, _ := json.Marshal(data)
  2701. var req *http.Request
  2702. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2703. resp, _ := client.Do(req)
  2704. defer resp.Body.Close()
  2705. body, ioErr := ioutil.ReadAll(resp.Body)
  2706. if ioErr != nil {
  2707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2708. }
  2709. var respJSON map[string]interface{}
  2710. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2712. }
  2713. var resSix10265 ResultSix10265 //1101结果
  2714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2715. result, _ := json.Marshal(respJSON)
  2716. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2717. utils.ErrorLog("解析失败:%v", err)
  2718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2719. return
  2720. }
  2721. res.InfRefmsgid = resSix10265.InfRefmsgid
  2722. res.ErrMsg = resSix10265.ErrMsg
  2723. res.Cainfo = resSix10265.Cainfo
  2724. res.WarnMsg = resSix10265.WarnMsg
  2725. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2726. res.Infcode = infocode
  2727. }
  2728. if res.Infcode == 0 {
  2729. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2730. item.IsSale = 0
  2731. item.SaleDate = ""
  2732. item.Bchno = ""
  2733. service.SaveDF(item)
  2734. } else {
  2735. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2736. }
  2737. }
  2738. }
  2739. c.ServeSuccessJSON(map[string]interface{}{
  2740. "msg": "删除销售数据成功",
  2741. })
  2742. }
  2743. // 删除
  2744. func (c *HisApiController) DeleteXSandBGThree() {
  2745. id, _ := c.GetInt64("id")
  2746. admin_user_id, _ := c.GetInt64("admin_user_id")
  2747. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2748. var flows []*models.DrugFlow
  2749. for _, item := range advicelist {
  2750. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2751. flows = append(flows, flow...)
  2752. }
  2753. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2754. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2755. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2756. var err []string
  2757. for _, item := range flows {
  2758. if item.IsSale == 1 {
  2759. var res FJ3507Result
  2760. var struct3507 models.Struct3507
  2761. struct3507.FixmedinsBchno = item.Bchno
  2762. struct3507.InvDataType = "4"
  2763. struct3507.Opter = roles.UserName
  2764. struct3507.OrgName = miConfig.OrgName
  2765. struct3507.AccessKey = miConfig.AccessKey
  2766. struct3507.RequestUrl = miConfig.Url
  2767. struct3507.FixmedinsCode = miConfig.Code
  2768. struct3507.SecretKey = miConfig.SecretKey
  2769. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2770. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2771. struct3507.Url = miConfig.Url
  2772. struct3507.AppId = miConfig.Cainfo
  2773. struct3507.AppSecret = miConfig.AppSecret
  2774. struct3507.Enckey = miConfig.EncKey
  2775. struct3507.SignKey = miConfig.SignKey
  2776. struct3507.SecretKey = miConfig.SecretKey
  2777. if miConfig.MdtrtareaAdmvs == "350500" {
  2778. result, result1, _ := service.FJyb3507(struct3507)
  2779. saveLog(result, result1, "3507", "3507")
  2780. var respJSON2 map[string]interface{}
  2781. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2784. return
  2785. }
  2786. userJSONBytes2, _ := json.Marshal(respJSON2)
  2787. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2788. utils.ErrorLog("解析失败:%v", err)
  2789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2790. return
  2791. }
  2792. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2793. data := make(map[string]interface{})
  2794. data["struct_3507s"] = struct3507
  2795. client := &http.Client{}
  2796. bytesData, _ := json.Marshal(data)
  2797. var req *http.Request
  2798. if miConfig.MdtrtareaAdmvs == "320921" {
  2799. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2800. } else {
  2801. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2802. }
  2803. resp, _ := client.Do(req)
  2804. defer resp.Body.Close()
  2805. body, ioErr := ioutil.ReadAll(resp.Body)
  2806. if ioErr != nil {
  2807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2808. }
  2809. var respJSON map[string]interface{}
  2810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2813. return
  2814. }
  2815. var resSix10265 ResultSix10265 //1101结果
  2816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2817. result, _ := json.Marshal(respJSON)
  2818. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2819. utils.ErrorLog("解析失败:%v", err)
  2820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2821. return
  2822. }
  2823. res.InfRefmsgid = resSix10265.InfRefmsgid
  2824. //res.Output = resSix10265.Output
  2825. res.ErrMsg = resSix10265.ErrMsg
  2826. res.Cainfo = resSix10265.Cainfo
  2827. res.WarnMsg = resSix10265.WarnMsg
  2828. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2829. res.Infcode = infocode
  2830. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2831. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2832. saveLog(result2, result1, "3507", "3507")
  2833. var respJSON2 map[string]interface{}
  2834. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2837. return
  2838. }
  2839. userJSONBytes2, _ := json.Marshal(respJSON2)
  2840. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2841. utils.ErrorLog("解析失败:%v", err)
  2842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2843. return
  2844. }
  2845. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2846. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2847. saveLog(result2, result1, "3507", "3507")
  2848. var respJSON2 map[string]interface{}
  2849. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2852. return
  2853. }
  2854. userJSONBytes2, _ := json.Marshal(respJSON2)
  2855. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2856. utils.ErrorLog("解析失败:%v", err)
  2857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2858. return
  2859. }
  2860. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2861. result1, result2 := service.Jxyb3507(struct3507)
  2862. saveLog(result2, result1, "3507", "3507")
  2863. var respJSON2 map[string]interface{}
  2864. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2867. return
  2868. }
  2869. userJSONBytes2, _ := json.Marshal(respJSON2)
  2870. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2871. utils.ErrorLog("解析失败:%v", err)
  2872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2873. return
  2874. }
  2875. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2876. result1, result2 := service.AHyb3507(struct3507)
  2877. saveLog(result2, result1, "3507", "3507")
  2878. var respJSON2 map[string]interface{}
  2879. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2882. return
  2883. }
  2884. userJSONBytes2, _ := json.Marshal(respJSON2)
  2885. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2886. utils.ErrorLog("解析失败:%v", err)
  2887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2888. return
  2889. }
  2890. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2891. data := make(map[string]interface{})
  2892. data["struct_3507s"] = struct3507
  2893. client := &http.Client{}
  2894. bytesData, _ := json.Marshal(data)
  2895. var req *http.Request
  2896. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2897. resp, _ := client.Do(req)
  2898. defer resp.Body.Close()
  2899. body, ioErr := ioutil.ReadAll(resp.Body)
  2900. if ioErr != nil {
  2901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2902. }
  2903. var respJSON map[string]interface{}
  2904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2906. }
  2907. var resSix10265 ResultSix10265 //1101结果
  2908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2909. result, _ := json.Marshal(respJSON)
  2910. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2911. utils.ErrorLog("解析失败:%v", err)
  2912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2913. return
  2914. }
  2915. res.InfRefmsgid = resSix10265.InfRefmsgid
  2916. res.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. }
  2922. if res.Infcode == 0 {
  2923. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2924. item.IsSale = 0
  2925. item.SaleDate = ""
  2926. item.Bchno = ""
  2927. service.SaveDF(item)
  2928. } else {
  2929. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2930. }
  2931. }
  2932. }
  2933. c.ServeSuccessJSON(map[string]interface{}{
  2934. "msg": "删除销售数据成功",
  2935. })
  2936. }
  2937. // 获取当天起止时间戳
  2938. func GetNowTime() (int64, int64) {
  2939. t := time.Now()
  2940. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2941. timesamp := addTime.Unix()
  2942. return timesamp, timesamp + 86399
  2943. }
  2944. func (c *HisApiController) ChangeDrugfour() {
  2945. patient_id, _ := c.GetInt64("patient_id")
  2946. admin_user_id, _ := c.GetInt64("admin_user_id")
  2947. times := c.GetString("time", "")
  2948. timeLayout := "2006-01-02"
  2949. loc, _ := time.LoadLocation("Local")
  2950. var stime, etime int64
  2951. if times == "" {
  2952. stime, etime = GetNowTime()
  2953. } else {
  2954. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2955. stime = stmp.Unix()
  2956. etime = stime + 86399
  2957. }
  2958. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2959. var flows []*models.DrugFlow
  2960. for _, item := range advicelist {
  2961. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2962. flows = append(flows, flow...)
  2963. }
  2964. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2965. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2966. var err []string
  2967. for _, item := range flows {
  2968. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2969. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2970. if prescription.OrderStatus == 2 {
  2971. if item.IsSale == 0 {
  2972. var res FJ3507Result
  2973. var res3507for10188 FJ3507ResultFor10188
  2974. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2975. //进行商品销售接口
  2976. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2977. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2978. var respJSON3 map[string]interface{}
  2979. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2982. return
  2983. }
  2984. userJSONBytes3, _ := json.Marshal(respJSON3)
  2985. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2986. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2987. utils.ErrorLog("解析失败:%v", err)
  2988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2989. return
  2990. }
  2991. //if res3507for10188.Infcode
  2992. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2993. //res.Output = resSix10265.Output
  2994. res.ErrMsg = res3507for10188.ErrMsg
  2995. res.Cainfo = res3507for10188.Cainfo
  2996. res.WarnMsg = res3507for10188.WarnMsg
  2997. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2998. res.Infcode = infocode
  2999. } else {
  3000. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3001. utils.ErrorLog("解析失败:%v", err)
  3002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3003. return
  3004. }
  3005. }
  3006. if res.Infcode == 0 {
  3007. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3008. item.IsSale = 1
  3009. item.Bchno = number
  3010. item.SaleDate = time.Now().Format("2006-01-02")
  3011. service.SaveDF(item)
  3012. } else {
  3013. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3014. }
  3015. }
  3016. } else { //还没结,提示用户去结算,并药品追溯上传
  3017. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3018. }
  3019. }
  3020. }
  3021. str := strings.Join(err, " ")
  3022. saveLog(str, str, "3505", "3505自动上传日志")
  3023. c.ServeSuccessJSON(map[string]interface{}{
  3024. "status": "1",
  3025. "msg": err,
  3026. })
  3027. }
  3028. func (c *HisApiController) ChangeDrugFive() {
  3029. id, _ := c.GetInt64("id")
  3030. admin_user_id, _ := c.GetInt64("admin_user_id")
  3031. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3032. var flows []*models.DrugFlow
  3033. for _, item := range advicelist {
  3034. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3035. flows = append(flows, flow...)
  3036. }
  3037. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3038. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3039. var err []string
  3040. for _, item := range flows {
  3041. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3042. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3043. if prescription.OrderStatus == 2 {
  3044. if item.IsSale == 0 {
  3045. var res FJ3507Result
  3046. var res3507for10188 FJ3507ResultFor10188
  3047. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3048. //进行商品销售接口
  3049. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3050. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3051. var respJSON3 map[string]interface{}
  3052. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3055. return
  3056. }
  3057. userJSONBytes3, _ := json.Marshal(respJSON3)
  3058. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3059. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3060. utils.ErrorLog("解析失败:%v", err)
  3061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3062. return
  3063. }
  3064. //if res3507for10188.Infcode
  3065. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3066. //res.Output = resSix10265.Output
  3067. res.ErrMsg = res3507for10188.ErrMsg
  3068. res.Cainfo = res3507for10188.Cainfo
  3069. res.WarnMsg = res3507for10188.WarnMsg
  3070. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3071. res.Infcode = infocode
  3072. } else {
  3073. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3074. utils.ErrorLog("解析失败:%v", err)
  3075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3076. return
  3077. }
  3078. }
  3079. if res.Infcode == 0 {
  3080. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3081. item.IsSale = 1
  3082. item.Bchno = number
  3083. item.SaleDate = time.Now().Format("2006-01-02")
  3084. service.SaveDF(item)
  3085. } else {
  3086. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3087. }
  3088. }
  3089. } else { //还没结,提示用户去结算,并药品追溯上传
  3090. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3091. }
  3092. }
  3093. }
  3094. str := strings.Join(err, " ")
  3095. saveLog(str, str, "3505", "3505自动上传日志")
  3096. c.ServeSuccessJSON(map[string]interface{}{
  3097. "status": "1",
  3098. "msg": err,
  3099. })
  3100. }
  3101. //func (c *HisApiController) ChangeDrugfour() {
  3102. // patient_id, _ := c.GetInt64("patient_id")
  3103. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3104. // //id_arr := strings.Split(ids, ",")
  3105. // times := c.GetString("time", "")
  3106. // timeLayout := "2006-01-02"
  3107. // loc, _ := time.LoadLocation("Local")
  3108. // var stime, etime int64
  3109. // if times == "" {
  3110. // stime, etime = GetNowTime()
  3111. // } else {
  3112. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3113. // stime = stmp.Unix()
  3114. // etime = stime + 86399
  3115. // }
  3116. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3117. // var flows []*models.DrugFlow
  3118. // for _, item := range advicelist {
  3119. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3120. // flows = append(flows, flow...)
  3121. // }
  3122. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3123. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3124. // var err []string
  3125. //
  3126. // for _, item := range flows {
  3127. // var res3 ResultSix
  3128. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3129. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3130. // if prescription.OrderStatus == 2 {
  3131. // //已经结算
  3132. // //判断是否已经销售
  3133. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3134. // //是否已经变更 1是 0否
  3135. // if item.IsChange == 0 { //没变更,进行变更操作
  3136. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3137. //
  3138. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3139. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3140. // var respJSON3 map[string]interface{}
  3141. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3142. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3144. // return
  3145. // }
  3146. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3147. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3148. // utils.ErrorLog("解析失败:%v", err)
  3149. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3150. // return
  3151. // }
  3152. // if res3.Infcode == 0 {
  3153. // item.IsChange = 1
  3154. // item.BgBchno = bg_number
  3155. // service.SaveDF2(item)
  3156. // } else {
  3157. //
  3158. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3159. // }
  3160. // }
  3161. // } else { //没销售,
  3162. // var res FJ3507Result
  3163. // var res3507for10188 FJ3507ResultFor10188
  3164. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3165. //
  3166. // //进行商品销售接口
  3167. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3168. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3169. // var respJSON3 map[string]interface{}
  3170. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3171. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3173. // return
  3174. // }
  3175. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3176. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3177. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3178. // utils.ErrorLog("解析失败:%v", err)
  3179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3180. // return
  3181. // }
  3182. // //if res3507for10188.Infcode
  3183. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3184. // //res.Output = resSix10265.Output
  3185. // res.ErrMsg = res3507for10188.ErrMsg
  3186. // res.Cainfo = res3507for10188.Cainfo
  3187. // res.WarnMsg = res3507for10188.WarnMsg
  3188. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3189. // res.Infcode = infocode
  3190. // } else {
  3191. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3192. // utils.ErrorLog("解析失败:%v", err)
  3193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3194. // return
  3195. // }
  3196. //
  3197. // }
  3198. // if res.Infcode == 0 {
  3199. // item.IsSale = 1
  3200. // item.Bchno = number
  3201. // item.SaleDate = time.Now().Format("2006-01-02")
  3202. //
  3203. // err5 := service.SaveDF(item)
  3204. // if err5 == nil {
  3205. // if item.IsChange == 0 { //没变更,进行变更操作
  3206. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3207. //
  3208. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3209. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3210. //
  3211. // var respJSON3 map[string]interface{}
  3212. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3213. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3215. // return
  3216. // }
  3217. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3218. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3219. // utils.ErrorLog("解析失败:%v", err)
  3220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3221. // return
  3222. // }
  3223. // //if res3507for10188.Infcode
  3224. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3225. // //res.Output = resSix10265.Output
  3226. // res3.ErrMsg = res3507for10188.ErrMsg
  3227. // res3.Cainfo = res3507for10188.Cainfo
  3228. // res3.WarnMsg = res3507for10188.WarnMsg
  3229. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3230. // res3.Infcode = infocode
  3231. // } else {
  3232. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3233. // utils.ErrorLog("解析失败:%v", err)
  3234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3235. // return
  3236. // }
  3237. // }
  3238. // if res3.Infcode == 0 {
  3239. // item.IsChange = 1
  3240. // item.BgBchno = bg_number
  3241. // service.SaveDF2(item)
  3242. // } else {
  3243. //
  3244. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3245. // }
  3246. // }
  3247. // }
  3248. // } else {
  3249. //
  3250. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3251. // }
  3252. // }
  3253. //
  3254. // } else { //还没结,提示用户去结算,并药品追溯上传
  3255. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3256. // }
  3257. // }
  3258. // }
  3259. // if len(err) == 0 {
  3260. // c.ServeSuccessJSON(map[string]interface{}{
  3261. // "msg": "销售变更成功",
  3262. // })
  3263. // } else {
  3264. // c.ServeSuccessJSON(map[string]interface{}{
  3265. // "failed_code": -10,
  3266. // "msg": err,
  3267. // })
  3268. // }
  3269. //}
  3270. func (c *HisApiController) ChangeDrug() {
  3271. ids := c.GetString("ids")
  3272. id_arr := strings.Split(ids, ",")
  3273. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3274. admin_user_id, _ := c.GetInt64("admin_user_id")
  3275. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3276. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3277. var err []string
  3278. for _, item := range flows {
  3279. var res3 ResultSix
  3280. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3281. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3282. if prescription.OrderStatus == 2 {
  3283. //已经结算
  3284. //判断是否已经销售
  3285. if item.IsSale == 1 { //是否已经销售,1是 0否
  3286. //是否已经变更 1是 0否
  3287. if item.IsChange == 0 { //没变更,进行变更操作
  3288. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3289. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3290. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3291. var respJSON3 map[string]interface{}
  3292. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3295. return
  3296. }
  3297. userJSONBytes3, _ := json.Marshal(respJSON3)
  3298. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3299. utils.ErrorLog("解析失败:%v", err)
  3300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3301. return
  3302. }
  3303. if res3.Infcode == 0 {
  3304. item.IsChange = 1
  3305. item.BgBchno = bg_number
  3306. service.SaveDF2(item)
  3307. } else {
  3308. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3309. }
  3310. }
  3311. } else { //没销售,
  3312. var res FJ3507Result
  3313. var res3507for10188 FJ3507ResultFor10188
  3314. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3315. //进行商品销售接口
  3316. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3317. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3318. var respJSON3 map[string]interface{}
  3319. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3322. return
  3323. }
  3324. userJSONBytes3, _ := json.Marshal(respJSON3)
  3325. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3326. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3327. utils.ErrorLog("解析失败:%v", err)
  3328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3329. return
  3330. }
  3331. //if res3507for10188.Infcode
  3332. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3333. //res.Output = resSix10265.Output
  3334. res.ErrMsg = res3507for10188.ErrMsg
  3335. res.Cainfo = res3507for10188.Cainfo
  3336. res.WarnMsg = res3507for10188.WarnMsg
  3337. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3338. res.Infcode = infocode
  3339. } else {
  3340. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3341. utils.ErrorLog("解析失败:%v", err)
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3343. return
  3344. }
  3345. }
  3346. if res.Infcode == 0 {
  3347. item.IsSale = 1
  3348. item.Bchno = number
  3349. item.SaleDate = time.Now().Format("2006-01-02")
  3350. err5 := service.SaveDF(item)
  3351. if err5 == nil {
  3352. if item.IsChange == 0 { //没变更,进行变更操作
  3353. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3354. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3355. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3356. var respJSON3 map[string]interface{}
  3357. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3360. return
  3361. }
  3362. userJSONBytes3, _ := json.Marshal(respJSON3)
  3363. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3364. utils.ErrorLog("解析失败:%v", err)
  3365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3366. return
  3367. }
  3368. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3369. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3370. utils.ErrorLog("解析失败:%v", err)
  3371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3372. return
  3373. }
  3374. //if res3507for10188.Infcode
  3375. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3376. //res.Output = resSix10265.Output
  3377. res3.ErrMsg = res3507for10188.ErrMsg
  3378. res3.Cainfo = res3507for10188.Cainfo
  3379. res3.WarnMsg = res3507for10188.WarnMsg
  3380. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3381. res3.Infcode = infocode
  3382. } else {
  3383. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3384. utils.ErrorLog("解析失败:%v", err)
  3385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3386. return
  3387. }
  3388. }
  3389. if res3.Infcode == 0 {
  3390. item.IsChange = 1
  3391. item.BgBchno = bg_number
  3392. service.SaveDF2(item)
  3393. } else {
  3394. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3395. }
  3396. }
  3397. }
  3398. } else {
  3399. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3400. }
  3401. }
  3402. } else { //还没结算
  3403. var res3507for10188 FJ3507ResultFor10188
  3404. if item.IsChange == 0 { //没变更,进行变更操作
  3405. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3406. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3407. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3408. var respJSON3 map[string]interface{}
  3409. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3412. return
  3413. }
  3414. userJSONBytes3, _ := json.Marshal(respJSON3)
  3415. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3416. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3417. utils.ErrorLog("解析失败:%v", err)
  3418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3419. return
  3420. }
  3421. //if res3507for10188.Infcode
  3422. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3423. //res.Output = resSix10265.Output
  3424. res3.ErrMsg = res3507for10188.ErrMsg
  3425. res3.Cainfo = res3507for10188.Cainfo
  3426. res3.WarnMsg = res3507for10188.WarnMsg
  3427. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3428. res3.Infcode = infocode
  3429. } else {
  3430. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3431. utils.ErrorLog("解析失败:%v", err)
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3433. return
  3434. }
  3435. }
  3436. if res3.Infcode == 0 {
  3437. item.IsChange = 1
  3438. item.BgBchno = bg_number
  3439. service.SaveDF2(item)
  3440. } else {
  3441. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3442. }
  3443. }
  3444. }
  3445. } else if item.ConsumableType == 7 {
  3446. var res3507for10188 FJ3507ResultFor10188
  3447. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3448. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3449. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3450. //判断是否已经销售
  3451. if item.IsSale == 2 { //是否已经销售,1是 0否
  3452. //是否已经变更 1是 0否
  3453. if item.IsChange == 0 { //没变更,进行变更操作
  3454. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3455. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3456. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3457. var respJSON3 map[string]interface{}
  3458. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3461. return
  3462. }
  3463. userJSONBytes3, _ := json.Marshal(respJSON3)
  3464. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3465. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3466. utils.ErrorLog("解析失败:%v", err)
  3467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3468. return
  3469. }
  3470. //if res3507for10188.Infcode
  3471. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3472. //res.Output = resSix10265.Output
  3473. res3.ErrMsg = res3507for10188.ErrMsg
  3474. res3.Cainfo = res3507for10188.Cainfo
  3475. res3.WarnMsg = res3507for10188.WarnMsg
  3476. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3477. res3.Infcode = infocode
  3478. } else {
  3479. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3480. utils.ErrorLog("解析失败:%v", err)
  3481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3482. return
  3483. }
  3484. }
  3485. if res3.Infcode == 0 {
  3486. item.IsChange = 1
  3487. item.BgBchno = bg_number
  3488. service.SaveDF2(item)
  3489. } else {
  3490. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3491. }
  3492. }
  3493. } else { //没销售,
  3494. //进行商品销售退货接口
  3495. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3496. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3497. saveLog(result111, result222, "3506", "销售退货")
  3498. var res7 FJ3507Result
  3499. //进行商品销售接口
  3500. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3501. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3502. var respJSON3 map[string]interface{}
  3503. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3506. return
  3507. }
  3508. userJSONBytes3, _ := json.Marshal(respJSON3)
  3509. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3510. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3511. utils.ErrorLog("解析失败:%v", err)
  3512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3513. return
  3514. }
  3515. //if res3507for10188.Infcode
  3516. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3517. //res.Output = resSix10265.Output
  3518. res7.ErrMsg = res3507for10188.ErrMsg
  3519. res7.Cainfo = res3507for10188.Cainfo
  3520. res7.WarnMsg = res3507for10188.WarnMsg
  3521. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3522. res7.Infcode = infocode
  3523. } else {
  3524. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3525. utils.ErrorLog("解析失败:%v", err)
  3526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3527. return
  3528. }
  3529. }
  3530. if res7.Infcode == 0 {
  3531. item.IsSale = 2
  3532. item.SaleDate = item.SaleDate
  3533. item.Bchno = number
  3534. service.SaveDF(item)
  3535. if item.IsChange == 0 { //没变更,进行变更操作
  3536. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3537. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3538. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3539. var respJSON3 map[string]interface{}
  3540. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3543. return
  3544. }
  3545. userJSONBytes3, _ := json.Marshal(respJSON3)
  3546. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3547. // utils.ErrorLog("解析失败:%v", err)
  3548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3549. // return
  3550. //}
  3551. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3552. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3553. utils.ErrorLog("解析失败:%v", err)
  3554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3555. return
  3556. }
  3557. //if res3507for10188.Infcode
  3558. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3559. //res.Output = resSix10265.Output
  3560. res3.ErrMsg = res3507for10188.ErrMsg
  3561. res3.Cainfo = res3507for10188.Cainfo
  3562. res3.WarnMsg = res3507for10188.WarnMsg
  3563. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3564. res3.Infcode = infocode
  3565. } else {
  3566. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3567. utils.ErrorLog("解析失败:%v", err)
  3568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3569. return
  3570. }
  3571. }
  3572. if res3.Infcode == 0 {
  3573. item.IsChange = 1
  3574. item.BgBchno = bg_number
  3575. service.SaveDF2(item)
  3576. } else {
  3577. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3578. }
  3579. }
  3580. } else {
  3581. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3582. }
  3583. }
  3584. } else { //还没结算
  3585. if item.IsChange == 0 { //没变更,进行变更操作
  3586. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3587. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3588. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3589. var respJSON3 map[string]interface{}
  3590. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3593. return
  3594. }
  3595. userJSONBytes3, _ := json.Marshal(respJSON3)
  3596. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3597. // utils.ErrorLog("解析失败:%v", err)
  3598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3599. // return
  3600. //}
  3601. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3602. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3603. utils.ErrorLog("解析失败:%v", err)
  3604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3605. return
  3606. }
  3607. //if res3507for10188.Infcode
  3608. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3609. //res.Output = resSix10265.Output
  3610. res3.ErrMsg = res3507for10188.ErrMsg
  3611. res3.Cainfo = res3507for10188.Cainfo
  3612. res3.WarnMsg = res3507for10188.WarnMsg
  3613. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3614. res3.Infcode = infocode
  3615. } else {
  3616. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3617. utils.ErrorLog("解析失败:%v", err)
  3618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3619. return
  3620. }
  3621. }
  3622. if res3.Infcode == 0 {
  3623. item.IsChange = 1
  3624. item.BgBchno = bg_number
  3625. service.SaveDF2(item)
  3626. } else {
  3627. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3628. }
  3629. }
  3630. }
  3631. }
  3632. }
  3633. if len(err) == 0 {
  3634. c.ServeSuccessJSON(map[string]interface{}{
  3635. "msg": "销售变更成功",
  3636. })
  3637. } else {
  3638. c.ServeSuccessJSON(map[string]interface{}{
  3639. "failed_code": -10,
  3640. "msg": err,
  3641. })
  3642. }
  3643. }
  3644. func (c *HisApiController) ChangeDrugtwo() {
  3645. //ids := c.GetString("ids")
  3646. //id_arr := strings.Split(ids, ",")
  3647. flows, _ := service.GetNewDrugFlowInfothree123()
  3648. admin_user_id, _ := c.GetInt64("admin_user_id")
  3649. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3650. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3651. var err []string
  3652. for _, item := range flows {
  3653. var res3 ResultSix
  3654. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3655. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3656. if prescription.OrderStatus == 2 {
  3657. //已经结算
  3658. //判断是否已经销售
  3659. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3660. // //是否已经变更 1是 0否
  3661. // if item.IsChange == 0 { //没变更,进行变更操作
  3662. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3663. //
  3664. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3665. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3666. // var respJSON3 map[string]interface{}
  3667. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3668. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3670. // return
  3671. // }
  3672. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3673. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3674. // utils.ErrorLog("解析失败:%v", err)
  3675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3676. // return
  3677. // }
  3678. // if res3.Infcode == 0 {
  3679. // item.IsChange = 1
  3680. // item.BgBchno = bg_number
  3681. // service.SaveDF2(item)
  3682. // } else {
  3683. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3684. // }
  3685. // }
  3686. //}
  3687. //else
  3688. { //没销售,
  3689. var res FJ3507Result
  3690. var res3507for10188 FJ3507ResultFor10188
  3691. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3692. //进行商品销售接口
  3693. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3694. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3695. var respJSON3 map[string]interface{}
  3696. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3699. return
  3700. }
  3701. userJSONBytes3, _ := json.Marshal(respJSON3)
  3702. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3703. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3704. utils.ErrorLog("解析失败:%v", err)
  3705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3706. return
  3707. }
  3708. //if res3507for10188.Infcode
  3709. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3710. //res.Output = resSix10265.Output
  3711. res.ErrMsg = res3507for10188.ErrMsg
  3712. res.Cainfo = res3507for10188.Cainfo
  3713. res.WarnMsg = res3507for10188.WarnMsg
  3714. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3715. res.Infcode = infocode
  3716. } else {
  3717. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3718. utils.ErrorLog("解析失败:%v", err)
  3719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3720. return
  3721. }
  3722. }
  3723. if res.Infcode == 0 {
  3724. item.IsSale = 1
  3725. item.Bchno = number
  3726. item.SaleDate = time.Now().Format("2006-01-02")
  3727. service.SaveDF(item)
  3728. //if err5 == nil {
  3729. // if item.IsChange == 0 { //没变更,进行变更操作
  3730. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3731. //
  3732. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3733. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3734. //
  3735. // var respJSON3 map[string]interface{}
  3736. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3737. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3738. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3739. // return
  3740. // }
  3741. //
  3742. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3743. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3744. // utils.ErrorLog("解析失败:%v", err)
  3745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3746. // return
  3747. // }
  3748. // //if res3507for10188.Infcode
  3749. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3750. // //res.Output = resSix10265.Output
  3751. // res3.ErrMsg = res3507for10188.ErrMsg
  3752. // res3.Cainfo = res3507for10188.Cainfo
  3753. // res3.WarnMsg = res3507for10188.WarnMsg
  3754. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3755. // res3.Infcode = infocode
  3756. // } else {
  3757. //
  3758. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3759. // utils.ErrorLog("解析失败:%v", err)
  3760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3761. // return
  3762. // }
  3763. //
  3764. // }
  3765. //
  3766. // if res3.Infcode == 0 {
  3767. // item.IsChange = 1
  3768. // item.BgBchno = bg_number
  3769. // service.SaveDF2(item)
  3770. // } else {
  3771. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3772. // }
  3773. // }
  3774. //}
  3775. } else {
  3776. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3777. }
  3778. }
  3779. } else { //还没结算
  3780. var res3507for10188 FJ3507ResultFor10188
  3781. if item.IsChange == 0 { //没变更,进行变更操作
  3782. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3783. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3784. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3785. var respJSON3 map[string]interface{}
  3786. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3789. return
  3790. }
  3791. userJSONBytes3, _ := json.Marshal(respJSON3)
  3792. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3793. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3794. utils.ErrorLog("解析失败:%v", err)
  3795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3796. return
  3797. }
  3798. //if res3507for10188.Infcode
  3799. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3800. //res.Output = resSix10265.Output
  3801. res3.ErrMsg = res3507for10188.ErrMsg
  3802. res3.Cainfo = res3507for10188.Cainfo
  3803. res3.WarnMsg = res3507for10188.WarnMsg
  3804. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3805. res3.Infcode = infocode
  3806. } else {
  3807. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3808. utils.ErrorLog("解析失败:%v", err)
  3809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3810. return
  3811. }
  3812. }
  3813. if res3.Infcode == 0 {
  3814. item.IsChange = 1
  3815. item.BgBchno = bg_number
  3816. service.SaveDF2(item)
  3817. } else {
  3818. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3819. }
  3820. }
  3821. }
  3822. }
  3823. //if item.ConsumableType == 7 {
  3824. // var res3507for10188 FJ3507ResultFor10188
  3825. //
  3826. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3827. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3828. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3829. // //判断是否已经销售
  3830. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3831. // //是否已经变更 1是 0否
  3832. // if item.IsChange == 0 { //没变更,进行变更操作
  3833. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3834. //
  3835. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3836. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3837. //
  3838. // var respJSON3 map[string]interface{}
  3839. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3840. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3841. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3842. // return
  3843. // }
  3844. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3845. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3846. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3847. // utils.ErrorLog("解析失败:%v", err)
  3848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3849. // return
  3850. // }
  3851. // //if res3507for10188.Infcode
  3852. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3853. // //res.Output = resSix10265.Output
  3854. // res3.ErrMsg = res3507for10188.ErrMsg
  3855. // res3.Cainfo = res3507for10188.Cainfo
  3856. // res3.WarnMsg = res3507for10188.WarnMsg
  3857. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3858. // res3.Infcode = infocode
  3859. // } else {
  3860. //
  3861. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3862. // utils.ErrorLog("解析失败:%v", err)
  3863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3864. // return
  3865. // }
  3866. //
  3867. // }
  3868. // if res3.Infcode == 0 {
  3869. // item.IsChange = 1
  3870. // item.BgBchno = bg_number
  3871. // service.SaveDF2(item)
  3872. // } else {
  3873. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3874. // }
  3875. // }
  3876. // } else { //没销售,
  3877. // //进行商品销售退货接口
  3878. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3879. //
  3880. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3881. // saveLog(result111, result222, "3506", "销售退货")
  3882. // var res7 FJ3507Result
  3883. //
  3884. // //进行商品销售接口
  3885. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3886. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3887. // var respJSON3 map[string]interface{}
  3888. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3889. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3891. // return
  3892. // }
  3893. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3894. //
  3895. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3896. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3897. // utils.ErrorLog("解析失败:%v", err)
  3898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3899. // return
  3900. // }
  3901. // //if res3507for10188.Infcode
  3902. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3903. // //res.Output = resSix10265.Output
  3904. // res7.ErrMsg = res3507for10188.ErrMsg
  3905. // res7.Cainfo = res3507for10188.Cainfo
  3906. // res7.WarnMsg = res3507for10188.WarnMsg
  3907. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3908. // res7.Infcode = infocode
  3909. // } else {
  3910. //
  3911. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3912. // utils.ErrorLog("解析失败:%v", err)
  3913. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3914. // return
  3915. // }
  3916. //
  3917. // }
  3918. // if res7.Infcode == 0 {
  3919. // item.IsSale = 2
  3920. // item.SaleDate = item.SaleDate
  3921. // item.Bchno = number
  3922. // service.SaveDF(item)
  3923. // if item.IsChange == 0 { //没变更,进行变更操作
  3924. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3925. //
  3926. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3927. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3928. //
  3929. // var respJSON3 map[string]interface{}
  3930. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3931. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3933. // return
  3934. // }
  3935. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3936. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3937. // // utils.ErrorLog("解析失败:%v", err)
  3938. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. // // return
  3940. // //}
  3941. //
  3942. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3943. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3944. // utils.ErrorLog("解析失败:%v", err)
  3945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3946. // return
  3947. // }
  3948. // //if res3507for10188.Infcode
  3949. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3950. // //res.Output = resSix10265.Output
  3951. // res3.ErrMsg = res3507for10188.ErrMsg
  3952. // res3.Cainfo = res3507for10188.Cainfo
  3953. // res3.WarnMsg = res3507for10188.WarnMsg
  3954. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3955. // res3.Infcode = infocode
  3956. // } else {
  3957. //
  3958. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3959. // utils.ErrorLog("解析失败:%v", err)
  3960. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3961. // return
  3962. // }
  3963. //
  3964. // }
  3965. // if res3.Infcode == 0 {
  3966. // item.IsChange = 1
  3967. // item.BgBchno = bg_number
  3968. // service.SaveDF2(item)
  3969. // } else {
  3970. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3971. // }
  3972. // }
  3973. // } else {
  3974. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3975. // }
  3976. // }
  3977. // } else { //还没结算
  3978. // if item.IsChange == 0 { //没变更,进行变更操作
  3979. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3980. //
  3981. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3982. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3983. //
  3984. // var respJSON3 map[string]interface{}
  3985. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3986. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3987. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. // return
  3989. // }
  3990. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3991. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3992. // // utils.ErrorLog("解析失败:%v", err)
  3993. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3994. // // return
  3995. // //}
  3996. //
  3997. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3998. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3999. // utils.ErrorLog("解析失败:%v", err)
  4000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4001. // return
  4002. // }
  4003. // //if res3507for10188.Infcode
  4004. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4005. // //res.Output = resSix10265.Output
  4006. // res3.ErrMsg = res3507for10188.ErrMsg
  4007. // res3.Cainfo = res3507for10188.Cainfo
  4008. // res3.WarnMsg = res3507for10188.WarnMsg
  4009. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4010. // res3.Infcode = infocode
  4011. // } else {
  4012. //
  4013. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4014. // utils.ErrorLog("解析失败:%v", err)
  4015. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4016. // return
  4017. // }
  4018. //
  4019. // }
  4020. // if res3.Infcode == 0 {
  4021. // item.IsChange = 1
  4022. // item.BgBchno = bg_number
  4023. // service.SaveDF2(item)
  4024. // } else {
  4025. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4026. // }
  4027. // }
  4028. // }
  4029. //}
  4030. }
  4031. if len(err) == 0 {
  4032. c.ServeSuccessJSON(map[string]interface{}{
  4033. "msg": "销售变更成功",
  4034. })
  4035. } else {
  4036. c.ServeSuccessJSON(map[string]interface{}{
  4037. "failed_code": -10,
  4038. "msg": err,
  4039. })
  4040. }
  4041. }
  4042. func (c *HisApiController) ChangeDrugthree() {
  4043. //ids := c.GetString("ids")
  4044. //id_arr := strings.Split(ids, ",")
  4045. flows, _ := service.GetNewDrugFlowInfothree()
  4046. admin_user_id, _ := c.GetInt64("admin_user_id")
  4047. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4048. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4049. var err []string
  4050. for _, item := range flows {
  4051. var res3 ResultSix
  4052. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4053. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4054. if prescription.OrderStatus == 2 {
  4055. //已经结算
  4056. //判断是否已经销售
  4057. if item.IsSale == 1 { //是否已经销售,1是 0否
  4058. //是否已经变更 1是 0否
  4059. if item.IsChange == 0 { //没变更,进行变更操作
  4060. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4061. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4062. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4063. var respJSON3 map[string]interface{}
  4064. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4067. return
  4068. }
  4069. userJSONBytes3, _ := json.Marshal(respJSON3)
  4070. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4071. utils.ErrorLog("解析失败:%v", err)
  4072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4073. return
  4074. }
  4075. if res3.Infcode == 0 {
  4076. item.IsChange = 1
  4077. item.BgBchno = bg_number
  4078. service.SaveDF2(item)
  4079. } else {
  4080. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4081. }
  4082. }
  4083. } else { //没销售,
  4084. var res FJ3507Result
  4085. var res3507for10188 FJ3507ResultFor10188
  4086. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4087. //进行商品销售接口
  4088. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4089. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4090. var respJSON3 map[string]interface{}
  4091. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4094. return
  4095. }
  4096. userJSONBytes3, _ := json.Marshal(respJSON3)
  4097. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4098. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4099. utils.ErrorLog("解析失败:%v", err)
  4100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4101. return
  4102. }
  4103. //if res3507for10188.Infcode
  4104. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4105. //res.Output = resSix10265.Output
  4106. res.ErrMsg = res3507for10188.ErrMsg
  4107. res.Cainfo = res3507for10188.Cainfo
  4108. res.WarnMsg = res3507for10188.WarnMsg
  4109. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4110. res.Infcode = infocode
  4111. } else {
  4112. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4113. utils.ErrorLog("解析失败:%v", err)
  4114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4115. return
  4116. }
  4117. }
  4118. if res.Infcode == 0 {
  4119. item.IsSale = 1
  4120. item.Bchno = number
  4121. item.SaleDate = time.Now().Format("2006-01-02")
  4122. err5 := service.SaveDF(item)
  4123. if err5 == nil {
  4124. if item.IsChange == 0 { //没变更,进行变更操作
  4125. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4126. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4127. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4128. var respJSON3 map[string]interface{}
  4129. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4132. return
  4133. }
  4134. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4135. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4136. utils.ErrorLog("解析失败:%v", err)
  4137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4138. return
  4139. }
  4140. //if res3507for10188.Infcode
  4141. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4142. //res.Output = resSix10265.Output
  4143. res3.ErrMsg = res3507for10188.ErrMsg
  4144. res3.Cainfo = res3507for10188.Cainfo
  4145. res3.WarnMsg = res3507for10188.WarnMsg
  4146. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4147. res3.Infcode = infocode
  4148. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4149. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4150. utils.ErrorLog("解析失败:%v", err)
  4151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4152. return
  4153. }
  4154. //if res3507for10188.Infcode
  4155. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4156. //res.Output = resSix10265.Output
  4157. res3.ErrMsg = res3507for10188.ErrMsg
  4158. res3.Cainfo = res3507for10188.Cainfo
  4159. res3.WarnMsg = res3507for10188.WarnMsg
  4160. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4161. res3.Infcode = infocode
  4162. } else {
  4163. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4164. utils.ErrorLog("解析失败:%v", err)
  4165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4166. return
  4167. }
  4168. }
  4169. if res3.Infcode == 0 {
  4170. item.IsChange = 1
  4171. item.BgBchno = bg_number
  4172. service.SaveDF2(item)
  4173. } else {
  4174. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4175. }
  4176. }
  4177. }
  4178. } else {
  4179. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4180. }
  4181. }
  4182. } else { //还没结算
  4183. var res3507for10188 FJ3507ResultFor10188
  4184. if item.IsChange == 0 { //没变更,进行变更操作
  4185. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4186. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4187. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4188. var respJSON3 map[string]interface{}
  4189. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4192. return
  4193. }
  4194. userJSONBytes3, _ := json.Marshal(respJSON3)
  4195. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4196. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4197. utils.ErrorLog("解析失败:%v", err)
  4198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4199. return
  4200. }
  4201. //if res3507for10188.Infcode
  4202. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4203. //res.Output = resSix10265.Output
  4204. res3.ErrMsg = res3507for10188.ErrMsg
  4205. res3.Cainfo = res3507for10188.Cainfo
  4206. res3.WarnMsg = res3507for10188.WarnMsg
  4207. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4208. res3.Infcode = infocode
  4209. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4210. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4211. utils.ErrorLog("解析失败:%v", err)
  4212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4213. return
  4214. }
  4215. //if res3507for10188.Infcode
  4216. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4217. //res.Output = resSix10265.Output
  4218. res3.ErrMsg = res3507for10188.ErrMsg
  4219. res3.Cainfo = res3507for10188.Cainfo
  4220. res3.WarnMsg = res3507for10188.WarnMsg
  4221. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4222. res3.Infcode = infocode
  4223. } else {
  4224. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4225. utils.ErrorLog("解析失败:%v", err)
  4226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4227. return
  4228. }
  4229. }
  4230. if res3.Infcode == 0 {
  4231. item.IsChange = 1
  4232. item.BgBchno = bg_number
  4233. service.SaveDF2(item)
  4234. } else {
  4235. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4236. }
  4237. }
  4238. }
  4239. } else if item.ConsumableType == 7 {
  4240. var res3507for10188 FJ3507ResultFor10188
  4241. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4242. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4243. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4244. //判断是否已经销售
  4245. if item.IsSale == 2 { //是否已经销售,1是 0否
  4246. //是否已经变更 1是 0否
  4247. if item.IsChange == 0 { //没变更,进行变更操作
  4248. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4249. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4250. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4251. var respJSON3 map[string]interface{}
  4252. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4255. return
  4256. }
  4257. userJSONBytes3, _ := json.Marshal(respJSON3)
  4258. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4259. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4260. utils.ErrorLog("解析失败:%v", err)
  4261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4262. return
  4263. }
  4264. //if res3507for10188.Infcode
  4265. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4266. //res.Output = resSix10265.Output
  4267. res3.ErrMsg = res3507for10188.ErrMsg
  4268. res3.Cainfo = res3507for10188.Cainfo
  4269. res3.WarnMsg = res3507for10188.WarnMsg
  4270. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4271. res3.Infcode = infocode
  4272. } else {
  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 res3.Infcode == 0 {
  4280. item.IsChange = 1
  4281. item.BgBchno = bg_number
  4282. service.SaveDF2(item)
  4283. } else {
  4284. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4285. }
  4286. }
  4287. } else { //没销售,
  4288. //进行商品销售退货接口
  4289. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4290. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4291. saveLog(result111, result222, "3506", "销售退货")
  4292. var res7 FJ3507Result
  4293. //进行商品销售接口
  4294. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4295. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4296. var respJSON3 map[string]interface{}
  4297. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4300. return
  4301. }
  4302. userJSONBytes3, _ := json.Marshal(respJSON3)
  4303. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4304. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4305. utils.ErrorLog("解析失败:%v", err)
  4306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4307. return
  4308. }
  4309. //if res3507for10188.Infcode
  4310. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4311. //res.Output = resSix10265.Output
  4312. res7.ErrMsg = res3507for10188.ErrMsg
  4313. res7.Cainfo = res3507for10188.Cainfo
  4314. res7.WarnMsg = res3507for10188.WarnMsg
  4315. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4316. res7.Infcode = infocode
  4317. } else {
  4318. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4319. utils.ErrorLog("解析失败:%v", err)
  4320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4321. return
  4322. }
  4323. }
  4324. if res7.Infcode == 0 {
  4325. item.IsSale = 2
  4326. item.SaleDate = item.SaleDate
  4327. item.Bchno = number
  4328. service.SaveDF(item)
  4329. if item.IsChange == 0 { //没变更,进行变更操作
  4330. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4331. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4332. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4333. var respJSON3 map[string]interface{}
  4334. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4337. return
  4338. }
  4339. userJSONBytes3, _ := json.Marshal(respJSON3)
  4340. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4341. // utils.ErrorLog("解析失败:%v", err)
  4342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4343. // return
  4344. //}
  4345. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4346. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4347. utils.ErrorLog("解析失败:%v", err)
  4348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4349. return
  4350. }
  4351. //if res3507for10188.Infcode
  4352. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4353. //res.Output = resSix10265.Output
  4354. res3.ErrMsg = res3507for10188.ErrMsg
  4355. res3.Cainfo = res3507for10188.Cainfo
  4356. res3.WarnMsg = res3507for10188.WarnMsg
  4357. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4358. res3.Infcode = infocode
  4359. } else {
  4360. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4361. utils.ErrorLog("解析失败:%v", err)
  4362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4363. return
  4364. }
  4365. }
  4366. if res3.Infcode == 0 {
  4367. item.IsChange = 1
  4368. item.BgBchno = bg_number
  4369. service.SaveDF2(item)
  4370. } else {
  4371. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4372. }
  4373. }
  4374. } else {
  4375. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4376. }
  4377. }
  4378. } else { //还没结算
  4379. if item.IsChange == 0 { //没变更,进行变更操作
  4380. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4381. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4382. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4383. var respJSON3 map[string]interface{}
  4384. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4387. return
  4388. }
  4389. userJSONBytes3, _ := json.Marshal(respJSON3)
  4390. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4391. // utils.ErrorLog("解析失败:%v", err)
  4392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4393. // return
  4394. //}
  4395. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4396. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4397. utils.ErrorLog("解析失败:%v", err)
  4398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4399. return
  4400. }
  4401. //if res3507for10188.Infcode
  4402. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4403. //res.Output = resSix10265.Output
  4404. res3.ErrMsg = res3507for10188.ErrMsg
  4405. res3.Cainfo = res3507for10188.Cainfo
  4406. res3.WarnMsg = res3507for10188.WarnMsg
  4407. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4408. res3.Infcode = infocode
  4409. } else {
  4410. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4411. utils.ErrorLog("解析失败:%v", err)
  4412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4413. return
  4414. }
  4415. }
  4416. if res3.Infcode == 0 {
  4417. item.IsChange = 1
  4418. item.BgBchno = bg_number
  4419. service.SaveDF2(item)
  4420. } else {
  4421. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4422. }
  4423. }
  4424. }
  4425. }
  4426. }
  4427. if len(err) == 0 {
  4428. c.ServeSuccessJSON(map[string]interface{}{
  4429. "msg": "销售变更成功",
  4430. })
  4431. } else {
  4432. c.ServeSuccessJSON(map[string]interface{}{
  4433. "failed_code": -10,
  4434. "msg": err,
  4435. })
  4436. }
  4437. }
  4438. func (c *HisApiController) ChangeDrugTen() {
  4439. start_time_str := c.GetString("start_time")
  4440. end_time_str := c.GetString("end_time")
  4441. //ids := c.GetString("ids")
  4442. //id_arr := strings.Split(ids, ",")
  4443. timeLayout := "2006-01-02"
  4444. loc, _ := time.LoadLocation("Local")
  4445. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4446. recordStartTime := theStartTime.Unix()
  4447. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4448. recordEndTime := theEndTime.Unix()
  4449. //timestamp := int64(1729612800)
  4450. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4451. admin_user_id, _ := c.GetInt64("admin_user_id")
  4452. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4453. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4454. var err []string
  4455. for _, item := range flows {
  4456. var res3 ResultSix
  4457. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4458. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4459. continue
  4460. }
  4461. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4462. continue
  4463. }
  4464. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4465. if prescription.OrderStatus == 2 {
  4466. //已经结算
  4467. //判断 是否已经销售
  4468. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4469. ////是否已经变更 1是 0否
  4470. //if item.IsChange == 0 { //没变更,进行变更操作
  4471. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4472. //
  4473. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4474. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4475. // var respJSON3 map[string]interface{}
  4476. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4477. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4479. // return
  4480. // }
  4481. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4482. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4483. // utils.ErrorLog("解析失败:%v", err)
  4484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4485. // return
  4486. // }
  4487. // if res3.Infcode == 0 {
  4488. // item.IsChange = 1
  4489. // item.BgBchno = bg_number
  4490. // service.SaveDF2(item)
  4491. // } else {
  4492. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4493. // }
  4494. //}
  4495. //} else
  4496. if item.IsSale == 0 { //没销售,
  4497. var res FJ3507Result
  4498. var res3507for10188 FJ3507ResultFor10188
  4499. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4500. //进行商品销售接口
  4501. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4502. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4503. var respJSON3 map[string]interface{}
  4504. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4507. return
  4508. }
  4509. userJSONBytes3, _ := json.Marshal(respJSON3)
  4510. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4511. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4512. utils.ErrorLog("解析失败:%v", err)
  4513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4514. return
  4515. }
  4516. //if res3507for10188.Infcode
  4517. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4518. //res.Output = resSix10265.Output
  4519. res.ErrMsg = res3507for10188.ErrMsg
  4520. res.Cainfo = res3507for10188.Cainfo
  4521. res.WarnMsg = res3507for10188.WarnMsg
  4522. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4523. res.Infcode = infocode
  4524. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4525. } else {
  4526. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4527. utils.ErrorLog("解析失败:%v", err)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. }
  4532. if res.Infcode == 0 {
  4533. item.IsSale = 1
  4534. item.Bchno = number
  4535. item.SaleDate = time.Now().Format("2006-01-02")
  4536. err5 := service.SaveDF(item)
  4537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4538. //if err5 == nil {
  4539. //
  4540. // if item.IsChange == 1 { //没变更,进行变更操作
  4541. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4542. //
  4543. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4544. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4545. //
  4546. // var respJSON3 map[string]interface{}
  4547. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4548. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4550. // return
  4551. // }
  4552. //
  4553. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4554. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4555. // utils.ErrorLog("解析失败:%v", err)
  4556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4557. // return
  4558. // }
  4559. // //if res3507for10188.Infcode
  4560. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4561. // //res.Output = resSix10265.Output
  4562. // res3.ErrMsg = res3507for10188.ErrMsg
  4563. // res3.Cainfo = res3507for10188.Cainfo
  4564. // res3.WarnMsg = res3507for10188.WarnMsg
  4565. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4566. // res3.Infcode = infocode
  4567. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4568. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4569. // utils.ErrorLog("解析失败:%v", err)
  4570. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. // return
  4572. // }
  4573. // //if res3507for10188.Infcode
  4574. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4575. // //res.Output = resSix10265.Output
  4576. // res3.ErrMsg = res3507for10188.ErrMsg
  4577. // res3.Cainfo = res3507for10188.Cainfo
  4578. // res3.WarnMsg = res3507for10188.WarnMsg
  4579. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4580. // res3.Infcode = infocode
  4581. //
  4582. // } else {
  4583. //
  4584. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4585. // utils.ErrorLog("解析失败:%v", err)
  4586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4587. // return
  4588. // }
  4589. //
  4590. // }
  4591. //
  4592. // if res3.Infcode == 0 {
  4593. // item.IsChange = 1
  4594. // item.BgBchno = bg_number
  4595. // service.SaveDF2(item)
  4596. // return
  4597. // } else {
  4598. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4599. // }
  4600. // }
  4601. //}
  4602. } else {
  4603. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4604. }
  4605. }
  4606. }
  4607. } else if item.ConsumableType == 7 {
  4608. var res3507for10188 FJ3507ResultFor10188
  4609. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4610. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4611. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4612. //判断是否已经销售
  4613. if item.IsSale == 2 { //是否已经销售,1是 0否
  4614. //是否已经变更 1是 0否
  4615. if item.IsChange == 0 { //没变更,进行变更操作
  4616. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4617. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4618. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4619. var respJSON3 map[string]interface{}
  4620. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4623. return
  4624. }
  4625. userJSONBytes3, _ := json.Marshal(respJSON3)
  4626. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4627. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4628. utils.ErrorLog("解析失败:%v", err)
  4629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4630. return
  4631. }
  4632. //if res3507for10188.Infcode
  4633. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4634. //res.Output = resSix10265.Output
  4635. res3.ErrMsg = res3507for10188.ErrMsg
  4636. res3.Cainfo = res3507for10188.Cainfo
  4637. res3.WarnMsg = res3507for10188.WarnMsg
  4638. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4639. res3.Infcode = infocode
  4640. } else {
  4641. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4642. utils.ErrorLog("解析失败:%v", err)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. }
  4647. if res3.Infcode == 0 {
  4648. item.IsChange = 1
  4649. item.BgBchno = bg_number
  4650. service.SaveDF2(item)
  4651. } else {
  4652. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4653. }
  4654. }
  4655. } else { //没销售,
  4656. //进行商品销售退货接口
  4657. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4658. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4659. saveLog(result111, result222, "3506", "销售退货")
  4660. var res7 FJ3507Result
  4661. //进行商品销售接口
  4662. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4663. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4664. var respJSON3 map[string]interface{}
  4665. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4668. return
  4669. }
  4670. userJSONBytes3, _ := json.Marshal(respJSON3)
  4671. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4672. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4673. utils.ErrorLog("解析失败:%v", err)
  4674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4675. return
  4676. }
  4677. //if res3507for10188.Infcode
  4678. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4679. //res.Output = resSix10265.Output
  4680. res7.ErrMsg = res3507for10188.ErrMsg
  4681. res7.Cainfo = res3507for10188.Cainfo
  4682. res7.WarnMsg = res3507for10188.WarnMsg
  4683. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4684. res7.Infcode = infocode
  4685. } else {
  4686. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4687. utils.ErrorLog("解析失败:%v", err)
  4688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4689. return
  4690. }
  4691. }
  4692. if res7.Infcode == 0 {
  4693. item.IsSale = 2
  4694. item.SaleDate = item.SaleDate
  4695. item.Bchno = number
  4696. service.SaveDF(item)
  4697. if item.IsChange == 0 { //没变更,进行变更操作
  4698. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4699. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4700. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4701. var respJSON3 map[string]interface{}
  4702. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4705. return
  4706. }
  4707. userJSONBytes3, _ := json.Marshal(respJSON3)
  4708. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4709. // utils.ErrorLog("解析失败:%v", err)
  4710. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4711. // return
  4712. //}
  4713. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4714. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4715. utils.ErrorLog("解析失败:%v", err)
  4716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4717. return
  4718. }
  4719. //if res3507for10188.Infcode
  4720. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4721. //res.Output = resSix10265.Output
  4722. res3.ErrMsg = res3507for10188.ErrMsg
  4723. res3.Cainfo = res3507for10188.Cainfo
  4724. res3.WarnMsg = res3507for10188.WarnMsg
  4725. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4726. res3.Infcode = infocode
  4727. } else {
  4728. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4729. utils.ErrorLog("解析失败:%v", err)
  4730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4731. return
  4732. }
  4733. }
  4734. if res3.Infcode == 0 {
  4735. item.IsChange = 1
  4736. item.BgBchno = bg_number
  4737. service.SaveDF2(item)
  4738. } else {
  4739. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4740. }
  4741. }
  4742. } else {
  4743. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4744. }
  4745. }
  4746. } else { //还没结算
  4747. if item.IsChange == 0 { //没变更,进行变更操作
  4748. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4749. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4750. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4751. var respJSON3 map[string]interface{}
  4752. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4755. return
  4756. }
  4757. userJSONBytes3, _ := json.Marshal(respJSON3)
  4758. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4759. // utils.ErrorLog("解析失败:%v", err)
  4760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4761. // return
  4762. //}
  4763. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4764. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4765. utils.ErrorLog("解析失败:%v", err)
  4766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4767. return
  4768. }
  4769. //if res3507for10188.Infcode
  4770. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4771. //res.Output = resSix10265.Output
  4772. res3.ErrMsg = res3507for10188.ErrMsg
  4773. res3.Cainfo = res3507for10188.Cainfo
  4774. res3.WarnMsg = res3507for10188.WarnMsg
  4775. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4776. res3.Infcode = infocode
  4777. } else {
  4778. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4779. utils.ErrorLog("解析失败:%v", err)
  4780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4781. return
  4782. }
  4783. }
  4784. if res3.Infcode == 0 {
  4785. item.IsChange = 1
  4786. item.BgBchno = bg_number
  4787. service.SaveDF2(item)
  4788. } else {
  4789. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4790. }
  4791. }
  4792. }
  4793. }
  4794. }
  4795. if len(err) == 0 {
  4796. c.ServeSuccessJSON(map[string]interface{}{
  4797. "msg": "销售变更成功",
  4798. })
  4799. } else {
  4800. c.ServeSuccessJSON(map[string]interface{}{
  4801. "failed_code": -10,
  4802. "msg": err,
  4803. })
  4804. }
  4805. }
  4806. func ChangeDrugTenone() {
  4807. //ids := c.GetString("ids")
  4808. //id_arr := strings.Split(ids, ",")
  4809. now := time.Now()
  4810. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4811. //timestamp := int64(1729612800)
  4812. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4813. admin_user_id := int64(2463)
  4814. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4815. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4816. var err []string
  4817. for _, item := range flows {
  4818. var res3 ResultSix
  4819. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4820. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4821. continue
  4822. }
  4823. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4824. continue
  4825. }
  4826. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4827. if prescription.OrderStatus == 2 {
  4828. //已经结算
  4829. //判断是否已经销售
  4830. if item.IsSale == 1 { //是否已经销售,1是 0否
  4831. //是否已经变更 1是 0否
  4832. if item.IsChange == 0 { //没变更,进行变更操作
  4833. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4834. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4835. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4836. var respJSON3 map[string]interface{}
  4837. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4839. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4840. return
  4841. }
  4842. userJSONBytes3, _ := json.Marshal(respJSON3)
  4843. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4844. utils.ErrorLog("解析失败:%v", err)
  4845. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4846. return
  4847. }
  4848. if res3.Infcode == 0 {
  4849. item.IsChange = 1
  4850. item.BgBchno = bg_number
  4851. service.SaveDF2(item)
  4852. } else {
  4853. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4854. }
  4855. }
  4856. } else { //没销售,
  4857. var res FJ3507Result
  4858. var res3507for10188 FJ3507ResultFor10188
  4859. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4860. //进行商品销售接口
  4861. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4862. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4863. var respJSON3 map[string]interface{}
  4864. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4866. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. return
  4868. }
  4869. userJSONBytes3, _ := json.Marshal(respJSON3)
  4870. {
  4871. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4872. utils.ErrorLog("解析失败:%v", err)
  4873. return
  4874. }
  4875. //if res3507for10188.Infcode
  4876. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4877. //res.Output = resSix10265.Output
  4878. res.ErrMsg = res3507for10188.ErrMsg
  4879. res.Cainfo = res3507for10188.Cainfo
  4880. res.WarnMsg = res3507for10188.WarnMsg
  4881. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4882. res.Infcode = infocode
  4883. }
  4884. if res.Infcode == 0 {
  4885. item.IsSale = 1
  4886. item.Bchno = number
  4887. item.SaleDate = time.Now().Format("2006-01-02")
  4888. err5 := service.SaveDF(item)
  4889. if err5 == nil {
  4890. if item.IsChange == 1 { //没变更,进行变更操作
  4891. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4892. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4893. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4894. var respJSON3 map[string]interface{}
  4895. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4897. return
  4898. }
  4899. {
  4900. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4901. utils.ErrorLog("解析失败:%v", err)
  4902. return
  4903. }
  4904. //if res3507for10188.Infcode
  4905. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4906. //res.Output = resSix10265.Output
  4907. res3.ErrMsg = res3507for10188.ErrMsg
  4908. res3.Cainfo = res3507for10188.Cainfo
  4909. res3.WarnMsg = res3507for10188.WarnMsg
  4910. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4911. res3.Infcode = infocode
  4912. }
  4913. if res3.Infcode == 0 {
  4914. item.IsChange = 1
  4915. item.BgBchno = bg_number
  4916. service.SaveDF2(item)
  4917. } else {
  4918. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4919. }
  4920. }
  4921. }
  4922. } else {
  4923. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4924. }
  4925. }
  4926. }
  4927. }
  4928. }
  4929. }
  4930. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4931. var struct3502 models.Struct3502
  4932. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4933. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4934. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4935. struct3502.FixmedinsCode = miConfig.Code
  4936. struct3502.Code = miConfig.Code
  4937. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4938. struct3502.Opter = role.UserName
  4939. struct3502.RxFlag = "1"
  4940. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4941. struct3502.OrgName = miConfig.OrgName
  4942. struct3502.AccessKey = miConfig.AccessKey
  4943. struct3502.RequestUrl = miConfig.Url
  4944. struct3502.SecretKey = miConfig.SecretKey
  4945. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4946. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4947. struct3502.Url = miConfig.Url
  4948. struct3502.AppId = miConfig.Cainfo
  4949. struct3502.AppSecret = miConfig.AppSecret
  4950. struct3502.Enckey = miConfig.EncKey
  4951. struct3502.SignKey = miConfig.SignKey
  4952. struct3502.SecretKey = miConfig.SecretKey
  4953. struct3502.InvChgType = chgType
  4954. struct3502.FixmedinsBchno = number
  4955. struct3502.Cnt = strconv.FormatInt(count, 10)
  4956. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4957. //result1, result2, _ := service.FJyb3502(struct3502)
  4958. if miConfig.MdtrtareaAdmvs == "350500" {
  4959. result1, result2, _ := service.FJyb3502(struct3502)
  4960. //saveLog(result1, result2, "3502", "3502")
  4961. return result1, result2
  4962. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4963. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4964. return result1, result2
  4965. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4966. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4967. return result1, result2
  4968. } else {
  4969. data := make(map[string]interface{})
  4970. data["struct_3502s"] = struct3502
  4971. client := &http.Client{}
  4972. bytesData, _ := json.Marshal(data)
  4973. var req *http.Request
  4974. if miConfig.MdtrtareaAdmvs == "320921" {
  4975. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4976. } else {
  4977. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4978. }
  4979. resp, _ := client.Do(req)
  4980. defer resp.Body.Close()
  4981. body, ioErr := ioutil.ReadAll(resp.Body)
  4982. if ioErr != nil {
  4983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4984. }
  4985. var respJSON map[string]interface{}
  4986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4988. }
  4989. //var resSix10265 ResultSix10265 //1101结果
  4990. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4991. result, _ := json.Marshal(respJSON)
  4992. return string(result), ""
  4993. }
  4994. }
  4995. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4996. var struct3505 models.Struct3505
  4997. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4998. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4999. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5000. struct3505.FixmedinsBchno = number
  5001. struct3505.Opter = role.UserName
  5002. struct3505.Bchno = "---"
  5003. struct3505.FixmedinsCode = miConfig.Code
  5004. struct3505.Code = miConfig.Code
  5005. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5006. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5007. struct3505.PrscDrName = roles.UserName
  5008. if org_id == 10191 {
  5009. struct3505.PharName = "刘水山"
  5010. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5011. }
  5012. if org_id == 10188 {
  5013. struct3505.PharName = "李汉清"
  5014. struct3505.PharPracCertNo = "30220200932022010034"
  5015. }
  5016. if org_id == 10217 {
  5017. struct3505.PharName = "张敏"
  5018. struct3505.PharPracCertNo = "30220230432090100108"
  5019. }
  5020. if org_id == 10318 {
  5021. struct3505.PharName = "邹刘阳"
  5022. struct3505.PharPracCertNo = "210441200001378"
  5023. }
  5024. if org_id == 10402 {
  5025. struct3505.PharName = "刘韶健"
  5026. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5027. }
  5028. if org_id == 9919 {
  5029. struct3505.PharName = "周君权"
  5030. struct3505.PharPracCertNo = "089644396094401375"
  5031. }
  5032. if org_id == 10644 {
  5033. struct3505.PharName = "陈金娣"
  5034. struct3505.PharPracCertNo = "20181441500320100066"
  5035. }
  5036. if org_id == 10567 {
  5037. struct3505.PharName = "范小兰"
  5038. struct3505.PharPracCertNo = "0200102079485"
  5039. }
  5040. if org_id == 10721 {
  5041. struct3505.PharName = "孙莉侠"
  5042. struct3505.PharPracCertNo = "060399"
  5043. }
  5044. if org_id == 10726 {
  5045. struct3505.PharName = "彭建福"
  5046. struct3505.PharPracCertNo = "D445281006261"
  5047. }
  5048. if org_id == 10265 {
  5049. struct3505.PharName = "李彩星"
  5050. struct3505.PharPracCertNo = "20171110600110100019"
  5051. }
  5052. if org_id == 10028 {
  5053. struct3505.PharName = "曾细平"
  5054. struct3505.PharPracCertNo = "D440307022134"
  5055. }
  5056. if org_id == 10138 {
  5057. struct3505.PharName = "彭斯遥"
  5058. struct3505.PharPracCertNo = "30220200943042010052"
  5059. }
  5060. if org_id == 10278 {
  5061. struct3505.PharName = "彭斯遥"
  5062. struct3505.PharPracCertNo = "30220200943042010052"
  5063. }
  5064. if org_id == 10610 {
  5065. struct3505.PharName = "彭斯遥"
  5066. struct3505.PharPracCertNo = "30220200943042010052"
  5067. }
  5068. if org_id == 10537 {
  5069. struct3505.PharName = "彭斯遥"
  5070. struct3505.PharPracCertNo = "30220200943042010052"
  5071. }
  5072. if org_id == 9504 {
  5073. struct3505.PharName = "资美红"
  5074. struct3505.PharPracCertNo = "D440904006635"
  5075. }
  5076. if org_id == 10480 {
  5077. struct3505.PharName = "陈思"
  5078. struct3505.PharPracCertNo = "30220240434110010470"
  5079. }
  5080. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5081. struct3505.SetlId = order.SetlId
  5082. struct3505.MdtrtSn = order.MdtrtId
  5083. struct3505.ManuLotnum = drug.BatchNumber
  5084. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5085. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5086. struct3505.RxFlag = "1"
  5087. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5088. struct3505.TrdnFlag = "0"
  5089. } else {
  5090. struct3505.TrdnFlag = "1"
  5091. }
  5092. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5093. struct3505.TrdnFlag = "1"
  5094. }
  5095. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5096. struct3505.TrdnFlag = "0"
  5097. }
  5098. struct3505.RtalDocno = order.Number
  5099. struct3505.PsnCertType = "01"
  5100. struct3505.CertNo = order.Certno
  5101. struct3505.PsnNo = order.PsnNo
  5102. struct3505.PsnName = order.PsnName
  5103. struct3505.Url = miConfig.Url
  5104. struct3505.AppId = miConfig.Cainfo
  5105. struct3505.AppSecret = miConfig.AppSecret
  5106. struct3505.Enckey = miConfig.EncKey
  5107. struct3505.SignKey = miConfig.SignKey
  5108. struct3505.SecretKey = miConfig.SecretKey
  5109. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5110. struct3505.SelRetnCnt = strValue
  5111. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5112. struct3505.SelRetnOpterName = role.UserName
  5113. if order.IsMedicineInsurance == 1 {
  5114. struct3505.MdtrtSetlType = "1"
  5115. } else {
  5116. struct3505.MdtrtSetlType = "2"
  5117. }
  5118. struct3505.OrgName = miConfig.OrgName
  5119. struct3505.AccessKey = miConfig.AccessKey
  5120. struct3505.RequestUrl = miConfig.Url
  5121. struct3505.SecretKey = miConfig.SecretKey
  5122. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5123. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5124. struct3505.Cainfo = miConfig.Cainfo
  5125. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5126. if miConfig.MdtrtareaAdmvs == "350500" {
  5127. result1, result2, _ := service.FJyb3505(struct3505)
  5128. return result1, result2
  5129. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5130. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5131. return result1, result2
  5132. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5133. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5134. return result1, result2
  5135. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5136. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5137. return result1, result2
  5138. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5139. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5140. return result1, result2
  5141. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5142. data := make(map[string]interface{})
  5143. data["struct_3505s"] = struct3505
  5144. client := &http.Client{}
  5145. bytesData, _ := json.Marshal(data)
  5146. var req *http.Request
  5147. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5148. resp, _ := client.Do(req)
  5149. defer resp.Body.Close()
  5150. body, ioErr := ioutil.ReadAll(resp.Body)
  5151. if ioErr != nil {
  5152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5153. }
  5154. var respJSON map[string]interface{}
  5155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5157. }
  5158. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5159. result, _ := json.Marshal(respJSON)
  5160. return string(result), ""
  5161. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5162. data := make(map[string]interface{})
  5163. data["struct_3505s"] = struct3505
  5164. client := &http.Client{}
  5165. bytesData, _ := json.Marshal(data)
  5166. var req *http.Request
  5167. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5168. resp, _ := client.Do(req)
  5169. defer resp.Body.Close()
  5170. body, ioErr := ioutil.ReadAll(resp.Body)
  5171. if ioErr != nil {
  5172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5173. }
  5174. var respJSON map[string]interface{}
  5175. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5177. }
  5178. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5179. if status == "0" {
  5180. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5181. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5182. }
  5183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5184. result, _ := json.Marshal(respJSON)
  5185. return string(result), ""
  5186. } else {
  5187. data := make(map[string]interface{})
  5188. data["struct_3505s"] = struct3505
  5189. client := &http.Client{}
  5190. bytesData, _ := json.Marshal(data)
  5191. var req *http.Request
  5192. if miConfig.MdtrtareaAdmvs == "320921" {
  5193. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5194. } else {
  5195. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5196. }
  5197. resp, _ := client.Do(req)
  5198. defer resp.Body.Close()
  5199. body, ioErr := ioutil.ReadAll(resp.Body)
  5200. if ioErr != nil {
  5201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5202. }
  5203. var respJSON map[string]interface{}
  5204. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5206. }
  5207. //var resSix10265 ResultSix10265 //1101结果
  5208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5209. result, _ := json.Marshal(respJSON)
  5210. return string(result), ""
  5211. }
  5212. }
  5213. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5214. var struct3505 models.Struct3505
  5215. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5216. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5217. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5218. struct3505.FixmedinsBchno = number
  5219. struct3505.Opter = role.UserName
  5220. struct3505.FixmedinsCode = miConfig.Code
  5221. struct3505.Code = miConfig.Code
  5222. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5223. struct3505.PrscDrName = roles.UserName
  5224. if org_id == 10191 {
  5225. struct3505.PharName = "刘水山"
  5226. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5227. }
  5228. if org_id == 10188 {
  5229. struct3505.PharName = "李汉清"
  5230. struct3505.PharPracCertNo = "30220200932022010034"
  5231. }
  5232. if org_id == 10217 {
  5233. struct3505.PharName = "张敏"
  5234. struct3505.PharPracCertNo = "30220230432090100108"
  5235. }
  5236. if org_id == 10318 {
  5237. struct3505.PharName = "邹刘阳"
  5238. struct3505.PharPracCertNo = "210441200001378"
  5239. }
  5240. if org_id == 10402 {
  5241. struct3505.PharName = "刘韶健"
  5242. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5243. }
  5244. if org_id == 9919 {
  5245. struct3505.PharName = "周君权"
  5246. struct3505.PharPracCertNo = "089644396094401375"
  5247. }
  5248. if org_id == 10644 {
  5249. struct3505.PharName = "陈金娣"
  5250. struct3505.PharPracCertNo = "20181441500320100066"
  5251. }
  5252. if org_id == 10567 {
  5253. struct3505.PharName = "范小兰"
  5254. struct3505.PharPracCertNo = "0200102079485"
  5255. }
  5256. if org_id == 10721 {
  5257. struct3505.PharName = "孙莉侠"
  5258. struct3505.PharPracCertNo = "060399"
  5259. }
  5260. if org_id == 10726 {
  5261. struct3505.PharName = "彭建福"
  5262. struct3505.PharPracCertNo = "D445281006261"
  5263. }
  5264. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5265. struct3505.SetlId = order.SetlId
  5266. struct3505.MdtrtSn = order.MdtrtId
  5267. struct3505.ManuLotnum = drug.Number
  5268. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5269. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5270. struct3505.RxFlag = "1"
  5271. struct3505.TrdnFlag = "0"
  5272. struct3505.RtalDocno = order.Number
  5273. struct3505.PsnCertType = "01"
  5274. struct3505.CertNo = order.Certno
  5275. struct3505.PsnNo = order.PsnNo
  5276. struct3505.PsnName = order.PsnName
  5277. struct3505.Url = miConfig.Url
  5278. struct3505.AppId = miConfig.Cainfo
  5279. struct3505.AppSecret = miConfig.AppSecret
  5280. struct3505.Enckey = miConfig.EncKey
  5281. struct3505.SignKey = miConfig.SignKey
  5282. struct3505.SecretKey = miConfig.SecretKey
  5283. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5284. struct3505.SelRetnCnt = strValue
  5285. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5286. struct3505.SelRetnOpterName = role.UserName
  5287. if order.IsMedicineInsurance == 1 {
  5288. struct3505.MdtrtSetlType = "1"
  5289. } else {
  5290. struct3505.MdtrtSetlType = "2"
  5291. }
  5292. struct3505.OrgName = miConfig.OrgName
  5293. struct3505.AccessKey = miConfig.AccessKey
  5294. struct3505.RequestUrl = miConfig.Url
  5295. struct3505.SecretKey = miConfig.SecretKey
  5296. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5297. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5298. struct3505.Cainfo = miConfig.Cainfo
  5299. struct3505.DrugTracCodg = drug.DrugCode
  5300. if miConfig.MdtrtareaAdmvs == "350500" {
  5301. result1, result2, _ := service.FJyb3505(struct3505)
  5302. return result1, result2
  5303. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5304. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5305. return result1, result2
  5306. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5307. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5308. return result1, result2
  5309. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5310. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5311. return result1, result2
  5312. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5313. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5314. return result1, result2
  5315. } else {
  5316. data := make(map[string]interface{})
  5317. data["struct_3505s"] = struct3505
  5318. client := &http.Client{}
  5319. bytesData, _ := json.Marshal(data)
  5320. var req *http.Request
  5321. if miConfig.MdtrtareaAdmvs == "320921" {
  5322. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5323. } else {
  5324. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5325. }
  5326. resp, _ := client.Do(req)
  5327. defer resp.Body.Close()
  5328. body, ioErr := ioutil.ReadAll(resp.Body)
  5329. if ioErr != nil {
  5330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5331. }
  5332. var respJSON map[string]interface{}
  5333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5335. }
  5336. //var resSix10265 ResultSix10265 //1101结果
  5337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5338. result, _ := json.Marshal(respJSON)
  5339. return string(result), ""
  5340. }
  5341. }
  5342. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5343. var struct3506 models.Struct3506
  5344. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5345. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5346. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5347. struct3506.FixmedinsCode = miConfig.Code
  5348. struct3506.Code = miConfig.Code
  5349. struct3506.FixmedinsBchno = number
  5350. struct3506.Opter = role.UserName
  5351. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5352. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5353. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5354. struct3506.MdtrtSn = order.MdtrtId
  5355. struct3506.ExpyEnd = ""
  5356. struct3506.RxFlag = "0"
  5357. struct3506.TrdnFlag = "1"
  5358. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5359. struct3506.SelRetnCnt = strValue
  5360. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5361. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5362. struct3506.SelRetnOpterName = role.UserName
  5363. struct3506.OrgName = miConfig.OrgName
  5364. struct3506.AccessKey = miConfig.AccessKey
  5365. struct3506.RequestUrl = miConfig.Url
  5366. struct3506.SecretKey = miConfig.SecretKey
  5367. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5368. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5369. struct3506.Url = miConfig.Url
  5370. struct3506.AppId = miConfig.Cainfo
  5371. struct3506.AppSecret = miConfig.AppSecret
  5372. struct3506.Enckey = miConfig.EncKey
  5373. struct3506.SignKey = miConfig.SignKey
  5374. struct3506.SecretKey = miConfig.SecretKey
  5375. struct3506.DrugTracCodg = drug.DrugCode
  5376. if miConfig.MdtrtareaAdmvs == "350500" {
  5377. result1, result2, _ := service.FJyb3506(struct3506)
  5378. return result1, result2
  5379. } else {
  5380. data := make(map[string]interface{})
  5381. data["struct_3506s"] = struct3506
  5382. client := &http.Client{}
  5383. bytesData, _ := json.Marshal(data)
  5384. var req *http.Request
  5385. if miConfig.MdtrtareaAdmvs == "320921" {
  5386. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5387. } else {
  5388. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5389. }
  5390. resp, _ := client.Do(req)
  5391. defer resp.Body.Close()
  5392. body, ioErr := ioutil.ReadAll(resp.Body)
  5393. if ioErr != nil {
  5394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5395. }
  5396. var respJSON map[string]interface{}
  5397. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5399. }
  5400. //var resSix10265 ResultSix10265 //1101结果
  5401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5402. result, _ := json.Marshal(respJSON)
  5403. return string(result), ""
  5404. }
  5405. }
  5406. func (c *HisApiController) Get1318() {
  5407. adminUser := c.GetAdminUserInfo()
  5408. admin_user_id, _ := c.GetInt64("admin_user_id")
  5409. code := c.GetString("code")
  5410. code = ""
  5411. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5412. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5413. api := ""
  5414. if miConfig.MdtrtareaAdmvs == "320921" {
  5415. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5416. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5417. } else {
  5418. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5419. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5420. }
  5421. resp, requestErr := http.Get(api)
  5422. if requestErr != nil {
  5423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5424. return
  5425. }
  5426. body, ioErr := ioutil.ReadAll(resp.Body)
  5427. if ioErr != nil {
  5428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5430. return
  5431. }
  5432. var respJSON map[string]interface{}
  5433. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5436. return
  5437. }
  5438. //var res Result2406
  5439. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5440. result, _ := json.Marshal(respJSON)
  5441. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5442. utils.ErrorLog("解析失败:%v", err)
  5443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5444. return
  5445. }
  5446. if res.Infcode == "0" {
  5447. c.ServeSuccessJSON(map[string]interface{}{
  5448. "result": "",
  5449. })
  5450. } else {
  5451. c.ServeSuccessJSON(map[string]interface{}{
  5452. "failed_code": -10,
  5453. "msg": res.ErrMsg,
  5454. })
  5455. */return
  5456. //}
  5457. }
  5458. func (c *HisApiController) Get2503() {
  5459. adminUser := c.GetAdminUserInfo()
  5460. admin_user_id, _ := c.GetInt64("admin_user_id")
  5461. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5462. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5463. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5464. }
  5465. func (c *HisApiController) Get2406() {
  5466. id, _ := c.GetInt64("id")
  5467. record_time := c.GetString("record_time")
  5468. his_patient_id, _ := c.GetInt64("his_patient_id")
  5469. admin_user_id, _ := c.GetInt64("admin_user_id")
  5470. diagnosis_id := c.GetString("diagnosis")
  5471. timeLayout := "2006-01-02"
  5472. loc, _ := time.LoadLocation("Local")
  5473. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5474. if err != nil {
  5475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5476. return
  5477. }
  5478. recordDateTime := theTime.Unix()
  5479. adminUser := c.GetAdminUserInfo()
  5480. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5481. var config []*models.HisXtDiagnoseConfig
  5482. for _, item := range diagnosis_ids {
  5483. id, _ := strconv.ParseInt(item, 10, 64)
  5484. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5485. config = append(config, &diagnosisConfig)
  5486. }
  5487. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5488. fmt.Println(his_patient_id)
  5489. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5490. //timestamp := time.Now().Unix()
  5491. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5492. var patientPrescription models.HisPrescriptionInfo
  5493. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5494. if patientPrescription.ID == 0 {
  5495. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5496. }
  5497. var res2 Result2406
  5498. if miConfig.MdtrtareaAdmvs == "341203" {
  5499. data := make(map[string]interface{})
  5500. client := &http.Client{}
  5501. data["psn_no"] = his.PsnNo
  5502. data["mdtrt_id"] = his.Number
  5503. data["operator"] = roles.UserName
  5504. data["cert_no"] = his.IdCardNo
  5505. data["org_name"] = miConfig.OrgName
  5506. data["psn_name"] = his.Name
  5507. data["ipt_otp_no"] = his.IptOtpNo
  5508. data["ipt_psn_sp_flag_type"] = "0901"
  5509. data["ipt_psn_sp_flag"] = "1"
  5510. data["fixmedins_code"] = miConfig.Code
  5511. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5512. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5513. data["url"] = miConfig.Url
  5514. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5515. bytesData, _ := json.Marshal(data)
  5516. var req *http.Request
  5517. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5518. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5519. resp, _ := client.Do(req)
  5520. defer resp.Body.Close()
  5521. body, ioErr := ioutil.ReadAll(resp.Body)
  5522. if ioErr != nil {
  5523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5525. return
  5526. }
  5527. var respJSON map[string]interface{}
  5528. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5531. return
  5532. }
  5533. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5534. if status == "0" {
  5535. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5536. c.ServeSuccessJSON(map[string]interface{}{
  5537. "failed_code": -10,
  5538. "msg": err_msg,
  5539. })
  5540. return
  5541. }
  5542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5543. userJSONBytes, _ := json.Marshal(respJSON)
  5544. fmt.Println("log")
  5545. fmt.Println(string(userJSONBytes))
  5546. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5547. utils.ErrorLog("解析失败:%v", err)
  5548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5549. return
  5550. }
  5551. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5552. data := make(map[string]interface{})
  5553. client := &http.Client{}
  5554. data["psn_no"] = his.PsnNo
  5555. data["mdtrt_id"] = his.Number
  5556. data["operator"] = roles.UserName
  5557. data["cert_no"] = his.IdCardNo
  5558. data["org_name"] = miConfig.OrgName
  5559. data["psn_name"] = his.Name
  5560. data["ipt_otp_no"] = his.IptOtpNo
  5561. data["ipt_psn_sp_flag_type"] = "0901"
  5562. data["ipt_psn_sp_flag"] = "1"
  5563. data["fixmedins_code"] = miConfig.Code
  5564. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5565. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5566. data["url"] = miConfig.Url
  5567. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5568. bytesData, _ := json.Marshal(data)
  5569. var req *http.Request
  5570. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5571. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5572. resp, _ := client.Do(req)
  5573. defer resp.Body.Close()
  5574. body, ioErr := ioutil.ReadAll(resp.Body)
  5575. if ioErr != nil {
  5576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5578. return
  5579. }
  5580. var respJSON map[string]interface{}
  5581. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5584. return
  5585. }
  5586. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5587. if status == "0" {
  5588. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5589. c.ServeSuccessJSON(map[string]interface{}{
  5590. "failed_code": -10,
  5591. "msg": err_msg,
  5592. })
  5593. return
  5594. }
  5595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5596. userJSONBytes, _ := json.Marshal(respJSON)
  5597. fmt.Println("log")
  5598. fmt.Println(string(userJSONBytes))
  5599. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5600. utils.ErrorLog("解析失败:%v", err)
  5601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5602. return
  5603. }
  5604. }
  5605. if res2.Infcode != 0 {
  5606. adminUser := c.GetAdminUserInfo()
  5607. errlog := &models.HisOrderError{
  5608. UserOrgId: adminUser.CurrentOrgId,
  5609. Ctime: time.Now().Unix(),
  5610. Mtime: time.Now().Unix(),
  5611. ErrMsg: res2.ErrMsg,
  5612. Status: 1,
  5613. PatientId: id,
  5614. RecordTime: recordDateTime,
  5615. Stage: 3,
  5616. }
  5617. service.CreateErrMsgLog(errlog)
  5618. c.ServeSuccessJSON(map[string]interface{}{
  5619. "failed_code": -10,
  5620. "msg": res2.ErrMsg,
  5621. })
  5622. return
  5623. } else {
  5624. c.ServeSuccessJSON(map[string]interface{}{
  5625. "msg": "上传成功",
  5626. })
  5627. return
  5628. }
  5629. }
  5630. func (c *HisApiController) Get4105() {
  5631. }
  5632. func (c *HisApiController) Post5302() {
  5633. patient_id, _ := c.GetInt64("id")
  5634. admin_user_id, _ := c.GetInt64("admin_user_id")
  5635. p, _ := service.GetHisPatientById(patient_id)
  5636. adminUser := c.GetAdminUserInfo()
  5637. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5638. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5639. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5640. }
  5641. func (c *HisApiController) Get4104() {
  5642. }
  5643. type Output struct {
  5644. CertNo string `json:"certno"`
  5645. PsnName string `json:"psn_name"`
  5646. CardNo string `json:"card_no"`
  5647. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5648. CardSN string `json:"card_sn"`
  5649. PsnCertType string `json:"psn_cert_type"`
  5650. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5651. MdtrtCertType string `json:"mdtrt_cert_type"`
  5652. QRCode string `json:"qrCode"`
  5653. EcToken string `json:"ecToken"`
  5654. }
  5655. type AHResponse struct {
  5656. Body AHBody `json:"body"`
  5657. Code int `json:"code"`
  5658. CSBCode int `json:"csbCode"`
  5659. Message string `json:"message"`
  5660. RequestID string `json:"requestId"`
  5661. State struct{} `json:"state"`
  5662. }
  5663. type AHBody struct {
  5664. ErrMsg string `json:"err_msg"`
  5665. InfRefMsgID string `json:"inf_refmsgid"`
  5666. InfCode int `json:"infcode"`
  5667. Output struct {
  5668. Result []struct {
  5669. BasMednFlag string `json:"bas_medn_flag"`
  5670. ChldMedcFlag string `json:"chld_medc_flag"`
  5671. ChrgitmLv string `json:"chrgitm_lv"`
  5672. Cnt float64 `json:"cnt"`
  5673. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5674. DrtReimFlag string `json:"drt_reim_flag"`
  5675. FeedetlSn string `json:"feedetl_sn"`
  5676. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5677. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5678. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5679. ListSpItemFlag string `json:"list_sp_item_flag"`
  5680. LmtUsedFlag string `json:"lmt_used_flag"`
  5681. MedChrgitmType string `json:"med_chrgitm_type"`
  5682. Memo string `json:"memo"`
  5683. OverlmtAmt float64 `json:"overlmt_amt"`
  5684. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5685. Pric float64 `json:"pric"`
  5686. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5687. SelfpayProp float64 `json:"selfpay_prop"`
  5688. } `json:"result"`
  5689. } `json:"output"`
  5690. }
  5691. type Response struct {
  5692. Output Output `json:"output"`
  5693. Infcode int `json:"infcode"`
  5694. InfRefMsgID string `json:"inf_refmsgid"`
  5695. RefMsgTime string `json:"refmsg_time"`
  5696. RespondTime string `json:"respond_time"`
  5697. ErrMsg string `json:"err_msg"`
  5698. WarnMsg string `json:"warn_msg"`
  5699. SignType string `json:"signtype"`
  5700. CAInfo string `json:"cainfo"`
  5701. }
  5702. func (c *HisApiController) Getquerydata() {
  5703. query_type, _ := c.GetInt64("type")
  5704. refd_setl_flag := c.GetString("refd_setl_flag")
  5705. med_type := c.GetString("med_type")
  5706. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5707. cert_no := c.GetString("cert_no")
  5708. psn_no := c.GetString("psn_no")
  5709. start_time := c.GetString("start_time")
  5710. end_time := c.GetString("end_time")
  5711. page, _ := c.GetInt64("page")
  5712. limit, _ := c.GetInt64("limit")
  5713. var bp models.BusinessParams5262
  5714. bp.RefdSetlFlag = refd_setl_flag
  5715. bp.MedType = med_type
  5716. bp.Certno = cert_no
  5717. bp.Psnno = psn_no
  5718. bp.QBegntime = start_time
  5719. bp.QEndtime = end_time
  5720. if query_type == 1 { //本地
  5721. Post5262(c, bp, page, limit)
  5722. } else { //异地
  5723. Post5267(c, bp, page, limit)
  5724. }
  5725. }
  5726. func (c *HisApiController) Drugscheck() {
  5727. admin_user_id, _ := c.GetInt64("admin_user_id")
  5728. adminUser := c.GetAdminUserInfo()
  5729. var queryResult []QueryResult
  5730. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5731. for _, item := range drugs {
  5732. result := QueryResult{
  5733. ID: item.ID,
  5734. Name: item.DrugName,
  5735. Code: item.MedicalInsuranceNumber,
  5736. List_type_code: "101",
  5737. }
  5738. queryResult = append(queryResult, result)
  5739. }
  5740. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5741. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5742. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5743. for _, item := range queryResult {
  5744. 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)
  5745. }
  5746. }
  5747. func (c *HisApiController) Goodcheck() {
  5748. admin_user_id, _ := c.GetInt64("admin_user_id")
  5749. adminUser := c.GetAdminUserInfo()
  5750. var queryResult []QueryResult
  5751. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5752. for _, item := range goods {
  5753. result := QueryResult{
  5754. ID: item.ID,
  5755. Name: item.GoodName,
  5756. Code: item.SocialSecurityDirectoryCode,
  5757. List_type_code: "301",
  5758. }
  5759. queryResult = append(queryResult, result)
  5760. }
  5761. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5762. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5763. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5764. for _, item := range queryResult {
  5765. 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)
  5766. //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)
  5767. }
  5768. }
  5769. func (c *HisApiController) Projectcheck() {
  5770. admin_user_id, _ := c.GetInt64("admin_user_id")
  5771. adminUser := c.GetAdminUserInfo()
  5772. var queryResult []QueryResult
  5773. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5774. for _, item := range projects {
  5775. result := QueryResult{
  5776. ID: item.ID,
  5777. Name: item.ProjectName,
  5778. Code: item.MedicalCode,
  5779. List_type_code: "201",
  5780. }
  5781. queryResult = append(queryResult, result)
  5782. }
  5783. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5784. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5785. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5786. for _, item := range queryResult {
  5787. 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)
  5788. }
  5789. }
  5790. //func (c *HisApiController)CancleDia(){
  5791. //
  5792. // id, _ := c.GetInt64("id")
  5793. // record_time := c.GetString("record_time")
  5794. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5795. //
  5796. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5797. //
  5798. // diagnosis_id := c.GetString("diagnosis")
  5799. // sick_type, _ := c.GetInt64("sick_type")
  5800. // reg_type, _ := c.GetInt64("p_type")
  5801. // begin_time := c.GetString("begin_time")
  5802. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5803. //
  5804. //
  5805. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5806. //
  5807. // fmt.Println(acct_used_flag)
  5808. //
  5809. //
  5810. // timeLayout := "2006-01-02"
  5811. // loc, _ := time.LoadLocation("Local")
  5812. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5813. // if err != nil {
  5814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5815. // return
  5816. // }
  5817. // recordDateTime := theTime.Unix()
  5818. // adminUser := c.GetAdminUserInfo()
  5819. //
  5820. //
  5821. //
  5822. //
  5823. //
  5824. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5825. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5826. // var patientPrescription models.HisPrescriptionInfo
  5827. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5828. // if patientPrescription.ID == 0 {
  5829. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5830. // }
  5831. // //if patientPrescription.Do
  5832. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5833. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5834. //
  5835. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5836. //
  5837. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5838. //
  5839. // var config []*models.HisXtDiagnoseConfig
  5840. // for _, item := range diagnosis_ids {
  5841. // id, _ := strconv.ParseInt(item, 10, 64)
  5842. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5843. // config = append(config, &diagnosisConfig)
  5844. // }
  5845. //
  5846. // sickConfig, _ := service.FindSickById(sick_type)
  5847. //
  5848. //
  5849. // data := make(map[string]interface{})
  5850. // client := &http.Client{}
  5851. // data["psn_no"] = his.PsnNo
  5852. // data["mdtrt_id"] = his.Number
  5853. // data["doctor"] = roles.UserName
  5854. // data["department"] = department.Name
  5855. // data["org_name"] = miConfig.OrgName
  5856. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5857. // data["doctor_id"] = doctor_info.DoctorNumber
  5858. // data["new_doctor_name"] = doctor_info.UserName
  5859. // data["fixmedins_code"] = miConfig.Code
  5860. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5861. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5862. // data["secret_key"] = miConfig.SecretKey
  5863. // data["sick_code"] = sickConfig.CountryCode
  5864. // data["sick_name"] = sickConfig.ClassName
  5865. // data["url"] = miConfig.Url
  5866. // data["ak"] = miConfig.AccessKey
  5867. // data["begin_time"] = begin_time
  5868. // data["cainfo"] = miConfig.Cainfo
  5869. // data["is_vaild"] = "0"
  5870. //
  5871. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5872. // data["config"] = config
  5873. // bytesData, _ := json.Marshal(data)
  5874. //
  5875. // var req *http.Request
  5876. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5877. // resp, _ := client.Do(req)
  5878. // defer resp.Body.Close()
  5879. // body, ioErr := ioutil.ReadAll(resp.Body)
  5880. // if ioErr != nil {
  5881. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5882. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5883. // return
  5884. // }
  5885. // var respJSON map[string]interface{}
  5886. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5887. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5889. // return
  5890. // }
  5891. //
  5892. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5893. // userJSONBytes, _ := json.Marshal(respJSON)
  5894. // fmt.Println("log")
  5895. // fmt.Println(string(userJSONBytes))
  5896. //
  5897. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5898. // utils.ErrorLog("解析失败:%v", err)
  5899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5900. // return
  5901. // }
  5902. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5903. // res2.Output = ressix10265.Output
  5904. // res2.ErrMsg = ressix10265.ErrMsg
  5905. // res2.Cainfo = ressix10265.Cainfo
  5906. // res2.WarnMsg = ressix10265.WarnMsg
  5907. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5908. // res2.Infcode = infocode
  5909. //
  5910. //}
  5911. func (c *HisApiController) Get4102() {
  5912. order_id, _ := c.GetInt64("order_id")
  5913. admin_user_id, _ := c.GetInt64("admin_user_id")
  5914. stas_type := c.GetString("stas_type")
  5915. order, _ := service.GetHisOrderByIDTwo(order_id)
  5916. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5917. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5918. var pp models.PublicParams
  5919. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5920. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5921. pp.FixmedinsName = miConfig.OrgName
  5922. pp.FixmedinsCode = miConfig.Code
  5923. pp.RequestUrl = miConfig.Url
  5924. pp.Cainfo = miConfig.Cainfo
  5925. pp.SecretKey = miConfig.SecretKey
  5926. pp.AccessKey = miConfig.AccessKey
  5927. pp.OpterName = curRoles.UserName
  5928. if miConfig.MdtrtareaAdmvs == "350500" {
  5929. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5930. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5931. saveLog(result, request, "4102", "清单确认")
  5932. var dat map[string]interface{}
  5933. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5934. fmt.Println(dat)
  5935. } else {
  5936. fmt.Println(err)
  5937. }
  5938. var empty ResultFourteen
  5939. userJSONBytes, _ := json.Marshal(dat)
  5940. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5941. utils.ErrorLog("解析失败:%v", err)
  5942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5943. return
  5944. }
  5945. if empty.Infcode == 0 {
  5946. c.ServeSuccessJSON(map[string]interface{}{
  5947. "msg": "确认成功",
  5948. })
  5949. return
  5950. }
  5951. } else {
  5952. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5953. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5954. result3, request3 := service.Jxyb4105(pp)
  5955. saveLog(result, request, "4102", "清单确认")
  5956. saveLog(result2, request2, "4103", "清单确认")
  5957. saveLog(result3, request3, "4105", "清单统计")
  5958. var dat map[string]interface{}
  5959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5960. fmt.Println(dat)
  5961. } else {
  5962. fmt.Println(err)
  5963. }
  5964. var empty ResultFourteen
  5965. userJSONBytes, _ := json.Marshal(dat)
  5966. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5967. utils.ErrorLog("解析失败:%v", err)
  5968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5969. return
  5970. }
  5971. if empty.Infcode == 0 {
  5972. c.ServeSuccessJSON(map[string]interface{}{
  5973. "msg": "确认成功",
  5974. })
  5975. return
  5976. }
  5977. }
  5978. }
  5979. // 对账权限查询
  5980. func (c *HisApiController) Get3260() {
  5981. admin_user_id, _ := c.GetInt64("admin_user_id")
  5982. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5983. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5984. var api string
  5985. var res models.JSResult3260
  5986. if miConfig.MdtrtareaAdmvs == "320921" {
  5987. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5988. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5989. } else {
  5990. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5991. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5992. }
  5993. resp, requestErr := http.Get(api)
  5994. if requestErr != nil {
  5995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5996. return
  5997. }
  5998. body, ioErr := ioutil.ReadAll(resp.Body)
  5999. if ioErr != nil {
  6000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6002. return
  6003. }
  6004. var respJSON map[string]interface{}
  6005. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6008. return
  6009. }
  6010. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6011. result, _ := json.Marshal(respJSON)
  6012. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6013. utils.ErrorLog("解析失败:%v", err)
  6014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6015. return
  6016. }
  6017. if res.Infcode == "0" {
  6018. c.ServeSuccessJSON(map[string]interface{}{
  6019. "result": res.Output.Data,
  6020. })
  6021. } else {
  6022. c.ServeSuccessJSON(map[string]interface{}{
  6023. "failed_code": -10,
  6024. "msg": res.ErrMsg,
  6025. })
  6026. return
  6027. }
  6028. }
  6029. func (c *HisApiController) Get3261() {
  6030. admin_user_id, _ := c.GetInt64("admin_user_id")
  6031. //month := c.GetString("month")
  6032. startTime := c.GetString("start_time")
  6033. //endTime, _ := c.GetString("end_time")
  6034. times := strings.Split(startTime, "-")
  6035. stmt_mon := times[0] + times[1]
  6036. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6037. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6038. var api string
  6039. var res models.JSResult3261
  6040. //var res10265 Result5301For10265
  6041. if miConfig.MdtrtareaAdmvs == "320921" {
  6042. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6043. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6044. } else {
  6045. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6046. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6047. }
  6048. resp, requestErr := http.Get(api)
  6049. if requestErr != nil {
  6050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6051. return
  6052. }
  6053. body, ioErr := ioutil.ReadAll(resp.Body)
  6054. if ioErr != nil {
  6055. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6057. return
  6058. }
  6059. var respJSON map[string]interface{}
  6060. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6063. return
  6064. }
  6065. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6066. result, _ := json.Marshal(respJSON)
  6067. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6068. utils.ErrorLog("解析失败:%v", err)
  6069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6070. return
  6071. }
  6072. if res.Infcode == "0" {
  6073. c.ServeSuccessJSON(map[string]interface{}{
  6074. "result": res.Output,
  6075. })
  6076. } else {
  6077. c.ServeSuccessJSON(map[string]interface{}{
  6078. "failed_code": -10,
  6079. "msg": res.ErrMsg,
  6080. })
  6081. return
  6082. }
  6083. }
  6084. type TempFun struct {
  6085. FundKey string
  6086. FundCode string
  6087. }
  6088. func (c *HisApiController) Get3262() {
  6089. admin_user_id, _ := c.GetInt64("admin_user_id")
  6090. startTime := c.GetString("start_time")
  6091. endTime := c.GetString("end_time")
  6092. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6093. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6094. //timeLayout := "2006-01-02"
  6095. //loc, _ := time.LoadLocation("Local")
  6096. //var theStartTIme int64
  6097. //if len(startTime) > 0 {
  6098. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6099. // if err != nil {
  6100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6101. // return
  6102. // }
  6103. // theStartTIme = theTime.Unix()
  6104. //}
  6105. //var theEndtTIme int64
  6106. //if len(endTime) > 0 {
  6107. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6108. // if err != nil {
  6109. // utils.ErrorLog(err.Error())
  6110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6111. // return
  6112. // }
  6113. // theEndtTIme = theTime.Unix()
  6114. //}
  6115. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6116. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6117. for _, team := range datas {
  6118. fmt.Println(team.PsnTime)
  6119. for _, team_two := range datas_two {
  6120. fmt.Println(team_two.PsnTime)
  6121. if team.FundKey == team_two.FundKey {
  6122. fmt.Println(team_two.PsnTime)
  6123. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6124. fmt.Println(team.PsnTime)
  6125. }
  6126. }
  6127. }
  6128. fmt.Println("1111")
  6129. fmt.Println(datas)
  6130. fmt.Println("1111")
  6131. var twos []models.FixMonRecDetailFileInTwo
  6132. for _, team := range datas {
  6133. var two models.FixMonRecDetailFileInTwo
  6134. two.MedType = team.MedType
  6135. two.Insutype = team.Insutype
  6136. two.PsnType = team.PsnType
  6137. two.MedType = team.MedType
  6138. two.FixBlngAdmdvs = "999999"
  6139. two.InsuAdmdvs = "555555"
  6140. two.PsnTime = team.PsnTime
  6141. two.PsnCnt = team.PsnCnt
  6142. two.FundKey = team.FundKey
  6143. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6144. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6145. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6146. two.MedfeeSumAmt = ms
  6147. two.InscpAmt = ia
  6148. two.FundPaySumAmt = fps
  6149. twos = append(twos, two)
  6150. }
  6151. //startTime := c.GetString("start_time")
  6152. //endTime, _ := c.GetString("end_time")
  6153. times := strings.Split(startTime, "-")
  6154. stmt_mon := times[0] + times[1]
  6155. var funs []models.FundDetail
  6156. for _, item := range datas {
  6157. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6158. funs = append(funs, fun...)
  6159. }
  6160. var funInfos []models.Fund
  6161. //for _, item := range funs {
  6162. // var rf []models.FundInfo
  6163. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6164. // for _, subitem := range rf {
  6165. // var fund models.Fund
  6166. // fund.FundCode = subitem.FundPayType
  6167. // fund.FundName = subitem.FundPayTypeName
  6168. // fund.FundAmt = subitem.FundPayAmt
  6169. // fund.FundKey = item.FundKey
  6170. // fund.InsuAdmdvs = "555555"
  6171. // fund.FixBlngAdmdvs = "999999"
  6172. // funInfos = append(funInfos, fund)
  6173. // }
  6174. //}
  6175. var tempFuns []TempFun
  6176. for _, funInfo := range funInfos {
  6177. var tempFun TempFun
  6178. tempFun.FundKey = funInfo.FundKey
  6179. tempFun.FundCode = funInfo.FundCode
  6180. tempFuns = append(tempFuns, tempFun)
  6181. }
  6182. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6183. fmt.Println(tempFuns)
  6184. var funInfosTwo []models.Fund
  6185. decimal.DivisionPrecision = 2
  6186. for _, item := range tempFuns {
  6187. var fund models.Fund
  6188. for _, subItem := range funInfos {
  6189. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6190. fund.FundKey = subItem.FundKey
  6191. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6192. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6193. fund.FundName = subItem.FundName
  6194. fund.FundCode = subItem.FundCode
  6195. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6196. }
  6197. }
  6198. funInfosTwo = append(funInfosTwo, fund)
  6199. }
  6200. fmt.Println("funInfosTwo")
  6201. fmt.Println(funInfosTwo)
  6202. var upld_btch string
  6203. var empty models.JSResultEmpty
  6204. data := make(map[string]interface{})
  6205. data["org_name"] = miConfig.OrgName
  6206. data["doctor"] = curRoles.UserName
  6207. data["doctor_name"] = curRoles.UserName
  6208. data["fixmedins_code"] = miConfig.Code
  6209. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6210. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6211. data["secret_key"] = miConfig.SecretKey
  6212. data["url"] = miConfig.Url
  6213. data["ak"] = miConfig.AccessKey
  6214. data["cainfo"] = miConfig.Cainfo
  6215. data["datas"] = twos
  6216. data["fund"] = funInfosTwo
  6217. fmt.Println(twos)
  6218. month := time.Unix(1557042972, 0).Format("1")
  6219. year := time.Now().Format("2006")
  6220. month = time.Now().Format("01")
  6221. day := time.Now().Format("02")
  6222. hour := time.Now().Format("15")
  6223. min := time.Now().Format("04")
  6224. sec := time.Now().Format("05")
  6225. fix_fill_date := year + month + day + hour + min + sec
  6226. data["fix_fill_dept"] = miConfig.OrgName
  6227. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6228. data["fix_fill_psn"] = curRoles.UserName
  6229. data["fix_fill_date"] = fix_fill_date
  6230. data["stmt_loc"] = "2"
  6231. data["setl_mon"] = stmt_mon
  6232. upld_btch = "0"
  6233. data["upld_btch"] = upld_btch
  6234. //fmt.Println(data)
  6235. client := &http.Client{}
  6236. bytesData, _ := json.Marshal(data)
  6237. var req *http.Request
  6238. if miConfig.MdtrtareaAdmvs == "320921" {
  6239. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6240. } else {
  6241. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6242. }
  6243. resp, _ := client.Do(req)
  6244. defer resp.Body.Close()
  6245. body, ioErr := ioutil.ReadAll(resp.Body)
  6246. if ioErr != nil {
  6247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6249. }
  6250. var respJSON map[string]interface{}
  6251. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6254. }
  6255. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6256. //fmt.Println(respJSON)
  6257. result, _ := json.Marshal(respJSON)
  6258. //fmt.Println(result)
  6259. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6260. utils.ErrorLog("解析失败:%v", err)
  6261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6262. }
  6263. if empty.Infcode != "0" {
  6264. c.ServeSuccessJSON(map[string]interface{}{
  6265. "failed_code": -10,
  6266. "msg": empty.ErrMsg,
  6267. })
  6268. return
  6269. } else {
  6270. c.ServeSuccessJSON(map[string]interface{}{
  6271. "msg": "上传成功",
  6272. })
  6273. return
  6274. }
  6275. }
  6276. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6277. newArr = make([]TempFun, 0)
  6278. for i := 0; i < len(arr); i++ {
  6279. repeat := false
  6280. for j := i + 1; j < len(arr); j++ {
  6281. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6282. repeat = true
  6283. break
  6284. }
  6285. }
  6286. if !repeat {
  6287. newArr = append(newArr, arr[i])
  6288. }
  6289. }
  6290. return
  6291. }
  6292. func (c *HisApiController) Get3263() {
  6293. admin_user_id, _ := c.GetInt64("admin_user_id")
  6294. startTime := c.GetString("start_time")
  6295. //endTime, _ := c.GetString("end_time")
  6296. times := strings.Split(startTime, "-")
  6297. setl_mon := times[0] + times[1]
  6298. upld_btch := "0"
  6299. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6300. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6301. var result3263 models.JSResult3263
  6302. data := make(map[string]interface{})
  6303. data["org_name"] = miConfig.OrgName
  6304. data["doctor"] = curRoles.UserName
  6305. data["doctor_name"] = curRoles.UserName
  6306. data["fixmedins_code"] = miConfig.Code
  6307. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6308. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6309. data["secret_key"] = miConfig.SecretKey
  6310. data["url"] = miConfig.Url
  6311. data["ak"] = miConfig.AccessKey
  6312. data["cainfo"] = miConfig.Cainfo
  6313. data["setl_mon"] = setl_mon
  6314. data["stmt_loc"] = "2"
  6315. data["upld_btch"] = upld_btch
  6316. client := &http.Client{}
  6317. bytesData, _ := json.Marshal(data)
  6318. var req *http.Request
  6319. if miConfig.MdtrtareaAdmvs == "320921" {
  6320. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6321. } else {
  6322. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6323. }
  6324. resp, _ := client.Do(req)
  6325. defer resp.Body.Close()
  6326. body, ioErr := ioutil.ReadAll(resp.Body)
  6327. if ioErr != nil {
  6328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6330. }
  6331. var respJSON map[string]interface{}
  6332. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6335. }
  6336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6337. fmt.Println(respJSON)
  6338. result, _ := json.Marshal(respJSON)
  6339. fmt.Println(result)
  6340. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6341. utils.ErrorLog("解析失败:%v", err)
  6342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6343. }
  6344. if result3263.Infcode != "0" {
  6345. c.ServeSuccessJSON(map[string]interface{}{
  6346. "failed_code": -10,
  6347. "msg": result3263.ErrMsg,
  6348. })
  6349. return
  6350. } else {
  6351. c.ServeSuccessJSON(map[string]interface{}{
  6352. "list": result3263.Output,
  6353. })
  6354. return
  6355. }
  6356. }
  6357. func (c *HisApiController) Get3264() {
  6358. admin_user_id, _ := c.GetInt64("admin_user_id")
  6359. startTime := c.GetString("start_time")
  6360. //endTime, _ := c.GetString("end_time")
  6361. times := strings.Split(startTime, "-")
  6362. setl_mon := times[0] + times[1]
  6363. upld_btch := "0"
  6364. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6365. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6366. //solidify_id := []
  6367. var result3263 models.JSResult3263
  6368. data := make(map[string]interface{})
  6369. data["org_name"] = miConfig.OrgName
  6370. data["doctor"] = curRoles.UserName
  6371. data["doctor_name"] = curRoles.UserName
  6372. data["fixmedins_code"] = miConfig.Code
  6373. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6374. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6375. data["secret_key"] = miConfig.SecretKey
  6376. data["url"] = miConfig.Url
  6377. data["ak"] = miConfig.AccessKey
  6378. data["cainfo"] = miConfig.Cainfo
  6379. data["setl_mon"] = setl_mon
  6380. data["stmt_loc"] = "2"
  6381. data["upld_btch"] = upld_btch
  6382. client := &http.Client{}
  6383. bytesData, _ := json.Marshal(data)
  6384. var req3263 *http.Request
  6385. if miConfig.MdtrtareaAdmvs == "320921" {
  6386. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6387. } else {
  6388. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6389. }
  6390. resp, _ := client.Do(req3263)
  6391. defer resp.Body.Close()
  6392. body, ioErr := ioutil.ReadAll(resp.Body)
  6393. if ioErr != nil {
  6394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6396. }
  6397. var respJSON3263 map[string]interface{}
  6398. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6401. }
  6402. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6403. fmt.Println(respJSON3263)
  6404. result, _ := json.Marshal(respJSON3263)
  6405. fmt.Println(result)
  6406. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6407. utils.ErrorLog("解析失败:%v", err)
  6408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6409. }
  6410. var ids []string
  6411. for _, item := range result3263.Output {
  6412. ids = append(ids, item.SolidifyID)
  6413. }
  6414. var empty models.JSResultEmpty
  6415. data2 := make(map[string]interface{})
  6416. data2["org_name"] = miConfig.OrgName
  6417. data2["doctor"] = curRoles.UserName
  6418. data2["doctor_name"] = curRoles.UserName
  6419. data2["fixmedins_code"] = miConfig.Code
  6420. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6421. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6422. data2["secret_key"] = miConfig.SecretKey
  6423. data2["url"] = miConfig.Url
  6424. data2["ak"] = miConfig.AccessKey
  6425. data2["cainfo"] = miConfig.Cainfo
  6426. data2["setl_mon"] = setl_mon
  6427. data2["stmt_loc"] = "2"
  6428. data2["upld_btch"] = upld_btch
  6429. data2["solidify_id"] = ids
  6430. client2 := &http.Client{}
  6431. bytesData2, _ := json.Marshal(data2)
  6432. var req *http.Request
  6433. if miConfig.MdtrtareaAdmvs == "320921" {
  6434. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6435. } else {
  6436. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6437. }
  6438. resp2, _ := client2.Do(req)
  6439. defer resp.Body.Close()
  6440. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6441. if ioErr2 != nil {
  6442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6444. }
  6445. var respJSON map[string]interface{}
  6446. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6449. }
  6450. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6451. fmt.Println(respJSON)
  6452. result2, _ := json.Marshal(respJSON)
  6453. fmt.Println(result2)
  6454. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6455. utils.ErrorLog("解析失败:%v", err)
  6456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6457. }
  6458. if empty.Infcode != "0" {
  6459. c.ServeSuccessJSON(map[string]interface{}{
  6460. "failed_code": -10,
  6461. "msg": empty.ErrMsg,
  6462. })
  6463. return
  6464. } else {
  6465. c.ServeSuccessJSON(map[string]interface{}{
  6466. "msg": "",
  6467. })
  6468. return
  6469. }
  6470. }
  6471. func (c *HisApiController) Get3265() {
  6472. admin_user_id, _ := c.GetInt64("admin_user_id")
  6473. startTime := c.GetString("start_time")
  6474. //endTime, _ := c.GetString("end_time")
  6475. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6476. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6477. times := strings.Split(startTime, "-")
  6478. setl_mon := times[0] + times[1]
  6479. var upld_btch string
  6480. upld_btch = "0"
  6481. //var empty models.JSResultEmpty
  6482. var result3265 models.JSResult3264
  6483. var result3263 models.JSResult3263
  6484. data2 := make(map[string]interface{})
  6485. data2["org_name"] = miConfig.OrgName
  6486. data2["doctor"] = curRoles.UserName
  6487. data2["doctor_name"] = curRoles.UserName
  6488. data2["fixmedins_code"] = miConfig.Code
  6489. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6490. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6491. data2["secret_key"] = miConfig.SecretKey
  6492. data2["url"] = miConfig.Url
  6493. data2["ak"] = miConfig.AccessKey
  6494. data2["cainfo"] = miConfig.Cainfo
  6495. data2["setl_mon"] = setl_mon
  6496. data2["stmt_loc"] = "2"
  6497. data2["upld_btch"] = upld_btch
  6498. client2 := &http.Client{}
  6499. bytesData2, _ := json.Marshal(data2)
  6500. var req3263 *http.Request
  6501. if miConfig.MdtrtareaAdmvs == "320921" {
  6502. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6503. } else {
  6504. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6505. }
  6506. resp2, _ := client2.Do(req3263)
  6507. defer resp2.Body.Close()
  6508. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6509. if ioErr2 != nil {
  6510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6512. }
  6513. var respJSON3263 map[string]interface{}
  6514. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6517. }
  6518. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6519. fmt.Println(respJSON3263)
  6520. result2, _ := json.Marshal(respJSON3263)
  6521. fmt.Println(result2)
  6522. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6523. utils.ErrorLog("解析失败:%v", err)
  6524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6525. }
  6526. var ids []string
  6527. for _, item := range result3263.Output {
  6528. ids = append(ids, item.SolidifyID)
  6529. }
  6530. data := make(map[string]interface{})
  6531. data["org_name"] = miConfig.OrgName
  6532. data["doctor"] = curRoles.UserName
  6533. data["doctor_name"] = curRoles.UserName
  6534. data["fixmedins_code"] = miConfig.Code
  6535. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6536. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6537. data["secret_key"] = miConfig.SecretKey
  6538. data["url"] = miConfig.Url
  6539. data["ak"] = miConfig.AccessKey
  6540. data["cainfo"] = miConfig.Cainfo
  6541. data["setl_mon"] = setl_mon
  6542. data["solidify_id"] = ids
  6543. month := time.Unix(1557042972, 0).Format("1")
  6544. year := time.Now().Format("2006")
  6545. month = time.Now().Format("01")
  6546. day := time.Now().Format("02")
  6547. hour := time.Now().Format("15")
  6548. min := time.Now().Format("04")
  6549. sec := time.Now().Format("05")
  6550. fix_fill_date := year + month + day + hour + min + sec
  6551. data["fix_fill_dept"] = miConfig.OrgName
  6552. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6553. data["fix_fill_psn"] = curRoles.UserName
  6554. data["fix_fill_date"] = fix_fill_date
  6555. data["stmt_loc"] = "2"
  6556. data["upld_btch"] = upld_btch
  6557. client := &http.Client{}
  6558. bytesData, _ := json.Marshal(data)
  6559. var req *http.Request
  6560. if miConfig.MdtrtareaAdmvs == "320921" {
  6561. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6562. } else {
  6563. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6564. }
  6565. resp, _ := client.Do(req)
  6566. defer resp.Body.Close()
  6567. body, ioErr := ioutil.ReadAll(resp.Body)
  6568. if ioErr != nil {
  6569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6571. }
  6572. var respJSON map[string]interface{}
  6573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6576. }
  6577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6578. fmt.Println(respJSON)
  6579. result, _ := json.Marshal(respJSON)
  6580. fmt.Println(result)
  6581. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6582. utils.ErrorLog("解析失败:%v", err)
  6583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6584. }
  6585. if result3265.Infcode != "0" {
  6586. c.ServeSuccessJSON(map[string]interface{}{
  6587. "failed_code": -10,
  6588. "msg": result3265.ErrMsg,
  6589. })
  6590. return
  6591. } else {
  6592. c.ServeSuccessJSON(map[string]interface{}{
  6593. "info": result3265.Output,
  6594. })
  6595. return
  6596. }
  6597. }
  6598. func (c *HisApiController) Get3266() {
  6599. admin_user_id, _ := c.GetInt64("admin_user_id")
  6600. startTime := c.GetString("start_time")
  6601. //endTime, _ := c.GetString("end_time")
  6602. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6603. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6604. times := strings.Split(startTime, "-")
  6605. stmt_mon := times[0] + times[1]
  6606. var upld_btch string
  6607. //var empty models.JSResultEmpty
  6608. var result3265 models.JSResult3264
  6609. data := make(map[string]interface{})
  6610. data["org_name"] = miConfig.OrgName
  6611. data["doctor"] = curRoles.UserName
  6612. data["doctor_name"] = curRoles.UserName
  6613. data["fixmedins_code"] = miConfig.Code
  6614. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6615. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6616. data["secret_key"] = miConfig.SecretKey
  6617. data["url"] = miConfig.Url
  6618. data["ak"] = miConfig.AccessKey
  6619. data["cainfo"] = miConfig.Cainfo
  6620. data["setl_mon"] = stmt_mon
  6621. month := time.Unix(1557042972, 0).Format("1")
  6622. year := time.Now().Format("2006")
  6623. month = time.Now().Format("01")
  6624. day := time.Now().Format("02")
  6625. hour := time.Now().Format("15")
  6626. min := time.Now().Format("04")
  6627. sec := time.Now().Format("05")
  6628. fix_fill_date := year + month + day + hour + min + sec
  6629. data["fix_fill_dept"] = miConfig.OrgName
  6630. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6631. data["fix_fill_psn"] = curRoles.UserName
  6632. data["fix_fill_date"] = fix_fill_date
  6633. data["stmt_loc"] = "2"
  6634. upld_btch = "0"
  6635. data["upld_btch"] = upld_btch
  6636. client := &http.Client{}
  6637. bytesData, _ := json.Marshal(data)
  6638. var req *http.Request
  6639. if miConfig.MdtrtareaAdmvs == "320921" {
  6640. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6641. } else {
  6642. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6643. }
  6644. resp, _ := client.Do(req)
  6645. defer resp.Body.Close()
  6646. body, ioErr := ioutil.ReadAll(resp.Body)
  6647. if ioErr != nil {
  6648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6650. }
  6651. var respJSON map[string]interface{}
  6652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6655. }
  6656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6657. fmt.Println(respJSON)
  6658. result, _ := json.Marshal(respJSON)
  6659. fmt.Println(result)
  6660. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6661. utils.ErrorLog("解析失败:%v", err)
  6662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6663. }
  6664. if result3265.Infcode != "0" {
  6665. c.ServeSuccessJSON(map[string]interface{}{
  6666. "failed_code": -10,
  6667. "msg": result3265.ErrMsg,
  6668. })
  6669. return
  6670. } else {
  6671. c.ServeSuccessJSON(map[string]interface{}{
  6672. "info": result3265.Output,
  6673. })
  6674. return
  6675. }
  6676. }
  6677. func (c *HisApiController) Get3267() {
  6678. admin_user_id, _ := c.GetInt64("admin_user_id")
  6679. startTime := c.GetString("start_time")
  6680. //endTime, _ := c.GetString("end_time")
  6681. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6682. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6683. times := strings.Split(startTime, "-")
  6684. setl_mon := times[0] + times[1]
  6685. var upld_btch string
  6686. //var empty models.JSResultEmpty
  6687. var result3265 models.JSResult3264
  6688. upld_btch = "0"
  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 == "320921" {
  6707. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6708. } else {
  6709. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6710. }
  6711. resp, _ := client.Do(req)
  6712. defer resp.Body.Close()
  6713. body, ioErr := ioutil.ReadAll(resp.Body)
  6714. if ioErr != nil {
  6715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6717. }
  6718. var respJSON map[string]interface{}
  6719. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6722. }
  6723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6724. fmt.Println(respJSON)
  6725. result, _ := json.Marshal(respJSON)
  6726. fmt.Println(result)
  6727. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6728. utils.ErrorLog("解析失败:%v", err)
  6729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6730. }
  6731. if result3265.Infcode != "0" {
  6732. c.ServeSuccessJSON(map[string]interface{}{
  6733. "failed_code": -10,
  6734. "msg": result3265.ErrMsg,
  6735. })
  6736. return
  6737. } else {
  6738. c.ServeSuccessJSON(map[string]interface{}{
  6739. "info": result3265.Output.Data,
  6740. })
  6741. return
  6742. }
  6743. }
  6744. func (c *HisApiController) Get3268() {
  6745. admin_user_id, _ := c.GetInt64("admin_user_id")
  6746. startTime := c.GetString("start_time")
  6747. endTime := c.GetString("end_time")
  6748. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6749. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6750. times := strings.Split(startTime, "-")
  6751. setl_mon := times[0] + times[1]
  6752. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6753. var twos []models.FixMonRecDetailFileInTwo
  6754. var funs []models.FundDetail
  6755. for _, item := range datas {
  6756. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6757. funs = append(funs, fun...)
  6758. }
  6759. var funInfos []models.Fund
  6760. //for _, item := range funs {
  6761. // var rf []models.FundInfo
  6762. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6763. // for _, subitem := range rf {
  6764. // var fund models.Fund
  6765. // fund.FundCode = subitem.FundPayType
  6766. // fund.FundName = subitem.FundPayTypeName
  6767. // fund.FundAmt = subitem.FundPayAmt
  6768. // fund.FundKey = item.FundKey
  6769. // fund.InsuAdmdvs = "555555"
  6770. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6771. // funInfos = append(funInfos, fund)
  6772. // }
  6773. //}
  6774. for _, team := range datas {
  6775. var two models.FixMonRecDetailFileInTwo
  6776. two.SetlDate = time.Now().Format("2006-01-02")
  6777. two.MedType = team.MedType
  6778. two.Insutype = team.Insutype
  6779. two.PsnType = team.PsnType
  6780. two.MedType = team.MedType
  6781. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6782. two.InsuAdmdvs = team.InsuAdmdvs
  6783. two.PsnTime = team.PsnTime
  6784. two.PsnCnt = team.PsnCnt
  6785. two.FundKey = team.FundKey
  6786. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6787. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6788. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6789. two.MedfeeSumAmt = ms
  6790. two.InscpAmt = ia
  6791. two.FundPaySumAmt = fps
  6792. twos = append(twos, two)
  6793. }
  6794. var upld_btch string
  6795. upld_btch = "0"
  6796. var empty models.JSResultEmpty
  6797. data := make(map[string]interface{})
  6798. data["org_name"] = miConfig.OrgName
  6799. data["doctor"] = curRoles.UserName
  6800. data["doctor_name"] = curRoles.UserName
  6801. data["fixmedins_code"] = miConfig.Code
  6802. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6803. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6804. data["secret_key"] = miConfig.SecretKey
  6805. data["url"] = miConfig.Url
  6806. data["ak"] = miConfig.AccessKey
  6807. data["cainfo"] = miConfig.Cainfo
  6808. data["datas"] = twos
  6809. data["fund"] = funInfos
  6810. data["setl_mon"] = setl_mon
  6811. month := time.Unix(1557042972, 0).Format("1")
  6812. year := time.Now().Format("2006")
  6813. month = time.Now().Format("01")
  6814. day := time.Now().Format("02")
  6815. hour := time.Now().Format("15")
  6816. min := time.Now().Format("04")
  6817. sec := time.Now().Format("05")
  6818. fix_fill_date := year + month + day + hour + min + sec
  6819. data["fix_fill_dept"] = miConfig.OrgName
  6820. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6821. data["fix_fill_psn"] = curRoles.UserName
  6822. data["fix_fill_date"] = fix_fill_date
  6823. data["stmt_loc"] = "2"
  6824. data["upld_btch"] = upld_btch
  6825. client := &http.Client{}
  6826. bytesData, _ := json.Marshal(data)
  6827. var req *http.Request
  6828. if miConfig.MdtrtareaAdmvs == "320921" {
  6829. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6830. } else {
  6831. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6832. }
  6833. resp, _ := client.Do(req)
  6834. defer resp.Body.Close()
  6835. body, ioErr := ioutil.ReadAll(resp.Body)
  6836. if ioErr != nil {
  6837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6839. }
  6840. var respJSON map[string]interface{}
  6841. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6844. }
  6845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6846. fmt.Println(respJSON)
  6847. result, _ := json.Marshal(respJSON)
  6848. fmt.Println(result)
  6849. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6850. utils.ErrorLog("解析失败:%v", err)
  6851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6852. }
  6853. if empty.Infcode != "0" {
  6854. c.ServeSuccessJSON(map[string]interface{}{
  6855. "failed_code": -10,
  6856. "msg": empty.ErrMsg,
  6857. })
  6858. return
  6859. } else {
  6860. c.ServeSuccessJSON(map[string]interface{}{
  6861. "msg": "上传成功",
  6862. })
  6863. return
  6864. }
  6865. }
  6866. func (c *HisApiController) Get3269() {
  6867. admin_user_id, _ := c.GetInt64("admin_user_id")
  6868. startTime := c.GetString("start_time")
  6869. //endTime, _ := c.GetString("end_time")
  6870. times := strings.Split(startTime, "-")
  6871. setl_mon := times[0] + times[1]
  6872. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6873. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6874. var result3263 models.JSResult3263
  6875. data := make(map[string]interface{})
  6876. data["org_name"] = miConfig.OrgName
  6877. data["doctor"] = curRoles.UserName
  6878. data["doctor_name"] = curRoles.UserName
  6879. data["fixmedins_code"] = miConfig.Code
  6880. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6881. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6882. data["secret_key"] = miConfig.SecretKey
  6883. data["url"] = miConfig.Url
  6884. data["ak"] = miConfig.AccessKey
  6885. data["cainfo"] = miConfig.Cainfo
  6886. data["setl_mon"] = setl_mon
  6887. data["stmt_loc"] = "2"
  6888. client := &http.Client{}
  6889. bytesData, _ := json.Marshal(data)
  6890. var req *http.Request
  6891. if miConfig.MdtrtareaAdmvs == "320921" {
  6892. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6893. } else {
  6894. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6895. }
  6896. resp, _ := client.Do(req)
  6897. defer resp.Body.Close()
  6898. body, ioErr := ioutil.ReadAll(resp.Body)
  6899. if ioErr != nil {
  6900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6902. }
  6903. var respJSON map[string]interface{}
  6904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. }
  6908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6909. fmt.Println(respJSON)
  6910. result, _ := json.Marshal(respJSON)
  6911. fmt.Println(result)
  6912. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6913. utils.ErrorLog("解析失败:%v", err)
  6914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6915. }
  6916. if result3263.Infcode != "0" {
  6917. c.ServeSuccessJSON(map[string]interface{}{
  6918. "failed_code": -10,
  6919. "msg": result3263.ErrMsg,
  6920. })
  6921. return
  6922. } else {
  6923. c.ServeSuccessJSON(map[string]interface{}{
  6924. "msg": "上传成功",
  6925. })
  6926. return
  6927. }
  6928. }
  6929. func (c *HisApiController) Get3270() {
  6930. admin_user_id, _ := c.GetInt64("admin_user_id")
  6931. startTime := c.GetString("start_time")
  6932. //endTime, _ := c.GetString("end_time")
  6933. times := strings.Split(startTime, "-")
  6934. setl_mon := times[0] + times[1]
  6935. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6936. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6937. var result3263 models.JSResult3263
  6938. data2 := make(map[string]interface{})
  6939. data2["org_name"] = miConfig.OrgName
  6940. data2["doctor"] = curRoles.UserName
  6941. data2["doctor_name"] = curRoles.UserName
  6942. data2["fixmedins_code"] = miConfig.Code
  6943. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6944. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6945. data2["secret_key"] = miConfig.SecretKey
  6946. data2["url"] = miConfig.Url
  6947. data2["ak"] = miConfig.AccessKey
  6948. data2["cainfo"] = miConfig.Cainfo
  6949. data2["setl_mon"] = setl_mon
  6950. data2["stmt_loc"] = "2"
  6951. client2 := &http.Client{}
  6952. bytesData2, _ := json.Marshal(data2)
  6953. var req3263 *http.Request
  6954. if miConfig.MdtrtareaAdmvs == "320921" {
  6955. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6956. } else {
  6957. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6958. }
  6959. resp2, _ := client2.Do(req3263)
  6960. defer resp2.Body.Close()
  6961. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6962. if ioErr2 != nil {
  6963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6965. }
  6966. var respJSON3263 map[string]interface{}
  6967. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6970. }
  6971. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6972. fmt.Println(respJSON3263)
  6973. result2, _ := json.Marshal(respJSON3263)
  6974. fmt.Println(result2)
  6975. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6976. utils.ErrorLog("解析失败:%v", err)
  6977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6978. }
  6979. var ids []string
  6980. for _, item := range result3263.Output {
  6981. ids = append(ids, item.SolidifyID)
  6982. }
  6983. var result3264 models.JSResult3264
  6984. data := make(map[string]interface{})
  6985. data["org_name"] = miConfig.OrgName
  6986. data["doctor"] = curRoles.UserName
  6987. data["doctor_name"] = curRoles.UserName
  6988. data["fixmedins_code"] = miConfig.Code
  6989. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6990. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6991. data["secret_key"] = miConfig.SecretKey
  6992. data["url"] = miConfig.Url
  6993. data["ak"] = miConfig.AccessKey
  6994. data["cainfo"] = miConfig.Cainfo
  6995. data["setl_mon"] = setl_mon
  6996. data["stmt_loc"] = "2"
  6997. data["solidify_id"] = ids
  6998. client := &http.Client{}
  6999. bytesData, _ := json.Marshal(data)
  7000. var req *http.Request
  7001. if miConfig.MdtrtareaAdmvs == "320921" {
  7002. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7003. } else {
  7004. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7005. }
  7006. resp, _ := client.Do(req)
  7007. defer resp.Body.Close()
  7008. body, ioErr := ioutil.ReadAll(resp.Body)
  7009. if ioErr != nil {
  7010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7012. }
  7013. var respJSON map[string]interface{}
  7014. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7017. }
  7018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7019. fmt.Println(respJSON)
  7020. result, _ := json.Marshal(respJSON)
  7021. fmt.Println(result)
  7022. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7023. utils.ErrorLog("解析失败:%v", err)
  7024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7025. }
  7026. if result3264.Infcode != "0" {
  7027. c.ServeSuccessJSON(map[string]interface{}{
  7028. "failed_code": -10,
  7029. "msg": result3264.ErrMsg,
  7030. })
  7031. return
  7032. } else {
  7033. c.ServeSuccessJSON(map[string]interface{}{
  7034. "info": result3264.Output,
  7035. })
  7036. return
  7037. }
  7038. }
  7039. func (c *HisApiController) Get3271() {
  7040. admin_user_id, _ := c.GetInt64("admin_user_id")
  7041. startTime := c.GetString("start_time")
  7042. //endTime, _ := c.GetString("end_time")
  7043. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7044. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7045. times := strings.Split(startTime, "-")
  7046. setl_mon := times[0] + times[1]
  7047. //var empty models.JSResultEmpty
  7048. var result3265 models.JSResult3264
  7049. var result3263 models.JSResult3263
  7050. data2 := make(map[string]interface{})
  7051. data2["org_name"] = miConfig.OrgName
  7052. data2["doctor"] = curRoles.UserName
  7053. data2["doctor_name"] = curRoles.UserName
  7054. data2["fixmedins_code"] = miConfig.Code
  7055. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7056. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7057. data2["secret_key"] = miConfig.SecretKey
  7058. data2["url"] = miConfig.Url
  7059. data2["ak"] = miConfig.AccessKey
  7060. data2["cainfo"] = miConfig.Cainfo
  7061. data2["setl_mon"] = setl_mon
  7062. data2["stmt_loc"] = "2"
  7063. client2 := &http.Client{}
  7064. bytesData2, _ := json.Marshal(data2)
  7065. var req3263 *http.Request
  7066. if miConfig.MdtrtareaAdmvs == "320921" {
  7067. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7068. } else {
  7069. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7070. }
  7071. resp2, _ := client2.Do(req3263)
  7072. defer resp2.Body.Close()
  7073. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7074. if ioErr2 != nil {
  7075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7077. }
  7078. var respJSON3263 map[string]interface{}
  7079. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7082. }
  7083. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7084. fmt.Println(respJSON3263)
  7085. result2, _ := json.Marshal(respJSON3263)
  7086. fmt.Println(result2)
  7087. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7088. utils.ErrorLog("解析失败:%v", err)
  7089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7090. }
  7091. var ids []string
  7092. for _, item := range result3263.Output {
  7093. ids = append(ids, item.SolidifyID)
  7094. }
  7095. data := make(map[string]interface{})
  7096. data["org_name"] = miConfig.OrgName
  7097. data["doctor"] = curRoles.UserName
  7098. data["doctor_name"] = curRoles.UserName
  7099. data["fixmedins_code"] = miConfig.Code
  7100. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7101. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7102. data["secret_key"] = miConfig.SecretKey
  7103. data["url"] = miConfig.Url
  7104. data["ak"] = miConfig.AccessKey
  7105. data["cainfo"] = miConfig.Cainfo
  7106. data["setl_mon"] = setl_mon
  7107. data["solidify_id"] = ids
  7108. month := time.Unix(1557042972, 0).Format("1")
  7109. year := time.Now().Format("2006")
  7110. month = time.Now().Format("01")
  7111. day := time.Now().Format("02")
  7112. hour := time.Now().Format("15")
  7113. min := time.Now().Format("04")
  7114. sec := time.Now().Format("05")
  7115. fix_fill_date := year + month + day + hour + min + sec
  7116. data["fix_fill_dept"] = miConfig.OrgName
  7117. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7118. data["fix_fill_psn"] = curRoles.UserName
  7119. data["fix_fill_date"] = fix_fill_date
  7120. data["stmt_loc"] = "2"
  7121. client := &http.Client{}
  7122. bytesData, _ := json.Marshal(data)
  7123. var req *http.Request
  7124. if miConfig.MdtrtareaAdmvs == "320921" {
  7125. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7126. } else {
  7127. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7128. }
  7129. resp, _ := client.Do(req)
  7130. defer resp.Body.Close()
  7131. body, ioErr := ioutil.ReadAll(resp.Body)
  7132. if ioErr != nil {
  7133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7135. }
  7136. var respJSON map[string]interface{}
  7137. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7140. }
  7141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7142. fmt.Println(respJSON)
  7143. result, _ := json.Marshal(respJSON)
  7144. fmt.Println(result)
  7145. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7146. utils.ErrorLog("解析失败:%v", err)
  7147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7148. }
  7149. if result3265.Infcode != "0" {
  7150. c.ServeSuccessJSON(map[string]interface{}{
  7151. "failed_code": -10,
  7152. "msg": result3265.ErrMsg,
  7153. })
  7154. return
  7155. } else {
  7156. c.ServeSuccessJSON(map[string]interface{}{
  7157. "info": result3265.Output.Data,
  7158. })
  7159. return
  7160. }
  7161. }
  7162. func (c *HisApiController) Get3272() {
  7163. admin_user_id, _ := c.GetInt64("admin_user_id")
  7164. startTime := c.GetString("start_time")
  7165. //endTime, _ := c.GetString("end_time")
  7166. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7167. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7168. times := strings.Split(startTime, "-")
  7169. setl_mon := times[0] + times[1]
  7170. var upld_btch string
  7171. //var empty models.JSResultEmpty
  7172. var result3265 models.JSResult3264
  7173. data := make(map[string]interface{})
  7174. data["org_name"] = miConfig.OrgName
  7175. data["doctor"] = curRoles.UserName
  7176. data["doctor_name"] = curRoles.UserName
  7177. data["fixmedins_code"] = miConfig.Code
  7178. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7179. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7180. data["secret_key"] = miConfig.SecretKey
  7181. data["url"] = miConfig.Url
  7182. data["ak"] = miConfig.AccessKey
  7183. data["cainfo"] = miConfig.Cainfo
  7184. data["setl_mon"] = setl_mon
  7185. month := time.Unix(1557042972, 0).Format("1")
  7186. year := time.Now().Format("2006")
  7187. month = time.Now().Format("01")
  7188. day := time.Now().Format("02")
  7189. hour := time.Now().Format("15")
  7190. min := time.Now().Format("04")
  7191. sec := time.Now().Format("05")
  7192. fix_fill_date := year + month + day + hour + min + sec
  7193. data["fix_fill_dept"] = miConfig.OrgName
  7194. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7195. data["fix_fill_psn"] = curRoles.UserName
  7196. data["fix_fill_date"] = fix_fill_date
  7197. data["stmt_loc"] = "2"
  7198. data["upld_btch"] = upld_btch
  7199. client := &http.Client{}
  7200. bytesData, _ := json.Marshal(data)
  7201. var req *http.Request
  7202. if miConfig.MdtrtareaAdmvs == "320921" {
  7203. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7204. } else {
  7205. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7206. }
  7207. resp, _ := client.Do(req)
  7208. defer resp.Body.Close()
  7209. body, ioErr := ioutil.ReadAll(resp.Body)
  7210. if ioErr != nil {
  7211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7213. }
  7214. var respJSON map[string]interface{}
  7215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7218. }
  7219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7220. fmt.Println(respJSON)
  7221. result, _ := json.Marshal(respJSON)
  7222. fmt.Println(result)
  7223. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7224. utils.ErrorLog("解析失败:%v", err)
  7225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7226. }
  7227. if result3265.Infcode != "0" {
  7228. c.ServeSuccessJSON(map[string]interface{}{
  7229. "failed_code": -10,
  7230. "msg": result3265.ErrMsg,
  7231. })
  7232. return
  7233. } else {
  7234. c.ServeSuccessJSON(map[string]interface{}{
  7235. "info": result3265.Output,
  7236. })
  7237. return
  7238. }
  7239. }
  7240. func (c *HisApiController) Get3273() {
  7241. admin_user_id, _ := c.GetInt64("admin_user_id")
  7242. startTime := c.GetString("start_time")
  7243. //endTime, _ := c.GetString("end_time")
  7244. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7245. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7246. times := strings.Split(startTime, "-")
  7247. setl_mon := times[0] + times[1]
  7248. var result3265 models.JSResult3264
  7249. data := make(map[string]interface{})
  7250. data["org_name"] = miConfig.OrgName
  7251. data["doctor"] = curRoles.UserName
  7252. data["doctor_name"] = curRoles.UserName
  7253. data["fixmedins_code"] = miConfig.Code
  7254. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7255. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7256. data["secret_key"] = miConfig.SecretKey
  7257. data["url"] = miConfig.Url
  7258. data["ak"] = miConfig.AccessKey
  7259. data["cainfo"] = miConfig.Cainfo
  7260. data["setl_mon"] = setl_mon
  7261. data["stmt_loc"] = "2"
  7262. client := &http.Client{}
  7263. bytesData, _ := json.Marshal(data)
  7264. var req *http.Request
  7265. if miConfig.MdtrtareaAdmvs == "320921" {
  7266. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7267. } else {
  7268. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7269. }
  7270. resp, _ := client.Do(req)
  7271. defer resp.Body.Close()
  7272. body, ioErr := ioutil.ReadAll(resp.Body)
  7273. if ioErr != nil {
  7274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7276. }
  7277. var respJSON map[string]interface{}
  7278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7281. }
  7282. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7283. fmt.Println(respJSON)
  7284. result, _ := json.Marshal(respJSON)
  7285. fmt.Println(result)
  7286. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7287. utils.ErrorLog("解析失败:%v", err)
  7288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7289. }
  7290. if result3265.Infcode != "0" {
  7291. c.ServeSuccessJSON(map[string]interface{}{
  7292. "failed_code": -10,
  7293. "msg": result3265.ErrMsg,
  7294. })
  7295. return
  7296. } else {
  7297. c.ServeSuccessJSON(map[string]interface{}{
  7298. "info": result3265.Output.Data,
  7299. })
  7300. return
  7301. }
  7302. }
  7303. func (c *HisApiController) Get3274() {
  7304. //if miConfig.MdtrtareaAdmvs == "320921" {
  7305. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7306. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7307. // "&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
  7308. //
  7309. //} else {
  7310. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7311. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7312. // "&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
  7313. //
  7314. //}
  7315. }
  7316. func (c *HisApiController) Get3275() {
  7317. //if miConfig.MdtrtareaAdmvs == "320921" {
  7318. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7319. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7320. // "&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
  7321. //
  7322. //} else {
  7323. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7324. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7325. // "&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
  7326. //
  7327. //}
  7328. }
  7329. func (c *HisApiController) Get3276() {
  7330. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7331. //month := c.GetString("month")
  7332. //
  7333. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7334. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7335. //var api string
  7336. //var res Result5301
  7337. //
  7338. //if miConfig.MdtrtareaAdmvs == "320921" {
  7339. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7340. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7341. //} else {
  7342. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7343. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7344. //}
  7345. //
  7346. //resp, requestErr := http.Get(api)
  7347. //if requestErr != nil {
  7348. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. // return
  7350. //}
  7351. //
  7352. //body, ioErr := ioutil.ReadAll(resp.Body)
  7353. //if ioErr != nil {
  7354. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7356. // return
  7357. //}
  7358. //var respJSON map[string]interface{}
  7359. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7360. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7362. // return
  7363. //}
  7364. //
  7365. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7366. //result, _ := json.Marshal(respJSON)
  7367. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7368. // utils.ErrorLog("解析失败:%v", err)
  7369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7370. // return
  7371. //}
  7372. }
  7373. func (c *HisApiController) Get3277() {
  7374. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7375. //month := c.GetString("month")
  7376. //
  7377. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7378. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7379. //var api string
  7380. //var res Result5301
  7381. //
  7382. //if miConfig.MdtrtareaAdmvs == "320921" {
  7383. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7384. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7385. //} else {
  7386. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7387. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7388. //}
  7389. //
  7390. //resp, requestErr := http.Get(api)
  7391. //if requestErr != nil {
  7392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7393. // return
  7394. //}
  7395. //
  7396. //body, ioErr := ioutil.ReadAll(resp.Body)
  7397. //if ioErr != nil {
  7398. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7400. // return
  7401. //}
  7402. //var respJSON map[string]interface{}
  7403. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7404. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7406. // return
  7407. //}
  7408. //
  7409. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7410. //result, _ := json.Marshal(respJSON)
  7411. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7412. // utils.ErrorLog("解析失败:%v", err)
  7413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7414. // return
  7415. //}
  7416. }
  7417. //func (c *HisApiController) GetCFYLJG001() {
  7418. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7419. // patient_id, _ := c.GetInt64("patient_id")
  7420. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7421. // record_time := c.GetString("record_time")
  7422. // admin_user_id = 3626
  7423. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7424. // psn, _ := service.GetPsnByPatientId(patient_id)
  7425. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7426. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7427. // var cFYLJG001 models.CFYLJG001
  7428. //
  7429. // timeLayout := "2006-01-02"
  7430. // loc, _ := time.LoadLocation("Local")
  7431. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7432. // if err != nil {
  7433. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7434. // return
  7435. // }
  7436. // recordDateTime := theTime.Unix()
  7437. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7438. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7439. //
  7440. // //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7441. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7442. //
  7443. // //dept, _ := service.GetDepartMentDetail(info.Departments)
  7444. //
  7445. // for _, item := range prescriptions {
  7446. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7447. // if his.IdCardType == 1 {
  7448. // bas := strings.Split(psn.CardInfo, "|")
  7449. // basNumber := bas[1]
  7450. // fmt.Println(basNumber)
  7451. // card_sn := bas[3]
  7452. // card_no := bas[2]
  7453. // cFYLJG001.MdtrtCertType = "03"
  7454. // cFYLJG001.CardSn = card_sn
  7455. // cFYLJG001.MdtrtCertNo = card_no
  7456. // cFYLJG001.EcToken = ""
  7457. // cFYLJG001.AuthNo = ""
  7458. // } else if his.IdCardType == 2 {
  7459. // cFYLJG001.MdtrtCertType = "02"
  7460. // cFYLJG001.CardSn = ""
  7461. // cFYLJG001.MdtrtCertNo = his.IdCardNo
  7462. // cFYLJG001.EcToken = ""
  7463. // cFYLJG001.AuthNo = ""
  7464. // } else if his.IdCardType == 4 {
  7465. // cFYLJG001.MdtrtCertType = "01"
  7466. // cFYLJG001.CardSn = ""
  7467. // cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7468. // cFYLJG001.EcToken = psn.VerifyNumber
  7469. // cFYLJG001.AuthNo = ""
  7470. // }
  7471. // cFYLJG001.BizTypeCode = "01"
  7472. // cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7473. // cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7474. // cFYLJG001.RxTypeCode = "1"
  7475. // tempTime := time.Unix(item.PreTime, 0)
  7476. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7477. // cFYLJG001.PrscTime = timeFormatOne
  7478. // var count float64
  7479. // if item.Type == 1 {
  7480. // for _, sumItem := range item.HisDoctorAdviceInfo {
  7481. // count = count + sumItem.PrescribingNumber
  7482. // }
  7483. // }
  7484. // cFYLJG001.RxDrugCnt = count
  7485. // cFYLJG001.ValiDays = "5"
  7486. // ts := time.Unix(item.PreTime, 0)
  7487. // record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7488. // tempTime3 := time.Unix(record_time2, 0)
  7489. // timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7490. // cFYLJG001.ValiEndTime = timeFormat3
  7491. // cFYLJG001.RxCotnFlag = "0"
  7492. // for _, subItem := range item.HisDoctorAdviceInfo {
  7493. // var drug models.RxDrug
  7494. // drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7495. // drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7496. // drug.RxItemTypeCode = "11"
  7497. //
  7498. // drug.DrugDosform = "乳膏剂" //TODO
  7499. // if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7500. // drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7501. // }
  7502. //
  7503. // drug.MedcWayDscr = subItem.DeliveryWay
  7504. //
  7505. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7506. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7507. // drug.MedcBegntime = timeFormatTwo
  7508. // if subItem.Day > 0 {
  7509. // ts := time.Unix(subItem.StartTime, 0)
  7510. // record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7511. // tempTime4 := time.Unix(record_time, 0)
  7512. // timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7513. // drug.MedcEndtime = timeFormat5
  7514. // } else {
  7515. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7516. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7517. // drug.MedcEndtime = timeFormatTwo
  7518. // }
  7519. //
  7520. // drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7521. // drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7522. // drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7523. // drug.DrugCnt = subItem.PrescribingNumber
  7524. // drug.DrugDosunt = subItem.PrescribingNumberUnit
  7525. // drug.DrugGenname = subItem.AdviceName
  7526. // drug.MedcWayCodg = subItem.DeliveryWay
  7527. // //drug.DrugTotlcnt = subItem.PrescribingNumber
  7528. // drug.SinDoscnt = subItem.SingleDose
  7529. // drug.SinDosunt = subItem.SingleDoseUnit
  7530. // drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7531. // drug.UsedFrquName = subItem.ExecutionFrequency
  7532. // drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7533. // drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7534. // drug.HospApprFlag = "1"
  7535. // cFYLJG001.List = append(cFYLJG001.List, drug)
  7536. // }
  7537. // cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7538. // cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7539. // cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7540. // cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7541. // cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7542. // cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7543. // cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7544. // cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7545. // cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7546. // cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7547. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7548. // cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7549. // cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7550. // cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7551. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7552. // cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7553. // cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7554. // cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7555. // cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7556. // cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7557. // cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7558. // cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7559. // cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7560. // cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7561. // tempTime2 := time.Now().Unix()
  7562. // tempTime6 := time.Unix(tempTime2, 0)
  7563. // timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7564. // cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7565. // cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7566. // cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7567. // cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7568. // cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7569. //
  7570. // //memo := make(map[string]interface{})
  7571. // //inputData := make(map[string]interface{}, 0)
  7572. //
  7573. // //type MyData struct {
  7574. // // Insutype string `json:"insutype"`
  7575. // //}
  7576. // //
  7577. // // data := MyData{
  7578. // // Insutype: his.Insutype,
  7579. // //}
  7580. // //
  7581. //
  7582. // diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7583. // var config []*models.HisXtDiagnoseConfig
  7584. // for _, item := range diagnosis_ids {
  7585. // id, _ := strconv.ParseInt(item, 10, 64)
  7586. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  7587. // config = append(config, &diagnosisConfig)
  7588. // }
  7589. // for index, subitem := range config {
  7590. // if index == 0 {
  7591. // var dia models.DiseInfo
  7592. // dia.DiagType = "1"
  7593. // dia.MaindiagFlag = "1"
  7594. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7595. // dia.DiagCode = subitem.CountryCode
  7596. // dia.DiagName = subitem.ClassName
  7597. // dia.DiagDept = "肾内科"
  7598. // dia.DiagDrNo = doctor.DoctorNumber
  7599. // dia.DiagDrName = doctor.UserName
  7600. // tempTime3 := time.Unix(item.PreTime, 0)
  7601. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7602. // dia.DiagTime = timeFormatTwo
  7603. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7604. // } else {
  7605. // var dia models.DiseInfo
  7606. // dia.DiagType = "1"
  7607. // dia.MaindiagFlag = "0"
  7608. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7609. // dia.DiagCode = subitem.CountryCode
  7610. // dia.DiagName = subitem.ClassName
  7611. // dia.DiagDept = "肾内科"
  7612. // dia.DiagDrNo = doctor.DoctorNumber
  7613. // dia.DiagDrName = doctor.UserName
  7614. // tempTime3 := time.Unix(item.PreTime, 0)
  7615. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7616. // dia.DiagTime = timeFormatTwo
  7617. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7618. // }
  7619. // }
  7620. // if miConfig.MdtrtareaAdmvs == "340699" {
  7621. // //result, request := service.GetAHCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7622. // //saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7623. //
  7624. // } else {
  7625. // result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7626. // saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7627. //
  7628. // }
  7629. //
  7630. // var res ResultCFYLJG001
  7631. // var respJSON2 map[string]interface{}
  7632. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7633. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7634. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7635. // return
  7636. // }
  7637. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7638. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7639. // utils.ErrorLog("解析失败:%v", err)
  7640. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7641. // return
  7642. // }
  7643. // if res.Infcode == -1 {
  7644. // c.ServeSuccessJSON(map[string]interface{}{
  7645. // "failed_code": -10,
  7646. // "msg": res.ErrMsg,
  7647. // })
  7648. // return
  7649. //
  7650. // } else {
  7651. // var flow models.HisPrescriptionFlow
  7652. // flow.Ctime = time.Now().Unix()
  7653. // flow.SignDigest = ""
  7654. // flow.RxTraceCode = res.Output.RxTraceCode
  7655. // flow.HiRxno = res.Output.HiRxno
  7656. // flow.MID = his.Number
  7657. // flow.Status = 1
  7658. // flow.DCode = doctor_info.DoctorNumber
  7659. // flow.OriginalRxFile = ""
  7660. // flow.OriginalValue = ""
  7661. // flow.SignCertDn = ""
  7662. // flow.UserOrgId = 10454
  7663. // flow.SignCertSn = ""
  7664. // flow.Mtime = time.Now().Unix()
  7665. //
  7666. // service.Createflow(&flow)
  7667. // c.ServeSuccessJSON(map[string]interface{}{
  7668. // "msg": "上传成功",
  7669. // })
  7670. // }
  7671. // }
  7672. //}
  7673. //func (c *HisApiController) GetCFYLJG002() {
  7674. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7675. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7676. // record_time := c.GetString("record_time")
  7677. // admin_user_id = 3626
  7678. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7679. // //id, _ := c.GetInt64("id")
  7680. // admin_user_id = 3626
  7681. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7682. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7683. //
  7684. // flow, _ := service.Getflowtwo(his.Number)
  7685. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  7686. // //record_time := c.GetString("record_time")
  7687. // patient_id, _ := c.GetInt64("patient_id")
  7688. // //patient_id = 23834
  7689. // //record_time = "2023-09-18"
  7690. // timeLayout := "2006-01-02"
  7691. // loc, _ := time.LoadLocation("Local")
  7692. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7693. // if err != nil {
  7694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7695. // return
  7696. // }
  7697. // recordDateTime := theTime.Unix()
  7698. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7699. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7700. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7701. //
  7702. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7703. //
  7704. // inputData := make(map[string]interface{})
  7705. // inputData["rxTraceCode"] = flow.RxTraceCode
  7706. // inputData["hiRxno"] = flow.HiRxno
  7707. // inputData["mdtrtId"] = flow.MID
  7708. // inputData["patnName"] = his.PsnName
  7709. // inputData["psnCertType"] = his.PsnCertType
  7710. // inputData["certno"] = his.Certno
  7711. // inputData["fixmedinsName"] = miConfig.OrgName
  7712. // inputData["fixmedinsCode"] = miConfig.Code
  7713. // inputData["drCode"] = doctor_info.DoctorNumber
  7714. // inputData["prscDrName"] = doctor_info.UserName
  7715. // inputData["pharDeptName"] = dept.Name
  7716. // inputData["pharDeptCode"] = dept.Number
  7717. // inputData["pharProfttlCodg"] = dept.Name
  7718. // inputData["pharProfttlName"] = ""
  7719. // inputData["pharCode"] = "HY440309002107"
  7720. // inputData["pharCertType"] = "01"
  7721. // inputData["pharCertno"] = "430482199408260023"
  7722. // inputData["pharName"] = "彭斯遥"
  7723. // inputData["pharPracCertNo"] = ""
  7724. // tempTime2 := time.Unix(info.Ctime, 0)
  7725. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7726. // inputData["pharChkTime"] = timeFormatTwo
  7727. //
  7728. // bytesData, _ := json.Marshal(inputData)
  7729. // fmt.Println(string(bytesData))
  7730. // encoded := base64.StdEncoding.EncodeToString(bytesData)
  7731. // pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7732. // if err != nil {
  7733. // fmt.Println("Error reading PDF file:", err)
  7734. // return
  7735. // }
  7736. //
  7737. // // 将 PDF 文件内容进行 Base64 编码
  7738. // rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7739. //
  7740. // fmt.Println(err)
  7741. //
  7742. // if miConfig.MdtrtareaAdmvs == "340699" {
  7743. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7744. // //saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7745. //
  7746. // } else {
  7747. // result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7748. // //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7749. // saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7750. //
  7751. // }
  7752. //
  7753. // var res2 Result002
  7754. // var respJSON2 map[string]interface{}
  7755. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7756. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7758. // return
  7759. // }
  7760. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7761. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7762. // utils.ErrorLog("解析失败:%v", err)
  7763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7764. // return
  7765. // }
  7766. // if res2.Infcode == 0 {
  7767. // flow.Ctime = time.Now().Unix()
  7768. // flow.SignDigest = res2.Output.SignDigest
  7769. // flow.RxFile = res2.Output.RxFile
  7770. // flow.MID = his.Number
  7771. // flow.Status = 1
  7772. // flow.DCode = doctor_info.DoctorNumber
  7773. // flow.OriginalRxFile = rx_encoded
  7774. // flow.OriginalValue = encoded
  7775. // flow.SignCertDn = res2.Output.SignCertDn
  7776. // flow.SignCertSn = res2.Output.SignCertSn
  7777. // flow.Mtime = time.Now().Unix()
  7778. // service.Saveflow(flow)
  7779. // c.ServeSuccessJSON(map[string]interface{}{
  7780. // "msg": "预签名成功",
  7781. // })
  7782. // } else {
  7783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7784. // return
  7785. // }
  7786. //}
  7787. //func (c *HisApiController) GetCFYLJG003() {
  7788. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7789. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7790. // record_time := c.GetString("record_time")
  7791. // admin_user_id = 3626
  7792. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7793. // //id, _ := c.GetInt64("id")
  7794. // admin_user_id = 3626
  7795. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7796. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7797. //
  7798. // flow, _ := service.Getflowtwo(his.Number)
  7799. // //id = 3
  7800. // patient_id, _ := c.GetInt64("patient_id")
  7801. // //patient_id = 23834
  7802. // //record_time = "2023-09-18"
  7803. // timeLayout := "2006-01-02"
  7804. // loc, _ := time.LoadLocation("Local")
  7805. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7806. // if err != nil {
  7807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7808. // return
  7809. // }
  7810. // recordDateTime := theTime.Unix()
  7811. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7812. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7813. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7814. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7815. //
  7816. // //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7817. //
  7818. // var cFYLJG003 models.CFYLJG003
  7819. //
  7820. // cFYLJG003.RxTraceCode = flow.RxTraceCode
  7821. // cFYLJG003.HiRxno = flow.HiRxno
  7822. // cFYLJG003.MdtrtID = flow.MID
  7823. // cFYLJG003.PatnName = his.Name
  7824. // cFYLJG003.Certno = his.Certno
  7825. // cFYLJG003.FixmedinsName = miConfig.OrgName
  7826. // cFYLJG003.FixmedinsCode = miConfig.Code
  7827. //
  7828. // cFYLJG003.DrCode = doctor_info.DoctorNumber
  7829. // cFYLJG003.PrscDrName = doctor_info.UserName
  7830. // cFYLJG003.PharDeptName = dept.Name
  7831. // cFYLJG003.PharDeptCode = dept.Number
  7832. // cFYLJG003.PharCode = "HY440309002107"
  7833. // cFYLJG003.PharCertType = "01"
  7834. // cFYLJG003.PharCertno = "430482199408260023"
  7835. // cFYLJG003.PharName = "彭斯遥"
  7836. // cFYLJG003.PsnCertType = "01"
  7837. // cFYLJG003.RxFile = flow.RxFile
  7838. // cFYLJG003.SignDigest = flow.SignDigest
  7839. // cFYLJG003.FixmedinsCode = miConfig.Code
  7840. // cFYLJG003.PsnCertType = "01"
  7841. // cFYLJG003.PharProfttlCodg = dept.Name
  7842. // //inputData["pharProfttlCodg"] =dept.Name
  7843. //
  7844. // tempTime2 := time.Unix(info.Ctime, 0)
  7845. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7846. // cFYLJG003.PharChkTime = timeFormatTwo
  7847. //
  7848. // if miConfig.MdtrtareaAdmvs == "340699" {
  7849. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7850. // //result, request := service.GetAHCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7851. // //saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  7852. // } else {
  7853. // result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7854. // saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7855. //
  7856. // }
  7857. //
  7858. // var res ResultCFYLJG003
  7859. // var respJSON2 map[string]interface{}
  7860. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7861. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7862. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7863. // return
  7864. // }
  7865. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7866. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7867. // utils.ErrorLog("解析失败:%v", err)
  7868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7869. // return
  7870. // }
  7871. // if res.Infcode == -1 {
  7872. // c.ServeSuccessJSON(map[string]interface{}{
  7873. // "failed_code": -10,
  7874. // "msg": res.ErrMsg,
  7875. // })
  7876. // return
  7877. // } else {
  7878. // c.ServeSuccessJSON(map[string]interface{}{
  7879. // "info": res.Output,
  7880. // })
  7881. // }
  7882. //
  7883. //}
  7884. //func (c *HisApiController) GetCFYLJG004() {
  7885. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7886. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7887. // record_time := c.GetString("record_time")
  7888. // admin_user_id = 3626
  7889. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7890. // //id, _ := c.GetInt64("id")
  7891. // admin_user_id = 3626
  7892. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7893. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7894. //
  7895. // flow, _ := service.Getflowtwo(his.Number)
  7896. // //id = 3
  7897. // patient_id, _ := c.GetInt64("patient_id")
  7898. // //patient_id = 23834
  7899. // //record_time = "2023-09-18"
  7900. // timeLayout := "2006-01-02"
  7901. // loc, _ := time.LoadLocation("Local")
  7902. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7903. // if err != nil {
  7904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7905. // return
  7906. // }
  7907. // recordDateTime := theTime.Unix()
  7908. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7909. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7910. // var cFYLJG004 models.CFYLJG004
  7911. // cFYLJG004.HiRxno = flow.HiRxno
  7912. // cFYLJG004.FixmedinsCode = miConfig.Code
  7913. // cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7914. // cFYLJG004.UndoDrCertType = "01"
  7915. // cFYLJG004.UndoRea = "撤销处方"
  7916. // cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7917. // cFYLJG004.UndoDrName = doctor_info.UserName
  7918. // cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7919. //
  7920. // if miConfig.MdtrtareaAdmvs == "340699" {
  7921. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7922. // //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7923. // //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  7924. //
  7925. // } else {
  7926. // result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7927. // saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7928. //
  7929. // }
  7930. //
  7931. // var res ResultCFYLJG004
  7932. // var respJSON2 map[string]interface{}
  7933. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7934. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7936. // return
  7937. // }
  7938. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7939. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7940. // utils.ErrorLog("解析失败:%v", err)
  7941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. // return
  7943. // }
  7944. // if res.Infcode == -1 {
  7945. // c.ServeSuccessJSON(map[string]interface{}{
  7946. // "failed_code": -10,
  7947. // "msg": res.ErrMsg,
  7948. // })
  7949. // return
  7950. // } else {
  7951. // flow.Status = 0
  7952. // service.Saveflow(flow)
  7953. // c.ServeSuccessJSON(map[string]interface{}{
  7954. // "msg": "撤销成功",
  7955. // })
  7956. // return
  7957. //
  7958. // }
  7959. //}
  7960. //func (c *HisApiController) GetCFYLJG005() {
  7961. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7962. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7963. // //record_time := c.GetString("record_time")
  7964. // admin_user_id = 3626
  7965. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7966. // //id, _ := c.GetInt64("id")
  7967. // admin_user_id = 3626
  7968. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7969. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7970. //
  7971. // flow, _ := service.Getflowtwo(his.Number)
  7972. // //id = 3
  7973. // var cFYLJG005 models.CFYLJG005
  7974. //
  7975. // //patient_id, _ := c.GetInt64("patient_id")
  7976. // cFYLJG005.HiRxno = flow.HiRxno
  7977. // cFYLJG005.MdtrtID = flow.MID
  7978. // cFYLJG005.EcToken = ""
  7979. // cFYLJG005.PsnName = his.Name
  7980. // cFYLJG005.PsnCertType = "01"
  7981. // cFYLJG005.Certno = his.IdCardNo
  7982. //
  7983. // if miConfig.MdtrtareaAdmvs == "340699" {
  7984. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7985. //
  7986. // //result, request := service.GetAHCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7987. // //saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7988. //
  7989. // } else {
  7990. // result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7991. // saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7992. //
  7993. // }
  7994. //
  7995. // var res ResultCFYLJG005
  7996. // var respJSON2 map[string]interface{}
  7997. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7998. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7999. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8000. // return
  8001. // }
  8002. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8003. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8004. // utils.ErrorLog("解析失败:%v", err)
  8005. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8006. // return
  8007. // }
  8008. // if res.Infcode == -1 {
  8009. // c.ServeSuccessJSON(map[string]interface{}{
  8010. // "failed_code": -10,
  8011. // "msg": res.ErrMsg,
  8012. // })
  8013. // return
  8014. // } else {
  8015. // c.ServeSuccessJSON(map[string]interface{}{
  8016. // "info": res.Output,
  8017. // })
  8018. // return
  8019. // }
  8020. //}
  8021. //func (c *HisApiController) GetCFYLJG006() {
  8022. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8023. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8024. // admin_user_id = 3626
  8025. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8026. // //id, _ := c.GetInt64("id")
  8027. // admin_user_id = 3626
  8028. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8029. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8030. //
  8031. // flow, _ := service.Getflowtwo(his.Number)
  8032. // //id = 3
  8033. // patient_id, _ := c.GetInt64("patient_id")
  8034. // var cFYLJG006 models.CFYLJG006
  8035. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8036. // cFYLJG006.HiRxno = flow.HiRxno
  8037. // cFYLJG006.MdtrtID = flow.MID
  8038. // cFYLJG006.PsnName = patient.Name
  8039. // cFYLJG006.PsnCertType = "01"
  8040. // cFYLJG006.Certno = patient.IdCardNo
  8041. //
  8042. // if miConfig.MdtrtareaAdmvs == "340699" {
  8043. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8044. //
  8045. // result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8046. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8047. // } else {
  8048. // result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8049. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8050. // }
  8051. //
  8052. // var res ResultCFYLJG006
  8053. // var respJSON2 map[string]interface{}
  8054. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8055. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8057. // return
  8058. // }
  8059. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8060. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8061. // utils.ErrorLog("解析失败:%v", err)
  8062. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8063. // return
  8064. // }
  8065. // if res.Infcode == -1 {
  8066. // c.ServeSuccessJSON(map[string]interface{}{
  8067. // "failed_code": -10,
  8068. // "msg": res.ErrMsg,
  8069. // })
  8070. // return
  8071. // } else {
  8072. // c.ServeSuccessJSON(map[string]interface{}{
  8073. // "info": res.Output,
  8074. // })
  8075. // return
  8076. // }
  8077. //}
  8078. //func (c *HisApiController) GetCFYLJG007() {
  8079. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8080. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8081. // admin_user_id = 3626
  8082. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8083. // //id, _ := c.GetInt64("id")
  8084. // admin_user_id = 3626
  8085. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8086. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8087. //
  8088. // flow, _ := service.Getflowtwo(his.Number)
  8089. // //id = 3
  8090. // patient_id, _ := c.GetInt64("patient_id")
  8091. // var cFYLJG007 models.CFYLJG007
  8092. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8093. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8094. //
  8095. // cFYLJG007.HiRxno = flow.HiRxno
  8096. // cFYLJG007.MdtrtID = flow.MID
  8097. // cFYLJG007.PsnNo = his.PsnNo
  8098. // cFYLJG007.PsnCertType = "01"
  8099. // cFYLJG007.Certno = patient.IdCardNo
  8100. // cFYLJG007.PsnName = patient.Name
  8101. //
  8102. // if miConfig.MdtrtareaAdmvs == "340699" {
  8103. // result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8104. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8105. // } else {
  8106. // result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8107. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8108. // }
  8109. //
  8110. // var res ResultCFYLJG007
  8111. // var respJSON2 map[string]interface{}
  8112. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8113. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8115. // return
  8116. // }
  8117. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8118. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8119. // utils.ErrorLog("解析失败:%v", err)
  8120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8121. // return
  8122. // }
  8123. // if res.Infcode == -1 {
  8124. // c.ServeSuccessJSON(map[string]interface{}{
  8125. // "failed_code": -10,
  8126. // "msg": res.ErrMsg,
  8127. // })
  8128. // return
  8129. // } else {
  8130. // c.ServeSuccessJSON(map[string]interface{}{
  8131. // "info": res,
  8132. // })
  8133. // return
  8134. // }
  8135. //}
  8136. //
  8137. //func (c *HisApiController) GetCFYLJG008() {
  8138. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8139. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8140. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8141. // var cFYLJG008 models.CFYLJG008
  8142. // //id, _ := c.GetInt64("id")
  8143. // patient_id, _ := c.GetInt64("patient_id")
  8144. // //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8145. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8146. // //id = 3
  8147. // //flow, _ := service.Getflow(id)
  8148. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  8149. //
  8150. // //
  8151. // //admin_user_id, _ := c.GetInt64("admin_user_id")
  8152. // //patient_id, _ := c.GetInt64("patient_id")
  8153. // //his_patient_id, _ := c.GetInt64("his_patient_id")
  8154. // record_time := c.GetString("record_time")
  8155. //
  8156. // admin_user_id = 3626
  8157. // patient_id = 19424
  8158. // //his_patient_id = 263947
  8159. // record_time = "2023-08-29"
  8160. //
  8161. // timeLayout := "2006-01-02"
  8162. // loc, _ := time.LoadLocation("Local")
  8163. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8164. // if err != nil {
  8165. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8166. // return
  8167. // }
  8168. // recordDateTime := theTime.Unix()
  8169. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8170. //
  8171. // cFYLJG008.FixmedinsName = ""
  8172. // cFYLJG008.Lat = ""
  8173. // cFYLJG008.Lng = ""
  8174. // cFYLJG008.OrderType = "1"
  8175. // cFYLJG008.PoolareaNo = ""
  8176. // cFYLJG008.Lng = ""
  8177. // cFYLJG008.PageNum = 1
  8178. // cFYLJG008.PageSize = 10
  8179. // var MPI models.MedinsProdInvChgDDTO
  8180. // MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8181. // MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8182. // cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8183. //
  8184. // if miConfig.MdtrtareaAdmvs == "340699" {
  8185. // result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8186. // saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8187. //
  8188. // } else {
  8189. // result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8190. // saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8191. //
  8192. // var res ResultCFYLJG008
  8193. // var respJSON2 map[string]interface{}
  8194. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8195. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8196. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8197. // return
  8198. // }
  8199. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8200. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8201. // utils.ErrorLog("解析失败:%v", err)
  8202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8203. // return
  8204. // }
  8205. // if res.Infcode == -1 {
  8206. // c.ServeSuccessJSON(map[string]interface{}{
  8207. // "failed_code": -10,
  8208. // "msg": res.ErrMsg,
  8209. // })
  8210. // return
  8211. // } else {
  8212. // c.ServeSuccessJSON(map[string]interface{}{
  8213. // "info": res.Output,
  8214. // })
  8215. // return
  8216. // }
  8217. // }
  8218. //
  8219. //}
  8220. func (c *HisApiController) GetBL4201A() {
  8221. order_id, _ := c.GetInt64("order_id")
  8222. admin_user_id, _ := c.GetInt64("admin_user_id")
  8223. order, _ := service.GetHisOrderByIDTwo(order_id)
  8224. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8225. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8226. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8227. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8228. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8229. department, _ := service.GetDepartMentDetail(his.Departments)
  8230. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8231. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8232. if order.ID == 0 {
  8233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8234. return
  8235. }
  8236. var struct4201A models.Struct4201A
  8237. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8238. for _, items := range order_info {
  8239. memo := make(map[string]interface{})
  8240. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8241. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8242. fsiOPFLD.MedType = "14"
  8243. fsiOPFLD.BkkpSn = items.FeedetlSn
  8244. fsiOPFLD.FixmedinsCode = miConfig.Code
  8245. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8246. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8247. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8248. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8249. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8250. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8251. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8252. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8253. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8254. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8255. fsiOPFLD.BilgDeptName = department.Name
  8256. fsiOPFLD.BilgDeptCodg = department.Number
  8257. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8258. fsiOPFLD.BilgDrName = doctor.UserName
  8259. fsiOPFLD.MedChrgitmType = "09"
  8260. memo["hosp_appr_flag"] = "1"
  8261. memo["invoice_no"] = order.MdtrtId
  8262. memo["memo"] = "自费"
  8263. bytesData, _ := json.Marshal(memo)
  8264. fsiOPFLD.Memo = string(bytesData)
  8265. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8266. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8267. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8268. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8269. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8270. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8271. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8272. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8273. fsiOPFLD.BilgDeptName = department.Name
  8274. fsiOPFLD.BilgDeptCodg = department.Number
  8275. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8276. fsiOPFLD.BilgDrName = doctor.UserName
  8277. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8278. case 0:
  8279. break
  8280. case 1:
  8281. fsiOPFLD.MedChrgitmType = "14"
  8282. break
  8283. case 2:
  8284. fsiOPFLD.MedChrgitmType = "05"
  8285. break
  8286. case 3:
  8287. fsiOPFLD.MedChrgitmType = "03"
  8288. break
  8289. case 4:
  8290. fsiOPFLD.MedChrgitmType = "03"
  8291. break
  8292. case 5:
  8293. fsiOPFLD.MedChrgitmType = "08"
  8294. break
  8295. case 6:
  8296. fsiOPFLD.MedChrgitmType = "14"
  8297. break
  8298. case 7:
  8299. fsiOPFLD.MedChrgitmType = "14"
  8300. break
  8301. case 8:
  8302. fsiOPFLD.MedChrgitmType = "03"
  8303. break
  8304. case 9:
  8305. fsiOPFLD.MedChrgitmType = "14"
  8306. break
  8307. case 10:
  8308. fsiOPFLD.MedChrgitmType = "14"
  8309. break
  8310. case 11:
  8311. fsiOPFLD.MedChrgitmType = "06"
  8312. break
  8313. case 12:
  8314. fsiOPFLD.MedChrgitmType = "12"
  8315. break
  8316. case 13:
  8317. fsiOPFLD.MedChrgitmType = "01"
  8318. break
  8319. case 14:
  8320. fsiOPFLD.MedChrgitmType = "04"
  8321. break
  8322. case 15:
  8323. fsiOPFLD.MedChrgitmType = "14"
  8324. break
  8325. }
  8326. memo["hosp_appr_flag"] = "1"
  8327. memo["invoice_no"] = order.MdtrtId
  8328. memo["memo"] = "自费"
  8329. bytesData, _ := json.Marshal(memo)
  8330. fsiOPFLD.Memo = string(bytesData)
  8331. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8332. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8333. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8334. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8335. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8336. fsiOPFLD.BilgDeptName = department.Name
  8337. fsiOPFLD.BilgDeptCodg = department.Number
  8338. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8339. fsiOPFLD.BilgDrName = doctor.UserName
  8340. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8341. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8342. fsiOPFLD.MedChrgitmType = "08"
  8343. memo["hosp_appr_flag"] = "1"
  8344. memo["invoice_no"] = order.MdtrtId
  8345. memo["memo"] = "自费"
  8346. bytesData, _ := json.Marshal(memo)
  8347. fsiOPFLD.Memo = string(bytesData)
  8348. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8349. }
  8350. }
  8351. }
  8352. for _, items := range order_info_two {
  8353. memo := make(map[string]interface{})
  8354. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8355. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8356. fsiOPFLD.MedType = "14"
  8357. fsiOPFLD.BkkpSn = items.FeedetlSn
  8358. fsiOPFLD.FixmedinsCode = miConfig.Code
  8359. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8360. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8361. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8362. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8363. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8364. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8365. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8366. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8367. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8368. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8369. fsiOPFLD.BilgDeptName = department.Name
  8370. fsiOPFLD.BilgDeptCodg = department.Number
  8371. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8372. fsiOPFLD.BilgDrName = doctor.UserName
  8373. fsiOPFLD.MedChrgitmType = "09"
  8374. memo["hosp_appr_flag"] = "1"
  8375. memo["invoice_no"] = order.MdtrtId
  8376. memo["memo"] = "自费"
  8377. bytesData, _ := json.Marshal(memo)
  8378. fsiOPFLD.Memo = string(bytesData)
  8379. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8380. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8381. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8382. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8383. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8384. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8385. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8386. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8387. fsiOPFLD.BilgDeptName = department.Name
  8388. fsiOPFLD.BilgDeptCodg = department.Number
  8389. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8390. fsiOPFLD.BilgDrName = doctor.UserName
  8391. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8392. case 0:
  8393. break
  8394. case 1:
  8395. fsiOPFLD.MedChrgitmType = "14"
  8396. break
  8397. case 2:
  8398. fsiOPFLD.MedChrgitmType = "05"
  8399. break
  8400. case 3:
  8401. fsiOPFLD.MedChrgitmType = "03"
  8402. break
  8403. case 4:
  8404. fsiOPFLD.MedChrgitmType = "03"
  8405. break
  8406. case 5:
  8407. fsiOPFLD.MedChrgitmType = "08"
  8408. break
  8409. case 6:
  8410. fsiOPFLD.MedChrgitmType = "14"
  8411. break
  8412. case 7:
  8413. fsiOPFLD.MedChrgitmType = "14"
  8414. break
  8415. case 8:
  8416. fsiOPFLD.MedChrgitmType = "03"
  8417. break
  8418. case 9:
  8419. fsiOPFLD.MedChrgitmType = "14"
  8420. break
  8421. case 10:
  8422. fsiOPFLD.MedChrgitmType = "14"
  8423. break
  8424. case 11:
  8425. fsiOPFLD.MedChrgitmType = "06"
  8426. break
  8427. case 12:
  8428. fsiOPFLD.MedChrgitmType = "12"
  8429. break
  8430. case 13:
  8431. fsiOPFLD.MedChrgitmType = "01"
  8432. break
  8433. case 14:
  8434. fsiOPFLD.MedChrgitmType = "04"
  8435. break
  8436. case 15:
  8437. fsiOPFLD.MedChrgitmType = "14"
  8438. break
  8439. }
  8440. memo["hosp_appr_flag"] = "1"
  8441. memo["invoice_no"] = order.MdtrtId
  8442. memo["memo"] = "自费"
  8443. bytesData, _ := json.Marshal(memo)
  8444. fsiOPFLD.Memo = string(bytesData)
  8445. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8446. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8447. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8448. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8449. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8450. fsiOPFLD.BilgDeptName = department.Name
  8451. fsiOPFLD.BilgDeptCodg = department.Number
  8452. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8453. fsiOPFLD.BilgDrName = doctor.UserName
  8454. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8455. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8456. fsiOPFLD.MedChrgitmType = "08"
  8457. memo["hosp_appr_flag"] = "1"
  8458. memo["invoice_no"] = order.MdtrtId
  8459. memo["memo"] = "自费"
  8460. bytesData, _ := json.Marshal(memo)
  8461. fsiOPFLD.Memo = string(bytesData)
  8462. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8463. }
  8464. }
  8465. }
  8466. fmt.Println(fsiOPFLDs)
  8467. struct4201A.Fopfd = fsiOPFLDs
  8468. fmt.Println(struct4201A.Fopfd)
  8469. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8470. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8471. var res2 ResultSix
  8472. var respJSON2 map[string]interface{}
  8473. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8476. return
  8477. }
  8478. userJSONBytes2, _ := json.Marshal(respJSON2)
  8479. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8480. utils.ErrorLog("解析失败:%v", err)
  8481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8482. return
  8483. }
  8484. if res2.Infcode != 0 {
  8485. c.ServeSuccessJSON(map[string]interface{}{
  8486. "failed_code": -10,
  8487. "msg": res2.ErrMsg,
  8488. })
  8489. return
  8490. } else {
  8491. order.IsUploadOrderInfo = 1
  8492. service.UpdateOrder(order)
  8493. c.ServeSuccessJSON(map[string]interface{}{
  8494. "msg": "上传成功",
  8495. })
  8496. }
  8497. }
  8498. func (c *HisApiController) Get2505() {
  8499. admin_user_id, _ := c.GetInt64("admin_user_id")
  8500. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8501. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8502. service.Gdyb2505("45000000000008100145868008", curRoles.UserName, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2024-01-12 09:00:00", "2026-12-31 23:00:00", admin_user_id)
  8503. }
  8504. func (c *HisApiController) Get4201A() {
  8505. order_id, _ := c.GetInt64("order_id")
  8506. admin_user_id, _ := c.GetInt64("admin_user_id")
  8507. order, _ := service.GetHisOrderByIDTwo(order_id)
  8508. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8509. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8510. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8511. //order_info = append(order_info, order_info_two...)
  8512. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8513. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8514. department, _ := service.GetDepartMentDetail(his.Departments)
  8515. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8516. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8517. if order.ID == 0 {
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8519. return
  8520. }
  8521. var struct4201A models.Struct4201A
  8522. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8523. for _, items := range order_info {
  8524. memo := make(map[string]interface{})
  8525. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8526. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8527. fsiOPFLD.MedType = "14"
  8528. fsiOPFLD.BkkpSn = items.FeedetlSn
  8529. fsiOPFLD.FixmedinsCode = miConfig.Code
  8530. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8531. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8532. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8533. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8534. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8535. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8536. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8537. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8538. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8539. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8540. fsiOPFLD.BilgDeptName = department.Name
  8541. fsiOPFLD.BilgDeptCodg = department.Number
  8542. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8543. fsiOPFLD.BilgDrName = doctor.UserName
  8544. fsiOPFLD.MedChrgitmType = "09"
  8545. memo["hosp_appr_flag"] = "1"
  8546. memo["invoice_no"] = order.MdtrtId
  8547. memo["memo"] = "自费"
  8548. bytesData, _ := json.Marshal(memo)
  8549. fsiOPFLD.Memo = string(bytesData)
  8550. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8551. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8552. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8553. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8554. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8555. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8556. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8557. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8558. fsiOPFLD.BilgDeptName = department.Name
  8559. fsiOPFLD.BilgDeptCodg = department.Number
  8560. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8561. fsiOPFLD.BilgDrName = doctor.UserName
  8562. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8563. case 0:
  8564. break
  8565. case 1:
  8566. fsiOPFLD.MedChrgitmType = "14"
  8567. break
  8568. case 2:
  8569. fsiOPFLD.MedChrgitmType = "05"
  8570. break
  8571. case 3:
  8572. fsiOPFLD.MedChrgitmType = "03"
  8573. break
  8574. case 4:
  8575. fsiOPFLD.MedChrgitmType = "03"
  8576. break
  8577. case 5:
  8578. fsiOPFLD.MedChrgitmType = "08"
  8579. break
  8580. case 6:
  8581. fsiOPFLD.MedChrgitmType = "14"
  8582. break
  8583. case 7:
  8584. fsiOPFLD.MedChrgitmType = "14"
  8585. break
  8586. case 8:
  8587. fsiOPFLD.MedChrgitmType = "03"
  8588. break
  8589. case 9:
  8590. fsiOPFLD.MedChrgitmType = "14"
  8591. break
  8592. case 10:
  8593. fsiOPFLD.MedChrgitmType = "14"
  8594. break
  8595. case 11:
  8596. fsiOPFLD.MedChrgitmType = "06"
  8597. break
  8598. case 12:
  8599. fsiOPFLD.MedChrgitmType = "12"
  8600. break
  8601. case 13:
  8602. fsiOPFLD.MedChrgitmType = "01"
  8603. break
  8604. case 14:
  8605. fsiOPFLD.MedChrgitmType = "04"
  8606. break
  8607. case 15:
  8608. fsiOPFLD.MedChrgitmType = "14"
  8609. break
  8610. }
  8611. memo["hosp_appr_flag"] = "1"
  8612. memo["invoice_no"] = order.MdtrtId
  8613. memo["memo"] = "自费"
  8614. bytesData, _ := json.Marshal(memo)
  8615. fsiOPFLD.Memo = string(bytesData)
  8616. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8617. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8618. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8619. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8620. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8621. fsiOPFLD.BilgDeptName = department.Name
  8622. fsiOPFLD.BilgDeptCodg = department.Number
  8623. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8624. fsiOPFLD.BilgDrName = doctor.UserName
  8625. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8626. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8627. fsiOPFLD.MedChrgitmType = "08"
  8628. memo["hosp_appr_flag"] = "1"
  8629. memo["invoice_no"] = order.MdtrtId
  8630. memo["memo"] = "自费"
  8631. bytesData, _ := json.Marshal(memo)
  8632. fsiOPFLD.Memo = string(bytesData)
  8633. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8634. }
  8635. }
  8636. }
  8637. for _, items := range order_info_two {
  8638. memo := make(map[string]interface{})
  8639. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8640. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8641. fsiOPFLD.MedType = "14"
  8642. fsiOPFLD.BkkpSn = items.FeedetlSn
  8643. fsiOPFLD.FixmedinsCode = miConfig.Code
  8644. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8645. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8646. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8647. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8648. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8649. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8650. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8651. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8652. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8653. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8654. fsiOPFLD.BilgDeptName = department.Name
  8655. fsiOPFLD.BilgDeptCodg = department.Number
  8656. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8657. fsiOPFLD.BilgDrName = doctor.UserName
  8658. fsiOPFLD.MedChrgitmType = "09"
  8659. memo["hosp_appr_flag"] = "1"
  8660. memo["invoice_no"] = order.MdtrtId
  8661. memo["memo"] = "自费"
  8662. bytesData, _ := json.Marshal(memo)
  8663. fsiOPFLD.Memo = string(bytesData)
  8664. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8665. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8666. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8667. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8668. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8669. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8670. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8671. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8672. fsiOPFLD.BilgDeptName = department.Name
  8673. fsiOPFLD.BilgDeptCodg = department.Number
  8674. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8675. fsiOPFLD.BilgDrName = doctor.UserName
  8676. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8677. case 0:
  8678. break
  8679. case 1:
  8680. fsiOPFLD.MedChrgitmType = "14"
  8681. break
  8682. case 2:
  8683. fsiOPFLD.MedChrgitmType = "05"
  8684. break
  8685. case 3:
  8686. fsiOPFLD.MedChrgitmType = "03"
  8687. break
  8688. case 4:
  8689. fsiOPFLD.MedChrgitmType = "03"
  8690. break
  8691. case 5:
  8692. fsiOPFLD.MedChrgitmType = "08"
  8693. break
  8694. case 6:
  8695. fsiOPFLD.MedChrgitmType = "14"
  8696. break
  8697. case 7:
  8698. fsiOPFLD.MedChrgitmType = "14"
  8699. break
  8700. case 8:
  8701. fsiOPFLD.MedChrgitmType = "03"
  8702. break
  8703. case 9:
  8704. fsiOPFLD.MedChrgitmType = "14"
  8705. break
  8706. case 10:
  8707. fsiOPFLD.MedChrgitmType = "14"
  8708. break
  8709. case 11:
  8710. fsiOPFLD.MedChrgitmType = "06"
  8711. break
  8712. case 12:
  8713. fsiOPFLD.MedChrgitmType = "12"
  8714. break
  8715. case 13:
  8716. fsiOPFLD.MedChrgitmType = "01"
  8717. break
  8718. case 14:
  8719. fsiOPFLD.MedChrgitmType = "04"
  8720. break
  8721. case 15:
  8722. fsiOPFLD.MedChrgitmType = "14"
  8723. break
  8724. }
  8725. memo["hosp_appr_flag"] = "1"
  8726. memo["invoice_no"] = order.MdtrtId
  8727. memo["memo"] = "自费"
  8728. bytesData, _ := json.Marshal(memo)
  8729. fsiOPFLD.Memo = string(bytesData)
  8730. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8731. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8732. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8733. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8734. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8735. fsiOPFLD.BilgDeptName = department.Name
  8736. fsiOPFLD.BilgDeptCodg = department.Number
  8737. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8738. fsiOPFLD.BilgDrName = doctor.UserName
  8739. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8740. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8741. fsiOPFLD.MedChrgitmType = "08"
  8742. memo["hosp_appr_flag"] = "1"
  8743. memo["invoice_no"] = order.MdtrtId
  8744. memo["memo"] = "自费"
  8745. bytesData, _ := json.Marshal(memo)
  8746. fsiOPFLD.Memo = string(bytesData)
  8747. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8748. }
  8749. }
  8750. }
  8751. fmt.Println(fsiOPFLDs)
  8752. struct4201A.Fopfd = fsiOPFLDs
  8753. fmt.Println(struct4201A.Fopfd)
  8754. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8755. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8756. var res2 ResultSix
  8757. var respJSON2 map[string]interface{}
  8758. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8761. return
  8762. }
  8763. userJSONBytes2, _ := json.Marshal(respJSON2)
  8764. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8765. utils.ErrorLog("解析失败:%v", err)
  8766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8767. return
  8768. }
  8769. if res2.Infcode != 0 {
  8770. c.ServeSuccessJSON(map[string]interface{}{
  8771. "failed_code": -10,
  8772. "msg": res2.ErrMsg,
  8773. })
  8774. return
  8775. } else {
  8776. order.IsUploadOrderInfo = 1
  8777. service.UpdateOrder(order)
  8778. c.ServeSuccessJSON(map[string]interface{}{
  8779. "msg": "上传成功",
  8780. })
  8781. }
  8782. }
  8783. func (c *HisApiController) Get4202() {
  8784. order_id, _ := c.GetInt64("order_id")
  8785. admin_user_id, _ := c.GetInt64("admin_user_id")
  8786. order, _ := service.GetHisOrderByIDTwo(order_id)
  8787. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8788. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8789. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8790. if order.ID == 0 {
  8791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8792. return
  8793. }
  8794. var struct4202 models.Struct4202
  8795. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8796. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8797. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8798. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8799. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8800. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8801. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8802. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8803. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8804. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8805. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8806. var config []*models.HisXtDiagnoseConfig
  8807. for _, item := range diagnosis_ids {
  8808. id, _ := strconv.ParseInt(item, 10, 64)
  8809. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8810. config = append(config, &diagnosisConfig)
  8811. }
  8812. var tempDiaginfos []models.OwnPayPatnDiagListD
  8813. for index, item := range config {
  8814. if index == 0 {
  8815. var tempDiaginfo models.OwnPayPatnDiagListD
  8816. tempDiaginfo.InoutDiagType = "1"
  8817. tempDiaginfo.DiagCode = item.CountryCode
  8818. tempDiaginfo.DiagName = item.CountryContentName
  8819. tempDiaginfo.DiagType = "1"
  8820. tempDiaginfo.DiagSrtNo = "1"
  8821. tempDiaginfo.MaindiagFlag = "1"
  8822. tempDiaginfo.ValiFlag = "1"
  8823. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8824. } else {
  8825. var tempDiaginfo models.OwnPayPatnDiagListD
  8826. tempDiaginfo.DiagCode = item.CountryCode
  8827. tempDiaginfo.DiagName = item.CountryContentName
  8828. tempDiaginfo.DiagType = "2"
  8829. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8830. tempDiaginfo.MaindiagFlag = "0"
  8831. tempDiaginfo.ValiFlag = "1"
  8832. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8833. }
  8834. }
  8835. struct4202.ODiagListD = tempDiaginfos
  8836. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8837. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8838. var res2 ResultSix
  8839. var respJSON2 map[string]interface{}
  8840. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8843. return
  8844. }
  8845. userJSONBytes2, _ := json.Marshal(respJSON2)
  8846. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8847. utils.ErrorLog("解析失败:%v", err)
  8848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8849. return
  8850. }
  8851. if res2.Infcode != 0 {
  8852. c.ServeSuccessJSON(map[string]interface{}{
  8853. "failed_code": -10,
  8854. "msg": res2.ErrMsg,
  8855. })
  8856. return
  8857. } else {
  8858. order.IsUploadDiagnose = 1
  8859. service.UpdateOrder(order)
  8860. c.ServeSuccessJSON(map[string]interface{}{
  8861. "msg": "上传成功",
  8862. })
  8863. }
  8864. }
  8865. func (c *HisApiController) Get4203() {
  8866. admin_user_id, _ := c.GetInt64("admin_user_id")
  8867. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8868. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8869. order_id, _ := c.GetInt64("order_id")
  8870. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8871. number := ""
  8872. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8873. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8874. if his.ID == 0 {
  8875. number = hospital.Number
  8876. } else {
  8877. number = his.Number
  8878. }
  8879. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8880. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8881. var res2 ResultSix
  8882. var respJSON2 map[string]interface{}
  8883. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8886. return
  8887. }
  8888. userJSONBytes2, _ := json.Marshal(respJSON2)
  8889. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8890. utils.ErrorLog("解析失败:%v", err)
  8891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8892. return
  8893. }
  8894. if res2.Infcode != 0 {
  8895. c.ServeSuccessJSON(map[string]interface{}{
  8896. "failed_code": -10,
  8897. "msg": res2.ErrMsg,
  8898. })
  8899. return
  8900. } else {
  8901. order.IsUploadSuccess = 1
  8902. service.UpdateOrderTwo(order)
  8903. c.ServeSuccessJSON(map[string]interface{}{
  8904. "msg": "上传成功",
  8905. })
  8906. }
  8907. }
  8908. func (c *HisApiController) Get4205() {
  8909. order_id, _ := c.GetInt64("order_id")
  8910. admin_user_id, _ := c.GetInt64("admin_user_id")
  8911. fapiao_code := c.GetString("fapiao_code")
  8912. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8913. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8914. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8915. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8916. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8917. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8918. //order_info = append(order_info, order_info_two...)
  8919. department, _ := service.GetDepartMentDetail(his.Departments)
  8920. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8921. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8922. if order.ID == 0 {
  8923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8924. return
  8925. }
  8926. var struct4201A models.Struct4201A
  8927. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8928. for _, items := range order_info {
  8929. memo := make(map[string]interface{})
  8930. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8931. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8932. fsiOPFLD.MedType = pre.MedType
  8933. fsiOPFLD.FixmedinsCode = miConfig.Code
  8934. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8935. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8936. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8937. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8938. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8939. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8940. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8941. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8942. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8943. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8944. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8945. fsiOPFLD.BilgDeptName = department.Name
  8946. fsiOPFLD.BilgDeptCodg = department.Number
  8947. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8948. fsiOPFLD.BilgDrName = doctor.UserName
  8949. fsiOPFLD.MedChrgitmType = "09"
  8950. memo["hosp_appr_flag"] = "1"
  8951. memo["invoice_no"] = fapiao_code
  8952. memo["memo"] = "自费"
  8953. bytesData, _ := json.Marshal(memo)
  8954. fsiOPFLD.Memo = string(bytesData)
  8955. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8956. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8957. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8958. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8959. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8960. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8961. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8962. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8963. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8964. fsiOPFLD.BilgDeptName = department.Name
  8965. fsiOPFLD.BilgDeptCodg = department.Number
  8966. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8967. fsiOPFLD.BilgDrName = doctor.UserName
  8968. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8969. case 0:
  8970. break
  8971. case 1:
  8972. fsiOPFLD.MedChrgitmType = "14"
  8973. break
  8974. case 2:
  8975. fsiOPFLD.MedChrgitmType = "05"
  8976. break
  8977. case 3:
  8978. fsiOPFLD.MedChrgitmType = "03"
  8979. break
  8980. case 4:
  8981. fsiOPFLD.MedChrgitmType = "03"
  8982. break
  8983. case 5:
  8984. fsiOPFLD.MedChrgitmType = "08"
  8985. break
  8986. case 6:
  8987. fsiOPFLD.MedChrgitmType = "14"
  8988. break
  8989. case 7:
  8990. fsiOPFLD.MedChrgitmType = "14"
  8991. break
  8992. case 8:
  8993. fsiOPFLD.MedChrgitmType = "03"
  8994. break
  8995. case 9:
  8996. fsiOPFLD.MedChrgitmType = "14"
  8997. break
  8998. case 10:
  8999. fsiOPFLD.MedChrgitmType = "14"
  9000. break
  9001. case 11:
  9002. fsiOPFLD.MedChrgitmType = "06"
  9003. break
  9004. case 12:
  9005. fsiOPFLD.MedChrgitmType = "12"
  9006. break
  9007. case 13:
  9008. fsiOPFLD.MedChrgitmType = "01"
  9009. break
  9010. case 14:
  9011. fsiOPFLD.MedChrgitmType = "04"
  9012. break
  9013. case 15:
  9014. fsiOPFLD.MedChrgitmType = "14"
  9015. break
  9016. }
  9017. memo["hosp_appr_flag"] = "1"
  9018. memo["invoice_no"] = fapiao_code
  9019. memo["memo"] = "自费"
  9020. bytesData, _ := json.Marshal(memo)
  9021. fsiOPFLD.Memo = string(bytesData)
  9022. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9023. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9024. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9025. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9026. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9027. fsiOPFLD.BilgDeptName = department.Name
  9028. fsiOPFLD.BilgDeptCodg = department.Number
  9029. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9030. fsiOPFLD.BilgDrName = doctor.UserName
  9031. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9032. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9033. fsiOPFLD.MedChrgitmType = "08"
  9034. memo["hosp_appr_flag"] = "1"
  9035. memo["invoice_no"] = fapiao_code
  9036. memo["memo"] = "自费"
  9037. bytesData, _ := json.Marshal(memo)
  9038. fsiOPFLD.Memo = string(bytesData)
  9039. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9040. }
  9041. }
  9042. }
  9043. for _, items := range order_info_two {
  9044. memo := make(map[string]interface{})
  9045. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9046. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9047. fsiOPFLD.MedType = pre.MedType
  9048. fsiOPFLD.BkkpSn = items.FeedetlSn
  9049. fsiOPFLD.FixmedinsCode = miConfig.Code
  9050. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9051. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9052. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9053. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9054. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9055. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9056. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9057. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9058. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9059. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9060. fsiOPFLD.BilgDeptName = department.Name
  9061. fsiOPFLD.BilgDeptCodg = department.Number
  9062. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9063. fsiOPFLD.BilgDrName = doctor.UserName
  9064. fsiOPFLD.MedChrgitmType = "09"
  9065. memo["hosp_appr_flag"] = "1"
  9066. memo["invoice_no"] = fapiao_code
  9067. memo["memo"] = "自费"
  9068. bytesData, _ := json.Marshal(memo)
  9069. fsiOPFLD.Memo = string(bytesData)
  9070. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9071. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9072. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9073. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9074. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9075. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9076. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9077. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9078. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9079. fsiOPFLD.BilgDeptName = department.Name
  9080. fsiOPFLD.BilgDeptCodg = department.Number
  9081. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9082. fsiOPFLD.BilgDrName = doctor.UserName
  9083. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9084. case 0:
  9085. break
  9086. case 1:
  9087. fsiOPFLD.MedChrgitmType = "14"
  9088. break
  9089. case 2:
  9090. fsiOPFLD.MedChrgitmType = "05"
  9091. break
  9092. case 3:
  9093. fsiOPFLD.MedChrgitmType = "03"
  9094. break
  9095. case 4:
  9096. fsiOPFLD.MedChrgitmType = "03"
  9097. break
  9098. case 5:
  9099. fsiOPFLD.MedChrgitmType = "08"
  9100. break
  9101. case 6:
  9102. fsiOPFLD.MedChrgitmType = "14"
  9103. break
  9104. case 7:
  9105. fsiOPFLD.MedChrgitmType = "14"
  9106. break
  9107. case 8:
  9108. fsiOPFLD.MedChrgitmType = "03"
  9109. break
  9110. case 9:
  9111. fsiOPFLD.MedChrgitmType = "14"
  9112. break
  9113. case 10:
  9114. fsiOPFLD.MedChrgitmType = "14"
  9115. break
  9116. case 11:
  9117. fsiOPFLD.MedChrgitmType = "06"
  9118. break
  9119. case 12:
  9120. fsiOPFLD.MedChrgitmType = "12"
  9121. break
  9122. case 13:
  9123. fsiOPFLD.MedChrgitmType = "01"
  9124. break
  9125. case 14:
  9126. fsiOPFLD.MedChrgitmType = "04"
  9127. break
  9128. case 15:
  9129. fsiOPFLD.MedChrgitmType = "14"
  9130. break
  9131. }
  9132. memo["hosp_appr_flag"] = "1"
  9133. memo["invoice_no"] = fapiao_code
  9134. memo["memo"] = "自费"
  9135. bytesData, _ := json.Marshal(memo)
  9136. fsiOPFLD.Memo = string(bytesData)
  9137. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9138. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9139. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9140. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9141. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9142. fsiOPFLD.BilgDeptName = department.Name
  9143. fsiOPFLD.BilgDeptCodg = department.Number
  9144. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9145. fsiOPFLD.BilgDrName = doctor.UserName
  9146. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9147. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9148. fsiOPFLD.MedChrgitmType = "08"
  9149. memo["hosp_appr_flag"] = "1"
  9150. memo["invoice_no"] = fapiao_code
  9151. memo["memo"] = "自费"
  9152. bytesData, _ := json.Marshal(memo)
  9153. fsiOPFLD.Memo = string(bytesData)
  9154. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9155. }
  9156. }
  9157. }
  9158. fmt.Println(fsiOPFLDs)
  9159. struct4201A.Fopfd = fsiOPFLDs
  9160. fmt.Println(struct4201A.Fopfd)
  9161. var struct4202 models.Struct4202
  9162. timeLayout := "2006-01-02 15:04:05"
  9163. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9164. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9165. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9166. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9167. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9168. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9169. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9170. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9171. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9172. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9173. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9174. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9175. var config []*models.HisXtDiagnoseConfig
  9176. for _, item := range diagnosis_ids {
  9177. id, _ := strconv.ParseInt(item, 10, 64)
  9178. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9179. config = append(config, &diagnosisConfig)
  9180. }
  9181. var tempDiaginfos []models.OwnPayPatnDiagListD
  9182. for index, item := range config {
  9183. if index == 0 {
  9184. var tempDiaginfo models.OwnPayPatnDiagListD
  9185. tempDiaginfo.InoutDiagType = "1"
  9186. tempDiaginfo.DiagCode = item.CountryCode
  9187. tempDiaginfo.DiagName = item.CountryContentName
  9188. tempDiaginfo.DiagType = "1"
  9189. tempDiaginfo.DiagSrtNo = "1"
  9190. tempDiaginfo.MaindiagFlag = "1"
  9191. tempDiaginfo.ValiFlag = "1"
  9192. tempDiaginfo.DiagDrName = doctor.UserName
  9193. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9194. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9195. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9196. } else {
  9197. var tempDiaginfo models.OwnPayPatnDiagListD
  9198. tempDiaginfo.DiagCode = item.CountryCode
  9199. tempDiaginfo.DiagName = item.CountryContentName
  9200. tempDiaginfo.DiagType = "2"
  9201. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9202. tempDiaginfo.MaindiagFlag = "0"
  9203. tempDiaginfo.ValiFlag = "1"
  9204. tempDiaginfo.DiagDrName = doctor.UserName
  9205. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9206. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9207. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9208. }
  9209. }
  9210. struct4202.ODiagListD = tempDiaginfos
  9211. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9212. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9213. var res2 ResultSix
  9214. var respJSON2 map[string]interface{}
  9215. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9218. return
  9219. }
  9220. userJSONBytes2, _ := json.Marshal(respJSON2)
  9221. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9222. utils.ErrorLog("解析失败:%v", err)
  9223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9224. return
  9225. }
  9226. if res2.Infcode != 0 {
  9227. c.ServeSuccessJSON(map[string]interface{}{
  9228. "failed_code": -10,
  9229. "msg": res2.ErrMsg,
  9230. })
  9231. return
  9232. } else {
  9233. order.IsUploadDiagnose = 1
  9234. order.IsUploadOrderInfo = 1
  9235. service.UpdateOrderTwo(order)
  9236. c.ServeSuccessJSON(map[string]interface{}{
  9237. "msg": "上传成功",
  9238. })
  9239. }
  9240. }
  9241. func (c *HisApiController) Get4207() {
  9242. admin_user_id, _ := c.GetInt64("admin_user_id")
  9243. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9244. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9245. order_id, _ := c.GetInt64("order_id")
  9246. order, _ := service.GetHisOrderByIDTwo(order_id)
  9247. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9248. var struct4207 models.Struct4207
  9249. struct4207.PageNum = "1"
  9250. struct4207.PageSize = "1000"
  9251. struct4207.FixmedinsCode = miConfig.Code
  9252. struct4207.FixmedinsMdtrtID = order.Number
  9253. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9254. saveLog(result, requestLog, "4207", "查询")
  9255. var res2 ResultSix
  9256. var respJSON2 map[string]interface{}
  9257. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9260. return
  9261. }
  9262. userJSONBytes2, _ := json.Marshal(respJSON2)
  9263. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9264. utils.ErrorLog("解析失败:%v", err)
  9265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9266. return
  9267. }
  9268. if res2.Infcode != 0 {
  9269. c.ServeSuccessJSON(map[string]interface{}{
  9270. "failed_code": -10,
  9271. "msg": res2.ErrMsg,
  9272. })
  9273. return
  9274. } else {
  9275. c.ServeSuccessJSON(map[string]interface{}{
  9276. "msg": "查询成功",
  9277. })
  9278. }
  9279. }
  9280. func (c *HisApiController) Get4208() {
  9281. admin_user_id, _ := c.GetInt64("admin_user_id")
  9282. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9283. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9284. order_id, _ := c.GetInt64("order_id")
  9285. order, _ := service.GetHisOrderByIDTwo(order_id)
  9286. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9287. var struct4208 models.Struct4208
  9288. struct4208.PageNum = "1"
  9289. struct4208.PageSize = "1000"
  9290. struct4208.PsnCertType = "01"
  9291. struct4208.Certno = his.Certno
  9292. struct4208.MedType = order.MedType
  9293. struct4208.PsnName = his.Name
  9294. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9295. saveLog(result, requestLog, "4208", "查询")
  9296. var res2 ResultSix
  9297. var respJSON2 map[string]interface{}
  9298. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9301. return
  9302. }
  9303. userJSONBytes2, _ := json.Marshal(respJSON2)
  9304. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9305. utils.ErrorLog("解析失败:%v", err)
  9306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9307. return
  9308. }
  9309. if res2.Infcode != 0 {
  9310. c.ServeSuccessJSON(map[string]interface{}{
  9311. "failed_code": -10,
  9312. "msg": res2.ErrMsg,
  9313. })
  9314. return
  9315. } else {
  9316. c.ServeSuccessJSON(map[string]interface{}{
  9317. "msg": "查询成功",
  9318. })
  9319. }
  9320. }
  9321. func (c *HisApiController) Get4209() {
  9322. admin_user_id, _ := c.GetInt64("admin_user_id")
  9323. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9324. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9325. order_id, _ := c.GetInt64("order_id")
  9326. order, _ := service.GetHisOrderByIDTwo(order_id)
  9327. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9328. var struct4209 models.Struct4209
  9329. struct4209.FixmedinsMdtrtID = order.Number
  9330. struct4209.FixmedinsCode = miConfig.Code
  9331. struct4209.PageSize = "1000"
  9332. struct4209.PageNum = "1"
  9333. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9334. saveLog(result, requestLog, "4209", "查询")
  9335. var res2 ResultSix
  9336. var respJSON2 map[string]interface{}
  9337. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9340. return
  9341. }
  9342. userJSONBytes2, _ := json.Marshal(respJSON2)
  9343. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9344. utils.ErrorLog("解析失败:%v", err)
  9345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9346. return
  9347. }
  9348. if res2.Infcode != 0 {
  9349. c.ServeSuccessJSON(map[string]interface{}{
  9350. "failed_code": -10,
  9351. "msg": res2.ErrMsg,
  9352. })
  9353. return
  9354. } else {
  9355. c.ServeSuccessJSON(map[string]interface{}{
  9356. "msg": "查询成功",
  9357. })
  9358. }
  9359. }
  9360. type Result3101 struct {
  9361. Infcode string `json:"infcode"`
  9362. InfRefmsgid string `json:"inf_refmsgid"`
  9363. RefmsgTime string `json:"refmsg_time"`
  9364. RespondTime string `json:"respond_time"`
  9365. Enctype string `json:"enctype"`
  9366. Signtype string `json:"signtype"`
  9367. ErrMsg string `json:"err_msg"`
  9368. Output struct {
  9369. Result []struct {
  9370. JudgeResultDetailDtos []struct {
  9371. VolaItemType string `json:"vola_item_type"`
  9372. MdtrtID string `json:"mdtrt_id"`
  9373. JrdID string `json:"jrd_id"`
  9374. PatnID string `json:"patn_id"`
  9375. RxID string `json:"rx_id"`
  9376. VolaAmt interface{} `json:"vola_amt"`
  9377. } `json:"judge_result_detail_dtos"`
  9378. RuleID string `json:"rule_id"`
  9379. VolaEvid string `json:"vola_evid"`
  9380. MdtrtID string `json:"mdtrt_id"`
  9381. RuleName string `json:"rule_name"`
  9382. VolaAmtStas string `json:"vola_amt_stas"`
  9383. JrID string `json:"jr_id"`
  9384. PatnID string `json:"patn_id"`
  9385. SevDeg string `json:"sev_deg"`
  9386. VolaAmt float64 `json:"vola_amt"`
  9387. VolaBhvrType string `json:"vola_bhvr_type"`
  9388. VolaCont string `json:"vola_cont"`
  9389. } `json:"result"`
  9390. } `json:"output"`
  9391. }
  9392. type Resultgd3101 struct {
  9393. Infcode int64 `json:"infcode"`
  9394. InfRefmsgid string `json:"inf_refmsgid"`
  9395. RefmsgTime string `json:"refmsg_time"`
  9396. RespondTime string `json:"respond_time"`
  9397. Enctype string `json:"enctype"`
  9398. Signtype string `json:"signtype"`
  9399. ErrMsg string `json:"err_msg"`
  9400. Output struct {
  9401. Result []struct {
  9402. JudgeResultDetailDtos []struct {
  9403. VolaItemType string `json:"vola_item_type"`
  9404. MdtrtID string `json:"mdtrt_id"`
  9405. JrdID string `json:"jrd_id"`
  9406. PatnID string `json:"patn_id"`
  9407. RxID string `json:"rx_id"`
  9408. VolaAmt interface{} `json:"vola_amt"`
  9409. } `json:"judge_result_detail_dtos"`
  9410. RuleID string `json:"rule_id"`
  9411. VolaEvid string `json:"vola_evid"`
  9412. MdtrtID string `json:"mdtrt_id"`
  9413. RuleName string `json:"rule_name"`
  9414. VolaAmtStas string `json:"vola_amt_stas"`
  9415. JrID string `json:"jr_id"`
  9416. PatnID string `json:"patn_id"`
  9417. SevDeg string `json:"sev_deg"`
  9418. VolaAmt float64 `json:"vola_amt"`
  9419. VolaBhvrType string `json:"vola_bhvr_type"`
  9420. VolaCont string `json:"vola_cont"`
  9421. } `json:"result"`
  9422. } `json:"output"`
  9423. }
  9424. func (c *HisApiController) ReadEleToken() {
  9425. admin_user_id, _ := c.GetInt64("admin_user_id")
  9426. his_patient_id, _ := c.GetInt64("his_patient_id")
  9427. adminUser := c.GetAdminUserInfo()
  9428. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9429. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9430. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9431. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9432. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9433. if len(tokens) > 0 {
  9434. c.ServeSuccessJSON(map[string]interface{}{
  9435. "msg": "读取成功",
  9436. })
  9437. } else {
  9438. c.ServeSuccessJSON(map[string]interface{}{
  9439. "failed_code": -10,
  9440. "msg": "读取失败",
  9441. })
  9442. }
  9443. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9444. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9445. if len(tokens) > 0 {
  9446. c.ServeSuccessJSON(map[string]interface{}{
  9447. "msg": "读取成功",
  9448. })
  9449. } else {
  9450. c.ServeSuccessJSON(map[string]interface{}{
  9451. "failed_code": -10,
  9452. "msg": "读取失败",
  9453. })
  9454. }
  9455. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9456. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9457. if len(tokens) > 0 {
  9458. c.ServeSuccessJSON(map[string]interface{}{
  9459. "msg": "读取成功",
  9460. })
  9461. } else {
  9462. c.ServeSuccessJSON(map[string]interface{}{
  9463. "failed_code": -10,
  9464. "msg": "读取失败",
  9465. })
  9466. }
  9467. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9468. var api string
  9469. 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 +
  9470. "&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"
  9471. resp, requestErr := http.Get(api)
  9472. if requestErr != nil {
  9473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9474. }
  9475. body, ioErr := ioutil.ReadAll(resp.Body)
  9476. if ioErr != nil {
  9477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9479. }
  9480. var respJSON map[string]interface{}
  9481. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9484. return
  9485. }
  9486. var status string
  9487. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9488. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9489. var token string
  9490. var res ResultTwo //1101结果
  9491. var res10265 ResultTwo10265 //1101结果
  9492. if status == "0" { //读卡成功
  9493. var card_info string //卡信息
  9494. var busi_card_info string
  9495. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9496. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9497. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9498. fmt.Println(card_info)
  9499. fmt.Println(busi_card_info)
  9500. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9501. result, _ := json.Marshal(respJSON)
  9502. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9503. utils.ErrorLog("解析失败:%v", err)
  9504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9505. return
  9506. }
  9507. res.ErrMsg = res10265.ErrMsg
  9508. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9509. res.Infcode = infocode
  9510. res.Output = res10265.Output
  9511. res.InfRefmsgid = res10265.InfRefmsgid
  9512. if res.Infcode == 0 {
  9513. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9514. if err == gorm.ErrRecordNotFound {
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9516. return
  9517. } else if err != nil {
  9518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9519. return
  9520. } else {
  9521. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9522. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9523. infoStr := string(Iinfos)
  9524. idetinfoStr := string(Idetinfos)
  9525. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9526. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9527. psn := &models.HisPsn{
  9528. PsnNo: res.Output.Baseinfo.PsnNo,
  9529. PatientId: patient.ID,
  9530. Certno: res.Output.Baseinfo.Certno,
  9531. Gend: res.Output.Baseinfo.Gend,
  9532. Naty: res.Output.Baseinfo.Naty,
  9533. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9534. PsnName: res.Output.Baseinfo.PsnName,
  9535. Age: float64(age),
  9536. Brdy: b,
  9537. Idetinfo: idetinfoStr,
  9538. Insuinfo: infoStr,
  9539. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9540. CardInfo: card_info,
  9541. VerifyNumber: token,
  9542. IdCardType: 4,
  9543. }
  9544. var rf []*ResultFive
  9545. json.Unmarshal([]byte(infoStr), &rf)
  9546. var insutypes []*ResultFive
  9547. var insutype string
  9548. var is390 int = 0
  9549. var is310 int = 0
  9550. for _, item := range rf {
  9551. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9552. insutypes = append(insutypes, item)
  9553. }
  9554. }
  9555. if len(insutypes) == 1 {
  9556. insutype = insutypes[0].Insutype
  9557. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9558. } else {
  9559. for _, i := range insutypes {
  9560. if i.Insutype == "390" {
  9561. is390 = 1
  9562. }
  9563. if i.Insutype == "310" {
  9564. is310 = 1
  9565. }
  9566. }
  9567. }
  9568. if is390 == 1 {
  9569. insutype = "390"
  9570. }
  9571. if is310 == 1 {
  9572. insutype = "310"
  9573. }
  9574. if len(insutypes) == 0 {
  9575. insutype = "310"
  9576. }
  9577. service.CreateHisPsn(psn)
  9578. c.ServeSuccessJSON(map[string]interface{}{
  9579. "patient": patient,
  9580. "number": token,
  9581. "insutype": insutype,
  9582. })
  9583. }
  9584. } else {
  9585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9586. return
  9587. }
  9588. } else { //读卡失败
  9589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9590. return
  9591. }
  9592. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9593. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9594. if len(errMsg) == 0 {
  9595. type ELeData struct {
  9596. Data struct {
  9597. IdNo string `json:"idNo"`
  9598. IdType string `json:"idType"`
  9599. UserName string `json:"userName"`
  9600. EcToken string `json:"ecToken"`
  9601. InsuOrg string `json:"insuOrg"`
  9602. Gender string `json:"gender"`
  9603. Birthday string `json:"birthday"`
  9604. Nationality string `json:"nationality"`
  9605. Email string `json:"email"`
  9606. Extra string `json:"extra"`
  9607. } `json:"data"`
  9608. Code int `json:"code"`
  9609. Message string `json:"message"`
  9610. }
  9611. var ele ELeData
  9612. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9613. if err != nil {
  9614. utils.ErrorLog("解析失败:%v", err)
  9615. }
  9616. token := ele.Data.EcToken
  9617. if len(token) > 0 {
  9618. psn := &models.HisPsn{
  9619. PsnNo: his.PsnNo,
  9620. Age: 0,
  9621. PatientId: his.PatientId,
  9622. Certno: his.Certno,
  9623. Brdy: his.Brdy,
  9624. Gend: his.Gend,
  9625. Naty: his.Naty,
  9626. PsnCertType: his.PsnCertType,
  9627. PsnName: his.PsnName,
  9628. Idetinfo: his.Idetinfo,
  9629. Insuinfo: his.Iinfo,
  9630. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9631. CardInfo: outPutInfo,
  9632. VerifyNumber: token,
  9633. }
  9634. service.CreateHisPsn(psn)
  9635. }
  9636. if len(token) > 0 {
  9637. c.ServeSuccessJSON(map[string]interface{}{
  9638. "msg": "读取成功",
  9639. })
  9640. } else {
  9641. c.ServeSuccessJSON(map[string]interface{}{
  9642. "failed_code": -10,
  9643. "msg": "读取失败",
  9644. })
  9645. }
  9646. }
  9647. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9648. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9649. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9650. type ELeData struct {
  9651. Data struct {
  9652. IdNo string `json:"idNo"`
  9653. IdType string `json:"idType"`
  9654. UserName string `json:"userName"`
  9655. EcToken string `json:"ecToken"`
  9656. InsuOrg string `json:"insuOrg"`
  9657. Gender string `json:"gender"`
  9658. Birthday string `json:"birthday"`
  9659. Nationality string `json:"nationality"`
  9660. Email string `json:"email"`
  9661. Extra string `json:"extra"`
  9662. } `json:"data"`
  9663. Code int `json:"code"`
  9664. Message string `json:"message"`
  9665. }
  9666. var ele ELeData
  9667. err := json.Unmarshal([]byte(result), &ele)
  9668. if err != nil {
  9669. utils.ErrorLog("解析失败:%v", err)
  9670. }
  9671. token := ele.Data.EcToken
  9672. token = Remove0000(token)
  9673. fmt.Println(ele.Data.UserName)
  9674. 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)
  9675. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9676. var res ResultTwo
  9677. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9678. utils.ErrorLog("解析失败:%v", err)
  9679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9680. return
  9681. }
  9682. if res.Infcode == 0 {
  9683. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9684. if err == gorm.ErrRecordNotFound {
  9685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9686. return
  9687. } else if err != nil {
  9688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9689. return
  9690. } else {
  9691. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9692. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9693. infoStr := string(Iinfos)
  9694. idetinfoStr := string(Idetinfos)
  9695. psn := &models.HisPsn{
  9696. PsnNo: res.Output.Baseinfo.PsnNo,
  9697. PatientId: patient.ID,
  9698. Certno: res.Output.Baseinfo.Certno,
  9699. Gend: res.Output.Baseinfo.Gend,
  9700. Naty: res.Output.Baseinfo.Naty,
  9701. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9702. PsnName: res.Output.Baseinfo.PsnName,
  9703. Idetinfo: idetinfoStr,
  9704. Insuinfo: infoStr,
  9705. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9706. CardInfo: "",
  9707. VerifyNumber: token,
  9708. }
  9709. service.CreateHisPsn(psn)
  9710. c.ServeSuccessJSON(map[string]interface{}{
  9711. "patient": patient,
  9712. "number": token,
  9713. })
  9714. }
  9715. } else {
  9716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9717. return
  9718. }
  9719. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9720. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9721. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9722. type ELeData struct {
  9723. Data struct {
  9724. IdNo string `json:"idNo"`
  9725. IdType string `json:"idType"`
  9726. UserName string `json:"userName"`
  9727. EcToken string `json:"ecToken"`
  9728. InsuOrg string `json:"insuOrg"`
  9729. Gender string `json:"gender"`
  9730. Birthday string `json:"birthday"`
  9731. Nationality string `json:"nationality"`
  9732. Email string `json:"email"`
  9733. Extra string `json:"extra"`
  9734. } `json:"data"`
  9735. Code int `json:"code"`
  9736. Message string `json:"message"`
  9737. }
  9738. var ele ELeData
  9739. err := json.Unmarshal([]byte(result), &ele)
  9740. if err != nil {
  9741. utils.ErrorLog("解析失败:%v", err)
  9742. }
  9743. token := ele.Data.EcToken
  9744. token = Remove0000(token)
  9745. fmt.Println(ele.Data.UserName)
  9746. 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)
  9747. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9748. var res ResultTwo
  9749. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9750. utils.ErrorLog("解析失败:%v", err)
  9751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9752. return
  9753. }
  9754. if res.Infcode == 0 {
  9755. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9756. if err == gorm.ErrRecordNotFound {
  9757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9758. return
  9759. } else if err != nil {
  9760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9761. return
  9762. } else {
  9763. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9764. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9765. infoStr := string(Iinfos)
  9766. idetinfoStr := string(Idetinfos)
  9767. psn := &models.HisPsn{
  9768. PsnNo: res.Output.Baseinfo.PsnNo,
  9769. PatientId: patient.ID,
  9770. Certno: res.Output.Baseinfo.Certno,
  9771. Gend: res.Output.Baseinfo.Gend,
  9772. Naty: res.Output.Baseinfo.Naty,
  9773. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9774. PsnName: res.Output.Baseinfo.PsnName,
  9775. Idetinfo: idetinfoStr,
  9776. Insuinfo: infoStr,
  9777. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9778. CardInfo: "",
  9779. VerifyNumber: token,
  9780. }
  9781. service.CreateHisPsn(psn)
  9782. c.ServeSuccessJSON(map[string]interface{}{
  9783. "patient": patient,
  9784. "number": token,
  9785. })
  9786. }
  9787. } else {
  9788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9789. return
  9790. }
  9791. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9792. //if initFlag == 0 {
  9793. //c.TestGetJiangXiBasBaseInit()
  9794. //}
  9795. //if initEleFlag == 0 {
  9796. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9797. //}
  9798. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9799. utils.ErrorLog("解析失败:%v", json_result)
  9800. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9801. type ELeData struct {
  9802. Data struct {
  9803. IdNo string `json:"idNo"`
  9804. IdType string `json:"idType"`
  9805. UserName string `json:"userName"`
  9806. EcToken string `json:"ecToken"`
  9807. InsuOrg string `json:"insuOrg"`
  9808. Gender string `json:"gender"`
  9809. Birthday string `json:"birthday"`
  9810. Nationality string `json:"nationality"`
  9811. Email string `json:"email"`
  9812. Extra string `json:"extra"`
  9813. } `json:"data"`
  9814. Code int `json:"code"`
  9815. Message string `json:"message"`
  9816. }
  9817. var ele ELeData
  9818. err := json.Unmarshal([]byte(json_result), &ele)
  9819. if err != nil {
  9820. utils.ErrorLog("解析失败:%v", err)
  9821. }
  9822. token := ele.Data.EcToken
  9823. token = Remove0000(token)
  9824. //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)
  9825. 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)
  9826. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9827. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9828. var res ResultTwo
  9829. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9830. utils.ErrorLog("解析失败:%v", err)
  9831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9832. return
  9833. }
  9834. if res.Infcode == 0 {
  9835. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9836. if err == gorm.ErrRecordNotFound {
  9837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9838. return
  9839. } else if err != nil {
  9840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9841. return
  9842. } else {
  9843. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9844. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9845. infoStr := string(Iinfos)
  9846. idetinfoStr := string(Idetinfos)
  9847. psn := &models.HisPsn{
  9848. PsnNo: res.Output.Baseinfo.PsnNo,
  9849. PatientId: patient.ID,
  9850. Certno: res.Output.Baseinfo.Certno,
  9851. Gend: res.Output.Baseinfo.Gend,
  9852. Naty: res.Output.Baseinfo.Naty,
  9853. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9854. PsnName: res.Output.Baseinfo.PsnName,
  9855. Idetinfo: idetinfoStr,
  9856. Insuinfo: infoStr,
  9857. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9858. CardInfo: "",
  9859. VerifyNumber: token,
  9860. InsuplcAdmdvs: ele.Data.InsuOrg,
  9861. }
  9862. service.CreateHisPsn(psn)
  9863. c.ServeSuccessJSON(map[string]interface{}{
  9864. "patient": patient,
  9865. "number": token,
  9866. })
  9867. }
  9868. } else {
  9869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9870. return
  9871. }
  9872. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9873. res := c.GetoleInfo()
  9874. if res.Infcode == 0 {
  9875. var result string
  9876. if res.Output.MdtrtCertType == "01" {
  9877. 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)
  9878. } else if res.Output.MdtrtCertType == "02" {
  9879. 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)
  9880. } else if res.Output.MdtrtCertType == "03" {
  9881. 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)
  9882. }
  9883. var dat map[string]interface{}
  9884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9885. fmt.Println(dat)
  9886. } else {
  9887. fmt.Println(err)
  9888. }
  9889. userJSONBytes, _ := json.Marshal(dat)
  9890. var res2 ResultTwo
  9891. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9892. utils.ErrorLog("解析失败:%v", err)
  9893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9894. return
  9895. }
  9896. if res2.Infcode == 0 {
  9897. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9898. if err == gorm.ErrRecordNotFound {
  9899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9900. return
  9901. } else if err != nil {
  9902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9903. return
  9904. } else {
  9905. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9906. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9907. infoStr := string(Iinfos)
  9908. idetinfoStr := string(Idetinfos)
  9909. var rf []*ResultFive
  9910. json.Unmarshal([]byte(infoStr), &rf)
  9911. var insutypes []*ResultFive
  9912. var insutype string
  9913. var is390 int = 0
  9914. var is310 int = 0
  9915. //var insuplc_admdvs string
  9916. for _, item := range rf {
  9917. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9918. insutypes = append(insutypes, item)
  9919. }
  9920. }
  9921. if len(insutypes) == 1 {
  9922. insutype = insutypes[0].Insutype
  9923. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9924. } else {
  9925. for _, i := range insutypes {
  9926. if i.Insutype == "390" {
  9927. is390 = 1
  9928. }
  9929. if i.Insutype == "310" {
  9930. is310 = 1
  9931. }
  9932. }
  9933. }
  9934. if is390 == 1 {
  9935. insutype = "390"
  9936. }
  9937. if is310 == 1 {
  9938. insutype = "310"
  9939. }
  9940. if len(insutypes) == 0 {
  9941. insutype = "310"
  9942. }
  9943. psn := &models.HisPsn{
  9944. PsnNo: res2.Output.Baseinfo.PsnNo,
  9945. PatientId: patient.ID,
  9946. Certno: res2.Output.Baseinfo.Certno,
  9947. Gend: res2.Output.Baseinfo.Gend,
  9948. Naty: res2.Output.Baseinfo.Naty,
  9949. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9950. PsnName: res2.Output.Baseinfo.PsnName,
  9951. Idetinfo: idetinfoStr,
  9952. Insuinfo: infoStr,
  9953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9954. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9955. VerifyNumber: res.Output.EcToken,
  9956. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9957. }
  9958. service.CreateHisPsn(psn)
  9959. c.ServeSuccessJSON(map[string]interface{}{
  9960. "patient": patient,
  9961. "number": res.Output.CardNo,
  9962. "insutype": insutype,
  9963. })
  9964. }
  9965. } else {
  9966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9967. return
  9968. }
  9969. } else {
  9970. c.ServeSuccessJSON(map[string]interface{}{
  9971. "failed_code": -10,
  9972. "msg": res.ErrMsg,
  9973. })
  9974. }
  9975. } else {
  9976. //if initFlag == 0 {
  9977. // c.TestGetBasBaseInit()
  9978. //}
  9979. //token := c.GetEleBaseInfo()
  9980. //token = Remove0000(token)
  9981. type ELeData struct {
  9982. Code string `json:"code"`
  9983. Data struct {
  9984. Aac002 string `json:"aac002"`
  9985. Aaz500 string `json:"aaz500"`
  9986. ActCardNo string `json:"actCardNo"`
  9987. Bab520 string `json:"bab520"`
  9988. Bkz543 string `json:"bkz543"`
  9989. BusinessType string `json:"businessType"`
  9990. CertfCodg string `json:"certfCodg"`
  9991. EcIndexNo string `json:"ecIndexNo"`
  9992. EcToken string `json:"ecToken"`
  9993. ID0000 string `json:"id0000"`
  9994. IDNo string `json:"idNo"`
  9995. IDType string `json:"idType"`
  9996. Idcode string `json:"idcode"`
  9997. IdentityToken string `json:"identity_token"`
  9998. InsuOrg string `json:"insuOrg"`
  9999. OfficeID string `json:"officeId"`
  10000. OfficeName string `json:"officeName"`
  10001. OperatorID string `json:"operatorId"`
  10002. OperatorName string `json:"operatorName"`
  10003. OrgID string `json:"orgId"`
  10004. UserName string `json:"userName"`
  10005. } `json:"data"`
  10006. Infno interface{} `json:"infno"`
  10007. Message string `json:"message"`
  10008. OrgID string `json:"orgId"`
  10009. TransType string `json:"transType"`
  10010. }
  10011. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10012. fmt.Println(result)
  10013. outPutInfo := Remove0000(result)
  10014. fmt.Println(outPutInfo)
  10015. var ele ELeData
  10016. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10017. if err != nil {
  10018. utils.ErrorLog("解析失败:%v", err)
  10019. }
  10020. token := ele.Data.EcToken
  10021. var result2 string
  10022. var requestLog2 string
  10023. if len(token) > 0 {
  10024. if strings.Contains(ele.Data.IDNo, "HKG") {
  10025. 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)
  10026. } else {
  10027. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10028. }
  10029. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10030. var res ResultTwo
  10031. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10032. utils.ErrorLog("解析失败:%v", err)
  10033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10034. return
  10035. }
  10036. if res.Infcode == 0 {
  10037. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10038. if err == gorm.ErrRecordNotFound {
  10039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10040. return
  10041. } else if err != nil {
  10042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10043. return
  10044. } else {
  10045. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10046. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10047. infoStr := string(Iinfos)
  10048. idetinfoStr := string(Idetinfos)
  10049. psn := &models.HisPsn{
  10050. PsnNo: res.Output.Baseinfo.PsnNo,
  10051. PatientId: patient.ID,
  10052. Certno: res.Output.Baseinfo.Certno,
  10053. Gend: res.Output.Baseinfo.Gend,
  10054. Naty: res.Output.Baseinfo.Naty,
  10055. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10056. PsnName: res.Output.Baseinfo.PsnName,
  10057. Idetinfo: idetinfoStr,
  10058. Insuinfo: infoStr,
  10059. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10060. CardInfo: "",
  10061. VerifyNumber: token,
  10062. }
  10063. service.CreateHisPsn(psn)
  10064. c.ServeSuccessJSON(map[string]interface{}{
  10065. "msg": "读取成功",
  10066. })
  10067. }
  10068. } else {
  10069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10070. return
  10071. }
  10072. } else {
  10073. c.ServeSuccessJSON(map[string]interface{}{
  10074. "failed_code": -10,
  10075. "msg": "读取失败",
  10076. })
  10077. }
  10078. }
  10079. }
  10080. func (c *HisApiController) ReadEleFace() {
  10081. admin_user_id, _ := c.GetInt64("admin_user_id")
  10082. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10083. adminUser := c.GetAdminUserInfo()
  10084. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10085. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10086. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10087. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10088. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10089. if len(tokens) > 0 {
  10090. c.ServeSuccessJSON(map[string]interface{}{
  10091. "msg": "读取成功",
  10092. })
  10093. } else {
  10094. c.ServeSuccessJSON(map[string]interface{}{
  10095. "failed_code": -10,
  10096. "msg": "读取失败",
  10097. })
  10098. }
  10099. }
  10100. }
  10101. func (c *HisApiController) Get9001() {
  10102. adminUser := c.GetAdminUserInfo()
  10103. admin_user_id, _ := c.GetInt64("admin_user_id")
  10104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10105. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10106. if miConfig.MdtrtareaAdmvs == "350500" {
  10107. service.GetFjAuthorizationInfo(miConfig.Code)
  10108. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10109. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10110. var dat map[string]interface{}
  10111. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10112. fmt.Println(dat)
  10113. } else {
  10114. fmt.Println(err)
  10115. }
  10116. userJSONBytes, _ := json.Marshal(dat)
  10117. var res models.Result9001
  10118. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10119. utils.ErrorLog("解析失败:%v", err)
  10120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10121. return
  10122. }
  10123. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10124. fmt.Println(miConfig.SecretKey)
  10125. var res models.Result9001Two
  10126. 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 +
  10127. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10128. resp, requestErr := http.Get(api)
  10129. if requestErr != nil {
  10130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10131. return
  10132. }
  10133. body, ioErr := ioutil.ReadAll(resp.Body)
  10134. if ioErr != nil {
  10135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10137. return
  10138. }
  10139. var respJSON map[string]interface{}
  10140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. return
  10144. }
  10145. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10146. if status == "0" {
  10147. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10148. c.ServeSuccessJSON(map[string]interface{}{
  10149. "failed_code": -10,
  10150. "msg": err_msg,
  10151. })
  10152. return
  10153. }
  10154. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10155. result, _ := json.Marshal(respJSON)
  10156. fmt.Println("log")
  10157. fmt.Println(string(result))
  10158. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10159. utils.ErrorLog("解析失败:%v", err)
  10160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10161. return
  10162. }
  10163. if res.Infcode == 0 {
  10164. sign := models.HisSignIn{
  10165. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10166. SignNo: res.Output.Signinoutb.SignNo,
  10167. SignTime: "",
  10168. Ctime: time.Now().Unix(),
  10169. Mtime: time.Now().Unix(),
  10170. Status: 1,
  10171. InputLog: "",
  10172. OutputLog: "",
  10173. FixmedinsCode: miConfig.Code,
  10174. }
  10175. err := service.CreateSignIn(&sign)
  10176. if err == nil {
  10177. c.ServeSuccessJSON(map[string]interface{}{
  10178. "msg": "签到成功",
  10179. })
  10180. }
  10181. } else {
  10182. c.ServeSuccessJSON(map[string]interface{}{
  10183. "failed_code": -10,
  10184. "msg": res.ErrMsg,
  10185. })
  10186. return
  10187. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10188. //return
  10189. }
  10190. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10191. fmt.Println(miConfig.SecretKey)
  10192. var res models.Result9001Two
  10193. 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 +
  10194. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10195. resp, requestErr := http.Get(api)
  10196. if requestErr != nil {
  10197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10198. return
  10199. }
  10200. body, ioErr := ioutil.ReadAll(resp.Body)
  10201. if ioErr != nil {
  10202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10204. return
  10205. }
  10206. var respJSON map[string]interface{}
  10207. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10210. return
  10211. }
  10212. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10213. if status == "0" {
  10214. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10215. c.ServeSuccessJSON(map[string]interface{}{
  10216. "failed_code": -10,
  10217. "msg": err_msg,
  10218. })
  10219. return
  10220. }
  10221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10222. result, _ := json.Marshal(respJSON)
  10223. fmt.Println("log")
  10224. fmt.Println(string(result))
  10225. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10226. utils.ErrorLog("解析失败:%v", err)
  10227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10228. return
  10229. }
  10230. if res.Infcode == 0 {
  10231. sign := models.HisSignIn{
  10232. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10233. SignNo: res.Output.Signinoutb.SignNo,
  10234. SignTime: "",
  10235. Ctime: time.Now().Unix(),
  10236. Mtime: time.Now().Unix(),
  10237. Status: 1,
  10238. InputLog: "",
  10239. OutputLog: "",
  10240. FixmedinsCode: miConfig.Code,
  10241. }
  10242. err := service.CreateSignIn(&sign)
  10243. if err == nil {
  10244. c.ServeSuccessJSON(map[string]interface{}{
  10245. "msg": "签到成功",
  10246. })
  10247. }
  10248. } else {
  10249. c.ServeSuccessJSON(map[string]interface{}{
  10250. "failed_code": -10,
  10251. "msg": res.ErrMsg,
  10252. })
  10253. return
  10254. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10255. //return
  10256. }
  10257. } else {
  10258. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10259. var dat map[string]interface{}
  10260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10261. fmt.Println(dat)
  10262. } else {
  10263. fmt.Println(err)
  10264. }
  10265. userJSONBytes, _ := json.Marshal(dat)
  10266. var res models.Result9001
  10267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10268. utils.ErrorLog("解析失败:%v", err)
  10269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10270. return
  10271. }
  10272. if res.Infcode == 0 {
  10273. sign := models.HisSignIn{
  10274. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10275. SignNo: res.Output.Signinoutb.SignNo,
  10276. SignTime: res.Output.Signinoutb.SignTime,
  10277. Ctime: time.Now().Unix(),
  10278. Mtime: time.Now().Unix(),
  10279. Status: 1,
  10280. InputLog: "",
  10281. OutputLog: "",
  10282. FixmedinsCode: miConfig.Code,
  10283. }
  10284. err := service.CreateSignIn(&sign)
  10285. if err == nil {
  10286. c.ServeSuccessJSON(map[string]interface{}{
  10287. "msg": "签到成功",
  10288. })
  10289. }
  10290. }
  10291. }
  10292. }
  10293. 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) {
  10294. var res Result3101
  10295. adminUser := c.GetAdminUserInfo()
  10296. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10297. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10298. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10299. //record_time := c.GetString("record_time")
  10300. //trig_scen := c.GetString("trig_scen")
  10301. timeLayout := "2006-01-02"
  10302. loc, _ := time.LoadLocation("Local")
  10303. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10304. if err != nil {
  10305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10306. return res
  10307. }
  10308. recordDateTime := theTime.Unix()
  10309. var patientPrescription models.HisPrescriptionInfo
  10310. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10311. //if patientPrescription.ID == 0 {
  10312. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10313. //}
  10314. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10315. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10316. //
  10317. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10318. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10319. var pp models.PublicParams
  10320. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10321. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10322. pp.FixmedinsName = miConfig.OrgName
  10323. pp.FixmedinsCode = miConfig.Code
  10324. pp.RequestUrl = miConfig.Url
  10325. pp.Cainfo = miConfig.Cainfo
  10326. pp.SecretKey = miConfig.SecretKey
  10327. pp.AccessKey = miConfig.AccessKey
  10328. pp.OpterName = roles.UserName
  10329. var config []*models.HisXtDiagnoseConfig
  10330. for _, item := range diagnosis_ids {
  10331. id, _ := strconv.ParseInt(item, 10, 64)
  10332. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10333. config = append(config, &diagnosisConfig)
  10334. }
  10335. var pd models.PatientDtos
  10336. pd.PatnID = his.PsnNo
  10337. pd.PatnName = his.Name
  10338. pd.Gend = his.Gend
  10339. pd.Brdy = his.Brdy
  10340. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10341. pd.CurrMdtrtID = his.Number
  10342. var fed models.FsiEncounterDtos
  10343. fed.MdtrtID = his.Number
  10344. fed.MedinsID = miConfig.Code
  10345. fed.MedinsName = miConfig.OrgName
  10346. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10347. fed.MedMdtrtType = "1"
  10348. fed.MedinsType = "1"
  10349. fed.MedinsLv = "11"
  10350. tm := time.Unix(his.RecordDate, 0)
  10351. s_tm := tm.Format("2006-01-02 15:04:05")
  10352. fed.AdmDate = s_tm
  10353. fed.DscgDate = s_tm
  10354. fed.DscgMainDiseCodg = config[0].CountryCode
  10355. fed.DscgMainDiseName = config[0].CountryContentName
  10356. //诊断信息
  10357. var fdds []*models.FsiDiagnoseDtos
  10358. for index, item := range config {
  10359. if index == 0 {
  10360. var fdd models.FsiDiagnoseDtos
  10361. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10362. fdd.InoutDiseType = "1"
  10363. fdd.MaindiseFlag = "1"
  10364. fdd.DiseDate = s_tm
  10365. fdd.DiasSrtNo = "1"
  10366. fdd.DiseName = item.CountryContentName
  10367. fdd.DiseCodg = item.CountryCode
  10368. fdds = append(fdds, &fdd)
  10369. } else {
  10370. var fdd models.FsiDiagnoseDtos
  10371. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10372. fdd.InoutDiseType = "1"
  10373. fdd.MaindiseFlag = "1"
  10374. fdd.DiseDate = s_tm
  10375. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10376. fdd.DiseName = item.CountryContentName
  10377. fdd.DiseCodg = item.CountryCode
  10378. fdds = append(fdds, &fdd)
  10379. }
  10380. }
  10381. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10382. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10383. fed.AdmDeptName = de.Name
  10384. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10385. fed.DscgDeptName = de.Name
  10386. fed.MedMdtrtType = "1"
  10387. fed.MedType = "11"
  10388. //if his.Insutype == "390" {
  10389. // fed.MedType = "1402"
  10390. //} else {
  10391. // fed.MedType = "9933"
  10392. //}
  10393. var orders []*models.FsiOrderDtos
  10394. if trig_scen == "2" {
  10395. //处方医嘱信息
  10396. for _, item := range prescriptions {
  10397. for _, subItem := range item.HisDoctorAdviceInfo {
  10398. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10399. var order models.FsiOrderDtos
  10400. order.RxID = strconv.FormatInt(item.ID, 10)
  10401. order.Rxno = strconv.FormatInt(item.ID, 10)
  10402. order.LongDrordFlag = "0"
  10403. order.HilistType = "1"
  10404. order.ChrgType = "1"
  10405. order.DrordBhvr = "-"
  10406. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10407. order.HosplistName = subItem.BaseDrugLib.DrugName
  10408. order.HilistLv = "1"
  10409. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10410. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10411. order.HosplistName = subItem.BaseDrugLib.DrugName
  10412. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10413. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10414. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10415. order.OwnpayAmt = ""
  10416. order.SelfpayAmt = ""
  10417. order.Spec = ""
  10418. order.SpecUnt = ""
  10419. order.DrordBegnDate = s_tm
  10420. order.DrordStopDate = ""
  10421. order.DrordDrCodg = doctor_info.DoctorNumber
  10422. order.DrordDeptName = department.Name
  10423. order.DrordDeptCodg = department.Number
  10424. order.DrordDrName = doctor_info.UserName
  10425. order.DrordDrProfttl = "234"
  10426. order.CurrDrordFlag = "1"
  10427. orders = append(orders, &order)
  10428. }
  10429. }
  10430. for _, subItem := range item.HisPrescriptionProject {
  10431. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10432. var order models.FsiOrderDtos
  10433. order.RxID = strconv.FormatInt(item.ID, 10)
  10434. order.Rxno = strconv.FormatInt(item.ID, 10)
  10435. order.LongDrordFlag = "0"
  10436. order.HilistType = "1"
  10437. order.ChrgType = "1"
  10438. order.DrordBhvr = "-"
  10439. order.HilistCode = subItem.HisProject.MedicalCode
  10440. order.HosplistName = subItem.HisProject.ProjectName
  10441. order.HilistLv = "1"
  10442. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10443. order.HosplistCode = subItem.HisProject.MedicalCode
  10444. order.HosplistName = subItem.HisProject.ProjectName
  10445. order.Cnt = subItem.Count
  10446. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10447. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10448. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10449. order.OwnpayAmt = ""
  10450. order.SelfpayAmt = ""
  10451. order.Spec = ""
  10452. order.SpecUnt = ""
  10453. order.DrordBegnDate = s_tm
  10454. order.DrordStopDate = ""
  10455. order.DrordDrCodg = doctor_info.DoctorNumber
  10456. order.DrordDeptName = department.Name
  10457. order.DrordDeptCodg = department.Number
  10458. order.DrordDrName = doctor_info.UserName
  10459. order.DrordDrProfttl = "234"
  10460. order.CurrDrordFlag = "1"
  10461. orders = append(orders, &order)
  10462. }
  10463. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10464. var order models.FsiOrderDtos
  10465. order.RxID = strconv.FormatInt(item.ID, 10)
  10466. order.Rxno = strconv.FormatInt(item.ID, 10)
  10467. order.LongDrordFlag = "0"
  10468. order.HilistType = "1"
  10469. order.ChrgType = "1"
  10470. order.DrordBhvr = "-"
  10471. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10472. order.HosplistName = subItem.GoodInfo.GoodName
  10473. order.HilistLv = "1"
  10474. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10475. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10476. order.HosplistName = subItem.GoodInfo.GoodName
  10477. order.Cnt = subItem.Count
  10478. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10479. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10480. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10481. order.OwnpayAmt = ""
  10482. order.SelfpayAmt = ""
  10483. order.Spec = ""
  10484. order.SpecUnt = ""
  10485. order.DrordBegnDate = s_tm
  10486. order.DrordStopDate = ""
  10487. order.DrordDrCodg = doctor_info.DoctorNumber
  10488. order.DrordDeptName = department.Name
  10489. order.DrordDeptCodg = department.Number
  10490. order.DrordDrName = doctor_info.UserName
  10491. order.DrordDrProfttl = "234"
  10492. order.CurrDrordFlag = "1"
  10493. orders = append(orders, &order)
  10494. }
  10495. }
  10496. }
  10497. //处方医嘱信息
  10498. }
  10499. fed.MatnStas = "0"
  10500. fed.MedfeeSumamt = "0"
  10501. fed.OwnpayAmt = "0"
  10502. fed.SelfpayAmt = "0"
  10503. fed.AcctPayamt = "0"
  10504. fed.MaAmt = "0"
  10505. fed.HifpPayamt = "0"
  10506. fed.SetlTotlnum = "1"
  10507. fed.Insutype = his.Insutype
  10508. fed.ReimFlag = "0"
  10509. fed.OutSetlFlag = "0"
  10510. var fopd []*models.FsiOperationDtosData
  10511. data := make(map[string]interface{})
  10512. data["fed"] = fed
  10513. data["fdd"] = fdds
  10514. data["fod"] = orders
  10515. data["pd"] = pd
  10516. data["pp"] = pp
  10517. data["fopd"] = fopd
  10518. data["trig_scen"] = trig_scen
  10519. fmt.Println(data)
  10520. fmt.Println(fed)
  10521. fmt.Println(fdds)
  10522. fmt.Println(orders)
  10523. fmt.Println(pd)
  10524. fmt.Println(pp)
  10525. fmt.Println(fopd)
  10526. client := &http.Client{}
  10527. bytesData, _ := json.Marshal(data)
  10528. var req *http.Request
  10529. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10530. if miConfig.MdtrtareaAdmvs == "320921" {
  10531. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10532. } else {
  10533. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10534. }
  10535. resp, _ := client.Do(req)
  10536. defer resp.Body.Close()
  10537. body, ioErr := ioutil.ReadAll(resp.Body)
  10538. if ioErr != nil {
  10539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10541. return res
  10542. }
  10543. var respJSON map[string]interface{}
  10544. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10547. return res
  10548. }
  10549. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10550. fmt.Println(respJSON)
  10551. result, _ := json.Marshal(respJSON)
  10552. fmt.Println(result)
  10553. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10554. utils.ErrorLog("解析失败:%v", err)
  10555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10556. return res
  10557. }
  10558. return res
  10559. } else {
  10560. //if miConfig.MdtrtareaAdmvs == "441202" {
  10561. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10562. saveLog(output, input, "3101", "事前")
  10563. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10564. utils.ErrorLog("解析失败:%v", err)
  10565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10566. return
  10567. }
  10568. return res
  10569. //}
  10570. }
  10571. }
  10572. 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) {
  10573. adminUser := c.GetAdminUserInfo()
  10574. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10575. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10576. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10577. //record_time := c.GetString("record_time")
  10578. //trig_scen := c.GetString("trig_scen")
  10579. timeLayout := "2006-01-02"
  10580. loc, _ := time.LoadLocation("Local")
  10581. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10582. if err != nil {
  10583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10584. return res
  10585. }
  10586. recordDateTime := theTime.Unix()
  10587. var patientPrescription models.HisPrescriptionInfo
  10588. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10589. if patientPrescription.ID == 0 {
  10590. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10591. }
  10592. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10593. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10594. //
  10595. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10596. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10597. var pp models.PublicParams
  10598. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10599. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10600. pp.FixmedinsName = miConfig.OrgName
  10601. pp.FixmedinsCode = miConfig.Code
  10602. pp.RequestUrl = miConfig.Url
  10603. pp.Cainfo = miConfig.Cainfo
  10604. pp.SecretKey = miConfig.SecretKey
  10605. pp.AccessKey = miConfig.AccessKey
  10606. pp.OpterName = roles.UserName
  10607. var config []*models.HisXtDiagnoseConfig
  10608. for _, item := range diagnosis_ids {
  10609. id, _ := strconv.ParseInt(item, 10, 64)
  10610. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10611. config = append(config, &diagnosisConfig)
  10612. }
  10613. var pd models.PatientDtos
  10614. pd.PatnID = his.PsnNo
  10615. pd.PatnName = his.Name
  10616. pd.Gend = his.Gend
  10617. pd.Brdy = his.Brdy
  10618. pd.Poolarea = his.InsuplcAdmdvs
  10619. pd.CurrMdtrtID = his.Number
  10620. var fed models.FsiEncounterDtos
  10621. fed.MdtrtID = his.Number
  10622. fed.MedinsID = miConfig.Code
  10623. fed.MedinsName = miConfig.OrgName
  10624. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10625. fed.MedMdtrtType = "1"
  10626. fed.MedinsType = "1"
  10627. fed.MedinsLv = "11"
  10628. tm := time.Unix(his.RecordDate, 0)
  10629. s_tm := tm.Format("2006-01-02 15:04:05")
  10630. fed.AdmDate = s_tm
  10631. fed.DscgDate = s_tm
  10632. fed.DscgMainDiseCodg = config[0].CountryCode
  10633. fed.DscgMainDiseName = config[0].CountryContentName
  10634. //诊断信息
  10635. var fdds []*models.FsiDiagnoseDtos
  10636. for index, item := range config {
  10637. if index == 0 {
  10638. var fdd models.FsiDiagnoseDtos
  10639. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10640. fdd.InoutDiseType = "1"
  10641. fdd.MaindiseFlag = "1"
  10642. fdd.DiseDate = s_tm
  10643. fdd.DiasSrtNo = "1"
  10644. fdd.DiseName = item.CountryContentName
  10645. fdd.DiseCodg = item.CountryCode
  10646. fdds = append(fdds, &fdd)
  10647. } else {
  10648. var fdd models.FsiDiagnoseDtos
  10649. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10650. fdd.InoutDiseType = "1"
  10651. fdd.MaindiseFlag = "1"
  10652. fdd.DiseDate = s_tm
  10653. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10654. fdd.DiseName = item.CountryContentName
  10655. fdd.DiseCodg = item.CountryCode
  10656. fdds = append(fdds, &fdd)
  10657. }
  10658. }
  10659. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10660. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10661. fed.AdmDeptName = department.Name
  10662. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10663. fed.DscgDeptName = department.Name
  10664. fed.MedMdtrtType = "1"
  10665. fed.MedType = "11"
  10666. //if his.Insutype == "390" {
  10667. // fed.MedType = "1402"
  10668. //} else {
  10669. // fed.MedType = "9933"
  10670. //}
  10671. var orders []*models.FsiOrderDtos
  10672. if trig_scen == "2" {
  10673. //处方医嘱信息
  10674. for _, item := range prescriptions {
  10675. for _, subItem := range item.HisDoctorAdviceInfo {
  10676. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10677. var order models.FsiOrderDtos
  10678. order.RxID = strconv.FormatInt(item.ID, 10)
  10679. order.Rxno = strconv.FormatInt(item.ID, 10)
  10680. order.LongDrordFlag = "0"
  10681. order.HilistType = "1"
  10682. order.ChrgType = "1"
  10683. order.DrordBhvr = "-"
  10684. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10685. order.HosplistName = subItem.BaseDrugLib.DrugName
  10686. order.HilistLv = "1"
  10687. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10688. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10689. order.HosplistName = subItem.BaseDrugLib.DrugName
  10690. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10691. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10692. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10693. order.OwnpayAmt = ""
  10694. order.SelfpayAmt = ""
  10695. order.Spec = ""
  10696. order.SpecUnt = ""
  10697. order.DrordBegnDate = s_tm
  10698. order.DrordStopDate = ""
  10699. order.DrordDrCodg = doctor_info.DoctorNumber
  10700. order.DrordDeptName = department.Name
  10701. order.DrordDeptCodg = department.Number
  10702. order.DrordDrName = doctor_info.UserName
  10703. order.DrordDrProfttl = "234"
  10704. order.CurrDrordFlag = "1"
  10705. orders = append(orders, &order)
  10706. }
  10707. }
  10708. for _, subItem := range item.HisPrescriptionProject {
  10709. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10710. var order models.FsiOrderDtos
  10711. order.RxID = strconv.FormatInt(item.ID, 10)
  10712. order.Rxno = strconv.FormatInt(item.ID, 10)
  10713. order.LongDrordFlag = "0"
  10714. order.HilistType = "1"
  10715. order.ChrgType = "1"
  10716. order.DrordBhvr = "-"
  10717. order.HilistCode = subItem.HisProject.MedicalCode
  10718. order.HosplistName = subItem.HisProject.ProjectName
  10719. order.HilistLv = "1"
  10720. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10721. order.HosplistCode = subItem.HisProject.MedicalCode
  10722. order.HosplistName = subItem.HisProject.ProjectName
  10723. order.Cnt = subItem.Count
  10724. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10725. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10726. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10727. order.OwnpayAmt = ""
  10728. order.SelfpayAmt = ""
  10729. order.Spec = ""
  10730. order.SpecUnt = ""
  10731. order.DrordBegnDate = s_tm
  10732. order.DrordStopDate = ""
  10733. order.DrordDrCodg = doctor_info.DoctorNumber
  10734. order.DrordDeptName = department.Name
  10735. order.DrordDeptCodg = department.Number
  10736. order.DrordDrName = doctor_info.UserName
  10737. order.DrordDrProfttl = "234"
  10738. order.CurrDrordFlag = "1"
  10739. orders = append(orders, &order)
  10740. }
  10741. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10742. var order models.FsiOrderDtos
  10743. order.RxID = strconv.FormatInt(item.ID, 10)
  10744. order.Rxno = strconv.FormatInt(item.ID, 10)
  10745. order.LongDrordFlag = "0"
  10746. order.HilistType = "1"
  10747. order.ChrgType = "1"
  10748. order.DrordBhvr = "-"
  10749. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10750. order.HosplistName = subItem.GoodInfo.GoodName
  10751. order.HilistLv = "1"
  10752. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10753. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10754. order.HosplistName = subItem.GoodInfo.GoodName
  10755. order.Cnt = subItem.Count
  10756. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10757. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10758. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10759. order.OwnpayAmt = ""
  10760. order.SelfpayAmt = ""
  10761. order.Spec = ""
  10762. order.SpecUnt = ""
  10763. order.DrordBegnDate = s_tm
  10764. order.DrordStopDate = ""
  10765. order.DrordDrCodg = doctor_info.DoctorNumber
  10766. order.DrordDeptName = department.Name
  10767. order.DrordDeptCodg = department.Number
  10768. order.DrordDrName = doctor_info.UserName
  10769. order.DrordDrProfttl = "234"
  10770. order.CurrDrordFlag = "1"
  10771. orders = append(orders, &order)
  10772. }
  10773. }
  10774. }
  10775. //处方医嘱信息
  10776. }
  10777. fed.MatnStas = "0"
  10778. fed.MedfeeSumamt = "0"
  10779. fed.OwnpayAmt = "0"
  10780. fed.SelfpayAmt = "0"
  10781. fed.AcctPayamt = "0"
  10782. fed.MaAmt = "0"
  10783. fed.HifpPayamt = "0"
  10784. fed.SetlTotlnum = "1"
  10785. fed.Insutype = his.Insutype
  10786. fed.ReimFlag = "0"
  10787. fed.OutSetlFlag = "0"
  10788. var fopd []*models.FsiOperationDtosData
  10789. data := make(map[string]interface{})
  10790. data["fed"] = fed
  10791. data["fdd"] = fdds
  10792. data["fod"] = orders
  10793. data["pd"] = pd
  10794. data["pp"] = pp
  10795. data["fopd"] = fopd
  10796. data["trig_scen"] = trig_scen
  10797. fmt.Println(data)
  10798. fmt.Println(fed)
  10799. fmt.Println(fdds)
  10800. fmt.Println(orders)
  10801. fmt.Println(pd)
  10802. fmt.Println(pp)
  10803. fmt.Println(fopd)
  10804. client := &http.Client{}
  10805. bytesData, _ := json.Marshal(data)
  10806. var req *http.Request
  10807. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10808. if miConfig.MdtrtareaAdmvs == "320921" {
  10809. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10810. } else {
  10811. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10812. }
  10813. resp, _ := client.Do(req)
  10814. defer resp.Body.Close()
  10815. body, ioErr := ioutil.ReadAll(resp.Body)
  10816. if ioErr != nil {
  10817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10819. return res
  10820. }
  10821. var respJSON map[string]interface{}
  10822. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10825. return res
  10826. }
  10827. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10828. fmt.Println(respJSON)
  10829. result, _ := json.Marshal(respJSON)
  10830. fmt.Println(result)
  10831. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10832. utils.ErrorLog("解析失败:%v", err)
  10833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10834. return res
  10835. }
  10836. return res
  10837. } else {
  10838. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10839. saveLog(output, input, "3101", "事前")
  10840. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10841. utils.ErrorLog("解析失败:%v", err)
  10842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10843. return
  10844. }
  10845. return res
  10846. }
  10847. return res
  10848. }
  10849. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10850. ////patient_id, _ := c.GetInt64("patient_id")
  10851. //order_id, _ := c.GetInt64("order_id")
  10852. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10853. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10854. //trig_scen := c.GetString("trig_scen")
  10855. adminUser := c.GetAdminUserInfo()
  10856. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10857. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10858. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10859. record_time := c.GetString("record_time")
  10860. order, _ := service.GetHisOrderByID(order_id)
  10861. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10862. timeLayout := "2006-01-02"
  10863. loc, _ := time.LoadLocation("Local")
  10864. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10865. if err != nil {
  10866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10867. return
  10868. }
  10869. recordDateTime := theTime.Unix()
  10870. var patientPrescription models.HisPrescriptionInfo
  10871. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10872. if patientPrescription.ID == 0 {
  10873. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10874. }
  10875. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10876. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10877. //
  10878. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10879. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10880. var pp models.PublicParams
  10881. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10882. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10883. pp.FixmedinsName = miConfig.OrgName
  10884. pp.FixmedinsCode = miConfig.Code
  10885. pp.RequestUrl = miConfig.Url
  10886. pp.Cainfo = miConfig.Cainfo
  10887. pp.SecretKey = miConfig.SecretKey
  10888. pp.AccessKey = miConfig.AccessKey
  10889. pp.OpterName = roles.UserName
  10890. var config []*models.HisXtDiagnoseConfig
  10891. for _, item := range diagnosis_ids {
  10892. id, _ := strconv.ParseInt(item, 10, 64)
  10893. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10894. config = append(config, &diagnosisConfig)
  10895. }
  10896. var pd models.PatientDtos
  10897. pd.PatnID = his.PsnNo
  10898. pd.PatnName = his.Name
  10899. pd.Gend = his.Gend
  10900. pd.Brdy = psn_info.Brdy
  10901. pd.Poolarea = his.InsuplcAdmdvs
  10902. pd.CurrMdtrtID = his.Number
  10903. var fed models.FsiEncounterDtos
  10904. fed.MdtrtID = his.Number
  10905. fed.MedinsID = miConfig.Code
  10906. fed.MedinsName = miConfig.OrgName
  10907. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10908. fed.MedMdtrtType = "1"
  10909. fed.MedinsType = "1"
  10910. fed.MedinsLv = "11"
  10911. tm := time.Unix(his.RecordDate, 0)
  10912. s_tm := tm.Format("2006-01-02 15:04:05")
  10913. fed.AdmDate = s_tm
  10914. fed.DscgDate = s_tm
  10915. fed.DscgMainDiseCodg = config[0].CountryCode
  10916. fed.DscgMainDiseName = config[0].CountryContentName
  10917. //诊断信息
  10918. var fdds []*models.FsiDiagnoseDtos
  10919. for index, item := range config {
  10920. if index == 0 {
  10921. var fdd models.FsiDiagnoseDtos
  10922. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10923. fdd.InoutDiseType = "1"
  10924. fdd.MaindiseFlag = "1"
  10925. fdd.DiseDate = s_tm
  10926. fdd.DiasSrtNo = "1"
  10927. fdd.DiseName = item.CountryContentName
  10928. fdd.DiseCodg = item.CountryCode
  10929. fdds = append(fdds, &fdd)
  10930. } else {
  10931. var fdd models.FsiDiagnoseDtos
  10932. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10933. fdd.InoutDiseType = "1"
  10934. fdd.MaindiseFlag = "1"
  10935. fdd.DiseDate = s_tm
  10936. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10937. fdd.DiseName = item.CountryContentName
  10938. fdd.DiseCodg = item.CountryCode
  10939. fdds = append(fdds, &fdd)
  10940. }
  10941. }
  10942. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10943. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10944. fed.AdmDeptName = department.Name
  10945. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10946. fed.DscgDeptName = department.Name
  10947. fed.MedType = order.MedType
  10948. //处方医嘱信息
  10949. var orders []*models.FsiOrderDtos
  10950. //for _, item := range prescriptions {
  10951. // for _, subItem := range item.HisDoctorAdviceInfo {
  10952. // var order models.FsiOrderDtos
  10953. // order.RxID = strconv.FormatInt(item.ID, 10)
  10954. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10955. // order.LongDrordFlag = "0"
  10956. // order.HilistType = "1"
  10957. // order.ChrgType = "1"
  10958. // order.DrordBhvr = "-"
  10959. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10960. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10961. // order.HilistLv = "1"
  10962. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10963. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10964. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10965. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10966. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10967. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10968. // order.OwnpayAmt = ""
  10969. // order.SelfpayAmt = ""
  10970. // order.Spec = ""
  10971. // order.SpecUnt = ""
  10972. // order.DrordBegnDate = s_tm
  10973. // order.DrordStopDate = ""
  10974. // order.DrordDrCodg = "1"
  10975. // order.DrordDeptName = department.Name
  10976. // order.DrordDrCodg = "1"
  10977. // order.DrordDrName = doctor_info.UserName
  10978. // order.DrordDrProfttl = ""
  10979. // order.CurrDrordFlag = "1"
  10980. // orders = append(orders, &order)
  10981. // }
  10982. // for _, subItem := range item.HisPrescriptionProject {
  10983. // if subItem.Type == 2 {
  10984. // var order models.FsiOrderDtos
  10985. // order.RxID = strconv.FormatInt(item.ID, 10)
  10986. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10987. // order.LongDrordFlag = "0"
  10988. // order.HilistType = "1"
  10989. // order.ChrgType = "1"
  10990. // order.DrordBhvr = "-"
  10991. // order.HilistCode = subItem.HisProject.MedicalCode
  10992. // order.HosplistName = subItem.HisProject.ProjectName
  10993. // order.HilistLv = "1"
  10994. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10995. // order.HosplistCode = subItem.HisProject.MedicalCode
  10996. // order.HosplistName = subItem.HisProject.ProjectName
  10997. // order.Cnt = subItem.Count
  10998. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10999. //
  11000. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11001. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11002. // order.OwnpayAmt = ""
  11003. // order.SelfpayAmt = ""
  11004. // order.Spec = ""
  11005. // order.SpecUnt = ""
  11006. // order.DrordBegnDate = s_tm
  11007. // order.DrordStopDate = ""
  11008. // order.DrordDrCodg = "1"
  11009. // order.DrordDeptName = department.Name
  11010. // order.DrordDrCodg = "1"
  11011. // order.DrordDrName = doctor_info.UserName
  11012. // order.DrordDrProfttl = ""
  11013. // order.CurrDrordFlag = "1"
  11014. // orders = append(orders, &order)
  11015. //
  11016. // }
  11017. // if subItem.Type == 3 {
  11018. //
  11019. // var order models.FsiOrderDtos
  11020. // order.RxID = strconv.FormatInt(item.ID, 10)
  11021. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11022. // order.LongDrordFlag = "0"
  11023. // order.HilistType = "1"
  11024. // order.ChrgType = "1"
  11025. // order.DrordBhvr = "-"
  11026. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11027. // order.HosplistName = subItem.GoodInfo.GoodName
  11028. // order.HilistLv = "1"
  11029. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11030. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11031. // order.HosplistName = subItem.GoodInfo.GoodName
  11032. // order.Cnt = subItem.Count
  11033. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11034. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11035. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11036. // order.OwnpayAmt = ""
  11037. // order.SelfpayAmt = ""
  11038. // order.Spec = ""
  11039. // order.SpecUnt = ""
  11040. // order.DrordBegnDate = s_tm
  11041. // order.DrordStopDate = ""
  11042. // order.DrordDrCodg = "1"
  11043. // order.DrordDeptName = department.Name
  11044. // order.DrordDrCodg = "1"
  11045. // order.DrordDrName = doctor_info.UserName
  11046. // order.DrordDrProfttl = ""
  11047. // order.CurrDrordFlag = "1"
  11048. // orders = append(orders, &order)
  11049. //
  11050. // }
  11051. // }
  11052. //}
  11053. for _, item := range prescriptions {
  11054. for _, subItem := range item.HisDoctorAdviceInfo {
  11055. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11056. var order models.FsiOrderDtos
  11057. order.RxID = strconv.FormatInt(item.ID, 10)
  11058. order.Rxno = strconv.FormatInt(item.ID, 10)
  11059. order.LongDrordFlag = "0"
  11060. order.HilistType = "1"
  11061. order.ChrgType = "1"
  11062. order.DrordBhvr = "-"
  11063. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11064. order.HosplistName = subItem.BaseDrugLib.DrugName
  11065. order.HilistLv = "1"
  11066. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11067. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11068. order.HosplistName = subItem.BaseDrugLib.DrugName
  11069. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11070. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11071. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11072. order.OwnpayAmt = ""
  11073. order.SelfpayAmt = ""
  11074. order.Spec = ""
  11075. order.SpecUnt = ""
  11076. order.DrordBegnDate = s_tm
  11077. order.DrordStopDate = ""
  11078. order.DrordDrCodg = doctor_info.DoctorNumber
  11079. order.DrordDeptName = department.Name
  11080. order.DrordDeptCodg = department.Number
  11081. order.DrordDrName = doctor_info.UserName
  11082. order.DrordDrProfttl = "234"
  11083. order.CurrDrordFlag = "1"
  11084. orders = append(orders, &order)
  11085. }
  11086. }
  11087. for _, subItem := range item.HisPrescriptionProject {
  11088. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11089. var order models.FsiOrderDtos
  11090. order.RxID = strconv.FormatInt(item.ID, 10)
  11091. order.Rxno = strconv.FormatInt(item.ID, 10)
  11092. order.LongDrordFlag = "0"
  11093. order.HilistType = "1"
  11094. order.ChrgType = "1"
  11095. order.DrordBhvr = "-"
  11096. order.HilistCode = subItem.HisProject.MedicalCode
  11097. order.HosplistName = subItem.HisProject.ProjectName
  11098. order.HilistLv = "1"
  11099. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11100. order.HosplistCode = subItem.HisProject.MedicalCode
  11101. order.HosplistName = subItem.HisProject.ProjectName
  11102. order.Cnt = subItem.Count
  11103. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11104. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11105. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11106. order.OwnpayAmt = ""
  11107. order.SelfpayAmt = ""
  11108. order.Spec = ""
  11109. order.SpecUnt = ""
  11110. order.DrordBegnDate = s_tm
  11111. order.DrordStopDate = ""
  11112. order.DrordDrCodg = doctor_info.DoctorNumber
  11113. order.DrordDeptName = department.Name
  11114. order.DrordDeptCodg = department.Number
  11115. order.DrordDrName = doctor_info.UserName
  11116. order.DrordDrProfttl = "234"
  11117. order.CurrDrordFlag = "1"
  11118. orders = append(orders, &order)
  11119. }
  11120. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11121. var order models.FsiOrderDtos
  11122. order.RxID = strconv.FormatInt(item.ID, 10)
  11123. order.Rxno = strconv.FormatInt(item.ID, 10)
  11124. order.LongDrordFlag = "0"
  11125. order.HilistType = "1"
  11126. order.ChrgType = "1"
  11127. order.DrordBhvr = "0"
  11128. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11129. order.HosplistName = subItem.GoodInfo.GoodName
  11130. order.HilistLv = "1"
  11131. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11132. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11133. order.HosplistName = subItem.GoodInfo.GoodName
  11134. order.Cnt = subItem.Count
  11135. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11136. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11137. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11138. order.OwnpayAmt = ""
  11139. order.SelfpayAmt = ""
  11140. order.Spec = ""
  11141. order.SpecUnt = ""
  11142. order.DrordBegnDate = s_tm
  11143. order.DrordStopDate = ""
  11144. order.DrordDrCodg = doctor_info.DoctorNumber
  11145. order.DrordDeptName = department.Name
  11146. order.DrordDeptCodg = department.Number
  11147. order.DrordDrName = doctor_info.UserName
  11148. order.DrordDrProfttl = "234"
  11149. order.CurrDrordFlag = "1"
  11150. orders = append(orders, &order)
  11151. }
  11152. }
  11153. }
  11154. //处方医嘱信息
  11155. fed.MatnStas = "0"
  11156. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11157. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11158. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11159. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11160. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11161. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11162. fed.SetlTotlnum = "1"
  11163. fed.Insutype = his.Insutype
  11164. fed.ReimFlag = "0"
  11165. fed.OutSetlFlag = "0"
  11166. var fopd []*models.FsiOperationDtosData
  11167. data := make(map[string]interface{})
  11168. data["fed"] = fed
  11169. data["fdd"] = fdds
  11170. data["fod"] = orders
  11171. data["pd"] = pd
  11172. data["pp"] = pp
  11173. data["fopd"] = fopd
  11174. data["trig_scen"] = trig_scen
  11175. client := &http.Client{}
  11176. bytesData, _ := json.Marshal(data)
  11177. var req *http.Request
  11178. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11179. if miConfig.MdtrtareaAdmvs == "320921" {
  11180. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11181. } else {
  11182. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11183. }
  11184. resp, _ := client.Do(req)
  11185. defer resp.Body.Close()
  11186. body, ioErr := ioutil.ReadAll(resp.Body)
  11187. if ioErr != nil {
  11188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11190. return res
  11191. }
  11192. var respJSON map[string]interface{}
  11193. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11196. return res
  11197. }
  11198. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11199. result, _ := json.Marshal(respJSON)
  11200. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11201. utils.ErrorLog("解析失败:%v", err)
  11202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11203. return res
  11204. }
  11205. return res
  11206. } else {
  11207. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11208. saveLog(output, input, "3102", "事中")
  11209. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11210. utils.ErrorLog("解析失败:%v", err)
  11211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11212. return
  11213. }
  11214. return res
  11215. }
  11216. return res
  11217. }
  11218. 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) {
  11219. var res Resultgd3101
  11220. adminUser := c.GetAdminUserInfo()
  11221. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11222. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11223. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11224. //record_time := c.GetString("record_time")
  11225. //trig_scen := c.GetString("trig_scen")
  11226. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11227. //psn_info, _ := service.GetPatientId(patient_id)
  11228. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11229. timeLayout := "2006-01-02"
  11230. loc, _ := time.LoadLocation("Local")
  11231. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11232. if err != nil {
  11233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11234. return res
  11235. }
  11236. recordDateTime := theTime.Unix()
  11237. var patientPrescription models.HisPrescriptionInfo
  11238. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11239. //if patientPrescription.ID == 0 {
  11240. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11241. //}
  11242. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11243. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11244. //
  11245. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11246. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11247. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11248. var pp models.PublicParams
  11249. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11250. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11251. pp.FixmedinsName = miConfig.OrgName
  11252. pp.FixmedinsCode = miConfig.Code
  11253. pp.RequestUrl = miConfig.Url
  11254. pp.Cainfo = miConfig.Cainfo
  11255. pp.SecretKey = miConfig.SecretKey
  11256. pp.AccessKey = miConfig.AccessKey
  11257. pp.OpterName = roles.UserName
  11258. var config []*models.HisXtDiagnoseConfig
  11259. for _, item := range diagnosis_ids {
  11260. id, _ := strconv.ParseInt(item, 10, 64)
  11261. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11262. config = append(config, &diagnosisConfig)
  11263. }
  11264. var pd models.PatientDtos
  11265. pd.PatnID = his.PsnNo
  11266. pd.PatnName = his.Name
  11267. pd.Gend = his.Gend
  11268. pd.Brdy = str
  11269. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11270. pd.CurrMdtrtID = his.Number
  11271. var fed models.FsiEncounterDtos
  11272. fed.MdtrtID = his.Number
  11273. fed.MedinsID = miConfig.Code
  11274. fed.MedinsName = miConfig.OrgName
  11275. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11276. fed.MedMdtrtType = "1"
  11277. fed.MedinsType = "1"
  11278. fed.MedinsLv = "11"
  11279. tm := time.Unix(his.RecordDate, 0)
  11280. s_tm := tm.Format("2006-01-02 15:04:05")
  11281. fed.AdmDate = s_tm
  11282. fed.DscgDate = s_tm
  11283. fed.DscgMainDiseCodg = config[0].CountryCode
  11284. fed.DscgMainDiseName = config[0].CountryContentName
  11285. //诊断信息
  11286. var fdds []*models.FsiDiagnoseDtos
  11287. for index, item := range config {
  11288. if index == 0 {
  11289. var fdd models.FsiDiagnoseDtos
  11290. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11291. fdd.InoutDiseType = "1"
  11292. fdd.MaindiseFlag = "1"
  11293. fdd.DiseDate = s_tm
  11294. fdd.DiasSrtNo = "1"
  11295. fdd.DiseName = item.CountryContentName
  11296. fdd.DiseCodg = item.CountryCode
  11297. fdds = append(fdds, &fdd)
  11298. } else {
  11299. var fdd models.FsiDiagnoseDtos
  11300. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11301. fdd.InoutDiseType = "1"
  11302. fdd.MaindiseFlag = "1"
  11303. fdd.DiseDate = s_tm
  11304. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11305. fdd.DiseName = item.CountryContentName
  11306. fdd.DiseCodg = item.CountryCode
  11307. fdds = append(fdds, &fdd)
  11308. }
  11309. }
  11310. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11311. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11312. fed.AdmDeptName = de.Name
  11313. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11314. fed.DscgDeptName = de.Name
  11315. fed.MedMdtrtType = "1"
  11316. fed.MedType = "11"
  11317. //if his.Insutype == "390" {
  11318. // fed.MedType = "1402"
  11319. //} else {
  11320. // fed.MedType = "9933"
  11321. //}
  11322. var orders []*models.FsiOrderDtos
  11323. if trig_scen == "2" {
  11324. //处方医嘱信息
  11325. for _, item := range prescriptions {
  11326. for _, subItem := range item.HisDoctorAdviceInfo {
  11327. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11328. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11329. var order models.FsiOrderDtos
  11330. order.RxID = strconv.FormatInt(item.ID, 10)
  11331. order.Rxno = strconv.FormatInt(item.ID, 10)
  11332. order.LongDrordFlag = "0"
  11333. order.HilistType = "1"
  11334. order.ChrgType = "1"
  11335. order.DrordBhvr = "0"
  11336. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11337. order.HosplistName = subItem.BaseDrugLib.DrugName
  11338. order.HilistLv = "1"
  11339. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11340. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11341. order.HosplistName = subItem.BaseDrugLib.DrugName
  11342. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11343. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11344. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11345. order.OwnpayAmt = ""
  11346. order.SelfpayAmt = ""
  11347. order.Spec = spec
  11348. order.SpecUnt = subItem.PrescribingNumberUnit
  11349. order.DrordBegnDate = s_tm
  11350. order.DrordStopDate = ""
  11351. order.DrordDrCodg = doctor_info.DoctorNumber
  11352. order.DrordDeptName = department.Name
  11353. order.DrordDeptCodg = department.Number
  11354. order.DrordDrName = doctor_info.UserName
  11355. order.DrordDrProfttl = "234"
  11356. order.CurrDrordFlag = "1"
  11357. orders = append(orders, &order)
  11358. }
  11359. }
  11360. for _, subItem := range item.HisPrescriptionProject {
  11361. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11362. var order models.FsiOrderDtos
  11363. order.RxID = strconv.FormatInt(item.ID, 10)
  11364. order.Rxno = strconv.FormatInt(item.ID, 10)
  11365. order.LongDrordFlag = "0"
  11366. order.HilistType = "1"
  11367. order.ChrgType = "1"
  11368. order.DrordBhvr = "0"
  11369. order.HilistCode = subItem.HisProject.MedicalCode
  11370. order.HosplistName = subItem.HisProject.ProjectName
  11371. order.HilistLv = "1"
  11372. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11373. order.HosplistCode = subItem.HisProject.MedicalCode
  11374. order.HosplistName = subItem.HisProject.ProjectName
  11375. order.Cnt = subItem.Count
  11376. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11377. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11378. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11379. order.OwnpayAmt = ""
  11380. order.SelfpayAmt = ""
  11381. order.Spec = subItem.Unit
  11382. order.SpecUnt = subItem.Unit
  11383. order.DrordBegnDate = s_tm
  11384. order.DrordStopDate = ""
  11385. order.DrordDrCodg = doctor_info.DoctorNumber
  11386. order.DrordDeptName = department.Name
  11387. order.DrordDeptCodg = department.Number
  11388. order.DrordDrName = doctor_info.UserName
  11389. order.DrordDrProfttl = "234"
  11390. order.CurrDrordFlag = "1"
  11391. orders = append(orders, &order)
  11392. }
  11393. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11394. var order models.FsiOrderDtos
  11395. order.RxID = strconv.FormatInt(item.ID, 10)
  11396. order.Rxno = strconv.FormatInt(item.ID, 10)
  11397. order.LongDrordFlag = "0"
  11398. order.HilistType = "1"
  11399. order.ChrgType = "1"
  11400. order.DrordBhvr = "0"
  11401. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11402. order.HosplistName = subItem.GoodInfo.GoodName
  11403. order.HilistLv = "1"
  11404. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11405. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11406. order.HosplistName = subItem.GoodInfo.GoodName
  11407. order.Cnt = subItem.Count
  11408. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11409. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11410. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11411. order.OwnpayAmt = ""
  11412. order.SelfpayAmt = ""
  11413. order.Spec = subItem.GoodInfo.SpecificationName
  11414. order.SpecUnt = subItem.Unit
  11415. order.DrordBegnDate = s_tm
  11416. order.DrordStopDate = ""
  11417. order.DrordDrCodg = doctor_info.DoctorNumber
  11418. order.DrordDeptName = department.Name
  11419. order.DrordDeptCodg = department.Number
  11420. order.DrordDrName = doctor_info.UserName
  11421. order.DrordDrProfttl = "234"
  11422. order.CurrDrordFlag = "1"
  11423. orders = append(orders, &order)
  11424. }
  11425. }
  11426. }
  11427. //处方医嘱信息
  11428. }
  11429. fed.MatnStas = "0"
  11430. fed.MedfeeSumamt = "0"
  11431. fed.OwnpayAmt = "0"
  11432. fed.SelfpayAmt = "0"
  11433. fed.AcctPayamt = "0"
  11434. fed.MaAmt = "0"
  11435. fed.HifpPayamt = "0"
  11436. fed.SetlTotlnum = "1"
  11437. fed.Insutype = his.Insutype
  11438. fed.ReimFlag = "0"
  11439. fed.OutSetlFlag = "0"
  11440. var fopd []*models.FsiOperationDtosData
  11441. data := make(map[string]interface{})
  11442. data["fed"] = fed
  11443. data["fdd"] = fdds
  11444. data["fod"] = orders
  11445. data["pd"] = pd
  11446. data["pp"] = pp
  11447. data["fopd"] = fopd
  11448. data["trig_scen"] = trig_scen
  11449. fmt.Println(data)
  11450. fmt.Println(fed)
  11451. fmt.Println(fdds)
  11452. fmt.Println(orders)
  11453. fmt.Println(pd)
  11454. fmt.Println(pp)
  11455. fmt.Println(fopd)
  11456. client := &http.Client{}
  11457. bytesData, _ := json.Marshal(data)
  11458. var req *http.Request
  11459. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11460. if miConfig.MdtrtareaAdmvs == "320921" {
  11461. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11462. } else {
  11463. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11464. }
  11465. resp, _ := client.Do(req)
  11466. defer resp.Body.Close()
  11467. body, ioErr := ioutil.ReadAll(resp.Body)
  11468. if ioErr != nil {
  11469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11471. return res
  11472. }
  11473. var respJSON map[string]interface{}
  11474. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11477. return res
  11478. }
  11479. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11480. fmt.Println(respJSON)
  11481. result, _ := json.Marshal(respJSON)
  11482. fmt.Println(result)
  11483. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11484. utils.ErrorLog("解析失败:%v", err)
  11485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11486. return res
  11487. }
  11488. return res
  11489. } else {
  11490. //if miConfig.MdtrtareaAdmvs == "441202" {
  11491. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11492. saveLog(output, input, "3101", "事前")
  11493. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11494. utils.ErrorLog("解析失败:%v", err)
  11495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11496. return
  11497. }
  11498. return res
  11499. //}
  11500. }
  11501. }
  11502. 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) {
  11503. adminUser := c.GetAdminUserInfo()
  11504. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11505. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11506. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11507. //record_time := c.GetString("record_time")
  11508. //trig_scen := c.GetString("trig_scen")
  11509. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11510. timeLayout := "2006-01-02"
  11511. loc, _ := time.LoadLocation("Local")
  11512. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11513. if err != nil {
  11514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11515. return res
  11516. }
  11517. recordDateTime := theTime.Unix()
  11518. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11519. var patientPrescription models.HisPrescriptionInfo
  11520. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11521. if patientPrescription.ID == 0 {
  11522. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11523. }
  11524. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11525. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11526. //
  11527. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11528. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11529. var pp models.PublicParams
  11530. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11531. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11532. pp.FixmedinsName = miConfig.OrgName
  11533. pp.FixmedinsCode = miConfig.Code
  11534. pp.RequestUrl = miConfig.Url
  11535. pp.Cainfo = miConfig.Cainfo
  11536. pp.SecretKey = miConfig.SecretKey
  11537. pp.AccessKey = miConfig.AccessKey
  11538. pp.OpterName = roles.UserName
  11539. var config []*models.HisXtDiagnoseConfig
  11540. for _, item := range diagnosis_ids {
  11541. id, _ := strconv.ParseInt(item, 10, 64)
  11542. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11543. config = append(config, &diagnosisConfig)
  11544. }
  11545. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11546. var pd models.PatientDtos
  11547. pd.PatnID = his.PsnNo
  11548. pd.PatnName = his.Name
  11549. pd.Gend = his.Gend
  11550. pd.Brdy = str
  11551. pd.Poolarea = his.InsuplcAdmdvs
  11552. pd.CurrMdtrtID = his.Number
  11553. var fed models.FsiEncounterDtos
  11554. fed.MdtrtID = his.Number
  11555. fed.MedinsID = miConfig.Code
  11556. fed.MedinsName = miConfig.OrgName
  11557. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11558. fed.MedMdtrtType = "1"
  11559. fed.MedinsType = "1"
  11560. fed.MedinsLv = "11"
  11561. tm := time.Unix(his.RecordDate, 0)
  11562. s_tm := tm.Format("2006-01-02 15:04:05")
  11563. fed.AdmDate = s_tm
  11564. fed.DscgDate = s_tm
  11565. fed.DscgMainDiseCodg = config[0].CountryCode
  11566. fed.DscgMainDiseName = config[0].CountryContentName
  11567. //诊断信息
  11568. var fdds []*models.FsiDiagnoseDtos
  11569. for index, item := range config {
  11570. if index == 0 {
  11571. var fdd models.FsiDiagnoseDtos
  11572. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11573. fdd.InoutDiseType = "1"
  11574. fdd.MaindiseFlag = "1"
  11575. fdd.DiseDate = s_tm
  11576. fdd.DiasSrtNo = "1"
  11577. fdd.DiseName = item.CountryContentName
  11578. fdd.DiseCodg = item.CountryCode
  11579. fdds = append(fdds, &fdd)
  11580. } else {
  11581. var fdd models.FsiDiagnoseDtos
  11582. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11583. fdd.InoutDiseType = "1"
  11584. fdd.MaindiseFlag = "1"
  11585. fdd.DiseDate = s_tm
  11586. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11587. fdd.DiseName = item.CountryContentName
  11588. fdd.DiseCodg = item.CountryCode
  11589. fdds = append(fdds, &fdd)
  11590. }
  11591. }
  11592. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11593. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11594. fed.AdmDeptName = department.Name
  11595. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11596. fed.DscgDeptName = department.Name
  11597. fed.MedMdtrtType = "1"
  11598. fed.MedType = "11"
  11599. //if his.Insutype == "390" {
  11600. // fed.MedType = "1402"
  11601. //} else {
  11602. // fed.MedType = "9933"
  11603. //}
  11604. var orders []*models.FsiOrderDtos
  11605. if trig_scen == "2" {
  11606. //处方医嘱信息
  11607. for _, item := range prescriptions {
  11608. for _, subItem := range item.HisDoctorAdviceInfo {
  11609. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11610. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11611. var order models.FsiOrderDtos
  11612. order.RxID = strconv.FormatInt(item.ID, 10)
  11613. order.Rxno = strconv.FormatInt(item.ID, 10)
  11614. order.LongDrordFlag = "0"
  11615. order.HilistType = "1"
  11616. order.ChrgType = "1"
  11617. order.DrordBhvr = "0"
  11618. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11619. order.HosplistName = subItem.BaseDrugLib.DrugName
  11620. order.HilistLv = "1"
  11621. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11622. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11623. order.HosplistName = subItem.BaseDrugLib.DrugName
  11624. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11625. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11626. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11627. order.OwnpayAmt = ""
  11628. order.SelfpayAmt = ""
  11629. order.Spec = spec
  11630. order.SpecUnt = subItem.PrescribingNumberUnit
  11631. order.DrordBegnDate = s_tm
  11632. order.DrordStopDate = ""
  11633. order.DrordDrCodg = doctor_info.DoctorNumber
  11634. order.DrordDeptName = department.Name
  11635. order.DrordDeptCodg = department.Number
  11636. order.DrordDrName = doctor_info.UserName
  11637. order.DrordDrProfttl = "234"
  11638. order.CurrDrordFlag = "1"
  11639. orders = append(orders, &order)
  11640. }
  11641. }
  11642. for _, subItem := range item.HisPrescriptionProject {
  11643. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11644. var order models.FsiOrderDtos
  11645. order.RxID = strconv.FormatInt(item.ID, 10)
  11646. order.Rxno = strconv.FormatInt(item.ID, 10)
  11647. order.LongDrordFlag = "0"
  11648. order.HilistType = "1"
  11649. order.ChrgType = "1"
  11650. order.DrordBhvr = "0"
  11651. order.HilistCode = subItem.HisProject.MedicalCode
  11652. order.HosplistName = subItem.HisProject.ProjectName
  11653. order.HilistLv = "1"
  11654. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11655. order.HosplistCode = subItem.HisProject.MedicalCode
  11656. order.HosplistName = subItem.HisProject.ProjectName
  11657. order.Cnt = subItem.Count
  11658. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11659. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11660. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11661. order.OwnpayAmt = ""
  11662. order.SelfpayAmt = ""
  11663. order.Spec = subItem.Unit
  11664. order.SpecUnt = subItem.Unit
  11665. order.DrordBegnDate = s_tm
  11666. order.DrordStopDate = ""
  11667. order.DrordDrCodg = doctor_info.DoctorNumber
  11668. order.DrordDeptName = department.Name
  11669. order.DrordDeptCodg = department.Number
  11670. order.DrordDrName = doctor_info.UserName
  11671. order.DrordDrProfttl = "234"
  11672. order.CurrDrordFlag = "1"
  11673. orders = append(orders, &order)
  11674. }
  11675. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11676. var order models.FsiOrderDtos
  11677. order.RxID = strconv.FormatInt(item.ID, 10)
  11678. order.Rxno = strconv.FormatInt(item.ID, 10)
  11679. order.LongDrordFlag = "0"
  11680. order.HilistType = "1"
  11681. order.ChrgType = "1"
  11682. order.DrordBhvr = "0"
  11683. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11684. order.HosplistName = subItem.GoodInfo.GoodName
  11685. order.HilistLv = "1"
  11686. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11687. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11688. order.HosplistName = subItem.GoodInfo.GoodName
  11689. order.Cnt = subItem.Count
  11690. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11691. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11692. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11693. order.OwnpayAmt = ""
  11694. order.SelfpayAmt = ""
  11695. order.Spec = subItem.GoodInfo.SpecificationName
  11696. order.SpecUnt = subItem.Unit
  11697. order.DrordBegnDate = s_tm
  11698. order.DrordStopDate = ""
  11699. order.DrordDrCodg = doctor_info.DoctorNumber
  11700. order.DrordDeptName = department.Name
  11701. order.DrordDeptCodg = department.Number
  11702. order.DrordDrName = doctor_info.UserName
  11703. order.DrordDrProfttl = "234"
  11704. order.CurrDrordFlag = "1"
  11705. orders = append(orders, &order)
  11706. }
  11707. }
  11708. }
  11709. //处方医嘱信息
  11710. }
  11711. fed.MatnStas = "0"
  11712. fed.MedfeeSumamt = "0"
  11713. fed.OwnpayAmt = "0"
  11714. fed.SelfpayAmt = "0"
  11715. fed.AcctPayamt = "0"
  11716. fed.MaAmt = "0"
  11717. fed.HifpPayamt = "0"
  11718. fed.SetlTotlnum = "1"
  11719. fed.Insutype = his.Insutype
  11720. fed.ReimFlag = "0"
  11721. fed.OutSetlFlag = "0"
  11722. var fopd []*models.FsiOperationDtosData
  11723. data := make(map[string]interface{})
  11724. data["fed"] = fed
  11725. data["fdd"] = fdds
  11726. data["fod"] = orders
  11727. data["pd"] = pd
  11728. data["pp"] = pp
  11729. data["fopd"] = fopd
  11730. data["trig_scen"] = trig_scen
  11731. fmt.Println(data)
  11732. fmt.Println(fed)
  11733. fmt.Println(fdds)
  11734. fmt.Println(orders)
  11735. fmt.Println(pd)
  11736. fmt.Println(pp)
  11737. fmt.Println(fopd)
  11738. client := &http.Client{}
  11739. bytesData, _ := json.Marshal(data)
  11740. var req *http.Request
  11741. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11742. if miConfig.MdtrtareaAdmvs == "320921" {
  11743. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11744. } else {
  11745. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11746. }
  11747. resp, _ := client.Do(req)
  11748. defer resp.Body.Close()
  11749. body, ioErr := ioutil.ReadAll(resp.Body)
  11750. if ioErr != nil {
  11751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11753. return res
  11754. }
  11755. var respJSON map[string]interface{}
  11756. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11759. return res
  11760. }
  11761. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11762. fmt.Println(respJSON)
  11763. result, _ := json.Marshal(respJSON)
  11764. fmt.Println(result)
  11765. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11766. utils.ErrorLog("解析失败:%v", err)
  11767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11768. return res
  11769. }
  11770. return res
  11771. } else {
  11772. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11773. saveLog(output, input, "3101", "事前")
  11774. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11775. utils.ErrorLog("解析失败:%v", err)
  11776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11777. return
  11778. }
  11779. return res
  11780. }
  11781. return res
  11782. }
  11783. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11784. ////patient_id, _ := c.GetInt64("patient_id")
  11785. //order_id, _ := c.GetInt64("order_id")
  11786. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11787. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11788. //trig_scen := c.GetString("trig_scen")
  11789. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11790. //utils.ErrorLog("解析失败:%v", psn_info)
  11791. adminUser := c.GetAdminUserInfo()
  11792. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11793. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11794. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11795. record_time := c.GetString("record_time")
  11796. order, _ := service.GetHisOrderByID(order_id)
  11797. timeLayout := "2006-01-02"
  11798. loc, _ := time.LoadLocation("Local")
  11799. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11800. if err != nil {
  11801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11802. return
  11803. }
  11804. recordDateTime := theTime.Unix()
  11805. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11806. var patientPrescription models.HisPrescriptionInfo
  11807. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11808. if patientPrescription.ID == 0 {
  11809. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11810. }
  11811. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11812. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11813. //
  11814. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11815. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11816. var pp models.PublicParams
  11817. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11818. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11819. pp.FixmedinsName = miConfig.OrgName
  11820. pp.FixmedinsCode = miConfig.Code
  11821. pp.RequestUrl = miConfig.Url
  11822. pp.Cainfo = miConfig.Cainfo
  11823. pp.SecretKey = miConfig.SecretKey
  11824. pp.AccessKey = miConfig.AccessKey
  11825. pp.OpterName = roles.UserName
  11826. var config []*models.HisXtDiagnoseConfig
  11827. for _, item := range diagnosis_ids {
  11828. id, _ := strconv.ParseInt(item, 10, 64)
  11829. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11830. config = append(config, &diagnosisConfig)
  11831. }
  11832. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11833. var pd models.PatientDtos
  11834. pd.PatnID = his.PsnNo
  11835. pd.PatnName = his.Name
  11836. pd.Gend = his.Gend
  11837. pd.Brdy = str
  11838. pd.Poolarea = his.InsuplcAdmdvs
  11839. pd.CurrMdtrtID = his.Number
  11840. var fed models.FsiEncounterDtos
  11841. fed.MdtrtID = his.Number
  11842. fed.MedinsID = miConfig.Code
  11843. fed.MedinsName = miConfig.OrgName
  11844. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11845. fed.MedMdtrtType = "1"
  11846. fed.MedinsType = "1"
  11847. fed.MedinsLv = "11"
  11848. tm := time.Unix(his.RecordDate, 0)
  11849. s_tm := tm.Format("2006-01-02 15:04:05")
  11850. fed.AdmDate = s_tm
  11851. fed.DscgDate = s_tm
  11852. fed.DscgMainDiseCodg = config[0].CountryCode
  11853. fed.DscgMainDiseName = config[0].CountryContentName
  11854. //诊断信息
  11855. var fdds []*models.FsiDiagnoseDtos
  11856. for index, item := range config {
  11857. if index == 0 {
  11858. var fdd models.FsiDiagnoseDtos
  11859. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11860. fdd.InoutDiseType = "1"
  11861. fdd.MaindiseFlag = "1"
  11862. fdd.DiseDate = s_tm
  11863. fdd.DiasSrtNo = "1"
  11864. fdd.DiseName = item.CountryContentName
  11865. fdd.DiseCodg = item.CountryCode
  11866. fdds = append(fdds, &fdd)
  11867. } else {
  11868. var fdd models.FsiDiagnoseDtos
  11869. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11870. fdd.InoutDiseType = "1"
  11871. fdd.MaindiseFlag = "1"
  11872. fdd.DiseDate = s_tm
  11873. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11874. fdd.DiseName = item.CountryContentName
  11875. fdd.DiseCodg = item.CountryCode
  11876. fdds = append(fdds, &fdd)
  11877. }
  11878. }
  11879. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11880. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11881. fed.AdmDeptName = department.Name
  11882. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11883. fed.DscgDeptName = department.Name
  11884. fed.MedType = order.MedType
  11885. //处方医嘱信息
  11886. var orders []*models.FsiOrderDtos
  11887. //for _, item := range prescriptions {
  11888. // for _, subItem := range item.HisDoctorAdviceInfo {
  11889. // var order models.FsiOrderDtos
  11890. // order.RxID = strconv.FormatInt(item.ID, 10)
  11891. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11892. // order.LongDrordFlag = "0"
  11893. // order.HilistType = "1"
  11894. // order.ChrgType = "1"
  11895. // order.DrordBhvr = "-"
  11896. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11897. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11898. // order.HilistLv = "1"
  11899. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11900. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11901. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11902. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11903. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11904. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11905. // order.OwnpayAmt = ""
  11906. // order.SelfpayAmt = ""
  11907. // order.Spec = ""
  11908. // order.SpecUnt = ""
  11909. // order.DrordBegnDate = s_tm
  11910. // order.DrordStopDate = ""
  11911. // order.DrordDrCodg = "1"
  11912. // order.DrordDeptName = department.Name
  11913. // order.DrordDrCodg = "1"
  11914. // order.DrordDrName = doctor_info.UserName
  11915. // order.DrordDrProfttl = ""
  11916. // order.CurrDrordFlag = "1"
  11917. // orders = append(orders, &order)
  11918. // }
  11919. // for _, subItem := range item.HisPrescriptionProject {
  11920. // if subItem.Type == 2 {
  11921. // var order models.FsiOrderDtos
  11922. // order.RxID = strconv.FormatInt(item.ID, 10)
  11923. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11924. // order.LongDrordFlag = "0"
  11925. // order.HilistType = "1"
  11926. // order.ChrgType = "1"
  11927. // order.DrordBhvr = "-"
  11928. // order.HilistCode = subItem.HisProject.MedicalCode
  11929. // order.HosplistName = subItem.HisProject.ProjectName
  11930. // order.HilistLv = "1"
  11931. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11932. // order.HosplistCode = subItem.HisProject.MedicalCode
  11933. // order.HosplistName = subItem.HisProject.ProjectName
  11934. // order.Cnt = subItem.Count
  11935. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11936. //
  11937. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11938. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11939. // order.OwnpayAmt = ""
  11940. // order.SelfpayAmt = ""
  11941. // order.Spec = ""
  11942. // order.SpecUnt = ""
  11943. // order.DrordBegnDate = s_tm
  11944. // order.DrordStopDate = ""
  11945. // order.DrordDrCodg = "1"
  11946. // order.DrordDeptName = department.Name
  11947. // order.DrordDrCodg = "1"
  11948. // order.DrordDrName = doctor_info.UserName
  11949. // order.DrordDrProfttl = ""
  11950. // order.CurrDrordFlag = "1"
  11951. // orders = append(orders, &order)
  11952. //
  11953. // }
  11954. // if subItem.Type == 3 {
  11955. //
  11956. // var order models.FsiOrderDtos
  11957. // order.RxID = strconv.FormatInt(item.ID, 10)
  11958. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11959. // order.LongDrordFlag = "0"
  11960. // order.HilistType = "1"
  11961. // order.ChrgType = "1"
  11962. // order.DrordBhvr = "-"
  11963. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11964. // order.HosplistName = subItem.GoodInfo.GoodName
  11965. // order.HilistLv = "1"
  11966. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11967. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11968. // order.HosplistName = subItem.GoodInfo.GoodName
  11969. // order.Cnt = subItem.Count
  11970. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11971. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11972. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11973. // order.OwnpayAmt = ""
  11974. // order.SelfpayAmt = ""
  11975. // order.Spec = ""
  11976. // order.SpecUnt = ""
  11977. // order.DrordBegnDate = s_tm
  11978. // order.DrordStopDate = ""
  11979. // order.DrordDrCodg = "1"
  11980. // order.DrordDeptName = department.Name
  11981. // order.DrordDrCodg = "1"
  11982. // order.DrordDrName = doctor_info.UserName
  11983. // order.DrordDrProfttl = ""
  11984. // order.CurrDrordFlag = "1"
  11985. // orders = append(orders, &order)
  11986. //
  11987. // }
  11988. // }
  11989. //}
  11990. for _, item := range prescriptions {
  11991. for _, subItem := range item.HisDoctorAdviceInfo {
  11992. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11993. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11994. var order models.FsiOrderDtos
  11995. order.RxID = strconv.FormatInt(item.ID, 10)
  11996. order.Rxno = strconv.FormatInt(item.ID, 10)
  11997. order.LongDrordFlag = "0"
  11998. order.HilistType = "1"
  11999. order.ChrgType = "1"
  12000. order.DrordBhvr = "0"
  12001. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12002. order.HosplistName = subItem.BaseDrugLib.DrugName
  12003. order.HilistLv = "1"
  12004. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12005. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12006. order.HosplistName = subItem.BaseDrugLib.DrugName
  12007. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12008. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12009. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12010. order.OwnpayAmt = ""
  12011. order.SelfpayAmt = ""
  12012. order.Spec = spec
  12013. order.SpecUnt = subItem.PrescribingNumberUnit
  12014. order.DrordBegnDate = s_tm
  12015. order.DrordStopDate = ""
  12016. order.DrordDrCodg = doctor_info.DoctorNumber
  12017. order.DrordDeptName = department.Name
  12018. order.DrordDeptCodg = department.Number
  12019. order.DrordDrName = doctor_info.UserName
  12020. order.DrordDrProfttl = "234"
  12021. order.CurrDrordFlag = "1"
  12022. orders = append(orders, &order)
  12023. }
  12024. }
  12025. for _, subItem := range item.HisPrescriptionProject {
  12026. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12027. var order models.FsiOrderDtos
  12028. order.RxID = strconv.FormatInt(item.ID, 10)
  12029. order.Rxno = strconv.FormatInt(item.ID, 10)
  12030. order.LongDrordFlag = "0"
  12031. order.HilistType = "1"
  12032. order.ChrgType = "1"
  12033. order.DrordBhvr = "0"
  12034. order.HilistCode = subItem.HisProject.MedicalCode
  12035. order.HosplistName = subItem.HisProject.ProjectName
  12036. order.HilistLv = "1"
  12037. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12038. order.HosplistCode = subItem.HisProject.MedicalCode
  12039. order.HosplistName = subItem.HisProject.ProjectName
  12040. order.Cnt = subItem.Count
  12041. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12042. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12043. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12044. order.OwnpayAmt = ""
  12045. order.SelfpayAmt = ""
  12046. order.Spec = subItem.Unit
  12047. order.SpecUnt = subItem.Unit
  12048. order.DrordBegnDate = s_tm
  12049. order.DrordStopDate = ""
  12050. order.DrordDrCodg = doctor_info.DoctorNumber
  12051. order.DrordDeptName = department.Name
  12052. order.DrordDeptCodg = department.Number
  12053. order.DrordDrName = doctor_info.UserName
  12054. order.DrordDrProfttl = "234"
  12055. order.CurrDrordFlag = "1"
  12056. orders = append(orders, &order)
  12057. }
  12058. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12059. var order models.FsiOrderDtos
  12060. order.RxID = strconv.FormatInt(item.ID, 10)
  12061. order.Rxno = strconv.FormatInt(item.ID, 10)
  12062. order.LongDrordFlag = "0"
  12063. order.HilistType = "1"
  12064. order.ChrgType = "1"
  12065. order.DrordBhvr = "0"
  12066. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12067. order.HosplistName = subItem.GoodInfo.GoodName
  12068. order.HilistLv = "1"
  12069. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12070. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12071. order.HosplistName = subItem.GoodInfo.GoodName
  12072. order.Cnt = subItem.Count
  12073. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12074. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12075. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12076. order.OwnpayAmt = ""
  12077. order.SelfpayAmt = ""
  12078. order.Spec = subItem.GoodInfo.SpecificationName
  12079. order.SpecUnt = subItem.Unit
  12080. order.DrordBegnDate = s_tm
  12081. order.DrordStopDate = ""
  12082. order.DrordDrCodg = doctor_info.DoctorNumber
  12083. order.DrordDeptName = department.Name
  12084. order.DrordDeptCodg = department.Number
  12085. order.DrordDrName = doctor_info.UserName
  12086. order.DrordDrProfttl = "234"
  12087. order.CurrDrordFlag = "1"
  12088. orders = append(orders, &order)
  12089. }
  12090. }
  12091. }
  12092. //处方医嘱信息
  12093. fed.MatnStas = "0"
  12094. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12095. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12096. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12097. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12098. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12099. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12100. fed.SetlTotlnum = "1"
  12101. fed.Insutype = his.Insutype
  12102. fed.ReimFlag = "0"
  12103. fed.OutSetlFlag = "0"
  12104. var fopd []*models.FsiOperationDtosData
  12105. data := make(map[string]interface{})
  12106. data["fed"] = fed
  12107. data["fdd"] = fdds
  12108. data["fod"] = orders
  12109. data["pd"] = pd
  12110. data["pp"] = pp
  12111. data["fopd"] = fopd
  12112. data["trig_scen"] = trig_scen
  12113. client := &http.Client{}
  12114. bytesData, _ := json.Marshal(data)
  12115. var req *http.Request
  12116. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12117. if miConfig.MdtrtareaAdmvs == "320921" {
  12118. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12119. } else {
  12120. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12121. }
  12122. resp, _ := client.Do(req)
  12123. defer resp.Body.Close()
  12124. body, ioErr := ioutil.ReadAll(resp.Body)
  12125. if ioErr != nil {
  12126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12128. return res
  12129. }
  12130. var respJSON map[string]interface{}
  12131. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12134. return res
  12135. }
  12136. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12137. result, _ := json.Marshal(respJSON)
  12138. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12139. utils.ErrorLog("解析失败:%v", err)
  12140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12141. return res
  12142. }
  12143. return res
  12144. } else {
  12145. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12146. saveLog(output, input, "3102", "事中")
  12147. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12148. utils.ErrorLog("解析失败:%v", err)
  12149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12150. return
  12151. }
  12152. return res
  12153. }
  12154. return res
  12155. }
  12156. func (c *HisApiController) Check() {
  12157. psn_no := c.GetString("psn_no")
  12158. in := c.GetString("in")
  12159. mt := c.GetString("mt")
  12160. baseParams := models.BaseParams{
  12161. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12162. FixmedinsCode: "H15049901371",
  12163. InsuplcAdmdvs: "150499",
  12164. MdtrtareaAdmvs: "150499",
  12165. OrgName: "赤峰费森血液透析中心",
  12166. Doctor: "1111",
  12167. }
  12168. service.Gdyb2001(baseParams, psn_no, in, mt)
  12169. }
  12170. func (c *HisApiController) GetPsnNcdsInfo() {
  12171. admin_user_id, _ := c.GetInt64("admin_user_id")
  12172. patient_id, _ := c.GetInt64("patient_id")
  12173. //id, _ := c.GetInt64("id")
  12174. adminUser := c.GetAdminUserInfo()
  12175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12176. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12177. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12178. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12179. //psn_record, _ := service.GetP(id)
  12180. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12181. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12182. //
  12183. //if psn_record.ID == 0 {
  12184. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12185. // return
  12186. //}
  12187. var res Result5301
  12188. var res10265 Result5301For10265
  12189. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12190. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12191. var api string
  12192. if miConfig.MdtrtareaAdmvs == "320921" {
  12193. 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 +
  12194. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12195. } else {
  12196. 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 +
  12197. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12198. }
  12199. resp, requestErr := http.Get(api)
  12200. if requestErr != nil {
  12201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12202. return
  12203. }
  12204. body, ioErr := ioutil.ReadAll(resp.Body)
  12205. if ioErr != nil {
  12206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12208. return
  12209. }
  12210. var respJSON map[string]interface{}
  12211. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12214. return
  12215. }
  12216. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12217. result, _ := json.Marshal(respJSON)
  12218. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12219. utils.ErrorLog("解析失败:%v", err)
  12220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12221. return
  12222. }
  12223. res.ErrMsg = res10265.ErrMsg
  12224. res.Output = res10265.Output
  12225. res.InfRefmsgid = res10265.InfRefmsgid
  12226. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12227. res.Infcode = infocode
  12228. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12229. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12230. var api string
  12231. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12232. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12233. resp, requestErr := http.Get(api)
  12234. if requestErr != nil {
  12235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12236. return
  12237. }
  12238. body, ioErr := ioutil.ReadAll(resp.Body)
  12239. if ioErr != nil {
  12240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12242. return
  12243. }
  12244. var respJSON map[string]interface{}
  12245. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12248. return
  12249. }
  12250. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12251. if status == "0" {
  12252. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12253. c.ServeSuccessJSON(map[string]interface{}{
  12254. "failed_code": -10,
  12255. "msg": err_msg,
  12256. })
  12257. return
  12258. }
  12259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12260. result, _ := json.Marshal(respJSON)
  12261. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12262. utils.ErrorLog("解析失败:%v", err)
  12263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12264. return
  12265. }
  12266. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12267. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12268. var api string
  12269. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12270. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12271. resp, requestErr := http.Get(api)
  12272. if requestErr != nil {
  12273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12274. return
  12275. }
  12276. body, ioErr := ioutil.ReadAll(resp.Body)
  12277. if ioErr != nil {
  12278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12280. return
  12281. }
  12282. var respJSON map[string]interface{}
  12283. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12286. return
  12287. }
  12288. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12289. if status == "0" {
  12290. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12291. c.ServeSuccessJSON(map[string]interface{}{
  12292. "failed_code": -10,
  12293. "msg": err_msg,
  12294. })
  12295. return
  12296. }
  12297. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12298. result, _ := json.Marshal(respJSON)
  12299. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12300. utils.ErrorLog("解析失败:%v", err)
  12301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12302. return
  12303. }
  12304. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12305. p, _ := service.GetHisPatientById(patient_id)
  12306. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12307. var dat map[string]interface{}
  12308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12309. fmt.Println(dat)
  12310. } else {
  12311. fmt.Println(err)
  12312. }
  12313. userJSONBytes, _ := json.Marshal(dat)
  12314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12315. utils.ErrorLog("解析失败:%v", err)
  12316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12317. return
  12318. }
  12319. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12320. p, _ := service.GetHisPatientById(patient_id)
  12321. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12322. var dat map[string]interface{}
  12323. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12324. fmt.Println(dat)
  12325. } else {
  12326. fmt.Println(err)
  12327. }
  12328. userJSONBytes, _ := json.Marshal(dat)
  12329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12330. utils.ErrorLog("解析失败:%v", err)
  12331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12332. return
  12333. }
  12334. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12335. p, _ := service.GetHisPatientById(patient_id)
  12336. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12337. var dat map[string]interface{}
  12338. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12339. fmt.Println(dat)
  12340. } else {
  12341. fmt.Println(err)
  12342. }
  12343. userJSONBytes, _ := json.Marshal(dat)
  12344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12345. utils.ErrorLog("解析失败:%v", err)
  12346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12347. return
  12348. }
  12349. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12350. p, _ := service.GetHisPatientById(patient_id)
  12351. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12352. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12353. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12354. resp, requestErr := http.Get(api)
  12355. if requestErr != nil {
  12356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12357. return
  12358. }
  12359. body, ioErr := ioutil.ReadAll(resp.Body)
  12360. if ioErr != nil {
  12361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12363. return
  12364. }
  12365. var respJSON map[string]interface{}
  12366. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12369. return
  12370. }
  12371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12372. result, _ := json.Marshal(respJSON)
  12373. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12374. utils.ErrorLog("解析失败:%v", err)
  12375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12376. return
  12377. }
  12378. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12379. p, _ := service.GetHisPatientById(patient_id)
  12380. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12381. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12382. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12383. resp, requestErr := http.Get(api)
  12384. if requestErr != nil {
  12385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12386. return
  12387. }
  12388. body, ioErr := ioutil.ReadAll(resp.Body)
  12389. if ioErr != nil {
  12390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12392. return
  12393. }
  12394. var respJSON map[string]interface{}
  12395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12398. return
  12399. }
  12400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12401. result, _ := json.Marshal(respJSON)
  12402. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12403. utils.ErrorLog("解析失败:%v", err)
  12404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12405. return
  12406. }
  12407. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12408. p, _ := service.GetHisPatientById(patient_id)
  12409. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12410. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12411. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12412. resp, requestErr := http.Get(api)
  12413. if requestErr != nil {
  12414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12415. return
  12416. }
  12417. body, ioErr := ioutil.ReadAll(resp.Body)
  12418. if ioErr != nil {
  12419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12421. return
  12422. }
  12423. var respJSON map[string]interface{}
  12424. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12427. return
  12428. }
  12429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12430. result, _ := json.Marshal(respJSON)
  12431. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12432. utils.ErrorLog("解析失败:%v", err)
  12433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12434. return
  12435. }
  12436. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12437. p, _ := service.GetHisPatientById(patient_id)
  12438. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12439. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12440. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12441. resp, requestErr := http.Get(api)
  12442. if requestErr != nil {
  12443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12444. return
  12445. }
  12446. body, ioErr := ioutil.ReadAll(resp.Body)
  12447. if ioErr != nil {
  12448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12450. return
  12451. }
  12452. var respJSON map[string]interface{}
  12453. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12456. return
  12457. }
  12458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12459. result, _ := json.Marshal(respJSON)
  12460. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12461. utils.ErrorLog("解析失败:%v", err)
  12462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12463. return
  12464. }
  12465. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12466. p, _ := service.GetHisPatientById(patient_id)
  12467. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12468. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12469. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12470. resp, requestErr := http.Get(api)
  12471. if requestErr != nil {
  12472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12473. return
  12474. }
  12475. body, ioErr := ioutil.ReadAll(resp.Body)
  12476. if ioErr != nil {
  12477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12479. return
  12480. }
  12481. var respJSON map[string]interface{}
  12482. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12485. return
  12486. }
  12487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12488. result, _ := json.Marshal(respJSON)
  12489. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12490. utils.ErrorLog("解析失败:%v", err)
  12491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12492. return
  12493. }
  12494. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12495. p, _ := service.GetHisPatientById(patient_id)
  12496. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12497. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12498. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12499. resp, requestErr := http.Get(api)
  12500. if requestErr != nil {
  12501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12502. return
  12503. }
  12504. body, ioErr := ioutil.ReadAll(resp.Body)
  12505. if ioErr != nil {
  12506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12508. return
  12509. }
  12510. var respJSON map[string]interface{}
  12511. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12514. return
  12515. }
  12516. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12517. result, _ := json.Marshal(respJSON)
  12518. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12519. utils.ErrorLog("解析失败:%v", err)
  12520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12521. return
  12522. }
  12523. } else {
  12524. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12525. var dat map[string]interface{}
  12526. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12527. fmt.Println(dat)
  12528. } else {
  12529. fmt.Println(err)
  12530. }
  12531. userJSONBytes, _ := json.Marshal(dat)
  12532. if miConfig.Code == "H15049901371" {
  12533. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12534. utils.ErrorLog("解析失败:%v", err)
  12535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12536. return
  12537. }
  12538. res.InfRefmsgid = res10265.InfRefmsgid
  12539. res.Output = res10265.Output
  12540. res.ErrMsg = res10265.ErrMsg
  12541. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12542. res.Infcode = infocode
  12543. } else {
  12544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12545. utils.ErrorLog("解析失败:%v", err)
  12546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12547. return
  12548. }
  12549. }
  12550. }
  12551. if res.Infcode == 0 {
  12552. c.ServeSuccessJSON(map[string]interface{}{
  12553. "result": res.Output.Result,
  12554. })
  12555. }
  12556. }
  12557. func (c *HisApiController) CheckInsutype() {
  12558. his_patient_id, _ := c.GetInt64("his_patient_id")
  12559. admin_user_id, _ := c.GetInt64("admin_user_id")
  12560. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12561. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12562. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12563. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12564. var dat map[string]interface{}
  12565. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12566. fmt.Println(dat)
  12567. } else {
  12568. fmt.Println(err)
  12569. }
  12570. userJSONBytes, _ := json.Marshal(dat)
  12571. var res Result90100
  12572. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12573. utils.ErrorLog("解析失败:%v", err)
  12574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12575. return
  12576. }
  12577. if res.Infcode != 0 {
  12578. c.ServeSuccessJSON(map[string]interface{}{
  12579. "failed_code": -10,
  12580. "msg": res.ErrMsg,
  12581. })
  12582. return
  12583. } else {
  12584. fmt.Println(res)
  12585. }
  12586. }
  12587. func (c *HisApiController) CheckCardPWD() {
  12588. card_pwd := c.GetString("card_pwd")
  12589. his_patient_id, _ := c.GetInt64("his_patient_id")
  12590. admin_user_id, _ := c.GetInt64("admin_user_id")
  12591. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12592. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12593. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12594. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12595. bas := strings.Split(psn.CardInfo, "|")
  12596. basNumber := bas[2]
  12597. if psn.InsuplcAdmdvs[:4] == "4403" {
  12598. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12599. var dat map[string]interface{}
  12600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12601. fmt.Println(dat)
  12602. } else {
  12603. fmt.Println(err)
  12604. }
  12605. userJSONBytes, _ := json.Marshal(dat)
  12606. var res Result90991
  12607. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12608. utils.ErrorLog("解析失败:%v", err)
  12609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12610. return
  12611. }
  12612. if res.Infcode != 0 {
  12613. c.ServeSuccessJSON(map[string]interface{}{
  12614. "failed_code": -10,
  12615. "msg": res.ErrMsg,
  12616. })
  12617. return
  12618. } else {
  12619. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12620. var msg string
  12621. switch res.Output.Result.CardStat {
  12622. case "00":
  12623. msg = "未激活"
  12624. break
  12625. case "10":
  12626. msg = "激活"
  12627. break
  12628. case "20":
  12629. msg = "窗口挂失"
  12630. break
  12631. case "21":
  12632. msg = "电话挂失"
  12633. break
  12634. case "22":
  12635. msg = "单位网上申报挂失"
  12636. break
  12637. case "23":
  12638. msg = "保健办挂失"
  12639. break
  12640. case "24":
  12641. msg = "个人网上挂失"
  12642. break
  12643. case "25":
  12644. msg = "网上服务大厅挂失"
  12645. break
  12646. case "30":
  12647. msg = "注销"
  12648. break
  12649. case "40":
  12650. msg = "回收"
  12651. break
  12652. case "99":
  12653. msg = "制卡中(无效卡)"
  12654. break
  12655. }
  12656. c.ServeSuccessJSON(map[string]interface{}{
  12657. "failed_code": -10,
  12658. "msg": msg,
  12659. })
  12660. return
  12661. } else {
  12662. c.ServeSuccessJSON(map[string]interface{}{
  12663. "msg": "校验成功",
  12664. })
  12665. return
  12666. }
  12667. }
  12668. } else {
  12669. c.ServeSuccessJSON(map[string]interface{}{
  12670. "msg": "校验成功",
  12671. })
  12672. return
  12673. }
  12674. }
  12675. func (c *HisApiController) CheckCardPWDTwo() {
  12676. //card_pwd := c.GetString("card_pwd")
  12677. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12678. admin_user_id, _ := c.GetInt64("admin_user_id")
  12679. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12680. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12681. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12682. var dat map[string]interface{}
  12683. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12684. fmt.Println(dat)
  12685. } else {
  12686. fmt.Println(err)
  12687. }
  12688. userJSONBytes, _ := json.Marshal(dat)
  12689. var res Result90991
  12690. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12691. utils.ErrorLog("解析失败:%v", err)
  12692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12693. return
  12694. }
  12695. if res.Infcode != 0 {
  12696. c.ServeSuccessJSON(map[string]interface{}{
  12697. "failed_code": -10,
  12698. "msg": res.ErrMsg,
  12699. })
  12700. return
  12701. } else {
  12702. if res.Output.Result.SscnoCheckStat == "0" {
  12703. var msg string
  12704. switch res.Output.Result.CardStat {
  12705. case "00":
  12706. msg = "未激活"
  12707. break
  12708. case "10":
  12709. msg = "激活"
  12710. break
  12711. case "20":
  12712. msg = "窗口挂失"
  12713. break
  12714. case "21":
  12715. msg = "电话挂失"
  12716. break
  12717. case "22":
  12718. msg = "单位网上申报挂失"
  12719. break
  12720. case "23":
  12721. msg = "保健办挂失"
  12722. break
  12723. case "24":
  12724. msg = "个人网上挂失"
  12725. break
  12726. case "25":
  12727. msg = "网上服务大厅挂失"
  12728. break
  12729. case "30":
  12730. msg = "注销"
  12731. break
  12732. case "40":
  12733. msg = "回收"
  12734. break
  12735. case "99":
  12736. msg = "制卡中(无效卡)"
  12737. break
  12738. }
  12739. c.ServeSuccessJSON(map[string]interface{}{
  12740. "failed_code": -10,
  12741. "msg": msg,
  12742. })
  12743. return
  12744. } else {
  12745. c.ServeSuccessJSON(map[string]interface{}{
  12746. "msg": "校验成功",
  12747. })
  12748. return
  12749. }
  12750. }
  12751. }
  12752. type ELeCertData struct {
  12753. Data struct {
  12754. Extra string `json:"extra"`
  12755. IDNo string `json:"idNo"`
  12756. IDType string `json:"idType"`
  12757. EcToken string `json:"ecToken"`
  12758. InsuOrg string `json:"insuOrg"`
  12759. UserName string `json:"userName"`
  12760. EcIndexNo string `json:"ecIndexNo"`
  12761. Gender string `json:"gender"`
  12762. Birthday string `json:"birthday"`
  12763. Nationality string `json:"nationality"`
  12764. Email string `json:"email"`
  12765. } `json:"OutData"`
  12766. }
  12767. func (c *HisApiController) ReadCard() {
  12768. id_card_type, _ := c.GetInt64("id_card_type")
  12769. admin_user_id, _ := c.GetInt64("admin_user_id")
  12770. certificates, _ := c.GetInt64("certificates")
  12771. //
  12772. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12773. id_card_no := c.GetString("id_card_no")
  12774. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12775. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12776. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12777. switch id_card_type {
  12778. case 1:
  12779. if miConfig.MdtrtareaAdmvs == "421300" {
  12780. var res ResultTwo
  12781. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12782. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12783. "&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)
  12784. resp, requestErr := http.Get(api)
  12785. if requestErr != nil {
  12786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12787. return
  12788. }
  12789. body, ioErr := ioutil.ReadAll(resp.Body)
  12790. if ioErr != nil {
  12791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12793. return
  12794. }
  12795. var respJSON map[string]interface{}
  12796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12799. return
  12800. }
  12801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12802. result, _ := json.Marshal(respJSON)
  12803. fmt.Println("log")
  12804. fmt.Println(string(result))
  12805. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12806. utils.ErrorLog("解析失败:%v", err)
  12807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12808. return
  12809. }
  12810. if res.Infcode == 0 {
  12811. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12812. if err == gorm.ErrRecordNotFound {
  12813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12814. return
  12815. } else if err != nil {
  12816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12817. return
  12818. } else {
  12819. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12820. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12821. infoStr := string(Iinfos)
  12822. idetinfoStr := string(Idetinfos)
  12823. var rf []*ResultFive
  12824. json.Unmarshal([]byte(infoStr), &rf)
  12825. var insutypes []*ResultFive
  12826. var insutype string
  12827. var is390 int = 0
  12828. var is310 int = 0
  12829. for _, item := range rf {
  12830. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12831. insutypes = append(insutypes, item)
  12832. }
  12833. }
  12834. if len(insutypes) == 1 {
  12835. insutype = insutypes[0].Insutype
  12836. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12837. } else {
  12838. for _, i := range insutypes {
  12839. if i.Insutype == "390" {
  12840. is390 = 1
  12841. }
  12842. if i.Insutype == "310" {
  12843. is310 = 1
  12844. }
  12845. }
  12846. }
  12847. if is390 == 1 {
  12848. insutype = "390"
  12849. }
  12850. if is310 == 1 {
  12851. insutype = "310"
  12852. }
  12853. if len(insutypes) == 0 {
  12854. insutype = "390"
  12855. }
  12856. var insuplc_admdvs string
  12857. for _, item := range rf {
  12858. if item.Insutype == insutype {
  12859. insuplc_admdvs = item.InsuplcAdmdvs
  12860. }
  12861. }
  12862. if strings.Contains(insuplc_admdvs, "4213") {
  12863. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12864. }
  12865. psn := &models.HisPsn{
  12866. PsnNo: res.Output.Baseinfo.PsnNo,
  12867. PatientId: patient.ID,
  12868. Certno: res.Output.Baseinfo.Certno,
  12869. Gend: res.Output.Baseinfo.Gend,
  12870. Naty: res.Output.Baseinfo.Naty,
  12871. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12872. PsnName: res.Output.Baseinfo.PsnName,
  12873. Idetinfo: idetinfoStr,
  12874. Insuinfo: infoStr,
  12875. InsuplcAdmdvs: insuplc_admdvs,
  12876. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12877. }
  12878. service.CreateHisPsn(psn)
  12879. c.ServeSuccessJSON(map[string]interface{}{
  12880. "patient": patient,
  12881. "number": res.Output.Baseinfo.Certno,
  12882. })
  12883. }
  12884. } else {
  12885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12886. return
  12887. }
  12888. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12889. var res ResultTwo
  12890. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12891. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12892. "&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)
  12893. resp, requestErr := http.Get(api)
  12894. if requestErr != nil {
  12895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12896. return
  12897. }
  12898. body, ioErr := ioutil.ReadAll(resp.Body)
  12899. if ioErr != nil {
  12900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12902. return
  12903. }
  12904. var respJSON map[string]interface{}
  12905. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12908. return
  12909. }
  12910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12911. result, _ := json.Marshal(respJSON)
  12912. fmt.Println("log")
  12913. fmt.Println(string(result))
  12914. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12915. utils.ErrorLog("解析失败:%v", err)
  12916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12917. return
  12918. }
  12919. if res.Infcode == 0 {
  12920. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12921. if err == gorm.ErrRecordNotFound {
  12922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12923. return
  12924. } else if err != nil {
  12925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12926. return
  12927. } else {
  12928. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12929. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12930. infoStr := string(Iinfos)
  12931. idetinfoStr := string(Idetinfos)
  12932. psn := &models.HisPsn{
  12933. PsnNo: res.Output.Baseinfo.PsnNo,
  12934. PatientId: patient.ID,
  12935. Certno: res.Output.Baseinfo.Certno,
  12936. Gend: res.Output.Baseinfo.Gend,
  12937. Naty: res.Output.Baseinfo.Naty,
  12938. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12939. PsnName: res.Output.Baseinfo.PsnName,
  12940. Idetinfo: idetinfoStr,
  12941. Insuinfo: infoStr,
  12942. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12943. }
  12944. service.CreateHisPsn(psn)
  12945. var rf []*ResultFive
  12946. json.Unmarshal([]byte(infoStr), &rf)
  12947. var insutypes []*ResultFive
  12948. var insutype string
  12949. var is390 int = 0
  12950. var is310 int = 0
  12951. for _, item := range rf {
  12952. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12953. insutypes = append(insutypes, item)
  12954. }
  12955. }
  12956. if len(insutypes) == 1 {
  12957. insutype = insutypes[0].Insutype
  12958. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12959. } else {
  12960. for _, i := range insutypes {
  12961. if i.Insutype == "390" {
  12962. is390 = 1
  12963. }
  12964. if i.Insutype == "310" {
  12965. is310 = 1
  12966. }
  12967. }
  12968. }
  12969. if is390 == 1 {
  12970. insutype = "390"
  12971. }
  12972. if is310 == 1 {
  12973. insutype = "310"
  12974. }
  12975. if len(insutypes) == 0 {
  12976. insutype = "310"
  12977. }
  12978. c.ServeSuccessJSON(map[string]interface{}{
  12979. "patient": patient,
  12980. "number": res.Output.Baseinfo.Certno,
  12981. "insutype": insutype,
  12982. })
  12983. }
  12984. } else {
  12985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12986. return
  12987. }
  12988. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12989. var res ResultTwo
  12990. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12991. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12992. "&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)
  12993. resp, requestErr := http.Get(api)
  12994. if requestErr != nil {
  12995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12996. return
  12997. }
  12998. body, ioErr := ioutil.ReadAll(resp.Body)
  12999. if ioErr != nil {
  13000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13002. return
  13003. }
  13004. var respJSON map[string]interface{}
  13005. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13008. return
  13009. }
  13010. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13011. result, _ := json.Marshal(respJSON)
  13012. fmt.Println("log")
  13013. fmt.Println(string(result))
  13014. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13015. utils.ErrorLog("解析失败:%v", err)
  13016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13017. return
  13018. }
  13019. if res.Infcode == 0 {
  13020. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13021. if err == gorm.ErrRecordNotFound {
  13022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13023. return
  13024. } else if err != nil {
  13025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13026. return
  13027. } else {
  13028. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13029. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13030. infoStr := string(Iinfos)
  13031. idetinfoStr := string(Idetinfos)
  13032. var rf []*ResultFive
  13033. json.Unmarshal([]byte(infoStr), &rf)
  13034. var insutypes []*ResultFive
  13035. var insutype string
  13036. var is390 int = 0
  13037. var is310 int = 0
  13038. for _, item := range rf {
  13039. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13040. insutypes = append(insutypes, item)
  13041. }
  13042. }
  13043. if len(insutypes) == 1 {
  13044. insutype = insutypes[0].Insutype
  13045. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13046. } else {
  13047. for _, i := range insutypes {
  13048. if i.Insutype == "390" {
  13049. is390 = 1
  13050. }
  13051. if i.Insutype == "310" {
  13052. is310 = 1
  13053. }
  13054. }
  13055. }
  13056. if is390 == 1 {
  13057. insutype = "390"
  13058. }
  13059. if is310 == 1 {
  13060. insutype = "310"
  13061. }
  13062. if len(insutypes) == 0 {
  13063. insutype = "390"
  13064. }
  13065. var insuplc_admdvs string
  13066. for _, item := range rf {
  13067. if item.Insutype == insutype {
  13068. insuplc_admdvs = item.InsuplcAdmdvs
  13069. }
  13070. }
  13071. psn := &models.HisPsn{
  13072. PsnNo: res.Output.Baseinfo.PsnNo,
  13073. PatientId: patient.ID,
  13074. Certno: res.Output.Baseinfo.Certno,
  13075. Gend: res.Output.Baseinfo.Gend,
  13076. Naty: res.Output.Baseinfo.Naty,
  13077. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13078. PsnName: res.Output.Baseinfo.PsnName,
  13079. Idetinfo: idetinfoStr,
  13080. Insuinfo: infoStr,
  13081. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13082. InsuplcAdmdvs: insuplc_admdvs,
  13083. }
  13084. service.CreateHisPsn(psn)
  13085. for _, item := range rf {
  13086. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13087. insutypes = append(insutypes, item)
  13088. }
  13089. }
  13090. if len(insutypes) == 1 {
  13091. insutype = insutypes[0].Insutype
  13092. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13093. } else {
  13094. for _, i := range insutypes {
  13095. if i.Insutype == "390" {
  13096. is390 = 1
  13097. }
  13098. if i.Insutype == "310" {
  13099. is310 = 1
  13100. }
  13101. }
  13102. }
  13103. if is390 == 1 {
  13104. insutype = "390"
  13105. }
  13106. if is310 == 1 {
  13107. insutype = "310"
  13108. }
  13109. if len(insutypes) == 0 {
  13110. insutype = "310"
  13111. }
  13112. c.ServeSuccessJSON(map[string]interface{}{
  13113. "patient": patient,
  13114. "number": res.Output.Baseinfo.Certno,
  13115. "insutype": insutype,
  13116. })
  13117. }
  13118. } else {
  13119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13120. return
  13121. }
  13122. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13123. var res ResultTwo
  13124. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13125. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13126. "&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)
  13127. resp, requestErr := http.Get(api)
  13128. if requestErr != nil {
  13129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13130. return
  13131. }
  13132. body, ioErr := ioutil.ReadAll(resp.Body)
  13133. if ioErr != nil {
  13134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13136. return
  13137. }
  13138. var respJSON map[string]interface{}
  13139. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13142. return
  13143. }
  13144. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13145. result, _ := json.Marshal(respJSON)
  13146. fmt.Println("log")
  13147. fmt.Println(string(result))
  13148. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13149. utils.ErrorLog("解析失败:%v", err)
  13150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13151. return
  13152. }
  13153. if res.Infcode == 0 {
  13154. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13155. if err == gorm.ErrRecordNotFound {
  13156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13157. return
  13158. } else if err != nil {
  13159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13160. return
  13161. } else {
  13162. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13163. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13164. infoStr := string(Iinfos)
  13165. idetinfoStr := string(Idetinfos)
  13166. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13167. psn := &models.HisPsn{
  13168. PsnNo: res.Output.Baseinfo.PsnNo,
  13169. PatientId: patient.ID,
  13170. Certno: res.Output.Baseinfo.Certno,
  13171. Brdy: b,
  13172. Age: float64(age),
  13173. Gend: res.Output.Baseinfo.Gend,
  13174. Naty: res.Output.Baseinfo.Naty,
  13175. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13176. PsnName: res.Output.Baseinfo.PsnName,
  13177. Idetinfo: idetinfoStr,
  13178. Insuinfo: infoStr,
  13179. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13180. }
  13181. service.CreateHisPsn(psn)
  13182. var rf []*ResultFive
  13183. json.Unmarshal([]byte(infoStr), &rf)
  13184. var insutypes []*ResultFive
  13185. var insutype string
  13186. var is390 int = 0
  13187. var is310 int = 0
  13188. for _, item := range rf {
  13189. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13190. insutypes = append(insutypes, item)
  13191. }
  13192. }
  13193. if len(insutypes) == 1 {
  13194. insutype = insutypes[0].Insutype
  13195. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13196. } else {
  13197. for _, i := range insutypes {
  13198. if i.Insutype == "390" {
  13199. is390 = 1
  13200. }
  13201. if i.Insutype == "310" {
  13202. is310 = 1
  13203. }
  13204. }
  13205. }
  13206. if is390 == 1 {
  13207. insutype = "390"
  13208. }
  13209. if is310 == 1 {
  13210. insutype = "310"
  13211. }
  13212. if len(insutypes) == 0 {
  13213. insutype = "310"
  13214. }
  13215. c.ServeSuccessJSON(map[string]interface{}{
  13216. "patient": patient,
  13217. "number": res.Output.Baseinfo.Certno,
  13218. "insutype": insutype,
  13219. })
  13220. }
  13221. } else {
  13222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13223. return
  13224. }
  13225. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13226. var api string
  13227. if miConfig.MdtrtareaAdmvs == "320921" {
  13228. 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 +
  13229. "&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
  13230. fmt.Println(api)
  13231. } else {
  13232. 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 +
  13233. "&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)
  13234. }
  13235. resp, requestErr := http.Get(api)
  13236. if requestErr != nil {
  13237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13238. return
  13239. }
  13240. body, ioErr := ioutil.ReadAll(resp.Body)
  13241. if ioErr != nil {
  13242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13244. return
  13245. }
  13246. var respJSON map[string]interface{}
  13247. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13250. return
  13251. }
  13252. var status string
  13253. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13254. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13255. //console.log()
  13256. fmt.Println("type===")
  13257. fmt.Println(card_type)
  13258. var token string
  13259. var res ResultTwo //1101结果
  13260. var res10265 ResultTwo10265 //1101结果
  13261. var card_info string //卡信息
  13262. var busi_card_info string
  13263. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13264. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13265. if status == "0" { //读卡成功
  13266. if card_type == "1" {
  13267. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13268. result, _ := json.Marshal(respJSON)
  13269. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13270. utils.ErrorLog("解析失败:%v", err)
  13271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13272. return
  13273. }
  13274. res.ErrMsg = res10265.ErrMsg
  13275. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13276. res.Infcode = infocode
  13277. res.Output = res10265.Output
  13278. res.InfRefmsgid = res10265.InfRefmsgid
  13279. } else {
  13280. //var card_info string //卡信息
  13281. //var busi_card_info string
  13282. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13283. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13284. //fmt.Println(card_info)
  13285. //fmt.Println(busi_card_info)
  13286. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13287. result, _ := json.Marshal(respJSON)
  13288. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13289. utils.ErrorLog("解析失败:%v", err)
  13290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13291. return
  13292. }
  13293. res.ErrMsg = res10265.ErrMsg
  13294. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13295. res.Infcode = infocode
  13296. res.Output = res10265.Output
  13297. res.InfRefmsgid = res10265.InfRefmsgid
  13298. }
  13299. if res.Infcode == 0 {
  13300. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13301. if err == gorm.ErrRecordNotFound {
  13302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13303. return
  13304. } else if err != nil {
  13305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13306. return
  13307. } else {
  13308. if card_type == "1" {
  13309. bas := strings.Split(card_info, "|")
  13310. basNumber := bas[2]
  13311. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13312. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13313. infoStr := string(Iinfos)
  13314. idetinfoStr := string(Idetinfos)
  13315. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13316. psn := &models.HisPsn{
  13317. PsnNo: res.Output.Baseinfo.PsnNo,
  13318. PatientId: patient.ID,
  13319. Certno: res.Output.Baseinfo.Certno,
  13320. Brdy: b,
  13321. Age: float64(age),
  13322. Gend: res.Output.Baseinfo.Gend,
  13323. Naty: res.Output.Baseinfo.Naty,
  13324. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13325. PsnName: res.Output.Baseinfo.PsnName,
  13326. Idetinfo: idetinfoStr,
  13327. Insuinfo: infoStr,
  13328. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13329. CardInfo: card_info,
  13330. VerifyNumber: busi_card_info,
  13331. }
  13332. service.CreateHisPsn(psn)
  13333. var rf []*ResultFive
  13334. json.Unmarshal([]byte(infoStr), &rf)
  13335. var insutypes []*ResultFive
  13336. var insutype string
  13337. var is390 int = 0
  13338. var is310 int = 0
  13339. for _, item := range rf {
  13340. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13341. insutypes = append(insutypes, item)
  13342. }
  13343. }
  13344. if len(insutypes) == 1 {
  13345. insutype = insutypes[0].Insutype
  13346. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13347. } else {
  13348. for _, i := range insutypes {
  13349. if i.Insutype == "390" {
  13350. is390 = 1
  13351. }
  13352. if i.Insutype == "310" {
  13353. is310 = 1
  13354. }
  13355. }
  13356. }
  13357. if is390 == 1 {
  13358. insutype = "390"
  13359. }
  13360. if is310 == 1 {
  13361. insutype = "310"
  13362. }
  13363. if len(insutypes) == 0 {
  13364. insutype = "310"
  13365. }
  13366. c.ServeSuccessJSON(map[string]interface{}{
  13367. "patient": patient,
  13368. "number": basNumber,
  13369. "insutype": insutype,
  13370. })
  13371. } else {
  13372. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13373. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13374. infoStr := string(Iinfos)
  13375. idetinfoStr := string(Idetinfos)
  13376. psn := &models.HisPsn{
  13377. PsnNo: res.Output.Baseinfo.PsnNo,
  13378. PatientId: patient.ID,
  13379. Certno: res.Output.Baseinfo.Certno,
  13380. Gend: res.Output.Baseinfo.Gend,
  13381. Naty: res.Output.Baseinfo.Naty,
  13382. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13383. PsnName: res.Output.Baseinfo.PsnName,
  13384. Idetinfo: idetinfoStr,
  13385. Insuinfo: infoStr,
  13386. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13387. CardInfo: card_info,
  13388. VerifyNumber: token,
  13389. }
  13390. service.CreateHisPsn(psn)
  13391. c.ServeSuccessJSON(map[string]interface{}{
  13392. "patient": patient,
  13393. "number": token,
  13394. })
  13395. }
  13396. }
  13397. } else {
  13398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13399. return
  13400. }
  13401. } else { //读卡失败
  13402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13403. return
  13404. }
  13405. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13406. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13407. cardnum = DeleteExtraSpaceTwo(cardnum)
  13408. cardCode = DeleteExtraSpaceTwo(cardCode)
  13409. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13410. name = DeleteExtraSpaceTwo(name)
  13411. errmsg = DeleteExtraSpaceTwo(errmsg)
  13412. cardnum = Remove0000(cardnum)
  13413. cardCode = Remove0000(cardCode)
  13414. id_card_no = Remove0000(id_card_no)
  13415. name = Remove0000(name)
  13416. errmsg = Remove0000(errmsg)
  13417. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13418. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13419. //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)
  13420. //fmt.Println(result2)
  13421. //fmt.Println(requestLog2)
  13422. //fmt.Println(errMsgLog2)
  13423. 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)
  13424. saveLog(result, requestLog, "1101", "获取人员信息")
  13425. fmt.Println(errMsgLog)
  13426. if len(errMsgLog) > 0 {
  13427. } else {
  13428. var dat map[string]interface{}
  13429. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13430. fmt.Println(dat)
  13431. } else {
  13432. fmt.Println(err)
  13433. }
  13434. userJSONBytes, _ := json.Marshal(dat)
  13435. var res ResultTwo
  13436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13437. utils.ErrorLog("解析失败:%v", err)
  13438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13439. return
  13440. }
  13441. res.ErrMsg = errMsgLog
  13442. if res.Infcode == 0 {
  13443. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13444. if err == gorm.ErrRecordNotFound {
  13445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13446. return
  13447. } else if err != nil {
  13448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13449. return
  13450. } else {
  13451. fmt.Println(res)
  13452. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13453. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13454. infoStr := string(Iinfos)
  13455. idetinfoStr := string(Idetinfos)
  13456. var rf []*ResultFive
  13457. json.Unmarshal([]byte(infoStr), &rf)
  13458. var insutypes []*ResultFive
  13459. var insutype string
  13460. var is390 int = 0
  13461. var is310 int = 0
  13462. for _, item := range rf {
  13463. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13464. insutypes = append(insutypes, item)
  13465. }
  13466. }
  13467. if len(insutypes) == 1 {
  13468. insutype = insutypes[0].Insutype
  13469. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13470. } else {
  13471. for _, i := range insutypes {
  13472. if i.Insutype == "390" {
  13473. is390 = 1
  13474. }
  13475. if i.Insutype == "310" {
  13476. is310 = 1
  13477. }
  13478. }
  13479. }
  13480. if is390 == 1 {
  13481. insutype = "390"
  13482. }
  13483. if is310 == 1 {
  13484. insutype = "310"
  13485. }
  13486. if len(insutypes) == 0 {
  13487. insutype = "390"
  13488. }
  13489. var insuplc_admdvs string
  13490. for _, item := range rf {
  13491. if item.Insutype == insutype {
  13492. insuplc_admdvs = item.InsuplcAdmdvs
  13493. }
  13494. }
  13495. psn := &models.HisPsn{
  13496. PsnNo: res.Output.Baseinfo.PsnNo,
  13497. PatientId: patient.ID,
  13498. Certno: res.Output.Baseinfo.Certno,
  13499. Gend: res.Output.Baseinfo.Gend,
  13500. Naty: res.Output.Baseinfo.Naty,
  13501. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13502. PsnName: res.Output.Baseinfo.PsnName,
  13503. Idetinfo: idetinfoStr,
  13504. Insuinfo: infoStr,
  13505. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13506. CardInfo: basStr,
  13507. VerifyNumber: "",
  13508. InsuplcAdmdvs: insuplc_admdvs,
  13509. }
  13510. service.CreateHisPsn(psn)
  13511. c.ServeSuccessJSON(map[string]interface{}{
  13512. "patient": patient,
  13513. "number": cardnum,
  13514. "insutype": insutype,
  13515. })
  13516. }
  13517. } else {
  13518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13519. return
  13520. }
  13521. }
  13522. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13523. fmt.Println(initFlag)
  13524. fmt.Println("initFlag")
  13525. if initFlag == 0 {
  13526. c.TestGetJiangXiBasBaseInit()
  13527. }
  13528. basStr := c.GetBasBaseInfo()
  13529. if len(basStr) == 0 {
  13530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13531. return
  13532. }
  13533. fmt.Println(basStr)
  13534. bas := strings.Split(basStr, "|")
  13535. basNumber := bas[1]
  13536. fmt.Println(basNumber)
  13537. card_sn := bas[3]
  13538. fmt.Println(card_sn)
  13539. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13540. 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)
  13541. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13542. var dat map[string]interface{}
  13543. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13544. fmt.Println(dat)
  13545. } else {
  13546. fmt.Println(err)
  13547. }
  13548. userJSONBytes, _ := json.Marshal(dat)
  13549. var res ResultTwo
  13550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13551. utils.ErrorLog("解析失败:%v", err)
  13552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13553. return
  13554. }
  13555. if res.Infcode == 0 {
  13556. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13557. if err == gorm.ErrRecordNotFound {
  13558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13559. return
  13560. } else if err != nil {
  13561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13562. return
  13563. } else {
  13564. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13565. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13566. infoStr := string(Iinfos)
  13567. idetinfoStr := string(Idetinfos)
  13568. var rf []*ResultFive
  13569. json.Unmarshal([]byte(infoStr), &rf)
  13570. var insutypes []*ResultFive
  13571. var insutype string
  13572. var is390 int = 0
  13573. var is310 int = 0
  13574. var insuplc_admdvs string
  13575. for _, item := range rf {
  13576. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13577. insutypes = append(insutypes, item)
  13578. }
  13579. }
  13580. if len(insutypes) == 1 {
  13581. insutype = insutypes[0].Insutype
  13582. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13583. } else {
  13584. for _, i := range insutypes {
  13585. if i.Insutype == "390" {
  13586. is390 = 1
  13587. }
  13588. if i.Insutype == "310" {
  13589. is310 = 1
  13590. }
  13591. }
  13592. }
  13593. if is390 == 1 {
  13594. insutype = "390"
  13595. }
  13596. if is310 == 1 {
  13597. insutype = "310"
  13598. }
  13599. if len(insutypes) == 0 {
  13600. insutype = "310"
  13601. }
  13602. for _, item := range rf {
  13603. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13604. insuplc_admdvs = item.InsuplcAdmdvs
  13605. }
  13606. }
  13607. psn := &models.HisPsn{
  13608. PsnNo: res.Output.Baseinfo.PsnNo,
  13609. PatientId: patient.ID,
  13610. Certno: res.Output.Baseinfo.Certno,
  13611. Gend: res.Output.Baseinfo.Gend,
  13612. Naty: res.Output.Baseinfo.Naty,
  13613. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13614. PsnName: res.Output.Baseinfo.PsnName,
  13615. Idetinfo: idetinfoStr,
  13616. Insuinfo: infoStr,
  13617. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13618. CardInfo: basStr,
  13619. InsuplcAdmdvs: insuplc_admdvs,
  13620. VerifyNumber: "",
  13621. }
  13622. service.CreateHisPsn(psn)
  13623. c.ServeSuccessJSON(map[string]interface{}{
  13624. "patient": patient,
  13625. "number": basNumber,
  13626. "insutype": insutype,
  13627. })
  13628. }
  13629. } else {
  13630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13631. return
  13632. }
  13633. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13634. basStr := c.GetBasBaseInfo22222()
  13635. fmt.Println(basStr)
  13636. if len(basStr) == 0 {
  13637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13638. return
  13639. }
  13640. fmt.Println(basStr)
  13641. bas := strings.Split(basStr, "|")
  13642. basNumber := bas[2] //卡号
  13643. card_sn := bas[3] //
  13644. id_card_No := bas[1] //卡号
  13645. fmt.Println(basNumber)
  13646. fmt.Println(card_sn)
  13647. fmt.Println(id_card_No)
  13648. var patient service.Patients
  13649. if len(id_card_No) == 0 {
  13650. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13651. } else {
  13652. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13653. }
  13654. 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)
  13655. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13656. var dat map[string]interface{}
  13657. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13658. fmt.Println(dat)
  13659. } else {
  13660. fmt.Println(err)
  13661. }
  13662. userJSONBytes, _ := json.Marshal(dat)
  13663. var res ResultTwo
  13664. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13665. utils.ErrorLog("解析失败:%v", err)
  13666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13667. return
  13668. }
  13669. if res.Infcode == 0 {
  13670. var pateint2 service.Patients
  13671. var err error
  13672. if len(id_card_No) == 0 {
  13673. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13674. } else {
  13675. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13676. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13677. }
  13678. if err == gorm.ErrRecordNotFound {
  13679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13680. return
  13681. } else if err != nil {
  13682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13683. return
  13684. } else {
  13685. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13686. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13687. infoStr := string(Iinfos)
  13688. idetinfoStr := string(Idetinfos)
  13689. var rf []*ResultFive
  13690. json.Unmarshal([]byte(infoStr), &rf)
  13691. var insutypes []*ResultFive
  13692. var insutype string
  13693. var is390 int = 0
  13694. var is310 int = 0
  13695. var insuplc_admdvs string
  13696. for _, item := range rf {
  13697. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13698. insutypes = append(insutypes, item)
  13699. }
  13700. }
  13701. if len(insutypes) == 1 {
  13702. insutype = insutypes[0].Insutype
  13703. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13704. } else {
  13705. for _, i := range insutypes {
  13706. if i.Insutype == "390" {
  13707. is390 = 1
  13708. }
  13709. if i.Insutype == "310" {
  13710. is310 = 1
  13711. }
  13712. }
  13713. }
  13714. if is390 == 1 {
  13715. insutype = "390"
  13716. }
  13717. if is310 == 1 {
  13718. insutype = "310"
  13719. }
  13720. if len(insutypes) == 0 {
  13721. insutype = "310"
  13722. }
  13723. for _, item := range rf {
  13724. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13725. insuplc_admdvs = item.InsuplcAdmdvs
  13726. }
  13727. }
  13728. psn := &models.HisPsn{
  13729. PsnNo: res.Output.Baseinfo.PsnNo,
  13730. PatientId: pateint2.ID,
  13731. Certno: res.Output.Baseinfo.Certno,
  13732. Gend: res.Output.Baseinfo.Gend,
  13733. Naty: res.Output.Baseinfo.Naty,
  13734. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13735. PsnName: res.Output.Baseinfo.PsnName,
  13736. Idetinfo: idetinfoStr,
  13737. Insuinfo: infoStr,
  13738. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13739. CardInfo: basStr,
  13740. InsuplcAdmdvs: insuplc_admdvs,
  13741. VerifyNumber: "",
  13742. }
  13743. service.CreateHisPsn(psn)
  13744. c.ServeSuccessJSON(map[string]interface{}{
  13745. "patient": patient,
  13746. "number": basNumber,
  13747. "insutype": insutype,
  13748. })
  13749. }
  13750. } else {
  13751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13752. return
  13753. }
  13754. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13755. fmt.Println(initFlag)
  13756. fmt.Println("initFlag")
  13757. if initFlag == 0 {
  13758. c.TestGetHnBasBaseInit()
  13759. }
  13760. basStr := c.GetBasBaseInfo()
  13761. if len(basStr) == 0 {
  13762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13763. return
  13764. }
  13765. fmt.Println(basStr)
  13766. bas := strings.Split(basStr, "|")
  13767. basNumber := bas[1]
  13768. fmt.Println(basNumber)
  13769. card_sn := bas[3]
  13770. card_no := bas[2]
  13771. fmt.Println(card_sn)
  13772. name := bas[4]
  13773. name = ConvertToString(name, "gbk", "utf-8")
  13774. 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)
  13775. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13776. var dat map[string]interface{}
  13777. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13778. fmt.Println(dat)
  13779. } else {
  13780. fmt.Println(err)
  13781. }
  13782. userJSONBytes, _ := json.Marshal(dat)
  13783. var res ResultTwo
  13784. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13785. utils.ErrorLog("解析失败:%v", err)
  13786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13787. return
  13788. }
  13789. if res.Infcode == 0 {
  13790. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13791. if err == gorm.ErrRecordNotFound {
  13792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13793. return
  13794. } else if err != nil {
  13795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13796. return
  13797. } else {
  13798. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13799. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13800. infoStr := string(Iinfos)
  13801. idetinfoStr := string(Idetinfos)
  13802. psn := &models.HisPsn{
  13803. PsnNo: res.Output.Baseinfo.PsnNo,
  13804. PatientId: patient.ID,
  13805. Certno: res.Output.Baseinfo.Certno,
  13806. Gend: res.Output.Baseinfo.Gend,
  13807. Naty: res.Output.Baseinfo.Naty,
  13808. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13809. PsnName: res.Output.Baseinfo.PsnName,
  13810. Idetinfo: idetinfoStr,
  13811. Insuinfo: infoStr,
  13812. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13813. CardInfo: basStr,
  13814. VerifyNumber: "",
  13815. }
  13816. service.CreateHisPsn(psn)
  13817. var rf []*ResultFive
  13818. json.Unmarshal([]byte(infoStr), &rf)
  13819. var insutypes []*ResultFive
  13820. var insutype string
  13821. var is390 int = 0
  13822. var is310 int = 0
  13823. for _, item := range rf {
  13824. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13825. insutypes = append(insutypes, item)
  13826. }
  13827. }
  13828. if len(insutypes) == 1 {
  13829. insutype = insutypes[0].Insutype
  13830. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13831. } else {
  13832. for _, i := range insutypes {
  13833. if i.Insutype == "390" {
  13834. is390 = 1
  13835. }
  13836. if i.Insutype == "310" {
  13837. is310 = 1
  13838. }
  13839. }
  13840. }
  13841. if is390 == 1 {
  13842. insutype = "390"
  13843. }
  13844. if is310 == 1 {
  13845. insutype = "310"
  13846. }
  13847. if len(insutypes) == 0 {
  13848. insutype = "310"
  13849. }
  13850. c.ServeSuccessJSON(map[string]interface{}{
  13851. "patient": patient,
  13852. "number": basNumber,
  13853. "insutype": insutype,
  13854. })
  13855. }
  13856. } else {
  13857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13858. return
  13859. }
  13860. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13861. var api string
  13862. 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 +
  13863. "&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
  13864. fmt.Println(api)
  13865. resp, requestErr := http.Get(api)
  13866. if requestErr != nil {
  13867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13868. return
  13869. }
  13870. body, ioErr := ioutil.ReadAll(resp.Body)
  13871. if ioErr != nil {
  13872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13874. return
  13875. }
  13876. var respJSON map[string]interface{}
  13877. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13880. return
  13881. }
  13882. var res ResultTwo //1101结果
  13883. var res10265 ResultTwo10265 //1101结果
  13884. var card_info string //卡信息
  13885. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13886. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13887. result, _ := json.Marshal(respJSON)
  13888. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13889. utils.ErrorLog("解析失败:%v", err)
  13890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13891. return
  13892. }
  13893. res.ErrMsg = res10265.ErrMsg
  13894. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13895. res.Infcode = infocode
  13896. res.Output = res10265.Output
  13897. res.InfRefmsgid = res10265.InfRefmsgid
  13898. if res.Infcode == 0 {
  13899. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13900. if err == gorm.ErrRecordNotFound {
  13901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13902. return
  13903. } else if err != nil {
  13904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13905. return
  13906. } else {
  13907. bas := strings.Split(card_info, "|")
  13908. basNumber := bas[2]
  13909. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13910. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13911. infoStr := string(Iinfos)
  13912. idetinfoStr := string(Idetinfos)
  13913. psn := &models.HisPsn{
  13914. PsnNo: res.Output.Baseinfo.PsnNo,
  13915. PatientId: patient.ID,
  13916. Certno: res.Output.Baseinfo.Certno,
  13917. Gend: res.Output.Baseinfo.Gend,
  13918. Naty: res.Output.Baseinfo.Naty,
  13919. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13920. PsnName: res.Output.Baseinfo.PsnName,
  13921. Idetinfo: idetinfoStr,
  13922. Insuinfo: infoStr,
  13923. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13924. CardInfo: card_info,
  13925. VerifyNumber: token,
  13926. }
  13927. service.CreateHisPsn(psn)
  13928. var rf []*ResultFive
  13929. json.Unmarshal([]byte(infoStr), &rf)
  13930. var insutypes []*ResultFive
  13931. var insutype string
  13932. var is390 int = 0
  13933. var is310 int = 0
  13934. for _, item := range rf {
  13935. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13936. insutypes = append(insutypes, item)
  13937. }
  13938. }
  13939. if len(insutypes) == 1 {
  13940. insutype = insutypes[0].Insutype
  13941. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13942. } else {
  13943. for _, i := range insutypes {
  13944. if i.Insutype == "390" {
  13945. is390 = 1
  13946. }
  13947. if i.Insutype == "310" {
  13948. is310 = 1
  13949. }
  13950. }
  13951. }
  13952. if is390 == 1 {
  13953. insutype = "390"
  13954. }
  13955. if is310 == 1 {
  13956. insutype = "310"
  13957. }
  13958. if len(insutypes) == 0 {
  13959. insutype = "310"
  13960. }
  13961. c.ServeSuccessJSON(map[string]interface{}{
  13962. "patient": patient,
  13963. "number": basNumber,
  13964. "insutype": insutype,
  13965. })
  13966. }
  13967. } else {
  13968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13969. return
  13970. }
  13971. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13972. res := c.GetoleInfo()
  13973. if res.Infcode == 0 {
  13974. var result string
  13975. if res.Output.MdtrtCertType == "01" {
  13976. 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)
  13977. } else if res.Output.MdtrtCertType == "02" {
  13978. 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)
  13979. } else if res.Output.MdtrtCertType == "03" {
  13980. 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)
  13981. }
  13982. var dat map[string]interface{}
  13983. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13984. fmt.Println(dat)
  13985. } else {
  13986. fmt.Println(err)
  13987. }
  13988. userJSONBytes, _ := json.Marshal(dat)
  13989. var res2 ResultTwo
  13990. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13991. utils.ErrorLog("解析失败:%v", err)
  13992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13993. return
  13994. }
  13995. if res2.Infcode == 0 {
  13996. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13997. if err == gorm.ErrRecordNotFound {
  13998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13999. return
  14000. } else if err != nil {
  14001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14002. return
  14003. } else {
  14004. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14005. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14006. infoStr := string(Iinfos)
  14007. idetinfoStr := string(Idetinfos)
  14008. var rf []*ResultFive
  14009. json.Unmarshal([]byte(infoStr), &rf)
  14010. var insutypes []*ResultFive
  14011. var insutype string
  14012. var is390 int = 0
  14013. var is310 int = 0
  14014. //var insuplc_admdvs string
  14015. for _, item := range rf {
  14016. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14017. insutypes = append(insutypes, item)
  14018. }
  14019. }
  14020. if len(insutypes) == 1 {
  14021. insutype = insutypes[0].Insutype
  14022. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14023. } else {
  14024. for _, i := range insutypes {
  14025. if i.Insutype == "390" {
  14026. is390 = 1
  14027. }
  14028. if i.Insutype == "310" {
  14029. is310 = 1
  14030. }
  14031. }
  14032. }
  14033. if is390 == 1 {
  14034. insutype = "390"
  14035. }
  14036. if is310 == 1 {
  14037. insutype = "310"
  14038. }
  14039. if len(insutypes) == 0 {
  14040. insutype = "310"
  14041. }
  14042. psn := &models.HisPsn{
  14043. PsnNo: res2.Output.Baseinfo.PsnNo,
  14044. PatientId: patient.ID,
  14045. Certno: res2.Output.Baseinfo.Certno,
  14046. Gend: res2.Output.Baseinfo.Gend,
  14047. Naty: res2.Output.Baseinfo.Naty,
  14048. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14049. PsnName: res2.Output.Baseinfo.PsnName,
  14050. Idetinfo: idetinfoStr,
  14051. Insuinfo: infoStr,
  14052. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14053. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14054. VerifyNumber: res.Output.EcToken,
  14055. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14056. }
  14057. if res.Output.MdtrtCertType == "01" {
  14058. psn.VerifyNumber = res.Output.EcToken
  14059. //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)
  14060. } else if res.Output.MdtrtCertType == "02" {
  14061. psn.VerifyNumber = res.Output.MdtrtCertNo
  14062. //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)
  14063. } else if res.Output.MdtrtCertType == "03" {
  14064. psn.VerifyNumber = res.Output.MdtrtCertNo
  14065. //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)
  14066. }
  14067. var balc float64
  14068. for _, item := range rf {
  14069. if item.Insutype == insutype {
  14070. balc = item.Balc
  14071. }
  14072. }
  14073. service.CreateHisPsn(psn)
  14074. c.ServeSuccessJSON(map[string]interface{}{
  14075. "patient": patient,
  14076. "number": res.Output.CardNo,
  14077. "insutype": insutype,
  14078. "blac": balc,
  14079. "desc": idetinfoStr,
  14080. })
  14081. }
  14082. } else {
  14083. c.ServeSuccessJSON(map[string]interface{}{
  14084. "failed_code": -10,
  14085. "msg": res2.ErrMsg,
  14086. })
  14087. }
  14088. } else {
  14089. c.ServeSuccessJSON(map[string]interface{}{
  14090. "failed_code": -10,
  14091. "msg": res.ErrMsg,
  14092. })
  14093. }
  14094. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14095. var api string
  14096. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14097. "&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
  14098. fmt.Println(api)
  14099. resp, requestErr := http.Get(api)
  14100. if requestErr != nil {
  14101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14102. return
  14103. }
  14104. body, ioErr := ioutil.ReadAll(resp.Body)
  14105. if ioErr != nil {
  14106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14108. return
  14109. }
  14110. var respJSON map[string]interface{}
  14111. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14114. return
  14115. }
  14116. var status string
  14117. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14118. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14119. //console.log()
  14120. fmt.Println("type===")
  14121. fmt.Println(card_type)
  14122. var token string
  14123. var res ResultTwo //1101结果
  14124. //var res10265 ResultTwoesultTwo10265 //1101结果
  14125. var card_info string //卡信息
  14126. var busi_card_info string
  14127. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14128. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14129. if status == "0" { //读卡成功
  14130. if card_type == "1" {
  14131. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14132. result, _ := json.Marshal(respJSON)
  14133. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14134. utils.ErrorLog("解析失败:%v", err)
  14135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14136. return
  14137. }
  14138. } else {
  14139. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14140. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14141. result, _ := json.Marshal(respJSON)
  14142. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14143. utils.ErrorLog("解析失败:%v", err)
  14144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14145. return
  14146. }
  14147. }
  14148. if res.Infcode == 0 {
  14149. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14150. if err == gorm.ErrRecordNotFound {
  14151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14152. return
  14153. } else if err != nil {
  14154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14155. return
  14156. } else {
  14157. if card_type == "1" {
  14158. bas := strings.Split(card_info, "|")
  14159. basNumber := bas[2]
  14160. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14161. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14162. infoStr := string(Iinfos)
  14163. idetinfoStr := string(Idetinfos)
  14164. psn := &models.HisPsn{
  14165. PsnNo: res.Output.Baseinfo.PsnNo,
  14166. PatientId: patient.ID,
  14167. Certno: res.Output.Baseinfo.Certno,
  14168. Gend: res.Output.Baseinfo.Gend,
  14169. Naty: res.Output.Baseinfo.Naty,
  14170. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14171. PsnName: res.Output.Baseinfo.PsnName,
  14172. Idetinfo: idetinfoStr,
  14173. Insuinfo: infoStr,
  14174. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14175. CardInfo: card_info,
  14176. VerifyNumber: busi_card_info,
  14177. }
  14178. service.CreateHisPsn(psn)
  14179. var rf []*ResultFive
  14180. json.Unmarshal([]byte(infoStr), &rf)
  14181. var insutypes []*ResultFive
  14182. var insutype string
  14183. var is390 int = 0
  14184. var is310 int = 0
  14185. for _, item := range rf {
  14186. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14187. insutypes = append(insutypes, item)
  14188. }
  14189. }
  14190. if len(insutypes) == 1 {
  14191. insutype = insutypes[0].Insutype
  14192. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14193. } else {
  14194. for _, i := range insutypes {
  14195. if i.Insutype == "390" {
  14196. is390 = 1
  14197. }
  14198. if i.Insutype == "310" {
  14199. is310 = 1
  14200. }
  14201. }
  14202. }
  14203. if is390 == 1 {
  14204. insutype = "390"
  14205. }
  14206. if is310 == 1 {
  14207. insutype = "310"
  14208. }
  14209. if len(insutypes) == 0 {
  14210. insutype = "310"
  14211. }
  14212. c.ServeSuccessJSON(map[string]interface{}{
  14213. "patient": patient,
  14214. "number": basNumber,
  14215. "insutype": insutype,
  14216. })
  14217. } else {
  14218. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14219. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14220. infoStr := string(Iinfos)
  14221. idetinfoStr := string(Idetinfos)
  14222. psn := &models.HisPsn{
  14223. PsnNo: res.Output.Baseinfo.PsnNo,
  14224. PatientId: patient.ID,
  14225. Certno: res.Output.Baseinfo.Certno,
  14226. Gend: res.Output.Baseinfo.Gend,
  14227. Naty: res.Output.Baseinfo.Naty,
  14228. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14229. PsnName: res.Output.Baseinfo.PsnName,
  14230. Idetinfo: idetinfoStr,
  14231. Insuinfo: infoStr,
  14232. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14233. CardInfo: card_info,
  14234. VerifyNumber: token,
  14235. }
  14236. service.CreateHisPsn(psn)
  14237. c.ServeSuccessJSON(map[string]interface{}{
  14238. "patient": patient,
  14239. "number": token,
  14240. })
  14241. }
  14242. }
  14243. } else {
  14244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14245. return
  14246. }
  14247. } else { //读卡失败
  14248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14249. return
  14250. }
  14251. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14252. var api string
  14253. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14254. "&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
  14255. fmt.Println(api)
  14256. resp, requestErr := http.Get(api)
  14257. if requestErr != nil {
  14258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14259. return
  14260. }
  14261. body, ioErr := ioutil.ReadAll(resp.Body)
  14262. if ioErr != nil {
  14263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14265. return
  14266. }
  14267. var respJSON map[string]interface{}
  14268. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14271. return
  14272. }
  14273. var status string
  14274. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14275. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14276. //console.log()
  14277. fmt.Println("type===")
  14278. fmt.Println(card_type)
  14279. var token string
  14280. var res ResultTwo //1101结果
  14281. //var res10265 ResultTwoesultTwo10265 //1101结果
  14282. var card_info string //卡信息
  14283. //var busi_card_info string
  14284. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14285. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14286. if status == "0" { //读卡成功
  14287. if card_type == "1" {
  14288. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14289. result, _ := json.Marshal(respJSON)
  14290. fmt.Println(result)
  14291. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14292. utils.ErrorLog("解析失败:%v", err)
  14293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14294. return
  14295. }
  14296. fmt.Println(res)
  14297. } else {
  14298. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14299. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14300. result, _ := json.Marshal(respJSON)
  14301. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14302. utils.ErrorLog("解析失败:%v", err)
  14303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14304. return
  14305. }
  14306. }
  14307. if res.Infcode == 0 {
  14308. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14309. if err == gorm.ErrRecordNotFound {
  14310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14311. return
  14312. } else if err != nil {
  14313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14314. return
  14315. } else {
  14316. if card_type == "1" {
  14317. bas := strings.Split(card_info, "|")
  14318. basNumber := bas[2]
  14319. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14320. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14321. infoStr := string(Iinfos)
  14322. idetinfoStr := string(Idetinfos)
  14323. psn := &models.HisPsn{
  14324. PsnNo: res.Output.Baseinfo.PsnNo,
  14325. PatientId: patient.ID,
  14326. Certno: res.Output.Baseinfo.Certno,
  14327. Gend: res.Output.Baseinfo.Gend,
  14328. Naty: res.Output.Baseinfo.Naty,
  14329. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14330. PsnName: res.Output.Baseinfo.PsnName,
  14331. Idetinfo: idetinfoStr,
  14332. Insuinfo: infoStr,
  14333. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14334. CardInfo: card_info,
  14335. //VerifyNumber: busi_card_info,
  14336. }
  14337. service.CreateHisPsn(psn)
  14338. var rf []*ResultFive
  14339. json.Unmarshal([]byte(infoStr), &rf)
  14340. var insutypes []*ResultFive
  14341. var insutype string
  14342. var is390 int = 0
  14343. var is310 int = 0
  14344. for _, item := range rf {
  14345. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14346. insutypes = append(insutypes, item)
  14347. }
  14348. }
  14349. if len(insutypes) == 1 {
  14350. insutype = insutypes[0].Insutype
  14351. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14352. } else {
  14353. for _, i := range insutypes {
  14354. if i.Insutype == "390" {
  14355. is390 = 1
  14356. }
  14357. if i.Insutype == "310" {
  14358. is310 = 1
  14359. }
  14360. }
  14361. }
  14362. if is390 == 1 {
  14363. insutype = "390"
  14364. }
  14365. if is310 == 1 {
  14366. insutype = "310"
  14367. }
  14368. if len(insutypes) == 0 {
  14369. insutype = "310"
  14370. }
  14371. c.ServeSuccessJSON(map[string]interface{}{
  14372. "patient": patient,
  14373. "number": basNumber,
  14374. "insutype": insutype,
  14375. })
  14376. } else {
  14377. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14378. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14379. infoStr := string(Iinfos)
  14380. idetinfoStr := string(Idetinfos)
  14381. psn := &models.HisPsn{
  14382. PsnNo: res.Output.Baseinfo.PsnNo,
  14383. PatientId: patient.ID,
  14384. Certno: res.Output.Baseinfo.Certno,
  14385. Gend: res.Output.Baseinfo.Gend,
  14386. Naty: res.Output.Baseinfo.Naty,
  14387. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14388. PsnName: res.Output.Baseinfo.PsnName,
  14389. Idetinfo: idetinfoStr,
  14390. Insuinfo: infoStr,
  14391. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14392. CardInfo: card_info,
  14393. VerifyNumber: token,
  14394. }
  14395. service.CreateHisPsn(psn)
  14396. c.ServeSuccessJSON(map[string]interface{}{
  14397. "patient": patient,
  14398. "number": token,
  14399. })
  14400. }
  14401. }
  14402. } else {
  14403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14404. return
  14405. }
  14406. } else { //读卡失败
  14407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14408. return
  14409. }
  14410. } else {
  14411. if initFlag == 0 {
  14412. c.TestGetBasBaseInit()
  14413. }
  14414. basStr := c.GetBasBaseInfo()
  14415. if len(basStr) == 0 {
  14416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14417. return
  14418. }
  14419. fmt.Println(basStr)
  14420. bas := strings.Split(basStr, "|")
  14421. basNumber := bas[1]
  14422. fmt.Println(basNumber)
  14423. card_sn := bas[3]
  14424. fmt.Println(card_sn)
  14425. cardNumber := bas[2]
  14426. fmt.Println(cardNumber)
  14427. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14428. var result string
  14429. if bas[0][:2] == "44" {
  14430. 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)
  14431. } else {
  14432. 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)
  14433. }
  14434. var dat map[string]interface{}
  14435. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14436. fmt.Println(dat)
  14437. } else {
  14438. fmt.Println(err)
  14439. }
  14440. userJSONBytes, _ := json.Marshal(dat)
  14441. var res ResultTwo
  14442. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14443. utils.ErrorLog("解析失败:%v", err)
  14444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14445. return
  14446. }
  14447. if res.Infcode == 0 {
  14448. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14449. if err == gorm.ErrRecordNotFound {
  14450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14451. return
  14452. } else if err != nil {
  14453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14454. return
  14455. } else {
  14456. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14457. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14458. infoStr := string(Iinfos)
  14459. idetinfoStr := string(Idetinfos)
  14460. var rf []*ResultFive
  14461. json.Unmarshal([]byte(infoStr), &rf)
  14462. var insutypes []*ResultFive
  14463. var insutype string
  14464. var is390 int = 0
  14465. var is310 int = 0
  14466. var insuplc_admdvs string
  14467. for _, item := range rf {
  14468. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14469. insutypes = append(insutypes, item)
  14470. }
  14471. }
  14472. if len(insutypes) == 1 {
  14473. insutype = insutypes[0].Insutype
  14474. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14475. } else {
  14476. for _, i := range insutypes {
  14477. if i.Insutype == "390" {
  14478. is390 = 1
  14479. }
  14480. if i.Insutype == "310" {
  14481. is310 = 1
  14482. }
  14483. }
  14484. }
  14485. if is390 == 1 {
  14486. insutype = "390"
  14487. }
  14488. if is310 == 1 {
  14489. insutype = "310"
  14490. }
  14491. if len(insutypes) == 0 {
  14492. insutype = "310"
  14493. }
  14494. for _, item := range rf {
  14495. if item.Insutype == insutype {
  14496. insuplc_admdvs = item.InsuplcAdmdvs
  14497. }
  14498. }
  14499. psn := &models.HisPsn{
  14500. PsnNo: res.Output.Baseinfo.PsnNo,
  14501. PatientId: patient.ID,
  14502. Certno: res.Output.Baseinfo.Certno,
  14503. Gend: res.Output.Baseinfo.Gend,
  14504. Naty: res.Output.Baseinfo.Naty,
  14505. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14506. PsnName: res.Output.Baseinfo.PsnName,
  14507. Idetinfo: idetinfoStr,
  14508. Insuinfo: infoStr,
  14509. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14510. CardInfo: basStr,
  14511. VerifyNumber: "",
  14512. InsuplcAdmdvs: insuplc_admdvs,
  14513. }
  14514. service.CreateHisPsn(psn)
  14515. c.ServeSuccessJSON(map[string]interface{}{
  14516. "patient": patient,
  14517. "number": basNumber,
  14518. })
  14519. }
  14520. } else {
  14521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14522. return
  14523. }
  14524. break
  14525. }
  14526. case 2:
  14527. if miConfig.MdtrtareaAdmvs == "430800" {
  14528. if initFlag == 0 {
  14529. c.TestGetHnBasBaseInit()
  14530. }
  14531. SFZStr := c.GetSFZBaseInfo()
  14532. if len(SFZStr) == 0 {
  14533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14534. return
  14535. }
  14536. fmt.Println(SFZStr)
  14537. id_card_str := strings.Split(SFZStr, "^")
  14538. card_no := id_card_str[0]
  14539. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14540. //name := id_card_str[1]
  14541. //name = ConvertToString(name, "gbk", "utf-8")
  14542. 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)
  14543. var dat map[string]interface{}
  14544. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14545. fmt.Println(dat)
  14546. } else {
  14547. fmt.Println(err)
  14548. }
  14549. userJSONBytes, _ := json.Marshal(dat)
  14550. var res ResultTwo
  14551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14552. utils.ErrorLog("解析失败:%v", err)
  14553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14554. return
  14555. }
  14556. if res.Infcode == 0 {
  14557. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14558. if err == gorm.ErrRecordNotFound {
  14559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14560. return
  14561. } else if err != nil {
  14562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14563. return
  14564. } else {
  14565. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14566. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14567. infoStr := string(Iinfos)
  14568. idetinfoStr := string(Idetinfos)
  14569. var rf []*ResultFive
  14570. json.Unmarshal([]byte(infoStr), &rf)
  14571. var insutypes []*ResultFive
  14572. var insutype string
  14573. var is390 int = 0
  14574. var is310 int = 0
  14575. for _, item := range rf {
  14576. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14577. insutypes = append(insutypes, item)
  14578. }
  14579. }
  14580. if len(insutypes) == 1 {
  14581. insutype = insutypes[0].Insutype
  14582. } else {
  14583. for _, i := range insutypes {
  14584. if i.Insutype == "390" {
  14585. is390 = 1
  14586. }
  14587. if i.Insutype == "310" {
  14588. is310 = 1
  14589. }
  14590. }
  14591. }
  14592. if is390 == 1 {
  14593. insutype = "390"
  14594. }
  14595. if is310 == 1 {
  14596. insutype = "310"
  14597. }
  14598. if len(insutypes) == 0 {
  14599. insutype = "310"
  14600. }
  14601. var InsuplcAdmdvs string
  14602. for _, item := range rf {
  14603. if item.Insutype == insutype {
  14604. InsuplcAdmdvs = item.InsuplcAdmdvs
  14605. }
  14606. }
  14607. psn := &models.HisPsn{
  14608. PsnNo: res.Output.Baseinfo.PsnNo,
  14609. PatientId: patient.ID,
  14610. Certno: res.Output.Baseinfo.Certno,
  14611. Gend: res.Output.Baseinfo.Gend,
  14612. Naty: res.Output.Baseinfo.Naty,
  14613. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14614. PsnName: res.Output.Baseinfo.PsnName,
  14615. Idetinfo: idetinfoStr,
  14616. Insuinfo: infoStr,
  14617. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14618. CardInfo: SFZStr,
  14619. VerifyNumber: "",
  14620. InsuplcAdmdvs: InsuplcAdmdvs,
  14621. }
  14622. service.CreateHisPsn(psn)
  14623. c.ServeSuccessJSON(map[string]interface{}{
  14624. "patient": patient,
  14625. "number": card_no,
  14626. "insutype": insutype,
  14627. })
  14628. }
  14629. } else {
  14630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14631. return
  14632. }
  14633. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14634. var res ResultTwo
  14635. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14636. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14637. "&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)
  14638. resp, requestErr := http.Get(api)
  14639. if requestErr != nil {
  14640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14641. return
  14642. }
  14643. body, ioErr := ioutil.ReadAll(resp.Body)
  14644. if ioErr != nil {
  14645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14647. return
  14648. }
  14649. var respJSON map[string]interface{}
  14650. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14653. return
  14654. }
  14655. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14656. result, _ := json.Marshal(respJSON)
  14657. fmt.Println("log")
  14658. fmt.Println(string(result))
  14659. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14660. utils.ErrorLog("解析失败:%v", err)
  14661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14662. return
  14663. }
  14664. if res.Infcode == 0 {
  14665. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14666. if err == gorm.ErrRecordNotFound {
  14667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14668. return
  14669. } else if err != nil {
  14670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14671. return
  14672. } else {
  14673. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14674. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14675. infoStr := string(Iinfos)
  14676. idetinfoStr := string(Idetinfos)
  14677. psn := &models.HisPsn{
  14678. PsnNo: res.Output.Baseinfo.PsnNo,
  14679. PatientId: patient.ID,
  14680. Certno: res.Output.Baseinfo.Certno,
  14681. Gend: res.Output.Baseinfo.Gend,
  14682. Naty: res.Output.Baseinfo.Naty,
  14683. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14684. PsnName: res.Output.Baseinfo.PsnName,
  14685. Idetinfo: idetinfoStr,
  14686. Insuinfo: infoStr,
  14687. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14688. }
  14689. service.CreateHisPsn(psn)
  14690. c.ServeSuccessJSON(map[string]interface{}{
  14691. "patient": patient,
  14692. "number": res.Output.Baseinfo.Certno,
  14693. })
  14694. }
  14695. } else {
  14696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14697. return
  14698. }
  14699. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14700. var res ResultTwo
  14701. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14702. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14703. "&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)
  14704. resp, requestErr := http.Get(api)
  14705. if requestErr != nil {
  14706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14707. return
  14708. }
  14709. body, ioErr := ioutil.ReadAll(resp.Body)
  14710. if ioErr != nil {
  14711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14713. return
  14714. }
  14715. var respJSON map[string]interface{}
  14716. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14719. return
  14720. }
  14721. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14722. result, _ := json.Marshal(respJSON)
  14723. fmt.Println("log")
  14724. fmt.Println(string(result))
  14725. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14726. utils.ErrorLog("解析失败:%v", err)
  14727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14728. return
  14729. }
  14730. if res.Infcode == 0 {
  14731. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14732. if err == gorm.ErrRecordNotFound {
  14733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14734. return
  14735. } else if err != nil {
  14736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14737. return
  14738. } else {
  14739. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14740. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14741. infoStr := string(Iinfos)
  14742. idetinfoStr := string(Idetinfos)
  14743. psn := &models.HisPsn{
  14744. PsnNo: res.Output.Baseinfo.PsnNo,
  14745. PatientId: patient.ID,
  14746. Certno: res.Output.Baseinfo.Certno,
  14747. Gend: res.Output.Baseinfo.Gend,
  14748. Naty: res.Output.Baseinfo.Naty,
  14749. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14750. PsnName: res.Output.Baseinfo.PsnName,
  14751. Idetinfo: idetinfoStr,
  14752. Insuinfo: infoStr,
  14753. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14754. }
  14755. service.CreateHisPsn(psn)
  14756. c.ServeSuccessJSON(map[string]interface{}{
  14757. "patient": patient,
  14758. "number": res.Output.Baseinfo.Certno,
  14759. })
  14760. }
  14761. } else {
  14762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14763. return
  14764. }
  14765. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14766. var res ResultTwo
  14767. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14768. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14769. "&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)
  14770. resp, requestErr := http.Get(api)
  14771. if requestErr != nil {
  14772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14773. return
  14774. }
  14775. body, ioErr := ioutil.ReadAll(resp.Body)
  14776. if ioErr != nil {
  14777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14779. return
  14780. }
  14781. var respJSON map[string]interface{}
  14782. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14785. return
  14786. }
  14787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14788. result, _ := json.Marshal(respJSON)
  14789. fmt.Println("log")
  14790. fmt.Println(string(result))
  14791. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14792. utils.ErrorLog("解析失败:%v", err)
  14793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14794. return
  14795. }
  14796. if res.Infcode == 0 {
  14797. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14798. if err == gorm.ErrRecordNotFound {
  14799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14800. return
  14801. } else if err != nil {
  14802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14803. return
  14804. } else {
  14805. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14806. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14807. infoStr := string(Iinfos)
  14808. idetinfoStr := string(Idetinfos)
  14809. var rf []*ResultFive
  14810. json.Unmarshal([]byte(infoStr), &rf)
  14811. var insutypes []*ResultFive
  14812. var insutype string
  14813. var is390 int = 0
  14814. var is310 int = 0
  14815. for _, item := range rf {
  14816. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14817. insutypes = append(insutypes, item)
  14818. }
  14819. }
  14820. if len(insutypes) == 1 {
  14821. insutype = insutypes[0].Insutype
  14822. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14823. } else {
  14824. for _, i := range insutypes {
  14825. if i.Insutype == "390" {
  14826. is390 = 1
  14827. }
  14828. if i.Insutype == "310" {
  14829. is310 = 1
  14830. }
  14831. }
  14832. }
  14833. if is390 == 1 {
  14834. insutype = "390"
  14835. }
  14836. if is310 == 1 {
  14837. insutype = "310"
  14838. }
  14839. if len(insutypes) == 0 {
  14840. insutype = "390"
  14841. }
  14842. var insuplc_admdvs string
  14843. for _, item := range rf {
  14844. if item.Insutype == insutype {
  14845. insuplc_admdvs = item.InsuplcAdmdvs
  14846. }
  14847. }
  14848. psn := &models.HisPsn{
  14849. PsnNo: res.Output.Baseinfo.PsnNo,
  14850. PatientId: patient.ID,
  14851. Certno: res.Output.Baseinfo.Certno,
  14852. Gend: res.Output.Baseinfo.Gend,
  14853. Naty: res.Output.Baseinfo.Naty,
  14854. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14855. PsnName: res.Output.Baseinfo.PsnName,
  14856. Idetinfo: idetinfoStr,
  14857. Insuinfo: infoStr,
  14858. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14859. InsuplcAdmdvs: insuplc_admdvs,
  14860. }
  14861. service.CreateHisPsn(psn)
  14862. c.ServeSuccessJSON(map[string]interface{}{
  14863. "patient": patient,
  14864. "number": res.Output.Baseinfo.Certno,
  14865. })
  14866. }
  14867. } else {
  14868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14869. return
  14870. }
  14871. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14872. res := c.GetoleInfo()
  14873. if res.Infcode == 0 {
  14874. var result string
  14875. if res.Output.MdtrtCertType == "01" {
  14876. 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)
  14877. } else if res.Output.MdtrtCertType == "02" {
  14878. 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)
  14879. } else if res.Output.MdtrtCertType == "03" {
  14880. 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)
  14881. }
  14882. var dat map[string]interface{}
  14883. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14884. fmt.Println(dat)
  14885. } else {
  14886. fmt.Println(err)
  14887. }
  14888. userJSONBytes, _ := json.Marshal(dat)
  14889. var res2 ResultTwo
  14890. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14891. utils.ErrorLog("解析失败:%v", err)
  14892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14893. return
  14894. }
  14895. if res2.Infcode == 0 {
  14896. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14897. if err == gorm.ErrRecordNotFound {
  14898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14899. return
  14900. } else if err != nil {
  14901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14902. return
  14903. } else {
  14904. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14905. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14906. infoStr := string(Iinfos)
  14907. idetinfoStr := string(Idetinfos)
  14908. var rf []*ResultFive
  14909. json.Unmarshal([]byte(infoStr), &rf)
  14910. var insutypes []*ResultFive
  14911. var insutype string
  14912. var is390 int = 0
  14913. var is310 int = 0
  14914. //var insuplc_admdvs string
  14915. for _, item := range rf {
  14916. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14917. insutypes = append(insutypes, item)
  14918. }
  14919. }
  14920. if len(insutypes) == 1 {
  14921. insutype = insutypes[0].Insutype
  14922. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14923. } else {
  14924. for _, i := range insutypes {
  14925. if i.Insutype == "390" {
  14926. is390 = 1
  14927. }
  14928. if i.Insutype == "310" {
  14929. is310 = 1
  14930. }
  14931. }
  14932. }
  14933. if is390 == 1 {
  14934. insutype = "390"
  14935. }
  14936. if is310 == 1 {
  14937. insutype = "310"
  14938. }
  14939. if len(insutypes) == 0 {
  14940. insutype = "310"
  14941. }
  14942. psn := &models.HisPsn{
  14943. PsnNo: res2.Output.Baseinfo.PsnNo,
  14944. PatientId: patient.ID,
  14945. //Brdy: res2.Output.Baseinfo.Brdy,
  14946. Certno: res2.Output.Baseinfo.Certno,
  14947. Gend: res2.Output.Baseinfo.Gend,
  14948. Naty: res2.Output.Baseinfo.Naty,
  14949. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14950. PsnName: res2.Output.Baseinfo.PsnName,
  14951. Idetinfo: idetinfoStr,
  14952. Insuinfo: infoStr,
  14953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14954. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14955. VerifyNumber: res.Output.EcToken,
  14956. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14957. }
  14958. service.CreateHisPsn(psn)
  14959. var balc float64
  14960. for _, item := range rf {
  14961. if item.Insutype == insutype {
  14962. balc = item.Balc
  14963. }
  14964. }
  14965. c.ServeSuccessJSON(map[string]interface{}{
  14966. "patient": patient,
  14967. "number": res.Output.CardNo,
  14968. "insutype": insutype,
  14969. "blac": balc,
  14970. "desc": idetinfoStr,
  14971. })
  14972. }
  14973. } else {
  14974. c.ServeSuccessJSON(map[string]interface{}{
  14975. "failed_code": -10,
  14976. "msg": res2.ErrMsg,
  14977. })
  14978. }
  14979. } else {
  14980. c.ServeSuccessJSON(map[string]interface{}{
  14981. "failed_code": -10,
  14982. "msg": res.ErrMsg,
  14983. })
  14984. }
  14985. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14986. var insuplc_admdvs string
  14987. if len(patient.InsuplcAdmdvs) > 0 {
  14988. insuplc_admdvs = patient.InsuplcAdmdvs
  14989. } else {
  14990. if len(insuplc_admdvs_str) > 0 {
  14991. insuplc_admdvs = insuplc_admdvs_str
  14992. } else {
  14993. insuplc_admdvs = miConfig.InsuplcAdmdvs
  14994. }
  14995. }
  14996. //请求内网数据
  14997. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  14998. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14999. "&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=" + ""
  15000. resp, requestErr := http.Get(api)
  15001. if requestErr != nil {
  15002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15003. return
  15004. }
  15005. body, ioErr := ioutil.ReadAll(resp.Body)
  15006. if ioErr != nil {
  15007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15009. return
  15010. }
  15011. var respJSON map[string]interface{}
  15012. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15015. return
  15016. }
  15017. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15018. if status == "0" {
  15019. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15020. c.ServeSuccessJSON(map[string]interface{}{
  15021. "failed_code": -10,
  15022. "msg": err_msg,
  15023. })
  15024. return
  15025. }
  15026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15027. var res ResultTwo
  15028. result, _ := json.Marshal(respJSON)
  15029. fmt.Println("log")
  15030. fmt.Println(string(result))
  15031. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15032. utils.ErrorLog("解析失败:%v", err)
  15033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15034. return
  15035. }
  15036. if res.Infcode == 0 {
  15037. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15038. if err == gorm.ErrRecordNotFound {
  15039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15040. return
  15041. } else if err != nil {
  15042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15043. return
  15044. } else {
  15045. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15046. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15047. infoStr := string(Iinfos)
  15048. idetinfoStr := string(Idetinfos)
  15049. psn := &models.HisPsn{
  15050. PsnNo: res.Output.Baseinfo.PsnNo,
  15051. PatientId: patient.ID,
  15052. Certno: res.Output.Baseinfo.Certno,
  15053. Gend: res.Output.Baseinfo.Gend,
  15054. Naty: res.Output.Baseinfo.Naty,
  15055. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15056. PsnName: res.Output.Baseinfo.PsnName,
  15057. Idetinfo: idetinfoStr,
  15058. Insuinfo: infoStr,
  15059. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15060. }
  15061. service.CreateHisPsn(psn)
  15062. var rf []*ResultFive
  15063. json.Unmarshal([]byte(infoStr), &rf)
  15064. var insutypes []*ResultFive
  15065. var is390 int = 0
  15066. var is310 int = 0
  15067. var insutype string
  15068. for _, item := range rf {
  15069. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15070. insutypes = append(insutypes, item)
  15071. }
  15072. }
  15073. if len(insutypes) == 1 {
  15074. insutype = insutypes[0].Insutype
  15075. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15076. } else {
  15077. for _, i := range insutypes {
  15078. if i.Insutype == "390" {
  15079. is390 = 1
  15080. }
  15081. if i.Insutype == "310" {
  15082. is310 = 1
  15083. }
  15084. }
  15085. }
  15086. if is390 == 1 {
  15087. insutype = "390"
  15088. }
  15089. if is310 == 1 {
  15090. insutype = "310"
  15091. }
  15092. if len(insutypes) == 0 {
  15093. insutype = "390"
  15094. }
  15095. c.ServeSuccessJSON(map[string]interface{}{
  15096. "patient": patient,
  15097. "insutype": insutype,
  15098. "number": res.Output.Baseinfo.Certno,
  15099. "info": res,
  15100. })
  15101. }
  15102. } else {
  15103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15104. return
  15105. }
  15106. } else {
  15107. SFZStr := c.GetSFZBaseInfo()
  15108. id_card_str := strings.Split(SFZStr, "^")
  15109. id_card_number := id_card_str[0]
  15110. card_sn := ""
  15111. 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)
  15112. var dat map[string]interface{}
  15113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15114. fmt.Println(dat)
  15115. } else {
  15116. fmt.Println(err)
  15117. }
  15118. userJSONBytes, _ := json.Marshal(dat)
  15119. var res ResultTwo
  15120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15121. utils.ErrorLog("解析失败:%v", err)
  15122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15123. return
  15124. }
  15125. if res.Infcode == 0 {
  15126. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15127. if err == gorm.ErrRecordNotFound {
  15128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15129. return
  15130. } else if err != nil {
  15131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15132. return
  15133. } else {
  15134. c.ServeSuccessJSON(map[string]interface{}{
  15135. "patient": patient,
  15136. "number": id_card_number,
  15137. })
  15138. }
  15139. } else {
  15140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15141. return
  15142. }
  15143. }
  15144. break
  15145. case 3:
  15146. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15147. var api string
  15148. if miConfig.MdtrtareaAdmvs == "320921" {
  15149. 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 +
  15150. "&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
  15151. fmt.Println(api)
  15152. } else {
  15153. 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 +
  15154. "&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)
  15155. }
  15156. resp, requestErr := http.Get(api)
  15157. if requestErr != nil {
  15158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15159. return
  15160. }
  15161. body, ioErr := ioutil.ReadAll(resp.Body)
  15162. if ioErr != nil {
  15163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15165. return
  15166. }
  15167. var respJSON map[string]interface{}
  15168. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15171. return
  15172. }
  15173. var status string
  15174. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15175. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15176. var token string
  15177. var res ResultTwo //1101结果
  15178. var res10265 ResultTwo10265 //1101结果
  15179. var card_info string //卡信息
  15180. var busi_card_info string
  15181. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15182. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15183. if status == "0" { //读卡成功
  15184. if card_type == "1" {
  15185. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15186. result, _ := json.Marshal(respJSON)
  15187. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15188. utils.ErrorLog("解析失败:%v", err)
  15189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15190. return
  15191. }
  15192. res.ErrMsg = res10265.ErrMsg
  15193. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15194. res.Infcode = infocode
  15195. res.Output = res10265.Output
  15196. res.InfRefmsgid = res10265.InfRefmsgid
  15197. } else {
  15198. //var card_info string //卡信息
  15199. //var busi_card_info string
  15200. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15201. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15202. //fmt.Println(card_info)
  15203. //fmt.Println(busi_card_info)
  15204. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15205. result, _ := json.Marshal(respJSON)
  15206. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15207. utils.ErrorLog("解析失败:%v", err)
  15208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15209. return
  15210. }
  15211. res.ErrMsg = res10265.ErrMsg
  15212. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15213. res.Infcode = infocode
  15214. res.Output = res10265.Output
  15215. res.InfRefmsgid = res10265.InfRefmsgid
  15216. }
  15217. if res.Infcode == 0 {
  15218. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15219. if err == gorm.ErrRecordNotFound {
  15220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15221. return
  15222. } else if err != nil {
  15223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15224. return
  15225. } else {
  15226. if card_type == "1" {
  15227. bas := strings.Split(card_info, "|")
  15228. basNumber := bas[2]
  15229. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15230. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15231. infoStr := string(Iinfos)
  15232. idetinfoStr := string(Idetinfos)
  15233. psn := &models.HisPsn{
  15234. PsnNo: res.Output.Baseinfo.PsnNo,
  15235. PatientId: patient.ID,
  15236. Certno: res.Output.Baseinfo.Certno,
  15237. //Brdy: res.Output.Baseinfo.Brdy,
  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. c.ServeSuccessJSON(map[string]interface{}{
  15250. "patient": patient,
  15251. "number": basNumber,
  15252. })
  15253. } else {
  15254. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15255. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15256. infoStr := string(Iinfos)
  15257. idetinfoStr := string(Idetinfos)
  15258. psn := &models.HisPsn{
  15259. PsnNo: res.Output.Baseinfo.PsnNo,
  15260. PatientId: patient.ID,
  15261. Certno: res.Output.Baseinfo.Certno,
  15262. Gend: res.Output.Baseinfo.Gend,
  15263. Naty: res.Output.Baseinfo.Naty,
  15264. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15265. PsnName: res.Output.Baseinfo.PsnName,
  15266. Idetinfo: idetinfoStr,
  15267. Insuinfo: infoStr,
  15268. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15269. CardInfo: card_info,
  15270. VerifyNumber: token,
  15271. }
  15272. service.CreateHisPsn(psn)
  15273. var rf []*ResultFive
  15274. json.Unmarshal([]byte(infoStr), &rf)
  15275. var insutypes []*ResultFive
  15276. var insutype string
  15277. var is390 int = 0
  15278. var is310 int = 0
  15279. for _, item := range rf {
  15280. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15281. insutypes = append(insutypes, item)
  15282. }
  15283. }
  15284. if len(insutypes) == 1 {
  15285. insutype = insutypes[0].Insutype
  15286. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15287. } else {
  15288. for _, i := range insutypes {
  15289. if i.Insutype == "390" {
  15290. is390 = 1
  15291. }
  15292. if i.Insutype == "310" {
  15293. is310 = 1
  15294. }
  15295. }
  15296. }
  15297. if is390 == 1 {
  15298. insutype = "390"
  15299. }
  15300. if is310 == 1 {
  15301. insutype = "310"
  15302. }
  15303. if len(insutypes) == 0 {
  15304. insutype = "310"
  15305. }
  15306. c.ServeSuccessJSON(map[string]interface{}{
  15307. "patient": patient,
  15308. "number": token,
  15309. "insutype": insutype,
  15310. })
  15311. }
  15312. }
  15313. } else {
  15314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15315. return
  15316. }
  15317. } else { //读卡失败
  15318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15319. return
  15320. }
  15321. }
  15322. break
  15323. case 4:
  15324. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15325. var api string
  15326. if miConfig.MdtrtareaAdmvs == "320921" {
  15327. 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 +
  15328. "&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
  15329. fmt.Println(api)
  15330. } else {
  15331. 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 +
  15332. "&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)
  15333. }
  15334. resp, requestErr := http.Get(api)
  15335. if requestErr != nil {
  15336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15337. return
  15338. }
  15339. body, ioErr := ioutil.ReadAll(resp.Body)
  15340. if ioErr != nil {
  15341. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15343. return
  15344. }
  15345. var respJSON map[string]interface{}
  15346. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15349. return
  15350. }
  15351. var status string
  15352. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15353. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15354. var token string
  15355. var res ResultTwo //1101结果
  15356. var res10265 ResultTwo10265 //1101结果
  15357. if status == "0" { //读卡成功
  15358. var card_info string //卡信息
  15359. var busi_card_info string
  15360. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15361. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15362. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15363. fmt.Println(card_info)
  15364. fmt.Println(busi_card_info)
  15365. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15366. result, _ := json.Marshal(respJSON)
  15367. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15368. utils.ErrorLog("解析失败:%v", err)
  15369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15370. return
  15371. }
  15372. res.ErrMsg = res10265.ErrMsg
  15373. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15374. res.Infcode = infocode
  15375. res.Output = res10265.Output
  15376. res.InfRefmsgid = res10265.InfRefmsgid
  15377. if res.Infcode == 0 {
  15378. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15379. if err == gorm.ErrRecordNotFound {
  15380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15381. return
  15382. } else if err != nil {
  15383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15384. return
  15385. } else {
  15386. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15387. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15388. infoStr := string(Iinfos)
  15389. idetinfoStr := string(Idetinfos)
  15390. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15391. psn := &models.HisPsn{
  15392. PsnNo: res.Output.Baseinfo.PsnNo,
  15393. PatientId: patient.ID,
  15394. Certno: res.Output.Baseinfo.Certno,
  15395. Brdy: b,
  15396. Age: float64(age),
  15397. //Brdy: res.Output.Baseinfo.Brdy,
  15398. Gend: res.Output.Baseinfo.Gend,
  15399. Naty: res.Output.Baseinfo.Naty,
  15400. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15401. PsnName: res.Output.Baseinfo.PsnName,
  15402. Idetinfo: idetinfoStr,
  15403. Insuinfo: infoStr,
  15404. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15405. CardInfo: card_info,
  15406. VerifyNumber: token,
  15407. }
  15408. var rf []*ResultFive
  15409. json.Unmarshal([]byte(infoStr), &rf)
  15410. var insutypes []*ResultFive
  15411. var insutype string
  15412. var is390 int = 0
  15413. var is310 int = 0
  15414. for _, item := range rf {
  15415. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15416. insutypes = append(insutypes, item)
  15417. }
  15418. }
  15419. if len(insutypes) == 1 {
  15420. insutype = insutypes[0].Insutype
  15421. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15422. } else {
  15423. for _, i := range insutypes {
  15424. if i.Insutype == "390" {
  15425. is390 = 1
  15426. }
  15427. if i.Insutype == "310" {
  15428. is310 = 1
  15429. }
  15430. }
  15431. }
  15432. if is390 == 1 {
  15433. insutype = "390"
  15434. }
  15435. if is310 == 1 {
  15436. insutype = "310"
  15437. }
  15438. if len(insutypes) == 0 {
  15439. insutype = "310"
  15440. }
  15441. service.CreateHisPsn(psn)
  15442. c.ServeSuccessJSON(map[string]interface{}{
  15443. "patient": patient,
  15444. "number": token,
  15445. "insutype": insutype,
  15446. })
  15447. }
  15448. } else {
  15449. c.ServeSuccessJSON(map[string]interface{}{
  15450. "failed_code": -10,
  15451. "msg": res.ErrMsg,
  15452. })
  15453. }
  15454. } else { //读卡失败
  15455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15456. return
  15457. }
  15458. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15459. var api string
  15460. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15461. "&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
  15462. resp, requestErr := http.Get(api)
  15463. if requestErr != nil {
  15464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15465. return
  15466. }
  15467. body, ioErr := ioutil.ReadAll(resp.Body)
  15468. if ioErr != nil {
  15469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15471. return
  15472. }
  15473. var respJSON map[string]interface{}
  15474. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15477. return
  15478. }
  15479. var status string
  15480. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15481. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15482. var token string
  15483. var res ResultTwo //1101结果
  15484. if status == "1" { //读卡成功
  15485. var card_info string //卡信息
  15486. var busi_card_info string
  15487. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15488. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15489. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15490. fmt.Println(card_info)
  15491. fmt.Println(busi_card_info)
  15492. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15493. result, _ := json.Marshal(respJSON)
  15494. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15495. utils.ErrorLog("解析失败:%v", err)
  15496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15497. return
  15498. }
  15499. if res.Infcode == 0 {
  15500. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15501. if err == gorm.ErrRecordNotFound {
  15502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15503. return
  15504. } else if err != nil {
  15505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15506. return
  15507. } else {
  15508. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15509. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15510. infoStr := string(Iinfos)
  15511. idetinfoStr := string(Idetinfos)
  15512. psn := &models.HisPsn{
  15513. PsnNo: res.Output.Baseinfo.PsnNo,
  15514. PatientId: patient.ID,
  15515. Certno: res.Output.Baseinfo.Certno,
  15516. Gend: res.Output.Baseinfo.Gend,
  15517. Naty: res.Output.Baseinfo.Naty,
  15518. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15519. PsnName: res.Output.Baseinfo.PsnName,
  15520. Idetinfo: idetinfoStr,
  15521. Insuinfo: infoStr,
  15522. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15523. CardInfo: card_info,
  15524. VerifyNumber: token,
  15525. }
  15526. var rf []*ResultFive
  15527. json.Unmarshal([]byte(infoStr), &rf)
  15528. var insutypes []*ResultFive
  15529. var insutype string
  15530. var is390 int = 0
  15531. var is310 int = 0
  15532. for _, item := range rf {
  15533. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15534. insutypes = append(insutypes, item)
  15535. }
  15536. }
  15537. if len(insutypes) == 1 {
  15538. insutype = insutypes[0].Insutype
  15539. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15540. } else {
  15541. for _, i := range insutypes {
  15542. if i.Insutype == "390" {
  15543. is390 = 1
  15544. }
  15545. if i.Insutype == "310" {
  15546. is310 = 1
  15547. }
  15548. }
  15549. }
  15550. if is390 == 1 {
  15551. insutype = "390"
  15552. }
  15553. if is310 == 1 {
  15554. insutype = "310"
  15555. }
  15556. if len(insutypes) == 0 {
  15557. insutype = "310"
  15558. }
  15559. service.CreateHisPsn(psn)
  15560. c.ServeSuccessJSON(map[string]interface{}{
  15561. "patient": patient,
  15562. "number": token,
  15563. "insutype": insutype,
  15564. })
  15565. }
  15566. } else {
  15567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15568. return
  15569. }
  15570. } else { //读卡失败
  15571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15572. return
  15573. }
  15574. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15575. var api string
  15576. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15577. "&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
  15578. resp, requestErr := http.Get(api)
  15579. if requestErr != nil {
  15580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15581. return
  15582. }
  15583. body, ioErr := ioutil.ReadAll(resp.Body)
  15584. if ioErr != nil {
  15585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15587. return
  15588. }
  15589. var respJSON map[string]interface{}
  15590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15593. return
  15594. }
  15595. var status string
  15596. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15597. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15598. var token string
  15599. var res ResultTwo //1101结果
  15600. if status == "1" { //读卡成功
  15601. var card_info string //卡信息
  15602. var busi_card_info string
  15603. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15604. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15605. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15606. fmt.Println(card_info)
  15607. fmt.Println(busi_card_info)
  15608. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15609. result, _ := json.Marshal(respJSON)
  15610. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15611. utils.ErrorLog("解析失败:%v", err)
  15612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15613. return
  15614. }
  15615. if res.Infcode == 0 {
  15616. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15617. if err == gorm.ErrRecordNotFound {
  15618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15619. return
  15620. } else if err != nil {
  15621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15622. return
  15623. } else {
  15624. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15625. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15626. infoStr := string(Iinfos)
  15627. idetinfoStr := string(Idetinfos)
  15628. psn := &models.HisPsn{
  15629. PsnNo: res.Output.Baseinfo.PsnNo,
  15630. PatientId: patient.ID,
  15631. Certno: res.Output.Baseinfo.Certno,
  15632. Gend: res.Output.Baseinfo.Gend,
  15633. Naty: res.Output.Baseinfo.Naty,
  15634. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15635. PsnName: res.Output.Baseinfo.PsnName,
  15636. Idetinfo: idetinfoStr,
  15637. Insuinfo: infoStr,
  15638. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15639. CardInfo: card_info,
  15640. VerifyNumber: token,
  15641. }
  15642. var rf []*ResultFive
  15643. json.Unmarshal([]byte(infoStr), &rf)
  15644. var insutypes []*ResultFive
  15645. var insutype string
  15646. var is390 int = 0
  15647. var is310 int = 0
  15648. for _, item := range rf {
  15649. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15650. insutypes = append(insutypes, item)
  15651. }
  15652. }
  15653. if len(insutypes) == 1 {
  15654. insutype = insutypes[0].Insutype
  15655. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15656. } else {
  15657. for _, i := range insutypes {
  15658. if i.Insutype == "390" {
  15659. is390 = 1
  15660. }
  15661. if i.Insutype == "310" {
  15662. is310 = 1
  15663. }
  15664. }
  15665. }
  15666. if is390 == 1 {
  15667. insutype = "390"
  15668. }
  15669. if is310 == 1 {
  15670. insutype = "310"
  15671. }
  15672. if len(insutypes) == 0 {
  15673. insutype = "310"
  15674. }
  15675. service.CreateHisPsn(psn)
  15676. c.ServeSuccessJSON(map[string]interface{}{
  15677. "patient": patient,
  15678. "number": token,
  15679. "insutype": insutype,
  15680. })
  15681. }
  15682. } else {
  15683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15684. return
  15685. }
  15686. } else { //读卡失败
  15687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15688. return
  15689. }
  15690. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15691. //idNo := c.GetString("idNo")
  15692. //userName := c.GetString("userName")
  15693. //ecToken := c.GetString("ecToken")
  15694. //insuOrg := c.GetString("insuOrg")
  15695. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15696. utils.ErrorLog("解析失败:%v", json_result)
  15697. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15698. type ELeData struct {
  15699. Data struct {
  15700. IdNo string `json:"idNo"`
  15701. IdType string `json:"idType"`
  15702. UserName string `json:"userName"`
  15703. EcToken string `json:"ecToken"`
  15704. InsuOrg string `json:"insuOrg"`
  15705. Gender string `json:"gender"`
  15706. Birthday string `json:"birthday"`
  15707. Nationality string `json:"nationality"`
  15708. Email string `json:"email"`
  15709. Extra string `json:"extra"`
  15710. } `json:"data"`
  15711. Code int `json:"code"`
  15712. Message string `json:"message"`
  15713. }
  15714. var ele ELeData
  15715. err := json.Unmarshal([]byte(json_result), &ele)
  15716. if err != nil {
  15717. utils.ErrorLog("解析失败:%v", err)
  15718. }
  15719. token := ele.Data.EcToken
  15720. token = Remove0000(token)
  15721. 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)
  15722. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15723. var res ResultTwo
  15724. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15725. utils.ErrorLog("解析失败:%v", err)
  15726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15727. return
  15728. }
  15729. if res.Infcode == 0 {
  15730. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15731. if err == gorm.ErrRecordNotFound {
  15732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15733. return
  15734. } else if err != nil {
  15735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15736. return
  15737. } else {
  15738. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15739. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15740. infoStr := string(Iinfos)
  15741. idetinfoStr := string(Idetinfos)
  15742. psn := &models.HisPsn{
  15743. PsnNo: res.Output.Baseinfo.PsnNo,
  15744. PatientId: patient.ID,
  15745. Certno: res.Output.Baseinfo.Certno,
  15746. Gend: res.Output.Baseinfo.Gend,
  15747. Naty: res.Output.Baseinfo.Naty,
  15748. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15749. PsnName: res.Output.Baseinfo.PsnName,
  15750. Idetinfo: idetinfoStr,
  15751. Insuinfo: infoStr,
  15752. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15753. CardInfo: "",
  15754. Stage: "1",
  15755. VerifyNumber: token,
  15756. InsuplcAdmdvs: ele.Data.InsuOrg,
  15757. }
  15758. service.CreateHisPsn(psn)
  15759. var rf []*ResultFive
  15760. json.Unmarshal([]byte(infoStr), &rf)
  15761. var insutypes []*ResultFive
  15762. var insutype string
  15763. var is390 int = 0
  15764. var is310 int = 0
  15765. for _, item := range rf {
  15766. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15767. insutypes = append(insutypes, item)
  15768. }
  15769. }
  15770. if len(insutypes) == 1 {
  15771. insutype = insutypes[0].Insutype
  15772. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15773. } else {
  15774. for _, i := range insutypes {
  15775. if i.Insutype == "390" {
  15776. is390 = 1
  15777. }
  15778. if i.Insutype == "310" {
  15779. is310 = 1
  15780. }
  15781. }
  15782. }
  15783. if is390 == 1 {
  15784. insutype = "390"
  15785. }
  15786. if is310 == 1 {
  15787. insutype = "310"
  15788. }
  15789. if len(insutypes) == 0 {
  15790. insutype = "310"
  15791. }
  15792. c.ServeSuccessJSON(map[string]interface{}{
  15793. "patient": patient,
  15794. "number": token,
  15795. "insutype": insutype,
  15796. })
  15797. }
  15798. } else {
  15799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15800. return
  15801. }
  15802. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15803. //if initFlag == 0 {
  15804. //c.TestGetJiangXiBasBaseInit()
  15805. //}
  15806. //if initEleFlag == 0 {
  15807. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15808. //}
  15809. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15810. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15811. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15812. type ELeData struct {
  15813. Data struct {
  15814. IdNo string `json:"idNo"`
  15815. IdType string `json:"idType"`
  15816. UserName string `json:"userName"`
  15817. EcToken string `json:"ecToken"`
  15818. InsuOrg string `json:"insuOrg"`
  15819. Gender string `json:"gender"`
  15820. Birthday string `json:"birthday"`
  15821. Nationality string `json:"nationality"`
  15822. Email string `json:"email"`
  15823. Extra string `json:"extra"`
  15824. } `json:"data"`
  15825. Code int `json:"code"`
  15826. Message string `json:"message"`
  15827. }
  15828. var ele ELeData
  15829. err := json.Unmarshal([]byte(result), &ele)
  15830. if err != nil {
  15831. utils.ErrorLog("解析失败:%v", err)
  15832. }
  15833. token := ele.Data.EcToken
  15834. token = Remove0000(token)
  15835. 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)
  15836. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15837. var res ResultTwo
  15838. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15839. utils.ErrorLog("解析失败:%v", err)
  15840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15841. return
  15842. }
  15843. if res.Infcode == 0 {
  15844. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15845. if err == gorm.ErrRecordNotFound {
  15846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15847. return
  15848. } else if err != nil {
  15849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15850. return
  15851. } else {
  15852. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15853. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15854. infoStr := string(Iinfos)
  15855. idetinfoStr := string(Idetinfos)
  15856. psn := &models.HisPsn{
  15857. PsnNo: res.Output.Baseinfo.PsnNo,
  15858. PatientId: patient.ID,
  15859. Certno: res.Output.Baseinfo.Certno,
  15860. Gend: res.Output.Baseinfo.Gend,
  15861. Naty: res.Output.Baseinfo.Naty,
  15862. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15863. PsnName: res.Output.Baseinfo.PsnName,
  15864. Idetinfo: idetinfoStr,
  15865. Insuinfo: infoStr,
  15866. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15867. CardInfo: "",
  15868. VerifyNumber: token,
  15869. InsuplcAdmdvs: ele.Data.InsuOrg,
  15870. }
  15871. service.CreateHisPsn(psn)
  15872. var rf []*ResultFive
  15873. json.Unmarshal([]byte(infoStr), &rf)
  15874. var insutypes []*ResultFive
  15875. var insutype string
  15876. var is390 int = 0
  15877. var is310 int = 0
  15878. for _, item := range rf {
  15879. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15880. insutypes = append(insutypes, item)
  15881. }
  15882. }
  15883. if len(insutypes) == 1 {
  15884. insutype = insutypes[0].Insutype
  15885. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15886. } else {
  15887. for _, i := range insutypes {
  15888. if i.Insutype == "390" {
  15889. is390 = 1
  15890. }
  15891. if i.Insutype == "310" {
  15892. is310 = 1
  15893. }
  15894. }
  15895. }
  15896. if is390 == 1 {
  15897. insutype = "390"
  15898. }
  15899. if is310 == 1 {
  15900. insutype = "310"
  15901. }
  15902. if len(insutypes) == 0 {
  15903. insutype = "310"
  15904. }
  15905. c.ServeSuccessJSON(map[string]interface{}{
  15906. "patient": patient,
  15907. "number": token,
  15908. "insutype": insutype,
  15909. })
  15910. }
  15911. } else {
  15912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15913. return
  15914. }
  15915. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15916. //if initFlag == 0 {
  15917. //c.TestGetJiangXiBasBaseInit()
  15918. //}
  15919. //if initEleFlag == 0 {
  15920. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15921. //}
  15922. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15923. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15924. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15925. type ELeData struct {
  15926. Data struct {
  15927. IdNo string `json:"idNo"`
  15928. IdType string `json:"idType"`
  15929. UserName string `json:"userName"`
  15930. EcToken string `json:"ecToken"`
  15931. InsuOrg string `json:"insuOrg"`
  15932. Gender string `json:"gender"`
  15933. Birthday string `json:"birthday"`
  15934. Nationality string `json:"nationality"`
  15935. Email string `json:"email"`
  15936. Extra string `json:"extra"`
  15937. } `json:"data"`
  15938. Code int `json:"code"`
  15939. Message string `json:"message"`
  15940. }
  15941. var ele ELeData
  15942. err := json.Unmarshal([]byte(result), &ele)
  15943. if err != nil {
  15944. utils.ErrorLog("解析失败:%v", err)
  15945. }
  15946. token := ele.Data.EcToken
  15947. token = Remove0000(token)
  15948. 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)
  15949. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15950. var res ResultTwo
  15951. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15952. utils.ErrorLog("解析失败:%v", err)
  15953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15954. return
  15955. }
  15956. if res.Infcode == 0 {
  15957. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15958. if err == gorm.ErrRecordNotFound {
  15959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15960. return
  15961. } else if err != nil {
  15962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15963. return
  15964. } else {
  15965. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15966. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15967. infoStr := string(Iinfos)
  15968. idetinfoStr := string(Idetinfos)
  15969. psn := &models.HisPsn{
  15970. PsnNo: res.Output.Baseinfo.PsnNo,
  15971. PatientId: patient.ID,
  15972. Certno: res.Output.Baseinfo.Certno,
  15973. Gend: res.Output.Baseinfo.Gend,
  15974. Naty: res.Output.Baseinfo.Naty,
  15975. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15976. PsnName: res.Output.Baseinfo.PsnName,
  15977. Idetinfo: idetinfoStr,
  15978. Insuinfo: infoStr,
  15979. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15980. CardInfo: "",
  15981. VerifyNumber: token,
  15982. InsuplcAdmdvs: ele.Data.InsuOrg,
  15983. }
  15984. service.CreateHisPsn(psn)
  15985. var rf []*ResultFive
  15986. json.Unmarshal([]byte(infoStr), &rf)
  15987. var insutypes []*ResultFive
  15988. var insutype string
  15989. var is390 int = 0
  15990. var is310 int = 0
  15991. for _, item := range rf {
  15992. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15993. insutypes = append(insutypes, item)
  15994. }
  15995. }
  15996. if len(insutypes) == 1 {
  15997. insutype = insutypes[0].Insutype
  15998. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15999. } else {
  16000. for _, i := range insutypes {
  16001. if i.Insutype == "390" {
  16002. is390 = 1
  16003. }
  16004. if i.Insutype == "310" {
  16005. is310 = 1
  16006. }
  16007. }
  16008. }
  16009. if is390 == 1 {
  16010. insutype = "390"
  16011. }
  16012. if is310 == 1 {
  16013. insutype = "310"
  16014. }
  16015. if len(insutypes) == 0 {
  16016. insutype = "310"
  16017. }
  16018. c.ServeSuccessJSON(map[string]interface{}{
  16019. "patient": patient,
  16020. "number": token,
  16021. "insutype": insutype,
  16022. })
  16023. }
  16024. } else {
  16025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16026. return
  16027. }
  16028. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16029. //if initFlag == 0 {
  16030. c.TestGetJiangXiBasBaseInit()
  16031. //}
  16032. //if initEleFlag == 0 {
  16033. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16034. //}
  16035. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16036. type ELeData struct {
  16037. Data struct {
  16038. IdNo string `json:"idNo"`
  16039. IdType string `json:"idType"`
  16040. UserName string `json:"userName"`
  16041. EcToken string `json:"ecToken"`
  16042. InsuOrg string `json:"insuOrg"`
  16043. Gender string `json:"gender"`
  16044. Birthday string `json:"birthday"`
  16045. Nationality string `json:"nationality"`
  16046. Email string `json:"email"`
  16047. Extra string `json:"extra"`
  16048. } `json:"data"`
  16049. Code int `json:"code"`
  16050. Message string `json:"message"`
  16051. }
  16052. var ele ELeData
  16053. err := json.Unmarshal([]byte(json_result), &ele)
  16054. if err != nil {
  16055. utils.ErrorLog("解析失败:%v", err)
  16056. }
  16057. token := ele.Data.EcToken
  16058. token = Remove0000(token)
  16059. 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)
  16060. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16061. var res ResultTwo
  16062. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16063. utils.ErrorLog("解析失败:%v", err)
  16064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16065. return
  16066. }
  16067. if res.Infcode == 0 {
  16068. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16069. if err == gorm.ErrRecordNotFound {
  16070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16071. return
  16072. } else if err != nil {
  16073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16074. return
  16075. } else {
  16076. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16077. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16078. infoStr := string(Iinfos)
  16079. idetinfoStr := string(Idetinfos)
  16080. psn := &models.HisPsn{
  16081. PsnNo: res.Output.Baseinfo.PsnNo,
  16082. PatientId: patient.ID,
  16083. Certno: res.Output.Baseinfo.Certno,
  16084. Gend: res.Output.Baseinfo.Gend,
  16085. Naty: res.Output.Baseinfo.Naty,
  16086. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16087. PsnName: res.Output.Baseinfo.PsnName,
  16088. Idetinfo: idetinfoStr,
  16089. Insuinfo: infoStr,
  16090. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16091. CardInfo: "",
  16092. VerifyNumber: token,
  16093. }
  16094. service.CreateHisPsn(psn)
  16095. var rf []*ResultFive
  16096. json.Unmarshal([]byte(infoStr), &rf)
  16097. var insutypes []*ResultFive
  16098. var insutype string
  16099. var is390 int = 0
  16100. var is310 int = 0
  16101. for _, item := range rf {
  16102. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16103. insutypes = append(insutypes, item)
  16104. }
  16105. }
  16106. if len(insutypes) == 1 {
  16107. insutype = insutypes[0].Insutype
  16108. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16109. } else {
  16110. for _, i := range insutypes {
  16111. if i.Insutype == "390" {
  16112. is390 = 1
  16113. }
  16114. if i.Insutype == "310" {
  16115. is310 = 1
  16116. }
  16117. }
  16118. }
  16119. if is390 == 1 {
  16120. insutype = "390"
  16121. }
  16122. if is310 == 1 {
  16123. insutype = "310"
  16124. }
  16125. if len(insutypes) == 0 {
  16126. insutype = "310"
  16127. }
  16128. c.ServeSuccessJSON(map[string]interface{}{
  16129. "patient": patient,
  16130. "number": token,
  16131. "insutype": insutype,
  16132. })
  16133. }
  16134. } else {
  16135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16136. return
  16137. }
  16138. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16139. type ELeData struct {
  16140. Code string `json:"code"`
  16141. Data struct {
  16142. Aac002 string `json:"aac002"`
  16143. Aaz500 string `json:"aaz500"`
  16144. ActCardNo string `json:"actCardNo"`
  16145. Bab520 string `json:"bab520"`
  16146. Bkz543 string `json:"bkz543"`
  16147. BusinessType string `json:"businessType"`
  16148. CertfCodg string `json:"certfCodg"`
  16149. EcIndexNo string `json:"ecIndexNo"`
  16150. EcToken string `json:"ecToken"`
  16151. ID0000 string `json:"id0000"`
  16152. IDNo string `json:"idNo"`
  16153. IDType string `json:"idType"`
  16154. Idcode string `json:"idcode"`
  16155. IdentityToken string `json:"identity_token"`
  16156. InsuOrg string `json:"insuOrg"`
  16157. OfficeID string `json:"officeId"`
  16158. OfficeName string `json:"officeName"`
  16159. OperatorID string `json:"operatorId"`
  16160. OperatorName string `json:"operatorName"`
  16161. OrgID string `json:"orgId"`
  16162. UserName string `json:"userName"`
  16163. } `json:"data"`
  16164. Infno interface{} `json:"infno"`
  16165. Message string `json:"message"`
  16166. OrgID string `json:"orgId"`
  16167. TransType string `json:"transType"`
  16168. }
  16169. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16170. outPutInfo = Remove0000(outPutInfo)
  16171. if len(outPutInfo) > 0 {
  16172. var ele ELeData
  16173. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16174. if err != nil {
  16175. utils.ErrorLog("解析失败:%v", err)
  16176. }
  16177. token := ele.Data.EcToken
  16178. fmt.Println(inputInfo)
  16179. fmt.Println(outPutInfo)
  16180. 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)
  16181. saveLog(result, requestLog, "1101", "获取人员信息")
  16182. var dat map[string]interface{}
  16183. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16184. fmt.Println(dat)
  16185. } else {
  16186. fmt.Println(err)
  16187. }
  16188. userJSONBytes, _ := json.Marshal(dat)
  16189. var res ResultTwo
  16190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16191. utils.ErrorLog("解析失败:%v", err)
  16192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16193. return
  16194. }
  16195. res.ErrMsg = errMsgLog
  16196. if res.Infcode == 0 {
  16197. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16198. if err == gorm.ErrRecordNotFound {
  16199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16200. return
  16201. } else if err != nil {
  16202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16203. return
  16204. } else {
  16205. fmt.Println(res)
  16206. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16207. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16208. infoStr := string(Iinfos)
  16209. idetinfoStr := string(Idetinfos)
  16210. psn := &models.HisPsn{
  16211. PsnNo: res.Output.Baseinfo.PsnNo,
  16212. PatientId: patient.ID,
  16213. Certno: res.Output.Baseinfo.Certno,
  16214. Gend: res.Output.Baseinfo.Gend,
  16215. Naty: res.Output.Baseinfo.Naty,
  16216. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16217. PsnName: res.Output.Baseinfo.PsnName,
  16218. Idetinfo: idetinfoStr,
  16219. Insuinfo: infoStr,
  16220. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16221. CardInfo: outPutInfo,
  16222. VerifyNumber: token,
  16223. InsuplcAdmdvs: ele.Data.InsuOrg,
  16224. }
  16225. service.CreateHisPsn(psn)
  16226. var rf []*ResultFive
  16227. json.Unmarshal([]byte(infoStr), &rf)
  16228. var insutypes []*ResultFive
  16229. var insutype string
  16230. var is390 int = 0
  16231. var is310 int = 0
  16232. for _, item := range rf {
  16233. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16234. insutypes = append(insutypes, item)
  16235. }
  16236. }
  16237. if len(insutypes) == 1 {
  16238. insutype = insutypes[0].Insutype
  16239. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16240. } else {
  16241. for _, i := range insutypes {
  16242. if i.Insutype == "390" {
  16243. is390 = 1
  16244. }
  16245. if i.Insutype == "310" {
  16246. is310 = 1
  16247. }
  16248. }
  16249. }
  16250. if is390 == 1 {
  16251. insutype = "390"
  16252. }
  16253. if is310 == 1 {
  16254. insutype = "310"
  16255. }
  16256. if len(insutypes) == 0 {
  16257. insutype = "310"
  16258. }
  16259. c.ServeSuccessJSON(map[string]interface{}{
  16260. "patient": patient,
  16261. "number": token,
  16262. "insutype": insutype,
  16263. })
  16264. }
  16265. } else {
  16266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16267. return
  16268. }
  16269. }
  16270. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16271. var api string
  16272. 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 +
  16273. "&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
  16274. resp, requestErr := http.Get(api)
  16275. if requestErr != nil {
  16276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16277. return
  16278. }
  16279. body, ioErr := ioutil.ReadAll(resp.Body)
  16280. if ioErr != nil {
  16281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16283. return
  16284. }
  16285. var respJSON map[string]interface{}
  16286. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16289. return
  16290. }
  16291. var status string
  16292. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16293. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16294. var token string
  16295. var res ResultTwo //1101结果
  16296. var res10265 ResultTwo10265 //1101结果
  16297. if status == "0" { //读卡成功
  16298. var card_info string //卡信息
  16299. var busi_card_info string
  16300. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16301. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16302. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16303. fmt.Println(card_info)
  16304. fmt.Println(busi_card_info)
  16305. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16306. result, _ := json.Marshal(respJSON)
  16307. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16308. utils.ErrorLog("解析失败:%v", err)
  16309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16310. return
  16311. }
  16312. res.ErrMsg = res10265.ErrMsg
  16313. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16314. res.Infcode = infocode
  16315. res.Output = res10265.Output
  16316. res.InfRefmsgid = res10265.InfRefmsgid
  16317. if res.Infcode == 0 {
  16318. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16319. if err == gorm.ErrRecordNotFound {
  16320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16321. return
  16322. } else if err != nil {
  16323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16324. return
  16325. } else {
  16326. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16327. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16328. infoStr := string(Iinfos)
  16329. idetinfoStr := string(Idetinfos)
  16330. psn := &models.HisPsn{
  16331. PsnNo: res.Output.Baseinfo.PsnNo,
  16332. PatientId: patient.ID,
  16333. Certno: res.Output.Baseinfo.Certno,
  16334. Gend: res.Output.Baseinfo.Gend,
  16335. Naty: res.Output.Baseinfo.Naty,
  16336. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16337. PsnName: res.Output.Baseinfo.PsnName,
  16338. Idetinfo: idetinfoStr,
  16339. Insuinfo: infoStr,
  16340. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16341. CardInfo: card_info,
  16342. VerifyNumber: token,
  16343. }
  16344. var rf []*ResultFive
  16345. json.Unmarshal([]byte(infoStr), &rf)
  16346. var insutypes []*ResultFive
  16347. var insutype string
  16348. var is390 int = 0
  16349. var is310 int = 0
  16350. for _, item := range rf {
  16351. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16352. insutypes = append(insutypes, item)
  16353. }
  16354. }
  16355. if len(insutypes) == 1 {
  16356. insutype = insutypes[0].Insutype
  16357. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16358. } else {
  16359. for _, i := range insutypes {
  16360. if i.Insutype == "390" {
  16361. is390 = 1
  16362. }
  16363. if i.Insutype == "310" {
  16364. is310 = 1
  16365. }
  16366. }
  16367. }
  16368. if is390 == 1 {
  16369. insutype = "390"
  16370. }
  16371. if is310 == 1 {
  16372. insutype = "310"
  16373. }
  16374. if len(insutypes) == 0 {
  16375. insutype = "310"
  16376. }
  16377. service.CreateHisPsn(psn)
  16378. c.ServeSuccessJSON(map[string]interface{}{
  16379. "patient": patient,
  16380. "number": token,
  16381. "insutype": insutype,
  16382. })
  16383. }
  16384. } else {
  16385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16386. return
  16387. }
  16388. } else { //读卡失败
  16389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16390. return
  16391. }
  16392. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16393. res := c.GetoleInfo()
  16394. if res.Infcode == 0 {
  16395. var result string
  16396. if res.Output.MdtrtCertType == "01" {
  16397. 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)
  16398. } else if res.Output.MdtrtCertType == "02" {
  16399. 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)
  16400. } else if res.Output.MdtrtCertType == "03" {
  16401. 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)
  16402. }
  16403. var dat map[string]interface{}
  16404. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16405. fmt.Println(dat)
  16406. } else {
  16407. fmt.Println(err)
  16408. }
  16409. userJSONBytes, _ := json.Marshal(dat)
  16410. var res2 ResultTwo
  16411. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16412. utils.ErrorLog("解析失败:%v", err)
  16413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16414. return
  16415. }
  16416. if res2.Infcode == 0 {
  16417. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16418. if err == gorm.ErrRecordNotFound {
  16419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16420. return
  16421. } else if err != nil {
  16422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16423. return
  16424. } else {
  16425. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16426. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16427. infoStr := string(Iinfos)
  16428. idetinfoStr := string(Idetinfos)
  16429. var rf []*ResultFive
  16430. json.Unmarshal([]byte(infoStr), &rf)
  16431. var insutypes []*ResultFive
  16432. var insutype string
  16433. var is390 int = 0
  16434. var is310 int = 0
  16435. //var insuplc_admdvs string
  16436. for _, item := range rf {
  16437. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16438. insutypes = append(insutypes, item)
  16439. }
  16440. }
  16441. if len(insutypes) == 1 {
  16442. insutype = insutypes[0].Insutype
  16443. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16444. } else {
  16445. for _, i := range insutypes {
  16446. if i.Insutype == "390" {
  16447. is390 = 1
  16448. }
  16449. if i.Insutype == "310" {
  16450. is310 = 1
  16451. }
  16452. }
  16453. }
  16454. if is390 == 1 {
  16455. insutype = "390"
  16456. }
  16457. if is310 == 1 {
  16458. insutype = "310"
  16459. }
  16460. if len(insutypes) == 0 {
  16461. insutype = "310"
  16462. }
  16463. psn := &models.HisPsn{
  16464. PsnNo: res2.Output.Baseinfo.PsnNo,
  16465. PatientId: patient.ID,
  16466. Certno: res2.Output.Baseinfo.Certno,
  16467. Gend: res2.Output.Baseinfo.Gend,
  16468. Naty: res2.Output.Baseinfo.Naty,
  16469. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16470. PsnName: res2.Output.Baseinfo.PsnName,
  16471. Idetinfo: idetinfoStr,
  16472. Insuinfo: infoStr,
  16473. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16474. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16475. VerifyNumber: res.Output.EcToken,
  16476. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16477. }
  16478. if res.Output.MdtrtCertType == "01" {
  16479. psn.VerifyNumber = res.Output.EcToken
  16480. //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)
  16481. } else if res.Output.MdtrtCertType == "02" {
  16482. psn.VerifyNumber = res.Output.CardNo
  16483. //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)
  16484. } else if res.Output.MdtrtCertType == "03" {
  16485. psn.VerifyNumber = res.Output.MdtrtCertNo
  16486. //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)
  16487. }
  16488. service.CreateHisPsn(psn)
  16489. var balc float64
  16490. for _, item := range rf {
  16491. if item.Insutype == insutype {
  16492. balc = item.Balc
  16493. }
  16494. }
  16495. c.ServeSuccessJSON(map[string]interface{}{
  16496. "patient": patient,
  16497. "number": res.Output.CardNo,
  16498. "insutype": insutype,
  16499. "blac": balc,
  16500. "desc": idetinfoStr,
  16501. })
  16502. }
  16503. } else {
  16504. c.ServeSuccessJSON(map[string]interface{}{
  16505. "failed_code": -10,
  16506. "msg": res2.ErrMsg,
  16507. })
  16508. }
  16509. } else {
  16510. c.ServeSuccessJSON(map[string]interface{}{
  16511. "failed_code": -10,
  16512. "msg": res.ErrMsg,
  16513. })
  16514. }
  16515. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16516. var res ResultTwo
  16517. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16518. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16519. "&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)
  16520. resp, requestErr := http.Get(api)
  16521. if requestErr != nil {
  16522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16523. return
  16524. }
  16525. body, ioErr := ioutil.ReadAll(resp.Body)
  16526. if ioErr != nil {
  16527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16529. return
  16530. }
  16531. var respJSON map[string]interface{}
  16532. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16535. return
  16536. }
  16537. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16538. result, _ := json.Marshal(respJSON)
  16539. fmt.Println("log")
  16540. fmt.Println(string(result))
  16541. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16542. utils.ErrorLog("解析失败:%v", err)
  16543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16544. return
  16545. }
  16546. if res.Infcode == 0 {
  16547. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16548. if err == gorm.ErrRecordNotFound {
  16549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16550. return
  16551. } else if err != nil {
  16552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16553. return
  16554. } else {
  16555. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16556. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16557. infoStr := string(Iinfos)
  16558. idetinfoStr := string(Idetinfos)
  16559. var rf []*ResultFive
  16560. json.Unmarshal([]byte(infoStr), &rf)
  16561. var insutypes []*ResultFive
  16562. var insutype string
  16563. var is390 int = 0
  16564. var is310 int = 0
  16565. for _, item := range rf {
  16566. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16567. insutypes = append(insutypes, item)
  16568. }
  16569. }
  16570. if len(insutypes) == 1 {
  16571. insutype = insutypes[0].Insutype
  16572. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16573. } else {
  16574. for _, i := range insutypes {
  16575. if i.Insutype == "390" {
  16576. is390 = 1
  16577. }
  16578. if i.Insutype == "310" {
  16579. is310 = 1
  16580. }
  16581. }
  16582. }
  16583. if is390 == 1 {
  16584. insutype = "390"
  16585. }
  16586. if is310 == 1 {
  16587. insutype = "310"
  16588. }
  16589. if len(insutypes) == 0 {
  16590. insutype = "390"
  16591. }
  16592. var insuplc_admdvs string
  16593. for _, item := range rf {
  16594. if item.Insutype == insutype {
  16595. insuplc_admdvs = item.InsuplcAdmdvs
  16596. }
  16597. }
  16598. psn := &models.HisPsn{
  16599. PsnNo: res.Output.Baseinfo.PsnNo,
  16600. PatientId: patient.ID,
  16601. Certno: res.Output.Baseinfo.Certno,
  16602. Gend: res.Output.Baseinfo.Gend,
  16603. Naty: res.Output.Baseinfo.Naty,
  16604. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16605. PsnName: res.Output.Baseinfo.PsnName,
  16606. Idetinfo: idetinfoStr,
  16607. Insuinfo: infoStr,
  16608. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16609. InsuplcAdmdvs: insuplc_admdvs,
  16610. }
  16611. service.CreateHisPsn(psn)
  16612. c.ServeSuccessJSON(map[string]interface{}{
  16613. "patient": patient,
  16614. "number": res.Output.Baseinfo.Certno,
  16615. })
  16616. }
  16617. } else {
  16618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16619. return
  16620. }
  16621. } else {
  16622. type ELeData struct {
  16623. Code string `json:"code"`
  16624. Data struct {
  16625. Aac002 string `json:"aac002"`
  16626. Aaz500 string `json:"aaz500"`
  16627. ActCardNo string `json:"actCardNo"`
  16628. Bab520 string `json:"bab520"`
  16629. Bkz543 string `json:"bkz543"`
  16630. BusinessType string `json:"businessType"`
  16631. CertfCodg string `json:"certfCodg"`
  16632. EcIndexNo string `json:"ecIndexNo"`
  16633. EcToken string `json:"ecToken"`
  16634. ID0000 string `json:"id0000"`
  16635. IDNo string `json:"idNo"`
  16636. IDType string `json:"idType"`
  16637. Idcode string `json:"idcode"`
  16638. IdentityToken string `json:"identity_token"`
  16639. InsuOrg string `json:"insuOrg"`
  16640. OfficeID string `json:"officeId"`
  16641. OfficeName string `json:"officeName"`
  16642. OperatorID string `json:"operatorId"`
  16643. OperatorName string `json:"operatorName"`
  16644. OrgID string `json:"orgId"`
  16645. UserName string `json:"userName"`
  16646. } `json:"data"`
  16647. Infno interface{} `json:"infno"`
  16648. Message string `json:"message"`
  16649. OrgID string `json:"orgId"`
  16650. TransType string `json:"transType"`
  16651. }
  16652. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16653. fmt.Println(result)
  16654. outPutInfo := Remove0000(result)
  16655. fmt.Println(outPutInfo)
  16656. if len(outPutInfo) > 0 {
  16657. var ele ELeData
  16658. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16659. if err != nil {
  16660. utils.ErrorLog("解析失败:%v", err)
  16661. }
  16662. token := ele.Data.EcToken
  16663. fmt.Println(outPutInfo)
  16664. 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)
  16665. saveLog(result, requestLog, "1101", "获取人员信息")
  16666. var dat map[string]interface{}
  16667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16668. fmt.Println(dat)
  16669. } else {
  16670. fmt.Println(err)
  16671. }
  16672. userJSONBytes, _ := json.Marshal(dat)
  16673. var res ResultTwo
  16674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16675. utils.ErrorLog("解析失败:%v", err)
  16676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16677. return
  16678. }
  16679. if res.Infcode == 0 {
  16680. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16681. if err == gorm.ErrRecordNotFound {
  16682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16683. return
  16684. } else if err != nil {
  16685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16686. return
  16687. } else {
  16688. fmt.Println(res)
  16689. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16690. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16691. infoStr := string(Iinfos)
  16692. idetinfoStr := string(Idetinfos)
  16693. psn := &models.HisPsn{
  16694. PsnNo: res.Output.Baseinfo.PsnNo,
  16695. PatientId: patient.ID,
  16696. Certno: res.Output.Baseinfo.Certno,
  16697. Gend: res.Output.Baseinfo.Gend,
  16698. Naty: res.Output.Baseinfo.Naty,
  16699. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16700. PsnName: res.Output.Baseinfo.PsnName,
  16701. Idetinfo: idetinfoStr,
  16702. Insuinfo: infoStr,
  16703. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16704. CardInfo: outPutInfo,
  16705. VerifyNumber: token,
  16706. InsuplcAdmdvs: ele.Data.InsuOrg,
  16707. }
  16708. service.CreateHisPsn(psn)
  16709. var rf []*ResultFive
  16710. json.Unmarshal([]byte(infoStr), &rf)
  16711. var insutypes []*ResultFive
  16712. var insutype string
  16713. var is390 int = 0
  16714. var is310 int = 0
  16715. for _, item := range rf {
  16716. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16717. insutypes = append(insutypes, item)
  16718. }
  16719. }
  16720. if len(insutypes) == 1 {
  16721. insutype = insutypes[0].Insutype
  16722. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16723. } else {
  16724. for _, i := range insutypes {
  16725. if i.Insutype == "390" {
  16726. is390 = 1
  16727. }
  16728. if i.Insutype == "310" {
  16729. is310 = 1
  16730. }
  16731. }
  16732. }
  16733. if is390 == 1 {
  16734. insutype = "390"
  16735. }
  16736. if is310 == 1 {
  16737. insutype = "310"
  16738. }
  16739. if len(insutypes) == 0 {
  16740. insutype = "310"
  16741. }
  16742. c.ServeSuccessJSON(map[string]interface{}{
  16743. "patient": patient,
  16744. "number": token,
  16745. "insutype": insutype,
  16746. })
  16747. }
  16748. } else {
  16749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16750. return
  16751. }
  16752. }
  16753. //fmt.Println(result)
  16754. //
  16755. //if initFlag == 0 {
  16756. // c.TestGetBasBaseInit()
  16757. //}
  16758. //token := c.GetEleBaseInfo()
  16759. //
  16760. //token = Remove0000(token)
  16761. //
  16762. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16763. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16764. ////
  16765. //var res ResultTwo
  16766. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16767. // utils.ErrorLog("解析失败:%v", err)
  16768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16769. // return
  16770. //}
  16771. //
  16772. //if res.Infcode == 0 {
  16773. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16774. // if err == gorm.ErrRecordNotFound {
  16775. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16776. // return
  16777. // } else if err != nil {
  16778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16779. // return
  16780. //
  16781. // } else {
  16782. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16783. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16784. // infoStr := string(Iinfos)
  16785. // idetinfoStr := string(Idetinfos)
  16786. //
  16787. //
  16788. //
  16789. //
  16790. // var rf []*ResultFive
  16791. // json.Unmarshal([]byte(infoStr), &rf)
  16792. //
  16793. // var insutypes []*ResultFive
  16794. // var insutype string
  16795. // var is390 int = 0
  16796. // var is310 int = 0
  16797. // var insuplc_admdvs string
  16798. //
  16799. // for _, item := range rf {
  16800. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16801. // insutypes = append(insutypes, item)
  16802. // }
  16803. // }
  16804. //
  16805. // if len(insutypes) == 1 {
  16806. // insutype = insutypes[0].Insutype
  16807. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16808. // } else {
  16809. // for _, i := range insutypes {
  16810. // if i.Insutype == "390" {
  16811. // is390 = 1
  16812. // }
  16813. //
  16814. // if i.Insutype == "310" {
  16815. // is310 = 1
  16816. // }
  16817. // }
  16818. // }
  16819. // if is390 == 1 {
  16820. // insutype = "390"
  16821. // }
  16822. //
  16823. // if is310 == 1 {
  16824. // insutype = "310"
  16825. // }
  16826. // if len(insutypes) == 0 {
  16827. // insutype = "310"
  16828. // }
  16829. // for _, item := range rf {
  16830. // if item.Insutype == insutype {
  16831. // insuplc_admdvs = item.InsuplcAdmdvs
  16832. // }
  16833. // }
  16834. // psn := &models.HisPsn{
  16835. // PsnNo: res.Output.Baseinfo.PsnNo,
  16836. // Age: res.Output.Baseinfo.Age,
  16837. // PatientId: patient.ID,
  16838. // Certno: res.Output.Baseinfo.Certno,
  16839. // Brdy: res.Output.Baseinfo.Brdy,
  16840. // Gend: res.Output.Baseinfo.Gend,
  16841. // Naty: res.Output.Baseinfo.Naty,
  16842. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16843. // PsnName: res.Output.Baseinfo.PsnName,
  16844. // Idetinfo: idetinfoStr,
  16845. // Insuinfo: infoStr,
  16846. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16847. // CardInfo: "",
  16848. // VerifyNumber: token,
  16849. // InsuplcAdmdvs: insuplc_admdvs,
  16850. // }
  16851. // service.CreateHisPsn(psn)
  16852. //
  16853. // c.ServeSuccessJSON(map[string]interface{}{
  16854. // "patient": patient,
  16855. // "number": token,
  16856. // })
  16857. // }
  16858. //} else {
  16859. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16860. // return
  16861. //}
  16862. }
  16863. break
  16864. case 5:
  16865. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16866. var api string
  16867. if miConfig.MdtrtareaAdmvs == "320921" {
  16868. 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 +
  16869. "&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
  16870. fmt.Println(api)
  16871. } else {
  16872. 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 +
  16873. "&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)
  16874. }
  16875. resp, requestErr := http.Get(api)
  16876. if requestErr != nil {
  16877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16878. return
  16879. }
  16880. body, ioErr := ioutil.ReadAll(resp.Body)
  16881. if ioErr != nil {
  16882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16884. return
  16885. }
  16886. var respJSON map[string]interface{}
  16887. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16890. return
  16891. }
  16892. var status string
  16893. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16894. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16895. var token string
  16896. var res ResultTwo //1101结果
  16897. var res10265 ResultTwo10265 //1101结果
  16898. if status == "0" { //读卡成功
  16899. var card_info string //卡信息
  16900. //var busi_card_info string
  16901. var auth_info string
  16902. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16903. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16904. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16905. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16906. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16907. result, _ := json.Marshal(respJSON)
  16908. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16909. utils.ErrorLog("解析失败:%v", err)
  16910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16911. return
  16912. }
  16913. res.ErrMsg = res10265.ErrMsg
  16914. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16915. res.Infcode = infocode
  16916. res.Output = res10265.Output
  16917. res.InfRefmsgid = res10265.InfRefmsgid
  16918. if res.Infcode == 0 {
  16919. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16920. if err == gorm.ErrRecordNotFound {
  16921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16922. return
  16923. } else if err != nil {
  16924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16925. return
  16926. } else {
  16927. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16928. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16929. infoStr := string(Iinfos)
  16930. idetinfoStr := string(Idetinfos)
  16931. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16932. psn := &models.HisPsn{
  16933. PsnNo: res.Output.Baseinfo.PsnNo,
  16934. PatientId: patient.ID,
  16935. Certno: res.Output.Baseinfo.Certno,
  16936. Gend: res.Output.Baseinfo.Gend,
  16937. Brdy: b,
  16938. Age: float64(age),
  16939. Naty: res.Output.Baseinfo.Naty,
  16940. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16941. PsnName: res.Output.Baseinfo.PsnName,
  16942. Idetinfo: idetinfoStr,
  16943. Insuinfo: infoStr,
  16944. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16945. CardInfo: card_info,
  16946. VerifyNumber: token,
  16947. AuthInfo: auth_info,
  16948. }
  16949. var rf []*ResultFive
  16950. json.Unmarshal([]byte(infoStr), &rf)
  16951. var insutypes []*ResultFive
  16952. var insutype string
  16953. var is390 int = 0
  16954. var is310 int = 0
  16955. for _, item := range rf {
  16956. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16957. insutypes = append(insutypes, item)
  16958. }
  16959. }
  16960. if len(insutypes) == 1 {
  16961. insutype = insutypes[0].Insutype
  16962. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16963. } else {
  16964. for _, i := range insutypes {
  16965. if i.Insutype == "390" {
  16966. is390 = 1
  16967. }
  16968. if i.Insutype == "310" {
  16969. is310 = 1
  16970. }
  16971. }
  16972. }
  16973. if is390 == 1 {
  16974. insutype = "390"
  16975. }
  16976. if is310 == 1 {
  16977. insutype = "310"
  16978. }
  16979. if len(insutypes) == 0 {
  16980. insutype = "310"
  16981. }
  16982. service.CreateHisPsn(psn)
  16983. c.ServeSuccessJSON(map[string]interface{}{
  16984. "patient": patient,
  16985. "number": token,
  16986. "insutype": insutype,
  16987. })
  16988. }
  16989. } else {
  16990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16991. return
  16992. }
  16993. } else { //读卡失败
  16994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16995. return
  16996. }
  16997. }
  16998. break
  16999. }
  17000. }
  17001. var initFlag int64 = 0
  17002. var initEleFlag int64 = 0
  17003. func (c *HisApiController) TestGetBasBaseInit() {
  17004. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17005. Iinit := DllDef.MustFindProc("Init")
  17006. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17007. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  17008. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  17009. if ret != 0 {
  17010. fmt.Println("SSCard的报错原因:", err)
  17011. fmt.Println("SSCard的运算结果为:", ret)
  17012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17013. return
  17014. }
  17015. result := int(ret)
  17016. fmt.Println("SSCard的运算结果为1:", result)
  17017. initFlag = 1
  17018. return
  17019. }
  17020. func (c *HisApiController) HandleJiangXiReadCard() {
  17021. fmt.Println("~~~~~~")
  17022. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17023. admin_user_id, _ := c.GetInt64("admin_user_id")
  17024. id_card_type, _ := c.GetInt64("id_card_type")
  17025. //certificates, _ := c.GetInt64("certificates")
  17026. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17027. if initFlag == 0 {
  17028. c.TestGetJiangXiBasBaseInit()
  17029. }
  17030. basStr := c.GetBasBaseInfo()
  17031. if len(basStr) == 0 {
  17032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17033. return
  17034. }
  17035. fmt.Println(basStr)
  17036. bas := strings.Split(basStr, "|")
  17037. basNumber := bas[1]
  17038. fmt.Println(basNumber)
  17039. card_sn := bas[3]
  17040. fmt.Println(card_sn)
  17041. 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, "")
  17042. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  17043. var dat map[string]interface{}
  17044. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17045. fmt.Println(dat)
  17046. } else {
  17047. fmt.Println(err)
  17048. }
  17049. userJSONBytes, _ := json.Marshal(dat)
  17050. var res ResultTwo
  17051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17052. utils.ErrorLog("解析失败:%v", err)
  17053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17054. return
  17055. }
  17056. if res.Infcode == 0 {
  17057. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  17058. if err == gorm.ErrRecordNotFound {
  17059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17060. return
  17061. } else if err != nil {
  17062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17063. return
  17064. } else {
  17065. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17066. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17067. infoStr := string(Iinfos)
  17068. idetinfoStr := string(Idetinfos)
  17069. psn := &models.HisPsn{
  17070. PsnNo: res.Output.Baseinfo.PsnNo,
  17071. PatientId: patient.ID,
  17072. Certno: res.Output.Baseinfo.Certno,
  17073. Gend: res.Output.Baseinfo.Gend,
  17074. Naty: res.Output.Baseinfo.Naty,
  17075. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17076. PsnName: res.Output.Baseinfo.PsnName,
  17077. Idetinfo: idetinfoStr,
  17078. Insuinfo: infoStr,
  17079. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17080. CardInfo: basStr,
  17081. VerifyNumber: "",
  17082. }
  17083. service.CreateHisPsn(psn)
  17084. c.ServeSuccessJSON(map[string]interface{}{
  17085. "patient": patient,
  17086. "number": basNumber,
  17087. })
  17088. }
  17089. } else {
  17090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17091. return
  17092. }
  17093. }
  17094. func (c *HisApiController) TestGetHnBasBaseInit() {
  17095. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17096. Iinit := DllDef.MustFindProc("Init")
  17097. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17098. //http://10.77.211.236/CSB/hsa-fsi-1303
  17099. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17100. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17101. // 调用 Init 函数
  17102. 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"))))
  17103. //if ret != 0 {
  17104. fmt.Println("SSCard的报错原因:", err)
  17105. fmt.Println("SSCard的运算结果为:", ret)
  17106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17107. // return
  17108. //}
  17109. result := int(ret)
  17110. fmt.Println("SSCard的运算结果为1:", result)
  17111. initFlag = 1
  17112. return
  17113. }
  17114. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17115. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17116. Iinit := DllDef.MustFindProc("Init")
  17117. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17118. //http://10.77.211.236/CSB/hsa-fsi-1303
  17119. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  17120. if ret != 0 {
  17121. fmt.Println("SSCard的报错原因:", err)
  17122. fmt.Println("SSCard的运算结果为:", ret)
  17123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17124. return
  17125. }
  17126. result := int(ret)
  17127. fmt.Println("SSCard的运算结果为1:", result)
  17128. initFlag = 1
  17129. return
  17130. }
  17131. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17132. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17133. Iinit := DllDef.MustFindProc("Init")
  17134. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17135. //http://10.77.211.236/CSB/hsa-fsi-1303
  17136. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17137. if ret != 0 {
  17138. fmt.Println("SSCard的报错原因:", err)
  17139. fmt.Println("SSCard的运算结果为:", ret)
  17140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17141. return
  17142. }
  17143. result := int(ret)
  17144. fmt.Println("SSCard的运算结果为1:", result)
  17145. initFlag = 1
  17146. return
  17147. }
  17148. func (c *HisApiController) GetSFZBaseInfo() string {
  17149. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17150. readCard := DllDef.MustFindProc("ReadSFZ")
  17151. if readCard == nil {
  17152. fmt.Println("readcard is nil")
  17153. readCard = DllDef.MustFindProc("ReadSFZ")
  17154. }
  17155. str := make([]byte, 8096)
  17156. str1 := make([]byte, 8096)
  17157. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17158. fmt.Println(r)
  17159. return Remove0000(string(str))
  17160. }
  17161. func (c *HisApiController) GetEleBaseInfo() string {
  17162. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17163. readCard := DllDef.MustFindProc("GetQRBase")
  17164. fmt.Println(readCard)
  17165. if readCard == nil {
  17166. fmt.Println("readcard is nil")
  17167. readCard = DllDef.MustFindProc("GetQRBase")
  17168. }
  17169. str := make([]byte, 1024)
  17170. str1 := make([]byte, 1024)
  17171. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17172. fmt.Println(ret2)
  17173. fmt.Println(string(str1))
  17174. fmt.Println(string(str))
  17175. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17176. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17177. if ret2 != 0 {
  17178. return ""
  17179. }
  17180. return string(str)
  17181. }
  17182. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17183. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17184. readCard := DllDef.MustFindProc("NationEcTrans")
  17185. fmt.Println(readCard)
  17186. fmt.Println("!!!!!")
  17187. pBusiCardInfo := make([]byte, 2048)
  17188. input := make(map[string]interface{})
  17189. inputData := make(map[string]interface{})
  17190. inputData["orgId"] = code
  17191. inputData["businessType"] = "01101"
  17192. inputData["operatorId"] = "1"
  17193. inputData["operatorName"] = "admin"
  17194. inputData["officeId"] = "001"
  17195. inputData["officeName"] = "血透室"
  17196. inputData["deviceType"] = ""
  17197. input["data"] = inputData
  17198. input["orgId"] = code
  17199. input["transType"] = "ec.query"
  17200. bytesData, _ := json.Marshal(input)
  17201. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17202. fmt.Println(ret2)
  17203. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17204. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17205. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17206. }
  17207. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17208. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17209. readCard := DllDef.MustFindProc("NationEcTrans")
  17210. fmt.Println(readCard)
  17211. fmt.Println("!!!!!")
  17212. pBusiCardInfo := make([]byte, 2048)
  17213. input := make(map[string]interface{})
  17214. inputData := make(map[string]interface{})
  17215. inputData["orgId"] = code
  17216. inputData["businessType"] = "01101"
  17217. inputData["operatorId"] = "9"
  17218. inputData["operatorName"] = "admin"
  17219. inputData["officeId"] = "001"
  17220. inputData["officeName"] = "血透室"
  17221. inputData["deviceType"] = ""
  17222. input["data"] = inputData
  17223. input["orgId"] = code
  17224. input["transType"] = "ec.query"
  17225. bytesData, _ := json.Marshal(input)
  17226. 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])))
  17227. fmt.Println(ret2)
  17228. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17229. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17230. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17231. }
  17232. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17233. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17234. readCard := DllDef.MustFindProc("NationEcTrans")
  17235. fmt.Println(readCard)
  17236. fmt.Println("!!!!!")
  17237. pBusiCardInfo := make([]byte, 2048)
  17238. input := make(map[string]interface{})
  17239. inputData := make(map[string]interface{})
  17240. inputData["orgId"] = code
  17241. inputData["businessType"] = "01301"
  17242. inputData["operatorId"] = "9"
  17243. inputData["operatorName"] = "admin"
  17244. inputData["officeId"] = "001"
  17245. inputData["officeName"] = "血透室"
  17246. inputData["deviceType"] = ""
  17247. input["data"] = inputData
  17248. input["orgId"] = code
  17249. input["transType"] = "ec.query"
  17250. bytesData, _ := json.Marshal(input)
  17251. 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])))
  17252. fmt.Println(ret2)
  17253. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17254. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17255. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17256. }
  17257. func GetJxEleBaseInfo(org_id int64) string {
  17258. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17259. readCard := DllDef.MustFindProc("NationEcTrans")
  17260. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17261. if readCard == nil {
  17262. fmt.Println("readcard is nil")
  17263. readCard = DllDef.MustFindProc("NationEcTrans")
  17264. }
  17265. str1 := make([]byte, 1024)
  17266. data := make(map[string]interface{})
  17267. inputData := make(map[string]interface{})
  17268. inputData["orgId"] = miConfig.Code
  17269. inputData["businessType"] = "01101"
  17270. inputData["operatorId"] = "test001"
  17271. inputData["operatorName"] = "cn"
  17272. inputData["officeId"] = "32760"
  17273. inputData["officeName"] = "waike"
  17274. inputData["deviceType"] = ""
  17275. data["data"] = inputData
  17276. data["transType"] = "ec.query"
  17277. data["extra "] = ""
  17278. data["orgId"] = miConfig.Code
  17279. bytesData, _ := json.Marshal(data)
  17280. //bytesData, _ := json.Marshal(data)
  17281. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17282. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17283. fmt.Println(ret2)
  17284. fmt.Println(string(str1))
  17285. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17286. if ret2 != 0 {
  17287. return ""
  17288. }
  17289. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17290. }
  17291. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17292. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17293. // readCard := DllDef.MustFindProc("NationEcTrans")
  17294. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17295. //
  17296. // if readCard == nil {
  17297. // fmt.Println("readcard is nil")
  17298. // readCard = DllDef.MustFindProc("NationEcTrans")
  17299. // }
  17300. // str1 := make([]byte, 1024)
  17301. //
  17302. // data := make(map[string]interface{})
  17303. //
  17304. // inputData := make(map[string]interface{})
  17305. // inputData["orgId"] = miConfig.Code
  17306. // inputData["businessType"] = "01101"
  17307. // inputData["operatorId"] = "test001"
  17308. // inputData["operatorName"] = "cn"
  17309. // inputData["officeId"] = "32760"
  17310. // inputData["officeName"] = "waike"
  17311. // inputData["deviceType"] = ""
  17312. //
  17313. // data["data"] = inputData
  17314. // data["transType"] = "ec.query"
  17315. // data["extra "] = ""
  17316. // data["orgId"] = miConfig.Code
  17317. // bytesData, _ := json.Marshal(data)
  17318. // //bytesData, _ := json.Marshal(data)
  17319. //
  17320. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17321. //
  17322. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17323. // fmt.Println(ret2)
  17324. // fmt.Println(string(str1))
  17325. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17326. //
  17327. // if ret2 != 0 {
  17328. // return ""
  17329. // }
  17330. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17331. //}
  17332. func GetJxEleBaseInitInfo(org_id int64) string {
  17333. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17334. readCard := DllDef.MustFindProc("NationEcTrans")
  17335. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17336. if readCard == nil {
  17337. fmt.Println("readcard is nil")
  17338. readCard = DllDef.MustFindProc("NationEcTrans")
  17339. }
  17340. str1 := make([]byte, 2048)
  17341. data := make(map[string]interface{})
  17342. inputData := make(map[string]interface{})
  17343. inputData["orgId"] = miConfig.Code
  17344. inputData["businessType"] = "01101"
  17345. inputData["operatorId"] = "1"
  17346. inputData["operatorName"] = "huangchuang"
  17347. inputData["officeId"] = "101"
  17348. inputData["officeName"] = "xuetou"
  17349. inputData["deviceType"] = ""
  17350. data["data"] = inputData
  17351. data["transType"] = "ec.query"
  17352. data["orgId"] = miConfig.Code
  17353. bytesData, _ := json.Marshal(data)
  17354. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17355. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17356. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17357. fmt.Println(ret2)
  17358. fmt.Println(string(str1))
  17359. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17360. if ret2 != 0 {
  17361. return ""
  17362. }
  17363. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17364. initEleFlag = 1
  17365. }
  17366. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17367. }
  17368. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17369. // // 构建命令
  17370. // cmd := exec.Command("python", "b.py")
  17371. //
  17372. // // 执行命令并等待完成
  17373. // output, err := cmd.CombinedOutput()
  17374. // if err != nil {
  17375. // fmt.Println("Error executing Python script:", err)
  17376. // return
  17377. // }
  17378. //
  17379. // // 打印Python脚本的输出
  17380. // fmt.Println(string(output))
  17381. //}
  17382. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17383. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17384. readCard := DllDef.MustFindProc("gxyb_call")
  17385. if readCard == nil {
  17386. fmt.Println("readcard is nil")
  17387. readCard = DllDef.MustFindProc("gxyb_call")
  17388. }
  17389. str := make([]byte, 1024)
  17390. str1 := make([]byte, 1024)
  17391. //data := make(map[string]interface{})
  17392. currentTime := time.Now()
  17393. // 格式化时间为 "YYYYMMDDHH24MISS"
  17394. formattedTime := currentTime.Format("20060102150405")
  17395. inputData := make(map[string]interface{})
  17396. inputData2 := make(map[string]interface{})
  17397. inputData["transNo"] = "1401"
  17398. inputData["transType"] = "passwordCheck"
  17399. inputData["timestamp"] = formattedTime
  17400. inputData2["fixmedinsCode"] = code
  17401. inputData2["psnNo"] = ""
  17402. inputData["data"] = inputData2
  17403. jsonBytes, err := json.Marshal(inputData)
  17404. if err != nil {
  17405. fmt.Println("Error encoding map to JSON:", err)
  17406. }
  17407. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17408. fmt.Println(string(str1))
  17409. fmt.Println(string(str))
  17410. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17411. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17412. if ret2 != 0 {
  17413. return ""
  17414. }
  17415. return string(str)
  17416. }
  17417. func (c *HisApiController) GetoleInfo() Response {
  17418. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17419. defer ole.CoUninitialize()
  17420. // Replace with the ProgID or CLSID of your COM object
  17421. progID := "YinHai.XJ.Actual.Interface.New"
  17422. // Create COM object
  17423. unknown, err := oleutil.CreateObject(progID)
  17424. if err != nil {
  17425. fmt.Println("Unable to create COM object:", err)
  17426. }
  17427. defer unknown.Release()
  17428. // Query for the IDispatch interface
  17429. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17430. if err != nil {
  17431. fmt.Println("Unable to get IDispatch interface:", err)
  17432. }
  17433. defer dispatch.Release()
  17434. // Prepare parameters
  17435. transNo := "1401"
  17436. transType := "passwordCheck"
  17437. timestamp := time.Now().Unix()
  17438. fixmedinsCode := "H45072101171"
  17439. psnNo := ""
  17440. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17441. result2 := ""
  17442. // Call COM object's method using the IDispatch interface
  17443. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17444. fmt.Println(resulr)
  17445. fmt.Println(result2)
  17446. if err != nil {
  17447. fmt.Println("调用COM对象方法失败:", err)
  17448. }
  17449. var response Response
  17450. err2 := json.Unmarshal([]byte(result2), &response)
  17451. if err2 != nil {
  17452. fmt.Println("解析JSON失败:", err)
  17453. }
  17454. return response
  17455. }
  17456. func (c *HisApiController) GetBasBaseInfo() string {
  17457. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17458. readCard := DllDef.MustFindProc("ReadCardBas")
  17459. if readCard == nil {
  17460. fmt.Println("readcard is nil")
  17461. readCard = DllDef.MustFindProc("ReadCardBas")
  17462. }
  17463. str := make([]byte, 1024)
  17464. str1 := make([]byte, 1024)
  17465. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17466. fmt.Println(string(str1))
  17467. fmt.Println(string(str))
  17468. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17469. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17470. if ret2 != 0 {
  17471. return ""
  17472. }
  17473. return string(str)
  17474. }
  17475. type Program struct {
  17476. FunctionID string `xml:"function_id"`
  17477. CardInfo string `xml:"cardinfo"`
  17478. User string `xml:"user"`
  17479. }
  17480. func (c *HisApiController) GetBasBaseInfo1111() string {
  17481. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17482. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17483. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17484. if readCard == nil {
  17485. fmt.Println("readcard is nil")
  17486. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17487. }
  17488. if readCard2 == nil {
  17489. fmt.Println("readcard is nil")
  17490. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17491. }
  17492. str := make([]byte, 1024)
  17493. str1 := make([]byte, 1024)
  17494. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17495. str3 := make([]byte, 1024)
  17496. str4 := make([]byte, 1024)
  17497. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17498. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17499. //if err != nil {
  17500. // fmt.Println("Error opening file:", err)
  17501. //}
  17502. //defer file.Close()
  17503. //
  17504. //var lastProgram Program
  17505. //scanner := bufio.NewScanner(file)
  17506. //inProgram := false
  17507. //
  17508. //for scanner.Scan() {
  17509. // line := scanner.Text()
  17510. // if strings.Contains(line, "<program>") {
  17511. // inProgram = true
  17512. // programXML := "<program>"
  17513. // for scanner.Scan() {
  17514. // line = scanner.Text()
  17515. // programXML += line
  17516. // if strings.Contains(line, "</program>") {
  17517. // programXML += "</program>"
  17518. // break
  17519. // }
  17520. // }
  17521. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17522. // // 解析成功,更新最后的 Program
  17523. // }
  17524. // inProgram = false
  17525. // }
  17526. //}
  17527. //
  17528. // fmt.Println("Error reading file:", inProgram)
  17529. //
  17530. //if err := scanner.Err(); err != nil {
  17531. // fmt.Println("Error reading file:", err)
  17532. //}
  17533. // 输出最后一次的 Program
  17534. //fmt.Printf("最后一次的 <program>:\n")
  17535. //fmt.Printf("<program>\n")
  17536. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17537. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17538. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17539. //fmt.Printf("</program>\n")
  17540. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17541. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17542. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17543. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17544. return ConvertToString(string(str), "gbk", "utf-8")
  17545. }
  17546. func (c *HisApiController) GetBasBaseInfo22222() string {
  17547. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17548. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17549. if readCard == nil {
  17550. fmt.Println("readcard is nil")
  17551. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17552. }
  17553. str := make([]byte, 1024)
  17554. str1 := make([]byte, 1024)
  17555. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17556. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17557. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17558. //if err != nil {
  17559. // fmt.Println("Error opening file:", err)
  17560. //}
  17561. //defer file.Close()
  17562. //
  17563. //var lastProgram Program
  17564. //scanner := bufio.NewScanner(file)
  17565. //inProgram := false
  17566. //
  17567. //for scanner.Scan() {
  17568. // line := scanner.Text()
  17569. // if strings.Contains(line, "<program>") {
  17570. // inProgram = true
  17571. // programXML := "<program>"
  17572. // for scanner.Scan() {
  17573. // line = scanner.Text()
  17574. // programXML += line
  17575. // if strings.Contains(line, "</program>") {
  17576. // programXML += "</program>"
  17577. // break
  17578. // }
  17579. // }
  17580. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17581. // // 解析成功,更新最后的 Program
  17582. // }
  17583. // inProgram = false
  17584. // }
  17585. //}
  17586. //
  17587. // fmt.Println("Error reading file:", inProgram)
  17588. //
  17589. //if err := scanner.Err(); err != nil {
  17590. // fmt.Println("Error reading file:", err)
  17591. //}
  17592. // 输出最后一次的 Program
  17593. //fmt.Printf("最后一次的 <program>:\n")
  17594. //fmt.Printf("<program>\n")
  17595. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17596. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17597. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17598. //fmt.Printf("</program>\n")
  17599. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17600. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17601. return ConvertToString(string(str1), "gbk", "utf-8")
  17602. }
  17603. func (c *HisApiController) GetahBasBaseInfo() string {
  17604. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17605. readCard := DllDef.MustFindProc("iReadCardBas")
  17606. if readCard == nil {
  17607. fmt.Println("readcard is nil")
  17608. readCard = DllDef.MustFindProc("iReadCardBas")
  17609. }
  17610. //str := make([]byte, 1024)
  17611. str1 := make([]byte, 1024)
  17612. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17613. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17614. //if err != nil {
  17615. // fmt.Println("Error opening file:", err)
  17616. //}
  17617. //defer file.Close()
  17618. //
  17619. //var lastProgram Program
  17620. //scanner := bufio.NewScanner(file)
  17621. //inProgram := false
  17622. //
  17623. //for scanner.Scan() {
  17624. // line := scanner.Text()
  17625. // if strings.Contains(line, "<program>") {
  17626. // inProgram = true
  17627. // programXML := "<program>"
  17628. // for scanner.Scan() {
  17629. // line = scanner.Text()
  17630. // programXML += line
  17631. // if strings.Contains(line, "</program>") {
  17632. // programXML += "</program>"
  17633. // break
  17634. // }
  17635. // }
  17636. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17637. // // 解析成功,更新最后的 Program
  17638. // }
  17639. // inProgram = false
  17640. // }
  17641. //}
  17642. //
  17643. // fmt.Println("Error reading file:", inProgram)
  17644. //
  17645. //if err := scanner.Err(); err != nil {
  17646. // fmt.Println("Error reading file:", err)
  17647. //}
  17648. // 输出最后一次的 Program
  17649. //fmt.Printf("最后一次的 <program>:\n")
  17650. //fmt.Printf("<program>\n")
  17651. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17652. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17653. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17654. //fmt.Printf("</program>\n")
  17655. fmt.Println(string(str1))
  17656. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17657. if ret2 != 0 {
  17658. return ""
  17659. }
  17660. return string(str1)
  17661. }
  17662. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17663. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17664. readCard := DllDef.MustFindProc("read_cardinfo")
  17665. if readCard == nil {
  17666. fmt.Println("readcard is nil")
  17667. readCard = DllDef.MustFindProc("read_cardinfo")
  17668. }
  17669. str := make([]byte, 1024) //卡号
  17670. str1 := make([]byte, 1024) //卡识别码
  17671. str2 := make([]byte, 1024) //身份证号
  17672. str3 := make([]byte, 1024) //姓名
  17673. str4 := make([]byte, 1024) //错误信息
  17674. 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])))
  17675. fmt.Println(string(str1))
  17676. fmt.Println(string(str))
  17677. fmt.Println(string(str2))
  17678. fmt.Println(string(str3))
  17679. fmt.Println(string(str4))
  17680. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17681. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17682. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17683. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17684. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17685. if ret2 != 0 {
  17686. return "", "", "", "", ""
  17687. }
  17688. return string(str), string(str1), string(str2), string(str3), string(str4)
  17689. }
  17690. type CustomFundPay struct {
  17691. FundPayType string `json:"fund_pay_type"`
  17692. FundPayamt float64 `json:"fund_payamt"`
  17693. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17694. }
  17695. //func (c *HisApiController) GetBatchSettleList() {
  17696. // start_time_str := c.GetString("start_time")
  17697. // //end_time_str := c.GetString("end_time")
  17698. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17699. //
  17700. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17701. //
  17702. // for _, item := range orders {
  17703. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17704. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17705. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17706. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17707. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17708. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17709. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17710. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17711. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17712. //
  17713. // if order.ID == 0 {
  17714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17715. // return
  17716. // }
  17717. //
  17718. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17719. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17720. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17721. // //fmt.Println(count)
  17722. // //var zero string
  17723. // //number := count + 1
  17724. // //if number >= 1000 {
  17725. // // zero = "0000" + strconv.FormatInt(number, 10)
  17726. // //} else if number >= 10000 {
  17727. // // zero = "000" + strconv.FormatInt(number, 10)
  17728. // //} else if number >= 100000 {
  17729. // // zero = "00" + strconv.FormatInt(number, 10)
  17730. // //} else if number >= 1000000 {
  17731. // // zero = "0" + strconv.FormatInt(number, 10)
  17732. // //} else {
  17733. // // zero = strconv.FormatInt(number, 10)
  17734. // //}
  17735. // //fmt.Println(zero)
  17736. //
  17737. // struct4101 := service.Struct4101{
  17738. // PsnNo: order.PsnNo,
  17739. // MdtrtId: order.MdtrtId,
  17740. // SetlId: order.SetlId,
  17741. // PsnName: order.PsnName,
  17742. // Gend: order.Gend,
  17743. // Brdy: his.Brdy,
  17744. // Age: his.Age,
  17745. // Naty: order.Naty,
  17746. // PatnCertType: "01",
  17747. // Certno: order.Certno,
  17748. // Prfs: "90",
  17749. // ConerName: roles[0].UserName,
  17750. // PatnRlts: "99",
  17751. // ConerAddr: miConfig.OrgName,
  17752. // ConerTel: admin.Mobile,
  17753. // HiType: order.Insutype,
  17754. // Insuplc: miConfig.InsuplcAdmdvs,
  17755. // MaindiagFlag: "1",
  17756. // BillCode: order.SetlId,
  17757. // BillNo: order.SetlId,
  17758. // BizSn: order.Number,
  17759. // PsnSelfPay: order.PsnPartAmt,
  17760. // PsnOwnPay: order.PsnPartAmt,
  17761. // AcctPay: order.AcctPay,
  17762. // PsnCashpay: order.PsnCashPay,
  17763. // HiPaymtd: "1",
  17764. // Hsorg: miConfig.InsuplcAdmdvs,
  17765. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17766. // MedinsFillPsn: curRoles.UserName,
  17767. // MedinsFillDept: miConfig.OrgName,
  17768. // IptMedType: "2",
  17769. // }
  17770. // struct4101.SetlBegnDate = order.SetlTime
  17771. // struct4101.SetlEndDate = order.SetlTime
  17772. // time_arr := strings.Split(order.SetlTime, " ")
  17773. // struct4101.AdmTime = time_arr[0]
  17774. // struct4101.AdmEndTime = time_arr[0]
  17775. //
  17776. // var rf []CustomFundPay
  17777. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17778. //
  17779. // var tempFunPays []service.CustomStruct
  17780. // for _, item := range rf {
  17781. // var tempFunPay service.CustomStruct
  17782. // tempFunPay.FundPayamt = item.FundPayamt
  17783. // tempFunPay.FundPayType = item.FundPayType
  17784. // tempFunPays = append(tempFunPays, tempFunPay)
  17785. // }
  17786. // struct4101.CustomStruct = tempFunPays
  17787. //
  17788. // var tempDiaginfos []service.DiaginfoStructTwo
  17789. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17790. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17791. //
  17792. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17793. // var config []*models.HisXtDiagnoseConfig
  17794. // for _, item := range diagnosis_ids {
  17795. // id, _ := strconv.ParseInt(item, 10, 64)
  17796. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17797. // config = append(config, &diagnosisConfig)
  17798. // }
  17799. //
  17800. // for index, item := range config {
  17801. // if index == 0 {
  17802. // var tempDiaginfo service.DiaginfoStructTwo
  17803. // tempDiaginfo.DiagCode = item.CountryCode
  17804. // tempDiaginfo.DiagName = item.CountryContentName
  17805. // tempDiaginfo.DiagType = "1"
  17806. // tempDiaginfo.MaindiagFlag = "1"
  17807. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17808. // } else {
  17809. // var tempDiaginfo service.DiaginfoStructTwo
  17810. // tempDiaginfo.DiagCode = item.CountryCode
  17811. // tempDiaginfo.DiagName = item.CountryContentName
  17812. // tempDiaginfo.DiagType = "1"
  17813. // tempDiaginfo.MaindiagFlag = "0"
  17814. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17815. // }
  17816. // }
  17817. // struct4101.Diseinfo = tempDiaginfos
  17818. //
  17819. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17820. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17821. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17822. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17823. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17824. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17825. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17826. //
  17827. // var iteminfo service.IteminfoStruct
  17828. //
  17829. // var bedCostTotal float64 = 0 //床位总费
  17830. // var bedCostSelfTotal float64 = 0 //床位自费
  17831. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17832. //
  17833. // var operationCostTotal float64 = 0 //手术费
  17834. // var operationCostSelfTotal float64 = 0 //手术费
  17835. // var operationCostPartSelfTotal float64 = 0 //手术费
  17836. //
  17837. // var otherCostTotal float64 = 0 //其他费用
  17838. // var otherCostSelfTotal float64 = 0 //其他费用
  17839. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17840. //
  17841. // var materialCostTotal float64 = 0 //材料费
  17842. // var materialCostSelfTotal float64 = 0 //材料费
  17843. // var materialCostPartSelfTotal float64 = 0 //材料费
  17844. //
  17845. // var westernMedicineCostTotal float64 = 0 //西药费
  17846. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17847. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17848. //
  17849. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17850. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17851. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17852. //
  17853. // var checkCostTotal float64 = 0 //检查费
  17854. // var checkCostSelfTotal float64 = 0 //检查费
  17855. // var checkCostPartSelfTotal float64 = 0 //检查费
  17856. //
  17857. // var laboratoryCostTotal float64 = 0 //化验费
  17858. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17859. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17860. //
  17861. // var treatCostTotal float64 = 0 //治疗费用
  17862. // var treatCostSelfTotal float64 = 0 //治疗费用
  17863. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17864. //
  17865. // decimal.DivisionPrecision = 2
  17866. //
  17867. // var bed_fulamt_ownpay_amt float64 = 0
  17868. // var operation_fulamt_ownpay_amt float64 = 0
  17869. // var other_fulamt_ownpay_amt float64 = 0
  17870. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17871. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17872. // var check_fulamt_ownpay_amt float64 = 0
  17873. // var material_fulamt_ownpay_amt float64 = 0
  17874. // var laboratory_fulamt_ownpay_amt float64 = 0
  17875. // var treat_fulamt_ownpay_amt float64 = 0
  17876. //
  17877. // var bed_claa_sunmfee float64 = 0
  17878. // var bed_clab_amt float64 = 0
  17879. // var bed_other_amt float64 = 0
  17880. //
  17881. // var operation_claa_sunmfee float64 = 0
  17882. // var operation_clab_amt float64 = 0
  17883. // var operation_other_amt float64 = 0
  17884. //
  17885. // var other_claa_sunmfee float64 = 0
  17886. // var other_clab_amt float64 = 0
  17887. // var other_other_amt float64 = 0
  17888. //
  17889. // var westernMedicine_claa_sunmfee float64 = 0
  17890. // var westernMedicine_clab_amt float64 = 0
  17891. // var westernMedicine_other_amt float64 = 0
  17892. //
  17893. // var chineseTraditional_claa_sunmfee float64 = 0
  17894. // var chineseTraditional_clab_amt float64 = 0
  17895. // var chineseTraditional_other_amt float64 = 0
  17896. //
  17897. // var check_claa_sunmfee float64 = 0
  17898. // var check_clab_amt float64 = 0
  17899. // var check_other_amt float64 = 0
  17900. //
  17901. // var material_claa_sunmfee float64 = 0
  17902. // var material_clab_amt float64 = 0
  17903. // var material_other_amt float64 = 0
  17904. //
  17905. // var laboratory_claa_sunmfee float64 = 0
  17906. // var laboratory_clab_amt float64 = 0
  17907. // var laboratory_other_amt float64 = 0
  17908. //
  17909. // var treat_claa_sunmfee float64 = 0
  17910. // var treat_clab_amt float64 = 0
  17911. // var treat_other_amt float64 = 0
  17912. //
  17913. // for _, item := range order.HisOrderInfo {
  17914. // if item.MedChrgitmType == "01" { //床位费
  17915. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17916. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17917. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17918. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17919. // if item.ChrgitmLv == "1" {
  17920. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17921. // }
  17922. // if item.ChrgitmLv == "2" {
  17923. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17924. //
  17925. // }
  17926. // if item.ChrgitmLv == "3" {
  17927. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17928. // }
  17929. //
  17930. // }
  17931. //
  17932. // if item.MedChrgitmType == "03" { //检查费
  17933. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17934. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17935. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17936. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17937. // if item.ChrgitmLv == "1" {
  17938. //
  17939. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17940. //
  17941. // }
  17942. // if item.ChrgitmLv == "2" {
  17943. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17944. //
  17945. // }
  17946. // if item.ChrgitmLv == "3" {
  17947. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17948. // }
  17949. // }
  17950. //
  17951. // if item.MedChrgitmType == "04" { //化验费
  17952. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17953. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17954. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17955. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17956. // if item.ChrgitmLv == "1" {
  17957. //
  17958. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17959. //
  17960. // }
  17961. // if item.ChrgitmLv == "2" {
  17962. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17963. //
  17964. // }
  17965. // if item.ChrgitmLv == "3" {
  17966. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17967. // }
  17968. // }
  17969. //
  17970. // if item.MedChrgitmType == "05" { //治疗费
  17971. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17972. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17973. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17974. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17975. // if item.ChrgitmLv == "1" {
  17976. //
  17977. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17978. //
  17979. // }
  17980. // if item.ChrgitmLv == "2" {
  17981. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17982. //
  17983. // }
  17984. // if item.ChrgitmLv == "3" {
  17985. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17986. // }
  17987. // }
  17988. //
  17989. // if item.MedChrgitmType == "06" { //手术费
  17990. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17991. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17992. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17993. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17994. //
  17995. // if item.ChrgitmLv == "1" {
  17996. //
  17997. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17998. //
  17999. // }
  18000. // if item.ChrgitmLv == "2" {
  18001. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18002. //
  18003. // }
  18004. // if item.ChrgitmLv == "3" {
  18005. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18006. // }
  18007. // }
  18008. //
  18009. // if item.MedChrgitmType == "08" { //材料费
  18010. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18011. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18012. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18013. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18014. // if item.ChrgitmLv == "1" {
  18015. //
  18016. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18017. //
  18018. // }
  18019. // if item.ChrgitmLv == "2" {
  18020. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18021. //
  18022. // }
  18023. // if item.ChrgitmLv == "3" {
  18024. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18025. // }
  18026. // }
  18027. //
  18028. // if item.MedChrgitmType == "09" { //西药费
  18029. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18030. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18031. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18032. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18033. // if item.ChrgitmLv == "1" {
  18034. //
  18035. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18036. //
  18037. // }
  18038. // if item.ChrgitmLv == "2" {
  18039. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18040. //
  18041. // }
  18042. // if item.ChrgitmLv == "3" {
  18043. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18044. // }
  18045. // }
  18046. //
  18047. // if item.MedChrgitmType == "11" { //中成费
  18048. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18049. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18050. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18051. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18052. // if item.ChrgitmLv == "1" {
  18053. //
  18054. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18055. //
  18056. // }
  18057. // if item.ChrgitmLv == "2" {
  18058. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18059. //
  18060. // }
  18061. // if item.ChrgitmLv == "3" {
  18062. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18063. // }
  18064. // }
  18065. //
  18066. // if item.MedChrgitmType == "14" { //其他费
  18067. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18068. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18069. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18070. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18071. // if item.ChrgitmLv == "1" {
  18072. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18073. //
  18074. // }
  18075. // if item.ChrgitmLv == "2" {
  18076. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18077. //
  18078. // }
  18079. // if item.ChrgitmLv == "3" {
  18080. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18081. // }
  18082. // }
  18083. //
  18084. // }
  18085. //
  18086. // var iteminfoStructs []service.IteminfoStruct
  18087. //
  18088. // if bedCostTotal != 0 {
  18089. // iteminfo.MedChrgitm = "01"
  18090. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18091. // iteminfo.Amt = bedCostTotal
  18092. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18093. // iteminfo.ClabAmt = bed_clab_amt
  18094. // iteminfo.OthAmt = bed_other_amt
  18095. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18096. // }
  18097. //
  18098. // if checkCostTotal != 0 {
  18099. // iteminfo.MedChrgitm = "03"
  18100. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18101. // iteminfo.Amt = checkCostTotal
  18102. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18103. // iteminfo.ClabAmt = check_clab_amt
  18104. // iteminfo.OthAmt = check_other_amt
  18105. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18106. //
  18107. // }
  18108. //
  18109. // if laboratoryCostTotal != 0 {
  18110. // iteminfo.MedChrgitm = "04"
  18111. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18112. // iteminfo.Amt = laboratoryCostTotal
  18113. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18114. // iteminfo.ClabAmt = laboratory_clab_amt
  18115. // iteminfo.OthAmt = laboratory_other_amt
  18116. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18117. //
  18118. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18119. //
  18120. // }
  18121. //
  18122. // if treatCostTotal != 0 {
  18123. // iteminfo.MedChrgitm = "05"
  18124. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18125. // iteminfo.Amt = treatCostTotal
  18126. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18127. // iteminfo.ClabAmt = treat_clab_amt
  18128. // iteminfo.OthAmt = treat_other_amt
  18129. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18130. // //(struct4101.IteminfoStruct, iteminfo)
  18131. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18132. // }
  18133. //
  18134. // if operationCostTotal != 0 {
  18135. // iteminfo.MedChrgitm = "06"
  18136. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18137. // iteminfo.Amt = operationCostTotal
  18138. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18139. // iteminfo.ClabAmt = operation_clab_amt
  18140. // iteminfo.OthAmt = operation_other_amt
  18141. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18142. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18143. // }
  18144. //
  18145. // if materialCostTotal != 0 {
  18146. // iteminfo.MedChrgitm = "08"
  18147. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18148. // iteminfo.Amt = materialCostTotal
  18149. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18150. // iteminfo.ClabAmt = material_clab_amt
  18151. // iteminfo.OthAmt = material_other_amt
  18152. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18153. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18154. // }
  18155. //
  18156. // if westernMedicineCostTotal != 0 {
  18157. // iteminfo.MedChrgitm = "09"
  18158. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18159. // iteminfo.Amt = westernMedicineCostTotal
  18160. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18161. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18162. // iteminfo.OthAmt = westernMedicine_other_amt
  18163. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18164. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18165. //
  18166. // }
  18167. // if chineseTraditionalMedicineCostTotal != 0 {
  18168. // iteminfo.MedChrgitm = "11"
  18169. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18170. // iteminfo.Amt = westernMedicineCostTotal
  18171. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18172. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18173. // iteminfo.OthAmt = westernMedicine_other_amt
  18174. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18175. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18176. //
  18177. // }
  18178. // if otherCostTotal != 0 {
  18179. // iteminfo.MedChrgitm = "14"
  18180. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18181. // iteminfo.Amt = otherCostTotal
  18182. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18183. // iteminfo.ClabAmt = other_clab_amt
  18184. // iteminfo.OthAmt = other_other_amt
  18185. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18186. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18187. //
  18188. // }
  18189. // struct4101.IteminfoStruct = iteminfoStructs
  18190. // struct4101.Ntly = "中国"
  18191. // struct4101.AdmCaty = "A03.06"
  18192. //
  18193. // struct4101.DoctorName = doctor.UserName
  18194. // struct4101.DoctorCode = doctor.DoctorNumber
  18195. //
  18196. // var res ResultSeventeen
  18197. //
  18198. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18199. // struct4101.BillCode = order.Number
  18200. // struct4101.BillNo = order.SetlId
  18201. // var resOther ResultSeventeenOther
  18202. // var pp models.PublicParams
  18203. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18204. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18205. // pp.FixmedinsName = miConfig.OrgName
  18206. // pp.FixmedinsCode = miConfig.Code
  18207. // pp.RequestUrl = miConfig.Url
  18208. // pp.Cainfo = miConfig.Cainfo
  18209. // pp.SecretKey = miConfig.SecretKey
  18210. // pp.AccessKey = miConfig.AccessKey
  18211. // pp.OpterName = curRoles.UserName
  18212. //
  18213. // client := &http.Client{}
  18214. // var req *http.Request
  18215. // data := make(map[string]interface{})
  18216. // data["struct4101"] = struct4101
  18217. // data["pp"] = pp
  18218. // bytesData, _ := json.Marshal(data)
  18219. // if miConfig.MdtrtareaAdmvs == "320921" {
  18220. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18221. // } else {
  18222. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18223. // }
  18224. // resp, _ := client.Do(req)
  18225. // defer resp.Body.Close()
  18226. // body, ioErr := ioutil.ReadAll(resp.Body)
  18227. // if ioErr != nil {
  18228. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18229. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18230. // return
  18231. // }
  18232. // var respJSON map[string]interface{}
  18233. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18234. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18236. // return
  18237. // }
  18238. //
  18239. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18240. // userJSONBytes, _ := json.Marshal(respJSON)
  18241. // fmt.Println("log")
  18242. // fmt.Println(string(userJSONBytes))
  18243. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18244. // utils.ErrorLog("解析失败:%v", err)
  18245. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18246. // return
  18247. // }
  18248. // res.InfRefmsgid = resOther.InfRefmsgid
  18249. // res.Output = resOther.Output
  18250. // res.ErrMsg = resOther.ErrMsg
  18251. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18252. // res.Infcode = infocode
  18253. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18254. //
  18255. // var pp models.PublicParams
  18256. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18257. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18258. // pp.FixmedinsName = miConfig.OrgName
  18259. // pp.FixmedinsCode = miConfig.Code
  18260. // pp.RequestUrl = miConfig.Url
  18261. // pp.Cainfo = miConfig.Cainfo
  18262. // pp.SecretKey = miConfig.SecretKey
  18263. // pp.AccessKey = miConfig.AccessKey
  18264. // pp.OpterName = curRoles.UserName
  18265. // result, _ := service.Jxyb4101(struct4101, pp)
  18266. // var dat map[string]interface{}
  18267. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18268. // fmt.Println(dat)
  18269. // } else {
  18270. // fmt.Println(err)
  18271. // }
  18272. // userJSONBytes, _ := json.Marshal(dat)
  18273. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18274. // utils.ErrorLog("解析失败:%v", err)
  18275. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18276. // return
  18277. // }
  18278. //
  18279. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18280. // var pp models.PublicParams
  18281. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18282. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18283. // pp.FixmedinsName = miConfig.OrgName
  18284. // pp.FixmedinsCode = miConfig.Code
  18285. // pp.RequestUrl = miConfig.Url
  18286. // pp.Cainfo = miConfig.Cainfo
  18287. // pp.SecretKey = miConfig.SecretKey
  18288. // pp.AccessKey = miConfig.AccessKey
  18289. // pp.OpterName = curRoles.UserName
  18290. // result, _ := service.Hnyb4101(struct4101, pp)
  18291. // var dat map[string]interface{}
  18292. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18293. // fmt.Println(dat)
  18294. // } else {
  18295. // fmt.Println(err)
  18296. // }
  18297. // userJSONBytes, _ := json.Marshal(dat)
  18298. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18299. // utils.ErrorLog("解析失败:%v", err)
  18300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18301. // return
  18302. // }
  18303. //
  18304. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18305. // var resOther ResultSeventeenOther
  18306. //
  18307. // var pp models.PublicParams
  18308. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18309. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18310. // pp.FixmedinsName = miConfig.OrgName
  18311. // pp.FixmedinsCode = miConfig.Code
  18312. // pp.RequestUrl = miConfig.Url
  18313. // pp.Cainfo = miConfig.Cainfo
  18314. // pp.SecretKey = miConfig.SecretKey
  18315. // pp.AccessKey = miConfig.AccessKey
  18316. // pp.OpterName = curRoles.UserName
  18317. // client := &http.Client{}
  18318. // var req *http.Request
  18319. // data := make(map[string]interface{})
  18320. // data["struct4101"] = struct4101
  18321. // data["pp"] = pp
  18322. // bytesData, _ := json.Marshal(data)
  18323. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18324. // resp, _ := client.Do(req)
  18325. // defer resp.Body.Close()
  18326. // body, ioErr := ioutil.ReadAll(resp.Body)
  18327. // if ioErr != nil {
  18328. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18330. // return
  18331. // }
  18332. // var respJSON map[string]interface{}
  18333. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18334. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18336. // return
  18337. // }
  18338. //
  18339. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18340. // userJSONBytes, _ := json.Marshal(respJSON)
  18341. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18342. // utils.ErrorLog("解析失败:%v", err)
  18343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18344. // return
  18345. // }
  18346. // res.InfRefmsgid = resOther.InfRefmsgid
  18347. // res.Output = resOther.Output
  18348. // res.ErrMsg = resOther.ErrMsg
  18349. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18350. // res.Infcode = infocode
  18351. //
  18352. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18353. // var pp models.PublicParams
  18354. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18355. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18356. // pp.FixmedinsName = miConfig.OrgName
  18357. // pp.FixmedinsCode = miConfig.Code
  18358. // pp.RequestUrl = miConfig.Url
  18359. // pp.Cainfo = miConfig.Cainfo
  18360. // pp.SecretKey = miConfig.SecretKey
  18361. // pp.AccessKey = miConfig.AccessKey
  18362. // pp.OpterName = curRoles.UserName
  18363. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18364. // fmt.Println(requestLog)
  18365. // fmt.Println(errMsgLog)
  18366. //
  18367. // saveLog(result, requestLog, "4101a", "上传清单")
  18368. //
  18369. // var dat map[string]interface{}
  18370. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18371. // fmt.Println(dat)
  18372. // } else {
  18373. // fmt.Println(err)
  18374. // }
  18375. // userJSONBytes, _ := json.Marshal(dat)
  18376. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18377. // utils.ErrorLog("解析失败:%v", err)
  18378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18379. // return
  18380. // }
  18381. //
  18382. // } else {
  18383. //
  18384. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18385. // var dat map[string]interface{}
  18386. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18387. // fmt.Println(dat)
  18388. // } else {
  18389. // fmt.Println(err)
  18390. // }
  18391. // userJSONBytes, _ := json.Marshal(dat)
  18392. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18393. // utils.ErrorLog("解析失败:%v", err)
  18394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18395. // return
  18396. // }
  18397. // }
  18398. //
  18399. // if res.Infcode != 0 {
  18400. // adminUser := c.GetAdminUserInfo()
  18401. // errlog := &models.HisOrderError{
  18402. // UserOrgId: adminUser.CurrentOrgId,
  18403. // Ctime: time.Now().Unix(),
  18404. // Mtime: time.Now().Unix(),
  18405. // ErrMsg: res.ErrMsg,
  18406. // Status: 1,
  18407. // PatientId: order.ID,
  18408. // Stage: 10265,
  18409. // }
  18410. // service.CreateErrMsgLog(errlog)
  18411. // continue
  18412. // } else {
  18413. // //order.FaPiaoNumber = zero
  18414. // //order.FaPiaoCode = last_order.FaPiaoCode
  18415. // //service.UpdateOrder(order)
  18416. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18417. // Number: res.Output.SetlListId,
  18418. // Status: 1,
  18419. // Ctime: time.Now().Unix(),
  18420. // Mtime: time.Now().Unix(),
  18421. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18422. // IsUpload: 1,
  18423. // OrderId: order.ID,
  18424. // }
  18425. // service.CreateUploadRecord(hisFundSettleListResult)
  18426. // c.ServeSuccessJSON(map[string]interface{}{
  18427. // "msg": "上传成功",
  18428. // "result": hisFundSettleListResult,
  18429. // })
  18430. // continue
  18431. // }
  18432. // }
  18433. //}
  18434. func (c *HisApiController) GetbatchSettleList() {
  18435. //order_id, _ := c.GetInt64("order_id")
  18436. admin_user_id, _ := c.GetInt64("admin_user_id")
  18437. orders, _ := service.GetAllHisOrderTwo10485()
  18438. for _, item := range orders {
  18439. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18440. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18441. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18442. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18443. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18444. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18445. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18446. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18447. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18448. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18449. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18450. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18451. //fmt.Println(count)
  18452. //var zero string
  18453. //number := count + 1
  18454. //if number >= 1000 {
  18455. // zero = "0000" + strconv.FormatInt(number, 10)
  18456. //} else if number >= 10000 {
  18457. // zero = "000" + strconv.FormatInt(number, 10)
  18458. //} else if number >= 100000 {
  18459. // zero = "00" + strconv.FormatInt(number, 10)
  18460. //} else if number >= 1000000 {
  18461. // zero = "0" + strconv.FormatInt(number, 10)
  18462. //} else {
  18463. // zero = strconv.FormatInt(number, 10)
  18464. //}
  18465. //fmt.Println(zero)
  18466. struct4101 := service.Struct4101{
  18467. PsnNo: order.PsnNo,
  18468. MdtrtId: order.MdtrtId,
  18469. SetlId: order.SetlId,
  18470. PsnName: order.PsnName,
  18471. Gend: order.Gend,
  18472. Brdy: his.Brdy,
  18473. Age: his.Age,
  18474. Naty: order.Naty,
  18475. PatnCertType: "01",
  18476. Certno: order.Certno,
  18477. Prfs: "90",
  18478. ConerName: roles[0].UserName,
  18479. PatnRlts: "99",
  18480. ConerAddr: miConfig.OrgName,
  18481. ConerTel: admin.Mobile,
  18482. HiType: order.Insutype,
  18483. Insuplc: miConfig.InsuplcAdmdvs,
  18484. MaindiagFlag: "1",
  18485. BillCode: order.SetlId,
  18486. BillNo: order.SetlId,
  18487. BizSn: order.Number,
  18488. PsnSelfPay: order.PsnPartAmt,
  18489. PsnOwnPay: order.PsnPartAmt,
  18490. AcctPay: order.AcctPay,
  18491. PsnCashpay: order.PsnCashPay,
  18492. HiPaymtd: "1",
  18493. Hsorg: miConfig.InsuplcAdmdvs,
  18494. HsorgOpter: miConfig.InsuplcAdmdvs,
  18495. MedinsFillPsn: curRoles.UserName,
  18496. MedinsFillDept: miConfig.OrgName,
  18497. IptMedType: "2",
  18498. }
  18499. struct4101.SetlBegnDate = order.SetlTime
  18500. struct4101.SetlEndDate = order.SetlTime
  18501. time_arr := strings.Split(order.SetlTime, " ")
  18502. struct4101.AdmTime = time_arr[0]
  18503. struct4101.AdmEndTime = time_arr[0]
  18504. //var rf []CustomFundPay
  18505. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18506. //
  18507. //var tempFunPays []service.CustomStruct
  18508. //for _, item := range rf {
  18509. // var tempFunPay service.CustomStruct
  18510. // tempFunPay.FundPayamt = item.FundPayamt
  18511. // tempFunPay.FundPayType = item.FundPayType
  18512. // tempFunPays = append(tempFunPays, tempFunPay)
  18513. //}
  18514. //struct4101.CustomStruct = tempFunPays
  18515. var tempDiaginfos []service.DiaginfoStructTwo
  18516. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18517. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18518. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18519. var config []*models.HisXtDiagnoseConfig
  18520. for _, item := range diagnosis_ids {
  18521. id, _ := strconv.ParseInt(item, 10, 64)
  18522. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18523. config = append(config, &diagnosisConfig)
  18524. }
  18525. for index, item := range config {
  18526. if index == 0 {
  18527. var tempDiaginfo service.DiaginfoStructTwo
  18528. tempDiaginfo.DiagCode = item.CountryCode
  18529. tempDiaginfo.DiagName = item.CountryContentName
  18530. tempDiaginfo.DiagType = "1"
  18531. tempDiaginfo.MaindiagFlag = "1"
  18532. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18533. } else {
  18534. var tempDiaginfo service.DiaginfoStructTwo
  18535. tempDiaginfo.DiagCode = item.CountryCode
  18536. tempDiaginfo.DiagName = item.CountryContentName
  18537. tempDiaginfo.DiagType = "1"
  18538. tempDiaginfo.MaindiagFlag = "0"
  18539. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18540. }
  18541. }
  18542. struct4101.Diseinfo = tempDiaginfos
  18543. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18544. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18545. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18546. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18547. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18548. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18549. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18550. var iteminfo service.IteminfoStruct
  18551. var bedCostTotal float64 = 0 //床位总费
  18552. var bedCostSelfTotal float64 = 0 //床位自费
  18553. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18554. var operationCostTotal float64 = 0 //手术费
  18555. var operationCostSelfTotal float64 = 0 //手术费
  18556. var operationCostPartSelfTotal float64 = 0 //手术费
  18557. var otherCostTotal float64 = 0 //其他费用
  18558. var otherCostSelfTotal float64 = 0 //其他费用
  18559. var otherCostPartSelfTotal float64 = 0 //其他费用
  18560. var materialCostTotal float64 = 0 //材料费
  18561. var materialCostSelfTotal float64 = 0 //材料费
  18562. var materialCostPartSelfTotal float64 = 0 //材料费
  18563. var westernMedicineCostTotal float64 = 0 //西药费
  18564. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18565. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18566. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18567. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18568. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18569. var checkCostTotal float64 = 0 //检查费
  18570. var checkCostSelfTotal float64 = 0 //检查费
  18571. var checkCostPartSelfTotal float64 = 0 //检查费
  18572. var laboratoryCostTotal float64 = 0 //化验费
  18573. var laboratoryCostSelfTotal float64 = 0 //化验费
  18574. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18575. var treatCostTotal float64 = 0 //治疗费用
  18576. var treatCostSelfTotal float64 = 0 //治疗费用
  18577. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18578. decimal.DivisionPrecision = 2
  18579. var bed_fulamt_ownpay_amt float64 = 0
  18580. var operation_fulamt_ownpay_amt float64 = 0
  18581. var other_fulamt_ownpay_amt float64 = 0
  18582. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18583. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18584. var check_fulamt_ownpay_amt float64 = 0
  18585. var material_fulamt_ownpay_amt float64 = 0
  18586. var laboratory_fulamt_ownpay_amt float64 = 0
  18587. var treat_fulamt_ownpay_amt float64 = 0
  18588. var bed_claa_sunmfee float64 = 0
  18589. var bed_clab_amt float64 = 0
  18590. var bed_other_amt float64 = 0
  18591. var operation_claa_sunmfee float64 = 0
  18592. var operation_clab_amt float64 = 0
  18593. var operation_other_amt float64 = 0
  18594. var other_claa_sunmfee float64 = 0
  18595. var other_clab_amt float64 = 0
  18596. var other_other_amt float64 = 0
  18597. var westernMedicine_claa_sunmfee float64 = 0
  18598. var westernMedicine_clab_amt float64 = 0
  18599. var westernMedicine_other_amt float64 = 0
  18600. var chineseTraditional_claa_sunmfee float64 = 0
  18601. var chineseTraditional_clab_amt float64 = 0
  18602. var chineseTraditional_other_amt float64 = 0
  18603. var check_claa_sunmfee float64 = 0
  18604. var check_clab_amt float64 = 0
  18605. var check_other_amt float64 = 0
  18606. var material_claa_sunmfee float64 = 0
  18607. var material_clab_amt float64 = 0
  18608. var material_other_amt float64 = 0
  18609. var laboratory_claa_sunmfee float64 = 0
  18610. var laboratory_clab_amt float64 = 0
  18611. var laboratory_other_amt float64 = 0
  18612. var treat_claa_sunmfee float64 = 0
  18613. var treat_clab_amt float64 = 0
  18614. var treat_other_amt float64 = 0
  18615. for _, item := range order.HisOrderInfo {
  18616. if item.MedChrgitmType == "01" { //床位费
  18617. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18618. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18619. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18620. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18621. if item.ChrgitmLv == "1" {
  18622. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18623. }
  18624. if item.ChrgitmLv == "2" {
  18625. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18626. }
  18627. if item.ChrgitmLv == "3" {
  18628. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18629. }
  18630. }
  18631. if item.MedChrgitmType == "03" { //检查费
  18632. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18633. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18634. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18635. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18636. if item.ChrgitmLv == "1" {
  18637. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18638. }
  18639. if item.ChrgitmLv == "2" {
  18640. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18641. }
  18642. if item.ChrgitmLv == "3" {
  18643. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18644. }
  18645. }
  18646. if item.MedChrgitmType == "04" { //化验费
  18647. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18648. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18649. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18650. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18651. if item.ChrgitmLv == "1" {
  18652. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18653. }
  18654. if item.ChrgitmLv == "2" {
  18655. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18656. }
  18657. if item.ChrgitmLv == "3" {
  18658. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18659. }
  18660. }
  18661. if item.MedChrgitmType == "05" { //治疗费
  18662. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18663. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18664. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18665. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18666. if item.ChrgitmLv == "1" {
  18667. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18668. }
  18669. if item.ChrgitmLv == "2" {
  18670. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18671. }
  18672. if item.ChrgitmLv == "3" {
  18673. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18674. }
  18675. }
  18676. if item.MedChrgitmType == "06" { //手术费
  18677. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18678. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18679. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18680. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18681. if item.ChrgitmLv == "1" {
  18682. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18683. }
  18684. if item.ChrgitmLv == "2" {
  18685. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18686. }
  18687. if item.ChrgitmLv == "3" {
  18688. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18689. }
  18690. }
  18691. if item.MedChrgitmType == "08" { //材料费
  18692. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18693. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18694. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18695. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18696. if item.ChrgitmLv == "1" {
  18697. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18698. }
  18699. if item.ChrgitmLv == "2" {
  18700. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18701. }
  18702. if item.ChrgitmLv == "3" {
  18703. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18704. }
  18705. }
  18706. if item.MedChrgitmType == "09" { //西药费
  18707. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18708. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18709. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18710. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18711. if item.ChrgitmLv == "1" {
  18712. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18713. }
  18714. if item.ChrgitmLv == "2" {
  18715. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18716. }
  18717. if item.ChrgitmLv == "3" {
  18718. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18719. }
  18720. }
  18721. if item.MedChrgitmType == "11" { //中成费
  18722. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18723. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18724. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18725. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18726. if item.ChrgitmLv == "1" {
  18727. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18728. }
  18729. if item.ChrgitmLv == "2" {
  18730. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18731. }
  18732. if item.ChrgitmLv == "3" {
  18733. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18734. }
  18735. }
  18736. if item.MedChrgitmType == "14" { //其他费
  18737. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18738. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18739. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18740. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18741. if item.ChrgitmLv == "1" {
  18742. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18743. }
  18744. if item.ChrgitmLv == "2" {
  18745. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18746. }
  18747. if item.ChrgitmLv == "3" {
  18748. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18749. }
  18750. }
  18751. }
  18752. var iteminfoStructs []service.IteminfoStruct
  18753. if bedCostTotal != 0 {
  18754. iteminfo.MedChrgitm = "01"
  18755. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18756. iteminfo.Amt = bedCostTotal
  18757. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18758. iteminfo.ClabAmt = bed_clab_amt
  18759. iteminfo.OthAmt = bed_other_amt
  18760. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18761. }
  18762. if checkCostTotal != 0 {
  18763. iteminfo.MedChrgitm = "03"
  18764. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18765. iteminfo.Amt = checkCostTotal
  18766. iteminfo.ClaaSumfee = check_claa_sunmfee
  18767. iteminfo.ClabAmt = check_clab_amt
  18768. iteminfo.OthAmt = check_other_amt
  18769. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18770. }
  18771. if laboratoryCostTotal != 0 {
  18772. iteminfo.MedChrgitm = "04"
  18773. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18774. iteminfo.Amt = laboratoryCostTotal
  18775. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18776. iteminfo.ClabAmt = laboratory_clab_amt
  18777. iteminfo.OthAmt = laboratory_other_amt
  18778. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18779. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18780. }
  18781. if treatCostTotal != 0 {
  18782. iteminfo.MedChrgitm = "05"
  18783. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18784. iteminfo.Amt = treatCostTotal
  18785. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18786. iteminfo.ClabAmt = treat_clab_amt
  18787. iteminfo.OthAmt = treat_other_amt
  18788. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18789. //(struct4101.IteminfoStruct, iteminfo)
  18790. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18791. }
  18792. if operationCostTotal != 0 {
  18793. iteminfo.MedChrgitm = "06"
  18794. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18795. iteminfo.Amt = operationCostTotal
  18796. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18797. iteminfo.ClabAmt = operation_clab_amt
  18798. iteminfo.OthAmt = operation_other_amt
  18799. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18800. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18801. }
  18802. if materialCostTotal != 0 {
  18803. iteminfo.MedChrgitm = "08"
  18804. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18805. iteminfo.Amt = materialCostTotal
  18806. iteminfo.ClaaSumfee = material_claa_sunmfee
  18807. iteminfo.ClabAmt = material_clab_amt
  18808. iteminfo.OthAmt = material_other_amt
  18809. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18810. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18811. }
  18812. if westernMedicineCostTotal != 0 {
  18813. iteminfo.MedChrgitm = "09"
  18814. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18815. iteminfo.Amt = westernMedicineCostTotal
  18816. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18817. iteminfo.ClabAmt = westernMedicine_clab_amt
  18818. iteminfo.OthAmt = westernMedicine_other_amt
  18819. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18820. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18821. }
  18822. if chineseTraditionalMedicineCostTotal != 0 {
  18823. iteminfo.MedChrgitm = "11"
  18824. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18825. iteminfo.Amt = westernMedicineCostTotal
  18826. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18827. iteminfo.ClabAmt = westernMedicine_clab_amt
  18828. iteminfo.OthAmt = westernMedicine_other_amt
  18829. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18830. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18831. }
  18832. if otherCostTotal != 0 {
  18833. iteminfo.MedChrgitm = "14"
  18834. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18835. iteminfo.Amt = otherCostTotal
  18836. iteminfo.ClaaSumfee = other_claa_sunmfee
  18837. iteminfo.ClabAmt = other_clab_amt
  18838. iteminfo.OthAmt = other_other_amt
  18839. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18840. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18841. }
  18842. struct4101.IteminfoStruct = iteminfoStructs
  18843. struct4101.Ntly = "中国"
  18844. struct4101.AdmCaty = "A03.06"
  18845. struct4101.DoctorName = doctor.UserName
  18846. struct4101.DoctorCode = doctor.DoctorNumber
  18847. var res ResultSeventeen
  18848. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18849. struct4101.BillCode = order.Number
  18850. struct4101.BillNo = order.SetlId
  18851. var resOther ResultSeventeenOther
  18852. var pp models.PublicParams
  18853. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18854. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18855. pp.FixmedinsName = miConfig.OrgName
  18856. pp.FixmedinsCode = miConfig.Code
  18857. pp.RequestUrl = miConfig.Url
  18858. pp.Cainfo = miConfig.Cainfo
  18859. pp.SecretKey = miConfig.SecretKey
  18860. pp.AccessKey = miConfig.AccessKey
  18861. pp.OpterName = curRoles.UserName
  18862. client := &http.Client{}
  18863. var req *http.Request
  18864. data := make(map[string]interface{})
  18865. data["struct4101"] = struct4101
  18866. data["pp"] = pp
  18867. bytesData, _ := json.Marshal(data)
  18868. if miConfig.MdtrtareaAdmvs == "320921" {
  18869. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18870. } else {
  18871. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18872. }
  18873. resp, _ := client.Do(req)
  18874. defer resp.Body.Close()
  18875. body, ioErr := ioutil.ReadAll(resp.Body)
  18876. if ioErr != nil {
  18877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18879. return
  18880. }
  18881. var respJSON map[string]interface{}
  18882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18885. return
  18886. }
  18887. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18888. userJSONBytes, _ := json.Marshal(respJSON)
  18889. fmt.Println("log")
  18890. fmt.Println(string(userJSONBytes))
  18891. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18892. utils.ErrorLog("解析失败:%v", err)
  18893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18894. return
  18895. }
  18896. res.InfRefmsgid = resOther.InfRefmsgid
  18897. res.Output = resOther.Output
  18898. res.ErrMsg = resOther.ErrMsg
  18899. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18900. res.Infcode = infocode
  18901. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18902. var pp models.PublicParams
  18903. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18904. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18905. pp.FixmedinsName = miConfig.OrgName
  18906. pp.FixmedinsCode = miConfig.Code
  18907. pp.RequestUrl = miConfig.Url
  18908. pp.Cainfo = miConfig.Cainfo
  18909. pp.SecretKey = miConfig.SecretKey
  18910. pp.AccessKey = miConfig.AccessKey
  18911. pp.OpterName = curRoles.UserName
  18912. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18913. result, _ := service.Jxyb4101(struct4101, pp)
  18914. var dat map[string]interface{}
  18915. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18916. fmt.Println(dat)
  18917. } else {
  18918. fmt.Println(err)
  18919. }
  18920. userJSONBytes, _ := json.Marshal(dat)
  18921. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18922. utils.ErrorLog("解析失败:%v", err)
  18923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18924. return
  18925. }
  18926. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18927. var pp models.PublicParams
  18928. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18929. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18930. pp.FixmedinsName = miConfig.OrgName
  18931. pp.FixmedinsCode = miConfig.Code
  18932. pp.RequestUrl = miConfig.Url
  18933. pp.Cainfo = miConfig.Cainfo
  18934. pp.SecretKey = miConfig.SecretKey
  18935. pp.AccessKey = miConfig.AccessKey
  18936. pp.OpterName = curRoles.UserName
  18937. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18938. result, _ := service.Jxyb4101(struct4101, pp)
  18939. var dat map[string]interface{}
  18940. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18941. fmt.Println(dat)
  18942. } else {
  18943. fmt.Println(err)
  18944. }
  18945. userJSONBytes, _ := json.Marshal(dat)
  18946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18947. utils.ErrorLog("解析失败:%v", err)
  18948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18949. return
  18950. }
  18951. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18952. var pp models.PublicParams
  18953. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18954. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18955. pp.FixmedinsName = miConfig.OrgName
  18956. pp.FixmedinsCode = miConfig.Code
  18957. pp.RequestUrl = miConfig.Url
  18958. pp.Cainfo = miConfig.Cainfo
  18959. pp.SecretKey = miConfig.SecretKey
  18960. pp.AccessKey = miConfig.AccessKey
  18961. pp.OpterName = curRoles.UserName
  18962. result, _ := service.Hnyb4101(struct4101, pp)
  18963. var dat map[string]interface{}
  18964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18965. fmt.Println(dat)
  18966. } else {
  18967. fmt.Println(err)
  18968. }
  18969. userJSONBytes, _ := json.Marshal(dat)
  18970. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18971. utils.ErrorLog("解析失败:%v", err)
  18972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18973. return
  18974. }
  18975. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18976. var resOther ResultSeventeenOther
  18977. var pp models.PublicParams
  18978. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18979. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18980. pp.FixmedinsName = miConfig.OrgName
  18981. pp.FixmedinsCode = miConfig.Code
  18982. pp.RequestUrl = miConfig.Url
  18983. pp.Cainfo = miConfig.Cainfo
  18984. pp.SecretKey = miConfig.SecretKey
  18985. pp.AccessKey = miConfig.AccessKey
  18986. pp.OpterName = curRoles.UserName
  18987. client := &http.Client{}
  18988. var req *http.Request
  18989. data := make(map[string]interface{})
  18990. data["struct4101"] = struct4101
  18991. data["pp"] = pp
  18992. bytesData, _ := json.Marshal(data)
  18993. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18994. resp, _ := client.Do(req)
  18995. defer resp.Body.Close()
  18996. body, ioErr := ioutil.ReadAll(resp.Body)
  18997. if ioErr != nil {
  18998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19000. return
  19001. }
  19002. var respJSON map[string]interface{}
  19003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19006. return
  19007. }
  19008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19009. userJSONBytes, _ := json.Marshal(respJSON)
  19010. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19011. utils.ErrorLog("解析失败:%v", err)
  19012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19013. return
  19014. }
  19015. res.InfRefmsgid = resOther.InfRefmsgid
  19016. res.Output = resOther.Output
  19017. res.ErrMsg = resOther.ErrMsg
  19018. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19019. res.Infcode = infocode
  19020. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19021. var pp models.PublicParams
  19022. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19023. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19024. pp.FixmedinsName = miConfig.OrgName
  19025. pp.FixmedinsCode = miConfig.Code
  19026. pp.RequestUrl = miConfig.Url
  19027. pp.Cainfo = miConfig.Cainfo
  19028. pp.SecretKey = miConfig.SecretKey
  19029. pp.AccessKey = miConfig.AccessKey
  19030. pp.OpterName = curRoles.UserName
  19031. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19032. fmt.Println(requestLog)
  19033. fmt.Println(errMsgLog)
  19034. saveLog(result, requestLog, "4101a", "上传清单")
  19035. var dat map[string]interface{}
  19036. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19037. fmt.Println(dat)
  19038. } else {
  19039. fmt.Println(err)
  19040. }
  19041. userJSONBytes, _ := json.Marshal(dat)
  19042. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19043. utils.ErrorLog("解析失败:%v", err)
  19044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19045. return
  19046. }
  19047. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19048. var pp models.PublicParams
  19049. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19050. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19051. pp.FixmedinsName = miConfig.OrgName
  19052. pp.FixmedinsCode = miConfig.Code
  19053. pp.RequestUrl = miConfig.Url
  19054. pp.Cainfo = miConfig.Cainfo
  19055. pp.SecretKey = miConfig.SecretKey
  19056. pp.AccessKey = miConfig.AccessKey
  19057. pp.OpterName = curRoles.UserName
  19058. client := &http.Client{}
  19059. var req *http.Request
  19060. data := make(map[string]interface{})
  19061. data["struct4101"] = struct4101
  19062. data["pp"] = pp
  19063. bytesData, _ := json.Marshal(data)
  19064. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19065. resp, _ := client.Do(req)
  19066. defer resp.Body.Close()
  19067. body, ioErr := ioutil.ReadAll(resp.Body)
  19068. if ioErr != nil {
  19069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19071. return
  19072. }
  19073. var respJSON map[string]interface{}
  19074. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19077. return
  19078. }
  19079. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19080. userJSONBytes, _ := json.Marshal(respJSON)
  19081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19082. utils.ErrorLog("解析失败:%v", err)
  19083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19084. return
  19085. }
  19086. } else {
  19087. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19088. var dat map[string]interface{}
  19089. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19090. fmt.Println(dat)
  19091. } else {
  19092. fmt.Println(err)
  19093. }
  19094. userJSONBytes, _ := json.Marshal(dat)
  19095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19096. utils.ErrorLog("解析失败:%v", err)
  19097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19098. return
  19099. }
  19100. }
  19101. if res.Infcode != 0 {
  19102. errlog := &models.HisOrderError{
  19103. UserOrgId: order.UserOrgId,
  19104. Ctime: time.Now().Unix(),
  19105. Mtime: time.Now().Unix(),
  19106. ErrMsg: res.ErrMsg + "解析失败",
  19107. Status: 1,
  19108. PatientId: order.ID,
  19109. Stage: 10485,
  19110. }
  19111. service.CreateErrMsgLog(errlog)
  19112. continue
  19113. //c.ServeSuccessJSON(map[string]interface{}{
  19114. // "failed_code": -10,
  19115. // "msg": res.ErrMsg,
  19116. //})
  19117. } else {
  19118. //order.FaPiaoNumber = zero
  19119. //order.FaPiaoCode = last_order.FaPiaoCode
  19120. //service.UpdateOrder(order)
  19121. hisFundSettleListResult := &models.HisFundSettleListResult{
  19122. Number: res.Output.SetlListId,
  19123. Status: 1,
  19124. Ctime: time.Now().Unix(),
  19125. Mtime: time.Now().Unix(),
  19126. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19127. IsUpload: 1,
  19128. OrderId: order.ID,
  19129. }
  19130. service.CreateUploadRecord(hisFundSettleListResult)
  19131. continue
  19132. }
  19133. }
  19134. }
  19135. func (c *HisApiController) GetSettleList() {
  19136. order_id, _ := c.GetInt64("order_id")
  19137. admin_user_id, _ := c.GetInt64("admin_user_id")
  19138. order, _ := service.GetHisOrderByIDTwo(order_id)
  19139. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19140. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19141. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19142. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19143. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19144. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19145. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19146. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19147. if order.ID == 0 {
  19148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19149. return
  19150. }
  19151. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19152. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19153. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19154. //fmt.Println(count)
  19155. //var zero string
  19156. //number := count + 1
  19157. //if number >= 1000 {
  19158. // zero = "0000" + strconv.FormatInt(number, 10)
  19159. //} else if number >= 10000 {
  19160. // zero = "000" + strconv.FormatInt(number, 10)
  19161. //} else if number >= 100000 {
  19162. // zero = "00" + strconv.FormatInt(number, 10)
  19163. //} else if number >= 1000000 {
  19164. // zero = "0" + strconv.FormatInt(number, 10)
  19165. //} else {
  19166. // zero = strconv.FormatInt(number, 10)
  19167. //}
  19168. //fmt.Println(zero)
  19169. struct4101 := service.Struct4101{
  19170. PsnNo: order.PsnNo,
  19171. MdtrtId: order.MdtrtId,
  19172. SetlId: order.SetlId,
  19173. PsnName: order.PsnName,
  19174. Gend: order.Gend,
  19175. Brdy: his.Brdy,
  19176. Age: his.Age,
  19177. Naty: order.Naty,
  19178. PatnCertType: "01",
  19179. Certno: order.Certno,
  19180. Prfs: "90",
  19181. ConerName: roles[0].UserName,
  19182. PatnRlts: "99",
  19183. ConerAddr: miConfig.OrgName,
  19184. ConerTel: admin.Mobile,
  19185. HiType: order.Insutype,
  19186. Insuplc: miConfig.InsuplcAdmdvs,
  19187. MaindiagFlag: "1",
  19188. BillCode: order.SetlId,
  19189. BillNo: order.SetlId,
  19190. BizSn: order.Number,
  19191. PsnSelfPay: order.PsnPartAmt,
  19192. PsnOwnPay: order.PsnPartAmt,
  19193. AcctPay: order.AcctPay,
  19194. PsnCashpay: order.PsnCashPay,
  19195. HiPaymtd: "1",
  19196. Hsorg: miConfig.InsuplcAdmdvs,
  19197. HsorgOpter: miConfig.InsuplcAdmdvs,
  19198. MedinsFillPsn: curRoles.UserName,
  19199. MedinsFillDept: miConfig.OrgName,
  19200. IptMedType: "2",
  19201. }
  19202. struct4101.SetlBegnDate = order.SetlTime
  19203. struct4101.SetlEndDate = order.SetlTime
  19204. time_arr := strings.Split(order.SetlTime, " ")
  19205. struct4101.AdmTime = time_arr[0]
  19206. struct4101.AdmEndTime = time_arr[0]
  19207. //
  19208. //var rf []CustomFundPay
  19209. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19210. //
  19211. //var tempFunPays []service.CustomStruct
  19212. //for _, item := range rf {
  19213. // var tempFunPay service.CustomStruct
  19214. // tempFunPay.FundPayamt = item.FundPayamt
  19215. // tempFunPay.FundPayType = item.FundPayType
  19216. // tempFunPays = append(tempFunPays, tempFunPay)
  19217. //}
  19218. //struct4101.CustomStruct = tempFunPays
  19219. var tempDiaginfos []service.DiaginfoStructTwo
  19220. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19221. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19222. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19223. var config []*models.HisXtDiagnoseConfig
  19224. for _, item := range diagnosis_ids {
  19225. id, _ := strconv.ParseInt(item, 10, 64)
  19226. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19227. config = append(config, &diagnosisConfig)
  19228. }
  19229. if miConfig.Code == "H15049901371" {
  19230. //for _, item := range config {
  19231. // if item.ID == 138 {
  19232. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19233. var tempDiaginfo service.DiaginfoStructTwo
  19234. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19235. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19236. tempDiaginfo.DiagType = "1"
  19237. tempDiaginfo.MaindiagFlag = "1"
  19238. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19239. //}
  19240. //}
  19241. for _, item := range config {
  19242. if item.ID != 138 {
  19243. var tempDiaginfo service.DiaginfoStructTwo
  19244. tempDiaginfo.DiagCode = item.CountryCode
  19245. tempDiaginfo.DiagName = item.CountryContentName
  19246. tempDiaginfo.DiagType = "1"
  19247. tempDiaginfo.MaindiagFlag = "0"
  19248. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19249. }
  19250. }
  19251. } else {
  19252. for index, item := range config {
  19253. if index == 0 {
  19254. var tempDiaginfo service.DiaginfoStructTwo
  19255. tempDiaginfo.DiagCode = item.CountryCode
  19256. tempDiaginfo.DiagName = item.CountryContentName
  19257. tempDiaginfo.DiagType = "1"
  19258. tempDiaginfo.MaindiagFlag = "1"
  19259. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19260. } else {
  19261. var tempDiaginfo service.DiaginfoStructTwo
  19262. tempDiaginfo.DiagCode = item.CountryCode
  19263. tempDiaginfo.DiagName = item.CountryContentName
  19264. tempDiaginfo.DiagType = "1"
  19265. tempDiaginfo.MaindiagFlag = "0"
  19266. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19267. }
  19268. }
  19269. }
  19270. struct4101.Diseinfo = tempDiaginfos
  19271. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19272. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19273. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19274. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19275. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19276. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19277. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19278. var iteminfo service.IteminfoStruct
  19279. var bedCostTotal float64 = 0 //床位总费
  19280. var bedCostSelfTotal float64 = 0 //床位自费
  19281. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19282. var operationCostTotal float64 = 0 //手术费
  19283. var operationCostSelfTotal float64 = 0 //手术费
  19284. var operationCostPartSelfTotal float64 = 0 //手术费
  19285. var otherCostTotal float64 = 0 //其他费用
  19286. var otherCostSelfTotal float64 = 0 //其他费用
  19287. var otherCostPartSelfTotal float64 = 0 //其他费用
  19288. var materialCostTotal float64 = 0 //材料费
  19289. var materialCostSelfTotal float64 = 0 //材料费
  19290. var materialCostPartSelfTotal float64 = 0 //材料费
  19291. var westernMedicineCostTotal float64 = 0 //西药费
  19292. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19293. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19294. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19295. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19296. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19297. var checkCostTotal float64 = 0 //检查费
  19298. var checkCostSelfTotal float64 = 0 //检查费
  19299. var checkCostPartSelfTotal float64 = 0 //检查费
  19300. var laboratoryCostTotal float64 = 0 //化验费
  19301. var laboratoryCostSelfTotal float64 = 0 //化验费
  19302. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19303. var treatCostTotal float64 = 0 //治疗费用
  19304. var treatCostSelfTotal float64 = 0 //治疗费用
  19305. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19306. decimal.DivisionPrecision = 2
  19307. var bed_fulamt_ownpay_amt float64 = 0
  19308. var operation_fulamt_ownpay_amt float64 = 0
  19309. var other_fulamt_ownpay_amt float64 = 0
  19310. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19311. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19312. var check_fulamt_ownpay_amt float64 = 0
  19313. var material_fulamt_ownpay_amt float64 = 0
  19314. var laboratory_fulamt_ownpay_amt float64 = 0
  19315. var treat_fulamt_ownpay_amt float64 = 0
  19316. var bed_claa_sunmfee float64 = 0
  19317. var bed_clab_amt float64 = 0
  19318. var bed_other_amt float64 = 0
  19319. var operation_claa_sunmfee float64 = 0
  19320. var operation_clab_amt float64 = 0
  19321. var operation_other_amt float64 = 0
  19322. var other_claa_sunmfee float64 = 0
  19323. var other_clab_amt float64 = 0
  19324. var other_other_amt float64 = 0
  19325. var westernMedicine_claa_sunmfee float64 = 0
  19326. var westernMedicine_clab_amt float64 = 0
  19327. var westernMedicine_other_amt float64 = 0
  19328. var chineseTraditional_claa_sunmfee float64 = 0
  19329. var chineseTraditional_clab_amt float64 = 0
  19330. var chineseTraditional_other_amt float64 = 0
  19331. var check_claa_sunmfee float64 = 0
  19332. var check_clab_amt float64 = 0
  19333. var check_other_amt float64 = 0
  19334. var material_claa_sunmfee float64 = 0
  19335. var material_clab_amt float64 = 0
  19336. var material_other_amt float64 = 0
  19337. var laboratory_claa_sunmfee float64 = 0
  19338. var laboratory_clab_amt float64 = 0
  19339. var laboratory_other_amt float64 = 0
  19340. var treat_claa_sunmfee float64 = 0
  19341. var treat_clab_amt float64 = 0
  19342. var treat_other_amt float64 = 0
  19343. for _, item := range order.HisOrderInfo {
  19344. if item.MedChrgitmType == "01" { //床位费
  19345. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19346. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19347. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19348. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19349. if item.ChrgitmLv == "1" {
  19350. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19351. }
  19352. if item.ChrgitmLv == "2" {
  19353. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19354. }
  19355. if item.ChrgitmLv == "3" {
  19356. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19357. }
  19358. }
  19359. if item.MedChrgitmType == "03" { //检查费
  19360. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19361. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19362. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19363. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19364. if item.ChrgitmLv == "1" {
  19365. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19366. }
  19367. if item.ChrgitmLv == "2" {
  19368. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19369. }
  19370. if item.ChrgitmLv == "3" {
  19371. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19372. }
  19373. }
  19374. if item.MedChrgitmType == "04" { //化验费
  19375. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19376. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19377. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19378. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19379. if item.ChrgitmLv == "1" {
  19380. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19381. }
  19382. if item.ChrgitmLv == "2" {
  19383. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19384. }
  19385. if item.ChrgitmLv == "3" {
  19386. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19387. }
  19388. }
  19389. if item.MedChrgitmType == "05" { //治疗费
  19390. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19391. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19392. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19393. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19394. if item.ChrgitmLv == "1" {
  19395. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19396. }
  19397. if item.ChrgitmLv == "2" {
  19398. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19399. }
  19400. if item.ChrgitmLv == "3" {
  19401. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19402. }
  19403. }
  19404. if item.MedChrgitmType == "06" { //手术费
  19405. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19406. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19407. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19408. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19409. if item.ChrgitmLv == "1" {
  19410. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19411. }
  19412. if item.ChrgitmLv == "2" {
  19413. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19414. }
  19415. if item.ChrgitmLv == "3" {
  19416. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19417. }
  19418. }
  19419. if item.MedChrgitmType == "08" { //材料费
  19420. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19421. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19422. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19423. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19424. if item.ChrgitmLv == "1" {
  19425. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19426. }
  19427. if item.ChrgitmLv == "2" {
  19428. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19429. }
  19430. if item.ChrgitmLv == "3" {
  19431. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19432. }
  19433. }
  19434. if item.MedChrgitmType == "09" { //西药费
  19435. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19436. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19437. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19438. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19439. if item.ChrgitmLv == "1" {
  19440. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19441. }
  19442. if item.ChrgitmLv == "2" {
  19443. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19444. }
  19445. if item.ChrgitmLv == "3" {
  19446. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19447. }
  19448. }
  19449. if item.MedChrgitmType == "11" { //中成费
  19450. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19451. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19452. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19453. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19454. if item.ChrgitmLv == "1" {
  19455. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19456. }
  19457. if item.ChrgitmLv == "2" {
  19458. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19459. }
  19460. if item.ChrgitmLv == "3" {
  19461. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19462. }
  19463. }
  19464. if item.MedChrgitmType == "14" { //其他费
  19465. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19466. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19467. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19468. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19469. if item.ChrgitmLv == "1" {
  19470. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19471. }
  19472. if item.ChrgitmLv == "2" {
  19473. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19474. }
  19475. if item.ChrgitmLv == "3" {
  19476. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19477. }
  19478. }
  19479. }
  19480. var iteminfoStructs []service.IteminfoStruct
  19481. if bedCostTotal != 0 {
  19482. iteminfo.MedChrgitm = "01"
  19483. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19484. iteminfo.Amt = bedCostTotal
  19485. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19486. iteminfo.ClabAmt = bed_clab_amt
  19487. iteminfo.OthAmt = bed_other_amt
  19488. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19489. }
  19490. if checkCostTotal != 0 {
  19491. iteminfo.MedChrgitm = "03"
  19492. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19493. iteminfo.Amt = checkCostTotal
  19494. iteminfo.ClaaSumfee = check_claa_sunmfee
  19495. iteminfo.ClabAmt = check_clab_amt
  19496. iteminfo.OthAmt = check_other_amt
  19497. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19498. }
  19499. if laboratoryCostTotal != 0 {
  19500. iteminfo.MedChrgitm = "04"
  19501. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19502. iteminfo.Amt = laboratoryCostTotal
  19503. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19504. iteminfo.ClabAmt = laboratory_clab_amt
  19505. iteminfo.OthAmt = laboratory_other_amt
  19506. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19507. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19508. }
  19509. if treatCostTotal != 0 {
  19510. iteminfo.MedChrgitm = "05"
  19511. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19512. iteminfo.Amt = treatCostTotal
  19513. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19514. iteminfo.ClabAmt = treat_clab_amt
  19515. iteminfo.OthAmt = treat_other_amt
  19516. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19517. //(struct4101.IteminfoStruct, iteminfo)
  19518. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19519. }
  19520. if operationCostTotal != 0 {
  19521. iteminfo.MedChrgitm = "06"
  19522. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19523. iteminfo.Amt = operationCostTotal
  19524. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19525. iteminfo.ClabAmt = operation_clab_amt
  19526. iteminfo.OthAmt = operation_other_amt
  19527. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19528. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19529. }
  19530. if materialCostTotal != 0 {
  19531. iteminfo.MedChrgitm = "08"
  19532. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19533. iteminfo.Amt = materialCostTotal
  19534. iteminfo.ClaaSumfee = material_claa_sunmfee
  19535. iteminfo.ClabAmt = material_clab_amt
  19536. iteminfo.OthAmt = material_other_amt
  19537. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19538. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19539. }
  19540. if westernMedicineCostTotal != 0 {
  19541. iteminfo.MedChrgitm = "09"
  19542. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19543. iteminfo.Amt = westernMedicineCostTotal
  19544. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19545. iteminfo.ClabAmt = westernMedicine_clab_amt
  19546. iteminfo.OthAmt = westernMedicine_other_amt
  19547. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19548. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19549. }
  19550. if chineseTraditionalMedicineCostTotal != 0 {
  19551. iteminfo.MedChrgitm = "11"
  19552. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19553. iteminfo.Amt = westernMedicineCostTotal
  19554. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19555. iteminfo.ClabAmt = westernMedicine_clab_amt
  19556. iteminfo.OthAmt = westernMedicine_other_amt
  19557. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19558. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19559. }
  19560. if otherCostTotal != 0 {
  19561. iteminfo.MedChrgitm = "14"
  19562. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19563. iteminfo.Amt = otherCostTotal
  19564. iteminfo.ClaaSumfee = other_claa_sunmfee
  19565. iteminfo.ClabAmt = other_clab_amt
  19566. iteminfo.OthAmt = other_other_amt
  19567. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19568. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19569. }
  19570. struct4101.IteminfoStruct = iteminfoStructs
  19571. struct4101.Ntly = "中国"
  19572. struct4101.AdmCaty = "A03.06"
  19573. struct4101.DoctorName = doctor.UserName
  19574. struct4101.DoctorCode = doctor.DoctorNumber
  19575. var res ResultSeventeen
  19576. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19577. struct4101.BillCode = order.Number
  19578. struct4101.BillNo = order.SetlId
  19579. var resOther ResultSeventeenOther
  19580. var pp models.PublicParams
  19581. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19582. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19583. pp.FixmedinsName = miConfig.OrgName
  19584. pp.FixmedinsCode = miConfig.Code
  19585. pp.RequestUrl = miConfig.Url
  19586. pp.Cainfo = miConfig.Cainfo
  19587. pp.SecretKey = miConfig.SecretKey
  19588. pp.AccessKey = miConfig.AccessKey
  19589. pp.OpterName = curRoles.UserName
  19590. client := &http.Client{}
  19591. var req *http.Request
  19592. data := make(map[string]interface{})
  19593. data["struct4101"] = struct4101
  19594. data["pp"] = pp
  19595. bytesData, _ := json.Marshal(data)
  19596. if miConfig.MdtrtareaAdmvs == "320921" {
  19597. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19598. } else {
  19599. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19600. }
  19601. resp, _ := client.Do(req)
  19602. defer resp.Body.Close()
  19603. body, ioErr := ioutil.ReadAll(resp.Body)
  19604. if ioErr != nil {
  19605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19607. return
  19608. }
  19609. var respJSON map[string]interface{}
  19610. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19613. return
  19614. }
  19615. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19616. userJSONBytes, _ := json.Marshal(respJSON)
  19617. fmt.Println("log")
  19618. fmt.Println(string(userJSONBytes))
  19619. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19620. utils.ErrorLog("解析失败:%v", err)
  19621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19622. return
  19623. }
  19624. res.InfRefmsgid = resOther.InfRefmsgid
  19625. res.Output = resOther.Output
  19626. res.ErrMsg = resOther.ErrMsg
  19627. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19628. res.Infcode = infocode
  19629. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19630. var pp models.PublicParams
  19631. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19632. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19633. pp.FixmedinsName = miConfig.OrgName
  19634. pp.FixmedinsCode = miConfig.Code
  19635. pp.RequestUrl = miConfig.Url
  19636. pp.Cainfo = miConfig.Cainfo
  19637. pp.SecretKey = miConfig.SecretKey
  19638. pp.AccessKey = miConfig.AccessKey
  19639. pp.OpterName = curRoles.UserName
  19640. result, _ := service.Jxyb4101(struct4101, pp)
  19641. var dat map[string]interface{}
  19642. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19643. fmt.Println(dat)
  19644. } else {
  19645. fmt.Println(err)
  19646. }
  19647. userJSONBytes, _ := json.Marshal(dat)
  19648. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19649. utils.ErrorLog("解析失败:%v", err)
  19650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19651. return
  19652. }
  19653. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19654. var pp models.PublicParams
  19655. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19656. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19657. pp.FixmedinsName = miConfig.OrgName
  19658. pp.FixmedinsCode = miConfig.Code
  19659. pp.RequestUrl = miConfig.Url
  19660. pp.Cainfo = miConfig.Cainfo
  19661. pp.SecretKey = miConfig.SecretKey
  19662. pp.AccessKey = miConfig.AccessKey
  19663. pp.OpterName = curRoles.UserName
  19664. result, _ := service.Jxyb4101(struct4101, pp)
  19665. var dat map[string]interface{}
  19666. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19667. fmt.Println(dat)
  19668. } else {
  19669. fmt.Println(err)
  19670. }
  19671. userJSONBytes, _ := json.Marshal(dat)
  19672. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19673. utils.ErrorLog("解析失败:%v", err)
  19674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19675. return
  19676. }
  19677. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19678. var pp models.PublicParams
  19679. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19680. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19681. pp.FixmedinsName = miConfig.OrgName
  19682. pp.FixmedinsCode = miConfig.Code
  19683. pp.RequestUrl = miConfig.Url
  19684. pp.Cainfo = miConfig.Cainfo
  19685. pp.SecretKey = miConfig.SecretKey
  19686. pp.AccessKey = miConfig.AccessKey
  19687. pp.OpterName = curRoles.UserName
  19688. result, _ := service.Hnyb4101(struct4101, pp)
  19689. var dat map[string]interface{}
  19690. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19691. fmt.Println(dat)
  19692. } else {
  19693. fmt.Println(err)
  19694. }
  19695. userJSONBytes, _ := json.Marshal(dat)
  19696. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19697. utils.ErrorLog("解析失败:%v", err)
  19698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19699. return
  19700. }
  19701. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19702. var resOther ResultSeventeenOther
  19703. var pp models.PublicParams
  19704. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19705. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19706. pp.FixmedinsName = miConfig.OrgName
  19707. pp.FixmedinsCode = miConfig.Code
  19708. pp.RequestUrl = miConfig.Url
  19709. pp.Cainfo = miConfig.Cainfo
  19710. pp.SecretKey = miConfig.SecretKey
  19711. pp.AccessKey = miConfig.AccessKey
  19712. pp.OpterName = curRoles.UserName
  19713. client := &http.Client{}
  19714. var req *http.Request
  19715. data := make(map[string]interface{})
  19716. data["struct4101"] = struct4101
  19717. data["pp"] = pp
  19718. bytesData, _ := json.Marshal(data)
  19719. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19720. resp, _ := client.Do(req)
  19721. defer resp.Body.Close()
  19722. body, ioErr := ioutil.ReadAll(resp.Body)
  19723. if ioErr != nil {
  19724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19726. return
  19727. }
  19728. var respJSON map[string]interface{}
  19729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19732. return
  19733. }
  19734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19735. userJSONBytes, _ := json.Marshal(respJSON)
  19736. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19737. utils.ErrorLog("解析失败:%v", err)
  19738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19739. return
  19740. }
  19741. res.InfRefmsgid = resOther.InfRefmsgid
  19742. res.Output = resOther.Output
  19743. res.ErrMsg = resOther.ErrMsg
  19744. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19745. res.Infcode = infocode
  19746. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19747. var pp models.PublicParams
  19748. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19749. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19750. pp.FixmedinsName = miConfig.OrgName
  19751. pp.FixmedinsCode = miConfig.Code
  19752. pp.RequestUrl = miConfig.Url
  19753. pp.Cainfo = miConfig.Cainfo
  19754. pp.SecretKey = miConfig.SecretKey
  19755. pp.AccessKey = miConfig.AccessKey
  19756. pp.OpterName = curRoles.UserName
  19757. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19758. fmt.Println(requestLog)
  19759. fmt.Println(errMsgLog)
  19760. saveLog(result, requestLog, "4101a", "上传清单")
  19761. var dat map[string]interface{}
  19762. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19763. fmt.Println(dat)
  19764. } else {
  19765. fmt.Println(err)
  19766. }
  19767. userJSONBytes, _ := json.Marshal(dat)
  19768. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19769. utils.ErrorLog("解析失败:%v", err)
  19770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19771. return
  19772. }
  19773. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19774. var pp models.PublicParams
  19775. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19776. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19777. pp.FixmedinsName = miConfig.OrgName
  19778. pp.FixmedinsCode = miConfig.Code
  19779. pp.RequestUrl = miConfig.Url
  19780. pp.Cainfo = miConfig.Cainfo
  19781. pp.SecretKey = miConfig.SecretKey
  19782. pp.AccessKey = miConfig.AccessKey
  19783. pp.OpterName = curRoles.UserName
  19784. client := &http.Client{}
  19785. var req *http.Request
  19786. data := make(map[string]interface{})
  19787. data["struct4101"] = struct4101
  19788. data["pp"] = pp
  19789. bytesData, _ := json.Marshal(data)
  19790. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19791. resp, _ := client.Do(req)
  19792. defer resp.Body.Close()
  19793. body, ioErr := ioutil.ReadAll(resp.Body)
  19794. if ioErr != nil {
  19795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19797. return
  19798. }
  19799. var respJSON map[string]interface{}
  19800. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19803. return
  19804. }
  19805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19806. userJSONBytes, _ := json.Marshal(respJSON)
  19807. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19808. utils.ErrorLog("解析失败:%v", err)
  19809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19810. return
  19811. }
  19812. } else {
  19813. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19814. var dat map[string]interface{}
  19815. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19816. fmt.Println(dat)
  19817. } else {
  19818. fmt.Println(err)
  19819. }
  19820. userJSONBytes, _ := json.Marshal(dat)
  19821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19822. utils.ErrorLog("解析失败:%v", err)
  19823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19824. return
  19825. }
  19826. }
  19827. if res.Infcode != 0 {
  19828. c.ServeSuccessJSON(map[string]interface{}{
  19829. "failed_code": -10,
  19830. "msg": res.ErrMsg,
  19831. })
  19832. return
  19833. } else {
  19834. //order.FaPiaoNumber = zero
  19835. //order.FaPiaoCode = last_order.FaPiaoCode
  19836. //service.UpdateOrder(order)
  19837. hisFundSettleListResult := &models.HisFundSettleListResult{
  19838. Number: res.Output.SetlListId,
  19839. Status: 1,
  19840. Ctime: time.Now().Unix(),
  19841. Mtime: time.Now().Unix(),
  19842. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19843. IsUpload: 1,
  19844. OrderId: order_id,
  19845. }
  19846. service.CreateUploadRecord(hisFundSettleListResult)
  19847. c.ServeSuccessJSON(map[string]interface{}{
  19848. "msg": "上传成功",
  19849. "result": hisFundSettleListResult,
  19850. })
  19851. return
  19852. }
  19853. }
  19854. func (c *HisApiController) GetSettleListHospital() {
  19855. order_id, _ := c.GetInt64("order_id")
  19856. admin_user_id, _ := c.GetInt64("admin_user_id")
  19857. order, _ := service.GetHisOrderByIDTwo(order_id)
  19858. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19859. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19860. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19861. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19862. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19863. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19864. if order.ID == 0 {
  19865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19866. return
  19867. }
  19868. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19869. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19870. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19871. fmt.Println(count)
  19872. var zero string
  19873. number := count + 1
  19874. if number >= 1000 {
  19875. zero = "0000" + strconv.FormatInt(number, 10)
  19876. } else if number >= 10000 {
  19877. zero = "000" + strconv.FormatInt(number, 10)
  19878. } else if number >= 100000 {
  19879. zero = "00" + strconv.FormatInt(number, 10)
  19880. } else if number >= 1000000 {
  19881. zero = "0" + strconv.FormatInt(number, 10)
  19882. } else {
  19883. zero = strconv.FormatInt(number, 10)
  19884. }
  19885. fmt.Println(zero)
  19886. struct4101 := service.Struct4101{
  19887. PsnNo: order.PsnNo,
  19888. MdtrtId: order.MdtrtId,
  19889. SetlId: order.SetlId,
  19890. PsnName: order.PsnName,
  19891. Gend: order.Gend,
  19892. Brdy: his.Brdy,
  19893. Age: int64(order.Age),
  19894. Naty: order.Naty,
  19895. PatnCertType: "01",
  19896. Certno: order.Certno,
  19897. Prfs: "90",
  19898. ConerName: roles[0].UserName,
  19899. PatnRlts: "99",
  19900. ConerAddr: miConfig.OrgName,
  19901. ConerTel: admin.Mobile,
  19902. HiType: order.Insutype,
  19903. Insuplc: miConfig.InsuplcAdmdvs,
  19904. MaindiagFlag: "1",
  19905. BillCode: order.SetlId,
  19906. BillNo: order.SetlId,
  19907. BizSn: order.Number,
  19908. PsnSelfPay: order.PsnPartAmt,
  19909. PsnOwnPay: order.PsnPartAmt,
  19910. AcctPay: order.AcctPay,
  19911. PsnCashpay: order.PsnCashPay,
  19912. HiPaymtd: "1",
  19913. Hsorg: miConfig.InsuplcAdmdvs,
  19914. HsorgOpter: miConfig.InsuplcAdmdvs,
  19915. MedinsFillPsn: curRoles.UserName,
  19916. MedinsFillDept: depart.Name,
  19917. IptMedType: "2",
  19918. AdmTime: his.InHosptialTime,
  19919. AdmEndTime: his.OutHosptialTime,
  19920. }
  19921. struct4101.SetlBegnDate = order.SetlTime
  19922. struct4101.SetlEndDate = order.SetlTime
  19923. //var rf []CustomFundPay
  19924. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19925. //
  19926. //var tempFunPays []service.CustomStruct
  19927. //for _, item := range rf {
  19928. // var tempFunPay service.CustomStruct
  19929. // tempFunPay.FundPayamt = item.FundPayamt
  19930. // tempFunPay.FundPayType = item.FundPayType
  19931. // tempFunPays = append(tempFunPays, tempFunPay)
  19932. //}
  19933. //struct4101.CustomStruct = tempFunPays
  19934. var tempDiaginfos []service.DiaginfoStructTwo
  19935. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19936. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19937. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19938. //for _, item := range infos {
  19939. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19940. //}
  19941. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19942. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19943. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19944. fmt.Println(diagnosis_ids_arr)
  19945. if order.UserOrgId == 10210 {
  19946. var diagnosis_ids_arr_two []int64
  19947. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19948. var config []*models.HisXtDiagnoseConfig
  19949. for _, id := range diagnosis_ids_arr_two {
  19950. //id, _ := strconv.ParseInt(item, 10, 64)
  19951. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19952. if diagnosisConfig.ID > 0 {
  19953. config = append(config, &diagnosisConfig)
  19954. }
  19955. }
  19956. for index, item := range config {
  19957. if item.ID > 0 {
  19958. if index == 0 {
  19959. var tempDiaginfo service.DiaginfoStructTwo
  19960. tempDiaginfo.DiagCode = item.CountryCode
  19961. tempDiaginfo.DiagName = item.CountryContentName
  19962. tempDiaginfo.DiagType = "1"
  19963. tempDiaginfo.MaindiagFlag = "1"
  19964. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19965. } else {
  19966. var tempDiaginfo service.DiaginfoStructTwo
  19967. tempDiaginfo.DiagCode = item.CountryCode
  19968. tempDiaginfo.DiagName = item.CountryContentName
  19969. tempDiaginfo.DiagType = "1"
  19970. tempDiaginfo.MaindiagFlag = "0"
  19971. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19972. }
  19973. }
  19974. }
  19975. struct4101.Diseinfo = tempDiaginfos
  19976. } else {
  19977. var config []*models.HisXtDiagnoseConfig
  19978. for _, item := range diagnosis_ids_arr {
  19979. id, _ := strconv.ParseInt(item, 10, 64)
  19980. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19981. if diagnosisConfig.ID > 0 {
  19982. config = append(config, &diagnosisConfig)
  19983. }
  19984. }
  19985. for index, item := range config {
  19986. if item.ID > 0 {
  19987. if index == 0 {
  19988. var tempDiaginfo service.DiaginfoStructTwo
  19989. tempDiaginfo.DiagCode = item.CountryCode
  19990. tempDiaginfo.DiagName = item.CountryContentName
  19991. tempDiaginfo.DiagType = "1"
  19992. tempDiaginfo.MaindiagFlag = "1"
  19993. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19994. } else {
  19995. var tempDiaginfo service.DiaginfoStructTwo
  19996. tempDiaginfo.DiagCode = item.CountryCode
  19997. tempDiaginfo.DiagName = item.CountryContentName
  19998. tempDiaginfo.DiagType = "1"
  19999. tempDiaginfo.MaindiagFlag = "0"
  20000. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20001. }
  20002. }
  20003. }
  20004. struct4101.Diseinfo = tempDiaginfos
  20005. }
  20006. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20007. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20008. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20009. tempOpspdiseinfo2.OprnOprtCode = ""
  20010. tempOpspdiseinfo2.OprnOprtName = ""
  20011. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20012. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20013. var iteminfo service.IteminfoStruct
  20014. var bedCostTotal float64 = 0 //床位总费
  20015. var bedCostSelfTotal float64 = 0 //床位自费
  20016. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20017. var operationCostTotal float64 = 0 //手术费
  20018. var operationCostSelfTotal float64 = 0 //手术费
  20019. var operationCostPartSelfTotal float64 = 0 //手术费
  20020. var otherCostTotal float64 = 0 //其他费用
  20021. var otherCostSelfTotal float64 = 0 //其他费用
  20022. var otherCostPartSelfTotal float64 = 0 //其他费用
  20023. var materialCostTotal float64 = 0 //材料费
  20024. var materialCostSelfTotal float64 = 0 //材料费
  20025. var materialCostPartSelfTotal float64 = 0 //材料费
  20026. var westernMedicineCostTotal float64 = 0 //西药费
  20027. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20028. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20029. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20030. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20031. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20032. var checkCostTotal float64 = 0 //检查费
  20033. var checkCostSelfTotal float64 = 0 //检查费
  20034. var checkCostPartSelfTotal float64 = 0 //检查费
  20035. var laboratoryCostTotal float64 = 0 //化验费
  20036. var laboratoryCostSelfTotal float64 = 0 //化验费
  20037. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20038. var treatCostTotal float64 = 0 //治疗费用
  20039. var treatCostSelfTotal float64 = 0 //治疗费用
  20040. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20041. decimal.DivisionPrecision = 2
  20042. var bed_fulamt_ownpay_amt float64 = 0
  20043. var operation_fulamt_ownpay_amt float64 = 0
  20044. var other_fulamt_ownpay_amt float64 = 0
  20045. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20046. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20047. var check_fulamt_ownpay_amt float64 = 0
  20048. var material_fulamt_ownpay_amt float64 = 0
  20049. var laboratory_fulamt_ownpay_amt float64 = 0
  20050. var treat_fulamt_ownpay_amt float64 = 0
  20051. var bed_claa_sunmfee float64 = 0
  20052. var bed_clab_amt float64 = 0
  20053. var bed_other_amt float64 = 0
  20054. var operation_claa_sunmfee float64 = 0
  20055. var operation_clab_amt float64 = 0
  20056. var operation_other_amt float64 = 0
  20057. var other_claa_sunmfee float64 = 0
  20058. var other_clab_amt float64 = 0
  20059. var other_other_amt float64 = 0
  20060. var westernMedicine_claa_sunmfee float64 = 0
  20061. var westernMedicine_clab_amt float64 = 0
  20062. var westernMedicine_other_amt float64 = 0
  20063. var chineseTraditional_claa_sunmfee float64 = 0
  20064. var chineseTraditional_clab_amt float64 = 0
  20065. var chineseTraditional_other_amt float64 = 0
  20066. var check_claa_sunmfee float64 = 0
  20067. var check_clab_amt float64 = 0
  20068. var check_other_amt float64 = 0
  20069. var material_claa_sunmfee float64 = 0
  20070. var material_clab_amt float64 = 0
  20071. var material_other_amt float64 = 0
  20072. var laboratory_claa_sunmfee float64 = 0
  20073. var laboratory_clab_amt float64 = 0
  20074. var laboratory_other_amt float64 = 0
  20075. var treat_claa_sunmfee float64 = 0
  20076. var treat_clab_amt float64 = 0
  20077. var treat_other_amt float64 = 0
  20078. for _, item := range order.HisOrderInfo {
  20079. if item.MedChrgitmType == "01" { //床位费
  20080. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20081. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20082. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20083. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20084. if item.ChrgitmLv == "1" {
  20085. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20086. }
  20087. if item.ChrgitmLv == "2" {
  20088. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20089. }
  20090. if item.ChrgitmLv == "3" {
  20091. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20092. }
  20093. }
  20094. if item.MedChrgitmType == "03" { //检查费
  20095. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20096. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20097. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20098. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20099. if item.ChrgitmLv == "1" {
  20100. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20101. }
  20102. if item.ChrgitmLv == "2" {
  20103. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20104. }
  20105. if item.ChrgitmLv == "3" {
  20106. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20107. }
  20108. }
  20109. if item.MedChrgitmType == "04" { //化验费
  20110. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20111. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20112. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20113. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20114. if item.ChrgitmLv == "1" {
  20115. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20116. }
  20117. if item.ChrgitmLv == "2" {
  20118. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20119. }
  20120. if item.ChrgitmLv == "3" {
  20121. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20122. }
  20123. }
  20124. if item.MedChrgitmType == "05" { //治疗费
  20125. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20126. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20127. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20128. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20129. if item.ChrgitmLv == "1" {
  20130. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20131. }
  20132. if item.ChrgitmLv == "2" {
  20133. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20134. }
  20135. if item.ChrgitmLv == "3" {
  20136. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20137. }
  20138. }
  20139. if item.MedChrgitmType == "06" { //手术费
  20140. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20141. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20142. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20143. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20144. if item.ChrgitmLv == "1" {
  20145. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20146. }
  20147. if item.ChrgitmLv == "2" {
  20148. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20149. }
  20150. if item.ChrgitmLv == "3" {
  20151. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20152. }
  20153. }
  20154. if item.MedChrgitmType == "08" { //材料费
  20155. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20156. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20157. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20158. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20159. if item.ChrgitmLv == "1" {
  20160. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20161. }
  20162. if item.ChrgitmLv == "2" {
  20163. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20164. }
  20165. if item.ChrgitmLv == "3" {
  20166. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20167. }
  20168. }
  20169. if item.MedChrgitmType == "09" { //西药费
  20170. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20171. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20172. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20173. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20174. if item.ChrgitmLv == "1" {
  20175. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20176. }
  20177. if item.ChrgitmLv == "2" {
  20178. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20179. }
  20180. if item.ChrgitmLv == "3" {
  20181. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20182. }
  20183. }
  20184. if item.MedChrgitmType == "11" { //中成费
  20185. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20186. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20187. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20188. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20189. if item.ChrgitmLv == "1" {
  20190. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20191. }
  20192. if item.ChrgitmLv == "2" {
  20193. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20194. }
  20195. if item.ChrgitmLv == "3" {
  20196. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20197. }
  20198. }
  20199. if item.MedChrgitmType == "14" { //其他费
  20200. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20201. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20202. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20203. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20204. if item.ChrgitmLv == "1" {
  20205. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20206. }
  20207. if item.ChrgitmLv == "2" {
  20208. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20209. }
  20210. if item.ChrgitmLv == "3" {
  20211. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20212. }
  20213. }
  20214. }
  20215. var iteminfoStructs []service.IteminfoStruct
  20216. if bedCostTotal != 0 {
  20217. iteminfo.MedChrgitm = "01"
  20218. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20219. iteminfo.Amt = bedCostTotal
  20220. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20221. iteminfo.ClabAmt = bed_clab_amt
  20222. iteminfo.OthAmt = bed_other_amt
  20223. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20224. }
  20225. if checkCostTotal != 0 {
  20226. iteminfo.MedChrgitm = "03"
  20227. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20228. iteminfo.Amt = checkCostTotal
  20229. iteminfo.ClaaSumfee = check_claa_sunmfee
  20230. iteminfo.ClabAmt = check_clab_amt
  20231. iteminfo.OthAmt = check_other_amt
  20232. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20233. }
  20234. if laboratoryCostTotal != 0 {
  20235. iteminfo.MedChrgitm = "04"
  20236. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20237. iteminfo.Amt = laboratoryCostTotal
  20238. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20239. iteminfo.ClabAmt = laboratory_clab_amt
  20240. iteminfo.OthAmt = laboratory_other_amt
  20241. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20242. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20243. }
  20244. if treatCostTotal != 0 {
  20245. iteminfo.MedChrgitm = "05"
  20246. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20247. iteminfo.Amt = treatCostTotal
  20248. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20249. iteminfo.ClabAmt = treat_clab_amt
  20250. iteminfo.OthAmt = treat_other_amt
  20251. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20252. //(struct4101.IteminfoStruct, iteminfo)
  20253. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20254. }
  20255. if operationCostTotal != 0 {
  20256. iteminfo.MedChrgitm = "06"
  20257. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20258. iteminfo.Amt = operationCostTotal
  20259. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20260. iteminfo.ClabAmt = operation_clab_amt
  20261. iteminfo.OthAmt = operation_other_amt
  20262. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20263. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20264. }
  20265. if materialCostTotal != 0 {
  20266. iteminfo.MedChrgitm = "08"
  20267. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20268. iteminfo.Amt = materialCostTotal
  20269. iteminfo.ClaaSumfee = material_claa_sunmfee
  20270. iteminfo.ClabAmt = material_clab_amt
  20271. iteminfo.OthAmt = material_other_amt
  20272. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20273. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20274. }
  20275. if westernMedicineCostTotal != 0 {
  20276. iteminfo.MedChrgitm = "09"
  20277. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20278. iteminfo.Amt = westernMedicineCostTotal
  20279. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20280. iteminfo.ClabAmt = westernMedicine_clab_amt
  20281. iteminfo.OthAmt = westernMedicine_other_amt
  20282. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20283. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20284. }
  20285. if chineseTraditionalMedicineCostTotal != 0 {
  20286. iteminfo.MedChrgitm = "11"
  20287. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20288. iteminfo.Amt = westernMedicineCostTotal
  20289. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20290. iteminfo.ClabAmt = westernMedicine_clab_amt
  20291. iteminfo.OthAmt = westernMedicine_other_amt
  20292. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20293. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20294. }
  20295. if otherCostTotal != 0 {
  20296. iteminfo.MedChrgitm = "14"
  20297. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20298. iteminfo.Amt = otherCostTotal
  20299. iteminfo.ClaaSumfee = other_claa_sunmfee
  20300. iteminfo.ClabAmt = other_clab_amt
  20301. iteminfo.OthAmt = other_other_amt
  20302. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20303. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20304. }
  20305. struct4101.IteminfoStruct = iteminfoStructs
  20306. struct4101.Ntly = "中国"
  20307. struct4101.AdmCaty = "A03.06"
  20308. var resOther ResultSeventeenOther
  20309. var res ResultSeventeen
  20310. if miConfig.MdtrtareaAdmvs == "150499" {
  20311. var pp models.PublicParams
  20312. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20313. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20314. pp.FixmedinsName = miConfig.OrgName
  20315. pp.FixmedinsCode = miConfig.Code
  20316. pp.RequestUrl = miConfig.Url
  20317. pp.Cainfo = miConfig.Cainfo
  20318. pp.SecretKey = miConfig.SecretKey
  20319. pp.AccessKey = miConfig.AccessKey
  20320. pp.OpterName = curRoles.UserName
  20321. client := &http.Client{}
  20322. var req *http.Request
  20323. data := make(map[string]interface{})
  20324. data["struct4101"] = struct4101
  20325. data["pp"] = pp
  20326. bytesData, _ := json.Marshal(data)
  20327. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20328. resp, _ := client.Do(req)
  20329. defer resp.Body.Close()
  20330. body, ioErr := ioutil.ReadAll(resp.Body)
  20331. if ioErr != nil {
  20332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20334. return
  20335. }
  20336. var respJSON map[string]interface{}
  20337. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20340. return
  20341. }
  20342. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20343. userJSONBytes, _ := json.Marshal(respJSON)
  20344. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20345. utils.ErrorLog("解析失败:%v", err)
  20346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20347. return
  20348. }
  20349. res.InfRefmsgid = resOther.InfRefmsgid
  20350. res.Output = resOther.Output
  20351. res.ErrMsg = resOther.ErrMsg
  20352. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20353. res.Infcode = infocode
  20354. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20355. var pp models.PublicParams
  20356. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20357. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20358. pp.FixmedinsName = miConfig.OrgName
  20359. pp.FixmedinsCode = miConfig.Code
  20360. pp.RequestUrl = miConfig.Url
  20361. pp.Cainfo = miConfig.Cainfo
  20362. pp.SecretKey = miConfig.SecretKey
  20363. pp.AccessKey = miConfig.AccessKey
  20364. pp.OpterName = curRoles.UserName
  20365. result, _ := service.Jxyb4101(struct4101, pp)
  20366. var dat map[string]interface{}
  20367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20368. fmt.Println(dat)
  20369. } else {
  20370. fmt.Println(err)
  20371. }
  20372. userJSONBytes, _ := json.Marshal(dat)
  20373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20374. utils.ErrorLog("解析失败:%v", err)
  20375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20376. return
  20377. }
  20378. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20379. var pp models.PublicParams
  20380. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20381. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20382. pp.FixmedinsName = miConfig.OrgName
  20383. pp.FixmedinsCode = miConfig.Code
  20384. pp.RequestUrl = miConfig.Url
  20385. pp.Cainfo = miConfig.Cainfo
  20386. pp.SecretKey = miConfig.SecretKey
  20387. pp.AccessKey = miConfig.AccessKey
  20388. pp.OpterName = curRoles.UserName
  20389. result, _ := service.Jxyb4101(struct4101, pp)
  20390. var dat map[string]interface{}
  20391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20392. fmt.Println(dat)
  20393. } else {
  20394. fmt.Println(err)
  20395. }
  20396. userJSONBytes, _ := json.Marshal(dat)
  20397. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20398. utils.ErrorLog("解析失败:%v", err)
  20399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20400. return
  20401. }
  20402. } else {
  20403. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20404. var dat map[string]interface{}
  20405. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20406. fmt.Println(dat)
  20407. } else {
  20408. fmt.Println(err)
  20409. }
  20410. userJSONBytes, _ := json.Marshal(dat)
  20411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20412. utils.ErrorLog("解析失败:%v", err)
  20413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20414. return
  20415. }
  20416. }
  20417. if res.Infcode != 0 {
  20418. c.ServeSuccessJSON(map[string]interface{}{
  20419. "failed_code": -10,
  20420. "msg": res.ErrMsg,
  20421. })
  20422. return
  20423. } else {
  20424. if miConfig.MdtrtareaAdmvs != "150499" {
  20425. order.FaPiaoNumber = zero
  20426. order.FaPiaoCode = last_order.FaPiaoCode
  20427. service.UpdateOrder(order)
  20428. }
  20429. hisFundSettleListResult := &models.HisFundSettleListResult{
  20430. Number: res.Output.SetlListId,
  20431. Status: 1,
  20432. Ctime: time.Now().Unix(),
  20433. Mtime: time.Now().Unix(),
  20434. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20435. IsUpload: 1,
  20436. OrderId: order_id,
  20437. }
  20438. service.CreateUploadRecord(hisFundSettleListResult)
  20439. c.ServeSuccessJSON(map[string]interface{}{
  20440. "msg": "上传成功",
  20441. "result": hisFundSettleListResult,
  20442. })
  20443. return
  20444. }
  20445. }
  20446. //func (c *HisApiController) GetBatchSettleList() {
  20447. // orders, _ := service.GetAllHisOrder(10106)
  20448. // for _, item := range orders {
  20449. // order_id := item.ID
  20450. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20451. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20452. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20453. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20454. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20455. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20456. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20457. //
  20458. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20459. //
  20460. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20461. //
  20462. // if order.ID == 0 {
  20463. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20464. // return
  20465. // }
  20466. // if his.BalanceAccountsType == 2 {
  20467. // continue
  20468. // }
  20469. // struct4101 := service.Struct4101{
  20470. // PsnNo: order.PsnNo,
  20471. // MdtrtId: order.MdtrtId,
  20472. // SetlId: order.SetlId,
  20473. // PsnName: order.PsnName,
  20474. // Gend: order.Gend,
  20475. // Brdy: his.Brdy,
  20476. // Age: his.Age,
  20477. // Naty: order.Naty,
  20478. // PatnCertType: "01",
  20479. // Certno: order.Certno,
  20480. // Prfs: "90",
  20481. // ConerName: roles[0].UserName,
  20482. // PatnRlts: "99",
  20483. // ConerAddr: miConfig.OrgName,
  20484. // ConerTel: admin.Mobile,
  20485. // HiType: order.Insutype,
  20486. // Insuplc: his.InsuplcAdmdvs,
  20487. // MaindiagFlag: "1",
  20488. // BillCode: order.SetlId,
  20489. // BillNo: order.SetlId,
  20490. // BizSn: order.Number,
  20491. // PsnSelfPay: order.PsnPartAmt,
  20492. // PsnOwnPay: order.PsnPartAmt,
  20493. // AcctPay: order.AcctPay,
  20494. // PsnCashpay: order.PsnCashPay,
  20495. // HiPaymtd: "1",
  20496. // Hsorg: his.InsuplcAdmdvs,
  20497. // HsorgOpter: his.InsuplcAdmdvs,
  20498. // MedinsFillPsn: curRoles.UserName,
  20499. // MedinsFillDept: depart.Name,
  20500. // IptMedType: "2",
  20501. // }
  20502. // struct4101.SetlBegnDate = order.SetlTime
  20503. // struct4101.SetlEndDate = order.SetlTime
  20504. // //if order.SettleType == 1 {
  20505. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20506. // // dateStr := t.Format("2006-01-02")
  20507. // // struct4101.SetlBegnDate = dateStr
  20508. // // struct4101.SetlEndDate = dateStr
  20509. // //} else {
  20510. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20511. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20512. // // dateStartStr := t.Format("2006-01-02")
  20513. // // dateEndStr := t2.Format("2006-01-02")
  20514. // // struct4101.SetlBegnDate = dateStartStr
  20515. // // struct4101.SetlEndDate = dateEndStr
  20516. // //}
  20517. //
  20518. // var rf []CustomFundPay
  20519. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20520. //
  20521. // var tempFunPays []service.CustomStruct
  20522. // var tempFunPay610100 service.CustomStruct
  20523. //
  20524. // for _, item := range rf {
  20525. // if item.FundPayType == "610100" {
  20526. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20527. // tempFunPay610100.FundPayType = item.FundPayType
  20528. // } else {
  20529. // var tempFunPay service.CustomStruct
  20530. // tempFunPay.FundPayamt = item.FundPayamt
  20531. // tempFunPay.FundPayType = item.FundPayType
  20532. // tempFunPays = append(tempFunPays, tempFunPay)
  20533. // }
  20534. // }
  20535. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20536. // struct4101.CustomStruct = tempFunPays
  20537. //
  20538. // var tempDiaginfos []service.DiaginfoStructTwo
  20539. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20540. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20541. //
  20542. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20543. // var config []*models.HisXtDiagnoseConfig
  20544. // for _, item := range diagnosis_ids {
  20545. // id, _ := strconv.ParseInt(item, 10, 64)
  20546. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20547. // config = append(config, &diagnosisConfig)
  20548. // }
  20549. //
  20550. // for index, item := range config {
  20551. // if index == 0 {
  20552. // var tempDiaginfo service.DiaginfoStructTwo
  20553. // tempDiaginfo.DiagCode = item.CountryCode
  20554. // tempDiaginfo.DiagName = item.CountryContentName
  20555. // tempDiaginfo.DiagType = "1"
  20556. // tempDiaginfo.MaindiagFlag = "1"
  20557. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20558. // } else {
  20559. //
  20560. // var tempDiaginfo service.DiaginfoStructTwo
  20561. // tempDiaginfo.DiagCode = item.CountryCode
  20562. // tempDiaginfo.DiagName = item.CountryContentName
  20563. // tempDiaginfo.DiagType = "2"
  20564. // tempDiaginfo.MaindiagFlag = "0"
  20565. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20566. // }
  20567. // }
  20568. // struct4101.Diseinfo = tempDiaginfos
  20569. //
  20570. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20571. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20572. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20573. // tempOpspdiseinfo2.OprnOprtCode = ""
  20574. // tempOpspdiseinfo2.OprnOprtName = ""
  20575. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20576. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20577. //
  20578. // var iteminfo service.IteminfoStruct
  20579. //
  20580. // var bedCostTotal float64 = 0 //床位总费
  20581. // var bedCostSelfTotal float64 = 0 //床位自费
  20582. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20583. //
  20584. // var examineCostTotal float64 = 0 //诊查总费
  20585. // var examineCostSelfTotal float64 = 0 //诊查自费
  20586. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20587. //
  20588. // var nursingCostTotal float64 = 0 //护理总费
  20589. // var nursingCostSelfTotal float64 = 0 //护理自费
  20590. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20591. //
  20592. // var chineseMedicineCostTotal float64 = 0 //中成药
  20593. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20594. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20595. //
  20596. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20597. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20598. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20599. //
  20600. // var registerCostTotal float64 = 0 //一般诊疗费
  20601. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20602. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20603. //
  20604. // var operationCostTotal float64 = 0 //手术费
  20605. // var operationCostSelfTotal float64 = 0 //手术费
  20606. // var operationCostPartSelfTotal float64 = 0 //手术费
  20607. //
  20608. // var otherCostTotal float64 = 0 //其他费用
  20609. // var otherCostSelfTotal float64 = 0 //其他费用
  20610. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20611. //
  20612. // var materialCostTotal float64 = 0 //材料费
  20613. // var materialCostSelfTotal float64 = 0 //材料费
  20614. // var materialCostPartSelfTotal float64 = 0 //材料费
  20615. //
  20616. // var westernMedicineCostTotal float64 = 0 //西药费
  20617. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20618. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20619. //
  20620. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20621. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20622. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20623. //
  20624. // var checkCostTotal float64 = 0 //检查费
  20625. // var checkCostSelfTotal float64 = 0 //检查费
  20626. // var checkCostPartSelfTotal float64 = 0 //检查费
  20627. //
  20628. // var laboratoryCostTotal float64 = 0 //化验费
  20629. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20630. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20631. //
  20632. // var treatCostTotal float64 = 0 //治疗费用
  20633. // var treatCostSelfTotal float64 = 0 //治疗费用
  20634. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20635. //
  20636. // decimal.DivisionPrecision = 2
  20637. //
  20638. // var bed_fulamt_ownpay_amt float64 = 0
  20639. //
  20640. // var examine_fulamt_ownpay_amt float64 = 0
  20641. //
  20642. // var nursing_fulamt_ownpay_amt float64 = 0
  20643. //
  20644. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20645. //
  20646. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20647. //
  20648. // var register_fulamt_ownpay_amt float64 = 0
  20649. //
  20650. // var operation_fulamt_ownpay_amt float64 = 0
  20651. // var other_fulamt_ownpay_amt float64 = 0
  20652. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20653. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20654. // var check_fulamt_ownpay_amt float64 = 0
  20655. // var material_fulamt_ownpay_amt float64 = 0
  20656. // var laboratory_fulamt_ownpay_amt float64 = 0
  20657. // var treat_fulamt_ownpay_amt float64 = 0
  20658. //
  20659. // var bed_claa_sunmfee float64 = 0
  20660. // var bed_clab_amt float64 = 0
  20661. // var bed_other_amt float64 = 0
  20662. //
  20663. // var examine_claa_sunmfee float64 = 0
  20664. // var examine_clab_amt float64 = 0
  20665. // var examine_other_amt float64 = 0
  20666. //
  20667. // var nursing_claa_sunmfee float64 = 0
  20668. // var nursing_clab_amt float64 = 0
  20669. // var nursing_other_amt float64 = 0
  20670. //
  20671. // var chinese_medicine_claa_sunmfee float64 = 0
  20672. // var chinese_medicine_clab_amt float64 = 0
  20673. // var chinese_medicine_other_amt float64 = 0
  20674. //
  20675. // var commonly_treatment_claa_sunmfee float64 = 0
  20676. // var commonly_treatment_clab_amt float64 = 0
  20677. // var commonly_treatment_other_amt float64 = 0
  20678. //
  20679. // var operation_claa_sunmfee float64 = 0
  20680. // var operation_clab_amt float64 = 0
  20681. // var operation_other_amt float64 = 0
  20682. //
  20683. // var other_claa_sunmfee float64 = 0
  20684. // var other_clab_amt float64 = 0
  20685. // var other_other_amt float64 = 0
  20686. //
  20687. // var westernMedicine_claa_sunmfee float64 = 0
  20688. // var westernMedicine_clab_amt float64 = 0
  20689. // var westernMedicine_other_amt float64 = 0
  20690. //
  20691. // var chineseTraditional_claa_sunmfee float64 = 0
  20692. // var chineseTraditional_clab_amt float64 = 0
  20693. // var chineseTraditional_other_amt float64 = 0
  20694. //
  20695. // var check_claa_sunmfee float64 = 0
  20696. // var check_clab_amt float64 = 0
  20697. // var check_other_amt float64 = 0
  20698. //
  20699. // var material_claa_sunmfee float64 = 0
  20700. // var material_clab_amt float64 = 0
  20701. // var material_other_amt float64 = 0
  20702. //
  20703. // var laboratory_claa_sunmfee float64 = 0
  20704. // var laboratory_clab_amt float64 = 0
  20705. // var laboratory_other_amt float64 = 0
  20706. //
  20707. // var treat_claa_sunmfee float64 = 0
  20708. // var treat_clab_amt float64 = 0
  20709. // var treat_other_amt float64 = 0
  20710. //
  20711. // var register_claa_sunmfee float64 = 0
  20712. // var register_clab_amt float64 = 0
  20713. // var register_other_amt float64 = 0
  20714. //
  20715. // for _, item := range order.HisOrderInfo {
  20716. // if item.MedChrgitmType == "01" { //床位费
  20717. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20718. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20719. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20720. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20721. // if item.ChrgitmLv == "1" {
  20722. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20723. // }
  20724. // if item.ChrgitmLv == "2" {
  20725. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20726. //
  20727. // }
  20728. // if item.ChrgitmLv == "3" {
  20729. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20730. // }
  20731. //
  20732. // }
  20733. //
  20734. // if item.MedChrgitmType == "02" { //诊查
  20735. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20736. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20737. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20738. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20739. // if item.ChrgitmLv == "1" {
  20740. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20741. // }
  20742. // if item.ChrgitmLv == "2" {
  20743. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20744. //
  20745. // }
  20746. // if item.ChrgitmLv == "3" {
  20747. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20748. // }
  20749. //
  20750. // }
  20751. //
  20752. // if item.MedChrgitmType == "03" { //检查费
  20753. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20754. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20755. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20756. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20757. // if item.ChrgitmLv == "1" {
  20758. //
  20759. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20760. //
  20761. // }
  20762. // if item.ChrgitmLv == "2" {
  20763. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20764. //
  20765. // }
  20766. // if item.ChrgitmLv == "3" {
  20767. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20768. // }
  20769. // }
  20770. //
  20771. // if item.MedChrgitmType == "04" { //化验费
  20772. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20773. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20774. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20775. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20776. // if item.ChrgitmLv == "1" {
  20777. //
  20778. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20779. //
  20780. // }
  20781. // if item.ChrgitmLv == "2" {
  20782. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20783. //
  20784. // }
  20785. // if item.ChrgitmLv == "3" {
  20786. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20787. // }
  20788. // }
  20789. //
  20790. // if item.MedChrgitmType == "05" { //治疗费
  20791. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20792. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20793. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20794. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20795. // if item.ChrgitmLv == "1" {
  20796. //
  20797. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20798. //
  20799. // }
  20800. // if item.ChrgitmLv == "2" {
  20801. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20802. //
  20803. // }
  20804. // if item.ChrgitmLv == "3" {
  20805. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20806. // }
  20807. // }
  20808. //
  20809. // if item.MedChrgitmType == "06" { //手术费
  20810. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20811. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20812. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20813. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20814. //
  20815. // if item.ChrgitmLv == "1" {
  20816. //
  20817. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20818. //
  20819. // }
  20820. // if item.ChrgitmLv == "2" {
  20821. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20822. //
  20823. // }
  20824. // if item.ChrgitmLv == "3" {
  20825. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20826. // }
  20827. // }
  20828. //
  20829. // if item.MedChrgitmType == "07" { //手术费
  20830. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20831. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20832. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20833. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20834. //
  20835. // if item.ChrgitmLv == "1" {
  20836. //
  20837. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20838. //
  20839. // }
  20840. // if item.ChrgitmLv == "2" {
  20841. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20842. //
  20843. // }
  20844. // if item.ChrgitmLv == "3" {
  20845. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20846. // }
  20847. // }
  20848. //
  20849. // if item.MedChrgitmType == "08" { //材料费
  20850. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20851. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20852. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20853. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20854. // if item.ChrgitmLv == "1" {
  20855. //
  20856. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20857. //
  20858. // }
  20859. // if item.ChrgitmLv == "2" {
  20860. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20861. //
  20862. // }
  20863. // if item.ChrgitmLv == "3" {
  20864. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20865. // }
  20866. // }
  20867. // if item.MedChrgitmType == "09" { //西药费
  20868. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20869. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20870. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20871. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20872. // if item.ChrgitmLv == "1" {
  20873. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20874. // }
  20875. // if item.ChrgitmLv == "2" {
  20876. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20877. // }
  20878. // if item.ChrgitmLv == "3" {
  20879. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20880. // }
  20881. // }
  20882. // if item.MedChrgitmType == "10" { //中药饮片
  20883. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20884. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20885. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20886. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20887. // if item.ChrgitmLv == "1" {
  20888. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20889. // }
  20890. // if item.ChrgitmLv == "2" {
  20891. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20892. // }
  20893. // if item.ChrgitmLv == "3" {
  20894. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20895. // }
  20896. // }
  20897. //
  20898. // if item.MedChrgitmType == "11" { //中成费
  20899. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20900. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20901. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20902. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20903. // if item.ChrgitmLv == "1" {
  20904. //
  20905. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20906. //
  20907. // }
  20908. // if item.ChrgitmLv == "2" {
  20909. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20910. //
  20911. // }
  20912. // if item.ChrgitmLv == "3" {
  20913. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20914. // }
  20915. // }
  20916. //
  20917. // if item.MedChrgitmType == "12" { //中成费
  20918. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20919. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20920. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20921. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20922. // if item.ChrgitmLv == "1" {
  20923. //
  20924. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20925. //
  20926. // }
  20927. // if item.ChrgitmLv == "2" {
  20928. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20929. //
  20930. // }
  20931. // if item.ChrgitmLv == "3" {
  20932. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20933. // }
  20934. // }
  20935. //
  20936. // if item.MedChrgitmType == "13" { //中成费
  20937. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20938. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20939. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20940. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20941. // if item.ChrgitmLv == "1" {
  20942. //
  20943. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20944. //
  20945. // }
  20946. // if item.ChrgitmLv == "2" {
  20947. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20948. //
  20949. // }
  20950. // if item.ChrgitmLv == "3" {
  20951. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20952. // }
  20953. // }
  20954. //
  20955. // if item.MedChrgitmType == "14" { //其他费
  20956. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20957. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20958. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20959. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20960. // if item.ChrgitmLv == "1" {
  20961. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20962. //
  20963. // }
  20964. // if item.ChrgitmLv == "2" {
  20965. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20966. //
  20967. // }
  20968. // if item.ChrgitmLv == "3" {
  20969. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20970. // }
  20971. // }
  20972. //
  20973. // }
  20974. //
  20975. // var iteminfoStructs []service.IteminfoStruct
  20976. //
  20977. // if bedCostTotal != 0 {
  20978. // iteminfo.MedChrgitm = "01"
  20979. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20980. // iteminfo.Amt = bedCostTotal
  20981. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20982. // iteminfo.ClabAmt = bed_clab_amt
  20983. // iteminfo.OthAmt = bed_other_amt
  20984. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20985. // }
  20986. //
  20987. // if examineCostTotal != 0 {
  20988. // iteminfo.MedChrgitm = "02"
  20989. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20990. // iteminfo.Amt = examineCostTotal
  20991. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20992. // iteminfo.ClabAmt = examine_clab_amt
  20993. // iteminfo.OthAmt = examine_other_amt
  20994. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20995. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20996. // }
  20997. //
  20998. // if checkCostTotal != 0 {
  20999. // iteminfo.MedChrgitm = "03"
  21000. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21001. // iteminfo.Amt = checkCostTotal
  21002. // iteminfo.ClaaSumfee = check_claa_sunmfee
  21003. // iteminfo.ClabAmt = check_clab_amt
  21004. // iteminfo.OthAmt = check_other_amt
  21005. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21006. //
  21007. // }
  21008. //
  21009. // if laboratoryCostTotal != 0 {
  21010. // iteminfo.MedChrgitm = "04"
  21011. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21012. // iteminfo.Amt = laboratoryCostTotal
  21013. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21014. // iteminfo.ClabAmt = laboratory_clab_amt
  21015. // iteminfo.OthAmt = laboratory_other_amt
  21016. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21017. //
  21018. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21019. //
  21020. // }
  21021. //
  21022. // if treatCostTotal != 0 {
  21023. // iteminfo.MedChrgitm = "05"
  21024. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21025. // iteminfo.Amt = treatCostTotal
  21026. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  21027. // iteminfo.ClabAmt = treat_clab_amt
  21028. // iteminfo.OthAmt = treat_other_amt
  21029. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21030. // //(struct4101.IteminfoStruct, iteminfo)
  21031. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21032. // }
  21033. //
  21034. // if operationCostTotal != 0 {
  21035. // iteminfo.MedChrgitm = "06"
  21036. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21037. // iteminfo.Amt = operationCostTotal
  21038. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  21039. // iteminfo.ClabAmt = operation_clab_amt
  21040. // iteminfo.OthAmt = operation_other_amt
  21041. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21042. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21043. // }
  21044. //
  21045. // if nursingCostTotal != 0 {
  21046. // iteminfo.MedChrgitm = "07"
  21047. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  21048. // iteminfo.Amt = nursingCostTotal
  21049. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  21050. // iteminfo.ClabAmt = nursing_clab_amt
  21051. // iteminfo.OthAmt = nursing_other_amt
  21052. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21053. // }
  21054. //
  21055. // if materialCostTotal != 0 {
  21056. // iteminfo.MedChrgitm = "08"
  21057. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21058. // iteminfo.Amt = materialCostTotal
  21059. // iteminfo.ClaaSumfee = material_claa_sunmfee
  21060. // iteminfo.ClabAmt = material_clab_amt
  21061. // iteminfo.OthAmt = material_other_amt
  21062. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21063. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21064. // }
  21065. //
  21066. // if westernMedicineCostTotal != 0 {
  21067. // iteminfo.MedChrgitm = "09"
  21068. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21069. // iteminfo.Amt = westernMedicineCostTotal
  21070. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21071. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21072. // iteminfo.OthAmt = westernMedicine_other_amt
  21073. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21074. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21075. //
  21076. // }
  21077. //
  21078. // if chineseMedicineCostTotal != 0 {
  21079. // iteminfo.MedChrgitm = "10"
  21080. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  21081. // iteminfo.Amt = chineseMedicineCostTotal
  21082. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  21083. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  21084. // iteminfo.OthAmt = chinese_medicine_other_amt
  21085. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21086. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21087. //
  21088. // }
  21089. //
  21090. // if chineseTraditionalMedicineCostTotal != 0 {
  21091. // iteminfo.MedChrgitm = "11"
  21092. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21093. // iteminfo.Amt = westernMedicineCostTotal
  21094. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21095. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21096. // iteminfo.OthAmt = westernMedicine_other_amt
  21097. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21098. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21099. //
  21100. // }
  21101. //
  21102. // if commonlyTreatmentCostTotal != 0 {
  21103. // iteminfo.MedChrgitm = "12"
  21104. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21105. // iteminfo.Amt = commonlyTreatmentCostTotal
  21106. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21107. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21108. // iteminfo.OthAmt = commonly_treatment_other_amt
  21109. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21110. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21111. //
  21112. // }
  21113. //
  21114. // if registerCostTotal != 0 {
  21115. // iteminfo.MedChrgitm = "13"
  21116. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21117. // iteminfo.Amt = registerCostTotal
  21118. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21119. // iteminfo.ClabAmt = register_clab_amt
  21120. // iteminfo.OthAmt = register_other_amt
  21121. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21122. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21123. //
  21124. // }
  21125. //
  21126. // if otherCostTotal != 0 {
  21127. // iteminfo.MedChrgitm = "14"
  21128. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21129. // iteminfo.Amt = otherCostTotal
  21130. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21131. // iteminfo.ClabAmt = other_clab_amt
  21132. // iteminfo.OthAmt = other_other_amt
  21133. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21134. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21135. //
  21136. // }
  21137. // struct4101.IteminfoStruct = iteminfoStructs
  21138. // time_arr := strings.Split(order.SetlTime, " ")
  21139. // struct4101.AdmTime = time_arr[0]
  21140. // struct4101.AdmEndTime = time_arr[0]
  21141. //
  21142. // struct4101.DoctorName = doctor.UserName
  21143. // struct4101.DoctorCode = doctor.DoctorNumber
  21144. //
  21145. // struct4101.Ntly = "中国"
  21146. // struct4101.AdmCaty = "A03.06"
  21147. // var res ResultSeventeen
  21148. // if miConfig.MdtrtareaAdmvs == "421300" {
  21149. // data := make(map[string]interface{})
  21150. // data["struct4101"] = struct4101
  21151. // data["secret_key"] = miConfig.SecretKey
  21152. // data["org_name"] = miConfig.OrgName
  21153. // data["opera"] = curRoles.UserName
  21154. // data["code"] = miConfig.Code
  21155. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21156. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21157. //
  21158. // client := &http.Client{}
  21159. // bytesData, _ := json.Marshal(data)
  21160. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21161. // resp, _ := client.Do(req)
  21162. // defer resp.Body.Close()
  21163. // body, ioErr := ioutil.ReadAll(resp.Body)
  21164. // if ioErr != nil {
  21165. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21167. // return
  21168. // }
  21169. // var respJSON map[string]interface{}
  21170. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21171. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21173. // return
  21174. // }
  21175. //
  21176. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21177. // userJSONBytes, _ := json.Marshal(respJSON)
  21178. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21179. // utils.ErrorLog("解析失败:%v", err)
  21180. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21181. // adminUser := c.GetAdminUserInfo()
  21182. // errlog := &models.HisOrderError{
  21183. // UserOrgId: adminUser.CurrentOrgId,
  21184. // Ctime: time.Now().Unix(),
  21185. // Mtime: time.Now().Unix(),
  21186. // ErrMsg: res.ErrMsg + "解析失败",
  21187. // Status: 1,
  21188. // PatientId: order_id,
  21189. // Stage: 10088,
  21190. // }
  21191. // service.CreateErrMsgLog(errlog)
  21192. // continue
  21193. // }
  21194. //
  21195. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21196. // data := make(map[string]interface{})
  21197. // data["struct4101"] = struct4101
  21198. // data["secret_key"] = miConfig.SecretKey
  21199. // data["org_name"] = miConfig.OrgName
  21200. // data["opera"] = curRoles.UserName
  21201. // data["code"] = miConfig.Code
  21202. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21203. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21204. //
  21205. // client := &http.Client{}
  21206. // bytesData, _ := json.Marshal(data)
  21207. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21208. // resp, _ := client.Do(req)
  21209. // defer resp.Body.Close()
  21210. // body, ioErr := ioutil.ReadAll(resp.Body)
  21211. // if ioErr != nil {
  21212. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21214. // return
  21215. // }
  21216. // var respJSON map[string]interface{}
  21217. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21218. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21220. // return
  21221. // }
  21222. //
  21223. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21224. // userJSONBytes, _ := json.Marshal(respJSON)
  21225. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21226. // utils.ErrorLog("解析失败:%v", err)
  21227. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21228. // adminUser := c.GetAdminUserInfo()
  21229. // errlog := &models.HisOrderError{
  21230. // UserOrgId: adminUser.CurrentOrgId,
  21231. // Ctime: time.Now().Unix(),
  21232. // Mtime: time.Now().Unix(),
  21233. // ErrMsg: res.ErrMsg + "解析失败",
  21234. // Status: 1,
  21235. // PatientId: order_id,
  21236. // Stage: 10088,
  21237. // }
  21238. // service.CreateErrMsgLog(errlog)
  21239. // continue
  21240. // }
  21241. //
  21242. // } else {
  21243. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21244. // fmt.Println(result)
  21245. //
  21246. // var dat map[string]interface{}
  21247. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21248. // fmt.Println(dat)
  21249. // } else {
  21250. // fmt.Println(err)
  21251. // }
  21252. // userJSONBytes, _ := json.Marshal(dat)
  21253. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21254. // utils.ErrorLog("解析失败:%v", err)
  21255. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21256. // adminUser := c.GetAdminUserInfo()
  21257. // errlog := &models.HisOrderError{
  21258. // UserOrgId: adminUser.CurrentOrgId,
  21259. // Ctime: time.Now().Unix(),
  21260. // Mtime: time.Now().Unix(),
  21261. // ErrMsg: res.ErrMsg + "解析失败",
  21262. // Status: 1,
  21263. // PatientId: order_id,
  21264. // Stage: 10106,
  21265. // }
  21266. // service.CreateErrMsgLog(errlog)
  21267. // continue
  21268. // }
  21269. // }
  21270. //
  21271. // if res.Infcode != 0 {
  21272. // adminUser := c.GetAdminUserInfo()
  21273. // errlog := &models.HisOrderError{
  21274. // UserOrgId: adminUser.CurrentOrgId,
  21275. // Ctime: time.Now().Unix(),
  21276. // Mtime: time.Now().Unix(),
  21277. // ErrMsg: res.ErrMsg,
  21278. // Status: 1,
  21279. // PatientId: order_id,
  21280. // Stage: 10106,
  21281. // }
  21282. // service.CreateErrMsgLog(errlog)
  21283. // continue
  21284. // } else {
  21285. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21286. // Number: res.Output.SetlListId,
  21287. // Status: 1,
  21288. // Ctime: time.Now().Unix(),
  21289. // Mtime: time.Now().Unix(),
  21290. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21291. // IsUpload: 1,
  21292. // OrderId: order_id,
  21293. // }
  21294. // service.CreateUploadRecord(hisFundSettleListResult)
  21295. // continue
  21296. // }
  21297. // }
  21298. //}
  21299. func (c *HisApiController) GetOrgInfo() {
  21300. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21301. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21302. }
  21303. func (c *HisApiController) GetHisPatientInfo() {
  21304. medical_insurance_card := c.GetString("medical_insurance_card")
  21305. id_card_type, _ := c.GetInt64("id_card_type")
  21306. id_card := c.GetString("id_card")
  21307. adminInfo := c.GetAdminUserInfo()
  21308. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21309. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21310. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21311. IdCardNo := ""
  21312. if id_card_type == 1 {
  21313. IdCardNo = medical_insurance_card
  21314. } else if id_card_type == 2 {
  21315. IdCardNo = id_card
  21316. }
  21317. if config.IsOpen == 1 {
  21318. 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
  21319. resp, requestErr := http.Get(api)
  21320. if requestErr != nil {
  21321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21322. return
  21323. }
  21324. defer resp.Body.Close()
  21325. body, ioErr := ioutil.ReadAll(resp.Body)
  21326. if ioErr != nil {
  21327. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21329. return
  21330. }
  21331. var respJSON map[string]interface{}
  21332. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21335. return
  21336. }
  21337. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21338. userJSONBytes, _ := json.Marshal(userJSON)
  21339. var res ResultTwo
  21340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21341. utils.ErrorLog("解析失败:%v", err)
  21342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21343. return
  21344. }
  21345. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21346. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21347. infoStr := string(Iinfos)
  21348. idetinfoStr := string(Idetinfos)
  21349. if res.Infcode == 0 {
  21350. his := models.VMHisPatient{
  21351. Status: 1,
  21352. Ctime: time.Now().Unix(),
  21353. Mtime: time.Now().Unix(),
  21354. PsnNo: res.Output.Baseinfo.PsnNo,
  21355. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21356. Certno: res.Output.Baseinfo.Certno,
  21357. PsnName: res.Output.Baseinfo.PsnName,
  21358. Gend: res.Output.Baseinfo.Gend,
  21359. Naty: res.Output.Baseinfo.Naty,
  21360. Iinfo: infoStr,
  21361. Idetinfo: idetinfoStr,
  21362. UserOrgId: adminInfo.CurrentOrgId,
  21363. IsReturn: 1,
  21364. IdCardType: id_card_type,
  21365. }
  21366. c.ServeSuccessJSON(map[string]interface{}{
  21367. "info": his,
  21368. })
  21369. } else {
  21370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21371. return
  21372. }
  21373. }
  21374. }
  21375. //func GetBasBaseInfo() (jsonStr string, err error) {
  21376. //
  21377. // handle := syscall.NewLazyDLL("SSCard.dll")
  21378. // add := handle.NewProc("ReadCardBas")
  21379. // str := make([]byte, 1024)
  21380. // str1 := make([]byte, 1024)
  21381. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21382. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21383. //
  21384. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21385. //
  21386. // fmt.Println("> Add(4,5)的结果为:", ret)
  21387. // handle.Release()
  21388. //
  21389. // return "", nil
  21390. //
  21391. //}
  21392. //func GetQRBaseInfo() (jsonStr string, err error) {
  21393. // handle := syscall.LoadDLL("SSCard.dll")
  21394. // ReadCardBas := handle.FindProc("GetQRBase")
  21395. //
  21396. // str := make([]byte, 256)
  21397. // str1 := make([]byte, 256)
  21398. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21399. //
  21400. // fmt.Println(string(str))
  21401. // fmt.Println(r)
  21402. // return string(str), nil
  21403. //}
  21404. //func CardInit() int {
  21405. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21406. // add := DllTestDef.MustFindProc("Init")
  21407. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21408. // if err != nil {
  21409. // fmt.Println("SSCard的运算结果为:", ret)
  21410. // }
  21411. // result := int(ret)
  21412. // return result
  21413. //}
  21414. //func CardInit() int {
  21415. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21416. // if err != nil {
  21417. // fmt.Println("SSCard的运算结果为:", ret)
  21418. // }
  21419. // fmt.Println(err)
  21420. // result := int(ret)
  21421. // return result
  21422. //}
  21423. func IntPtr(n int) uintptr {
  21424. return uintptr(n)
  21425. }
  21426. func StrPtr(s string) uintptr {
  21427. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21428. }
  21429. type Result2001 struct {
  21430. Cainfo interface{} `json:"cainfo"`
  21431. ErrMsg string `json:"err_msg"`
  21432. InfRefmsgid string `json:"inf_refmsgid"`
  21433. Infcode int64 `json:"infcode"`
  21434. Output struct {
  21435. Trtinfo struct {
  21436. PsnNo string `json:"psn_no"`
  21437. TrtChkType string `json:"trt_chk_type"`
  21438. FundPayType string `json:"fund_pay_type"`
  21439. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21440. Begndate string `json:"begndate"`
  21441. Enddate string `json:"enddate"`
  21442. TrtChkRslt string `json:"trt_chk_rslt"`
  21443. } `json:"trtinfo"`
  21444. } `json:"output"`
  21445. RefmsgTime string `json:"refmsg_time"`
  21446. RespondTime string `json:"respond_time"`
  21447. Signtype interface{} `json:"signtype"`
  21448. WarnMsg interface{} `json:"warn_msg"`
  21449. }
  21450. type Result2001Org10265 struct {
  21451. Cainfo interface{} `json:"cainfo"`
  21452. ErrMsg string `json:"err_msg"`
  21453. InfRefmsgid string `json:"inf_refmsgid"`
  21454. Infcode string `json:"infcode"`
  21455. Output struct {
  21456. Trtinfo struct {
  21457. PsnNo string `json:"psn_no"`
  21458. TrtChkType string `json:"trt_chk_type"`
  21459. FundPayType string `json:"fund_pay_type"`
  21460. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21461. Begndate string `json:"begndate"`
  21462. Enddate string `json:"enddate"`
  21463. TrtChkRslt string `json:"trt_chk_rslt"`
  21464. } `json:"trtinfo"`
  21465. } `json:"output"`
  21466. RefmsgTime string `json:"refmsg_time"`
  21467. RespondTime string `json:"respond_time"`
  21468. Signtype interface{} `json:"signtype"`
  21469. WarnMsg interface{} `json:"warn_msg"`
  21470. }
  21471. type ResultTwo struct {
  21472. ErrMsg string `json:"err_msg"`
  21473. InfRefmsgid string `json:"inf_refmsgid"`
  21474. Infcode int64 `json:"infcode"`
  21475. Output struct {
  21476. Baseinfo struct {
  21477. //Brdy string `json:"brdy"`
  21478. Certno string `json:"certno"`
  21479. Gend string `json:"gend"`
  21480. Naty string `json:"naty"`
  21481. PsnCertType string `json:"psn_cert_type"`
  21482. PsnName string `json:"psn_name"`
  21483. PsnNo string `json:"psn_no"`
  21484. } `json:"baseinfo"`
  21485. Idetinfo []interface{} `json:"idetinfo"`
  21486. Iinfo []struct {
  21487. Balc float64 `json:"balc"`
  21488. CvlservFlag string `json:"cvlserv_flag"`
  21489. EmpName string `json:"emp_name"`
  21490. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21491. Insutype string `json:"insutype"`
  21492. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21493. //PausInsuDate string `json:"paus_insu_date"`
  21494. //PsnInsuDate string `json:"psn_insu_date"`
  21495. PsnInsuStas string `json:"psn_insu_stas"`
  21496. PsnType string `json:"psn_type"`
  21497. } `json:"insuinfo"`
  21498. } `json:"output"`
  21499. RefmsgTime string `json:"refmsg_time"`
  21500. RespondTime string `json:"respond_time"`
  21501. Signtype interface{} `json:"signtype"`
  21502. WarnInfo interface{} `json:"warn_info"`
  21503. }
  21504. type ResultTwo10265 struct {
  21505. ErrMsg string `json:"err_msg"`
  21506. InfRefmsgid string `json:"inf_refmsgid"`
  21507. Infcode string `json:"infcode"`
  21508. Output struct {
  21509. Baseinfo struct {
  21510. //Brdy string `json:"brdy"`
  21511. Certno string `json:"certno"`
  21512. Gend string `json:"gend"`
  21513. Naty string `json:"naty"`
  21514. PsnCertType string `json:"psn_cert_type"`
  21515. PsnName string `json:"psn_name"`
  21516. PsnNo string `json:"psn_no"`
  21517. } `json:"baseinfo"`
  21518. Idetinfo []interface{} `json:"idetinfo"`
  21519. Iinfo []struct {
  21520. Balc float64 `json:"balc"`
  21521. CvlservFlag string `json:"cvlserv_flag"`
  21522. EmpName string `json:"emp_name"`
  21523. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21524. Insutype string `json:"insutype"`
  21525. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21526. PsnInsuStas string `json:"psn_insu_stas"`
  21527. PsnType string `json:"psn_type"`
  21528. } `json:"insuinfo"`
  21529. } `json:"output"`
  21530. RefmsgTime string `json:"refmsg_time"`
  21531. RespondTime string `json:"respond_time"`
  21532. Signtype interface{} `json:"signtype"`
  21533. WarnInfo interface{} `json:"warn_info"`
  21534. }
  21535. type ResultThree struct {
  21536. Cainfo interface{} `json:"cainfo"`
  21537. ErrMsg string `json:"err_msg"`
  21538. InfRefmsgid string `json:"inf_refmsgid"`
  21539. Infcode int64 `json:"infcode"`
  21540. Output struct {
  21541. Data struct {
  21542. IptOtpNo string `json:"ipt_otp_no"`
  21543. MdtrtID string `json:"mdtrt_id"`
  21544. PsnNo string `json:"psn_no"`
  21545. } `json:"data"`
  21546. } `json:"output"`
  21547. RefmsgTime string `json:"refmsg_time"`
  21548. RespondTime string `json:"respond_time"`
  21549. Signtype interface{} `json:"signtype"`
  21550. WarnMsg interface{} `json:"warn_msg"`
  21551. }
  21552. type ResultThree10265 struct {
  21553. Cainfo interface{} `json:"cainfo"`
  21554. ErrMsg string `json:"err_msg"`
  21555. InfRefmsgid string `json:"inf_refmsgid"`
  21556. Infcode string `json:"infcode"`
  21557. Output struct {
  21558. Data struct {
  21559. IptOtpNo string `json:"ipt_otp_no"`
  21560. MdtrtID string `json:"mdtrt_id"`
  21561. PsnNo string `json:"psn_no"`
  21562. } `json:"data"`
  21563. } `json:"output"`
  21564. RefmsgTime string `json:"refmsg_time"`
  21565. RespondTime string `json:"respond_time"`
  21566. Signtype interface{} `json:"signtype"`
  21567. WarnMsg interface{} `json:"warn_msg"`
  21568. }
  21569. type ResultFour struct {
  21570. Cainfo string `json:"cainfo"`
  21571. ErrMsg string `json:"err_msg"`
  21572. InfRefmsgid string `json:"inf_refmsgid"`
  21573. Infcode int64 `json:"infcode"`
  21574. Output struct {
  21575. Result []struct {
  21576. BasMednFlag string `json:"bas_medn_flag"`
  21577. ChldMedcFlag string `json:"chld_medc_flag"`
  21578. ChrgitmLv string `json:"chrgitm_lv"`
  21579. Cnt float64 `json:"cnt"`
  21580. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21581. DrtReimFlag string `json:"drt_reim_flag"`
  21582. FeedetlSn string `json:"feedetl_sn"`
  21583. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21584. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21585. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21586. ListSpItemFlag string `json:"list_sp_item_flag"`
  21587. LmtUsedFlag string `json:"lmt_used_flag"`
  21588. MedChrgitmType string `json:"med_chrgitm_type"`
  21589. Memo string `json:"memo"`
  21590. OverlmtAmt float64 `json:"overlmt_amt"`
  21591. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21592. Pric float64 `json:"pric"`
  21593. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21594. SelfpayProp float64 `json:"selfpay_prop"`
  21595. } `json:"result"`
  21596. } `json:"output"`
  21597. RefmsgTime string `json:"refmsg_time"`
  21598. RespondTime string `json:"respond_time"`
  21599. Signtype string `json:"signtype"`
  21600. WarnMsg string `json:"warn_msg"`
  21601. }
  21602. type ResultFour10265 struct {
  21603. Cainfo string `json:"cainfo"`
  21604. ErrMsg string `json:"err_msg"`
  21605. InfRefmsgid string `json:"inf_refmsgid"`
  21606. Infcode string `json:"infcode"`
  21607. Output struct {
  21608. Result []struct {
  21609. BasMednFlag string `json:"bas_medn_flag"`
  21610. ChldMedcFlag string `json:"chld_medc_flag"`
  21611. ChrgitmLv string `json:"chrgitm_lv"`
  21612. Cnt float64 `json:"cnt"`
  21613. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21614. DrtReimFlag string `json:"drt_reim_flag"`
  21615. FeedetlSn string `json:"feedetl_sn"`
  21616. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21617. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21618. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21619. ListSpItemFlag string `json:"list_sp_item_flag"`
  21620. LmtUsedFlag string `json:"lmt_used_flag"`
  21621. MedChrgitmType string `json:"med_chrgitm_type"`
  21622. Memo string `json:"memo"`
  21623. OverlmtAmt float64 `json:"overlmt_amt"`
  21624. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21625. Pric float64 `json:"pric"`
  21626. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21627. SelfpayProp float64 `json:"selfpay_prop"`
  21628. } `json:"result"`
  21629. } `json:"output"`
  21630. RefmsgTime string `json:"refmsg_time"`
  21631. RespondTime string `json:"respond_time"`
  21632. Signtype string `json:"signtype"`
  21633. WarnMsg string `json:"warn_msg"`
  21634. }
  21635. type ResultMemo struct {
  21636. InsuAdmdvs string `json:"insuAdmdvs"`
  21637. }
  21638. // [{"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}]
  21639. type ResultIDInfo struct {
  21640. Begntime string `json:"begntime"`
  21641. Endtime string `json:"endtime"`
  21642. Memo string `json:"memo"`
  21643. }
  21644. type ResultFive struct {
  21645. Balc float64 `json:"balc"`
  21646. CvlservFlag string `json:"cvlserv_flag"`
  21647. EmpName string `json:"emp_name"`
  21648. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21649. Insutype string `json:"insutype"`
  21650. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21651. PausInsuDate string `json:"paus_insu_date"`
  21652. PsnInsuDate string `json:"psn_insu_date"`
  21653. PsnInsuStas string `json:"psn_insu_stas"`
  21654. PsnType string `json:"psn_type"`
  21655. }
  21656. type ResultSix struct {
  21657. Cainfo interface{} `json:"cainfo"`
  21658. ErrMsg string `json:"err_msg"`
  21659. InfRefmsgid string `json:"inf_refmsgid"`
  21660. Infcode int64 `json:"infcode"`
  21661. Output struct {
  21662. } `json:"output"`
  21663. RefmsgTime string `json:"refmsg_time"`
  21664. RespondTime string `json:"respond_time"`
  21665. Signtype interface{} `json:"signtype"`
  21666. WarnMsg interface{} `json:"warn_msg"`
  21667. }
  21668. type FJ3507Result struct {
  21669. Cainfo interface{} `json:"cainfo"`
  21670. ErrMsg string `json:"err_msg"`
  21671. InfRefmsgid string `json:"inf_refmsgid"`
  21672. Infcode int64 `json:"infcode"`
  21673. Output struct {
  21674. retRslt string `json:"retRslt"`
  21675. msgRslt string `json:"msgRslt"`
  21676. } `json:"output"`
  21677. RefmsgTime string `json:"refmsg_time"`
  21678. RespondTime string `json:"respond_time"`
  21679. Signtype interface{} `json:"signtype"`
  21680. WarnMsg interface{} `json:"warn_msg"`
  21681. }
  21682. type FJ3507ResultFor10188 struct {
  21683. Cainfo interface{} `json:"cainfo"`
  21684. ErrMsg string `json:"err_msg"`
  21685. InfRefmsgid string `json:"inf_refmsgid"`
  21686. Infcode string `json:"infcode"`
  21687. RefmsgTime string `json:"refmsg_time"`
  21688. RespondTime string `json:"respond_time"`
  21689. Signtype interface{} `json:"signtype"`
  21690. WarnMsg interface{} `json:"warn_msg"`
  21691. }
  21692. type Result2406 struct {
  21693. Cainfo interface{} `json:"cainfo"`
  21694. ErrMsg string `json:"err_msg"`
  21695. InfRefmsgid string `json:"inf_refmsgid"`
  21696. Infcode int64 `json:"infcode"`
  21697. Output struct {
  21698. Result struct {
  21699. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21700. } `json:"result"`
  21701. } `json:"output"`
  21702. RefmsgTime string `json:"refmsg_time"`
  21703. RespondTime string `json:"respond_time"`
  21704. Signtype interface{} `json:"signtype"`
  21705. WarnMsg interface{} `json:"warn_msg"`
  21706. }
  21707. type GZResultSix struct {
  21708. Cainfo interface{} `json:"cainfo"`
  21709. ErrMsg string `json:"err_msg"`
  21710. InfRefmsgid string `json:"inf_refmsgid"`
  21711. Infcode int64 `json:"infcode"`
  21712. Output string `json:"output"`
  21713. RefmsgTime string `json:"refmsg_time"`
  21714. RespondTime string `json:"respond_time"`
  21715. Signtype interface{} `json:"signtype"`
  21716. WarnMsg interface{} `json:"warn_msg"`
  21717. }
  21718. type ResultSix10265 struct {
  21719. Cainfo interface{} `json:"cainfo"`
  21720. ErrMsg string `json:"err_msg"`
  21721. InfRefmsgid string `json:"inf_refmsgid"`
  21722. Infcode string `json:"infcode"`
  21723. Output struct {
  21724. } `json:"output"`
  21725. RefmsgTime string `json:"refmsg_time"`
  21726. RespondTime string `json:"respond_time"`
  21727. Signtype interface{} `json:"signtype"`
  21728. WarnMsg interface{} `json:"warn_msg"`
  21729. }
  21730. type ResultSeven struct {
  21731. Cainfo string `json:"cainfo"`
  21732. ErrMsg string `json:"err_msg"`
  21733. InfRefmsgid string `json:"inf_refmsgid"`
  21734. Infcode int64 `json:"infcode"`
  21735. Output struct {
  21736. Setlinfo struct {
  21737. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21738. AcctPay float64 `json:"acct_pay"`
  21739. ActPayDedc float64 `json:"act_pay_dedc"`
  21740. Age float64 `json:"age"`
  21741. Balc float64 `json:"balc"`
  21742. Certno string `json:"certno"`
  21743. ClrOptins string `json:"clr_optins"`
  21744. ClrType string `json:"clr_type"`
  21745. ClrWay string `json:"clr_way"`
  21746. CvlservFlag string `json:"cvlserv_flag"`
  21747. CvlservPay float64 `json:"cvlserv_pay"`
  21748. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21749. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21750. Gend string `json:"gend"`
  21751. HifesPay float64 `json:"hifes_pay"`
  21752. HifmiPay float64 `json:"hifmi_pay"`
  21753. HifpPay float64 `json:"hifp_pay"`
  21754. HospPartAmt float64 `json:"hosp_part_amt"`
  21755. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21756. Insutype string `json:"insutype"`
  21757. MafPay float64 `json:"maf_pay"`
  21758. MdtrtCertType string `json:"mdtrt_cert_type"`
  21759. HifobPay float64 `json:"hifob_pay"`
  21760. MdtrtID string `json:"mdtrt_id"`
  21761. MedType string `json:"med_type"`
  21762. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21763. MedinsSetlID string `json:"medins_setl_id"`
  21764. Naty string `json:"naty"`
  21765. OthPay float64 `json:"oth_pay"`
  21766. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21767. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21768. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21769. PsnCashPay float64 `json:"psn_cash_pay"`
  21770. PsnCertType string `json:"psn_cert_type"`
  21771. PsnName string `json:"psn_name"`
  21772. PsnNo string `json:"psn_no"`
  21773. PsnPartAmt float64 `json:"psn_part_amt"`
  21774. PsnType string `json:"psn_type"`
  21775. SetlID string `json:"setl_id"`
  21776. SetlTime string `json:"setl_time"`
  21777. } `json:"setlinfo"`
  21778. Setldetail interface{} `json:"setldetail"`
  21779. } `json:"output"`
  21780. RefmsgTime string `json:"refmsg_time"`
  21781. RespondTime string `json:"respond_time"`
  21782. Signtype interface{} `json:"signtype"`
  21783. WarnMsg interface{} `json:"warn_msg"`
  21784. }
  21785. type ResultSevenAH struct {
  21786. Cainfo string `json:"cainfo"`
  21787. ErrMsg string `json:"err_msg"`
  21788. InfRefmsgid string `json:"inf_refmsgid"`
  21789. Infcode int64 `json:"infcode"`
  21790. Output struct {
  21791. Setlinfo struct {
  21792. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21793. AcctPay float64 `json:"acct_pay"`
  21794. ActPayDedc float64 `json:"act_pay_dedc"`
  21795. Age float64 `json:"age"`
  21796. Balc float64 `json:"balc"`
  21797. Certno string `json:"certno"`
  21798. ClrOptins string `json:"clr_optins"`
  21799. ClrType string `json:"clr_type"`
  21800. ClrWay string `json:"clr_way"`
  21801. CvlservFlag string `json:"cvlserv_flag"`
  21802. CvlservPay float64 `json:"cvlserv_pay"`
  21803. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21804. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21805. Gend string `json:"gend"`
  21806. HifesPay float64 `json:"hifes_pay"`
  21807. HifmiPay float64 `json:"hifmi_pay"`
  21808. HifpPay float64 `json:"hifp_pay"`
  21809. HospPartAmt float64 `json:"hosp_part_amt"`
  21810. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21811. Insutype string `json:"insutype"`
  21812. MafPay float64 `json:"maf_pay"`
  21813. MdtrtCertType string `json:"mdtrt_cert_type"`
  21814. HifobPay float64 `json:"hifob_pay"`
  21815. MdtrtID string `json:"mdtrt_id"`
  21816. MedType string `json:"med_type"`
  21817. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21818. MedinsSetlID string `json:"medins_setl_id"`
  21819. Naty string `json:"naty"`
  21820. OthPay float64 `json:"oth_pay"`
  21821. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21822. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21823. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21824. PsnCashPay float64 `json:"psn_cash_pay"`
  21825. PsnCertType string `json:"psn_cert_type"`
  21826. PsnName string `json:"psn_name"`
  21827. PsnNo string `json:"psn_no"`
  21828. PsnPartAmt float64 `json:"psn_part_amt"`
  21829. PsnType string `json:"psn_type"`
  21830. SetlID string `json:"setl_id"`
  21831. SetlTime int64 `json:"setl_time"`
  21832. } `json:"setlinfo"`
  21833. Setldetail interface{} `json:"setldetail"`
  21834. } `json:"output"`
  21835. RefmsgTime string `json:"refmsg_time"`
  21836. RespondTime string `json:"respond_time"`
  21837. Signtype interface{} `json:"signtype"`
  21838. WarnMsg interface{} `json:"warn_msg"`
  21839. }
  21840. type ResultSeven10265 struct {
  21841. Cainfo string `json:"cainfo"`
  21842. ErrMsg string `json:"err_msg"`
  21843. InfRefmsgid string `json:"inf_refmsgid"`
  21844. Infcode string `json:"infcode"`
  21845. Output struct {
  21846. Setlinfo struct {
  21847. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21848. AcctPay float64 `json:"acct_pay"`
  21849. ActPayDedc float64 `json:"act_pay_dedc"`
  21850. Age float64 `json:"age"`
  21851. Balc float64 `json:"balc"`
  21852. Certno string `json:"certno"`
  21853. ClrOptins string `json:"clr_optins"`
  21854. ClrType string `json:"clr_type"`
  21855. ClrWay string `json:"clr_way"`
  21856. CvlservFlag string `json:"cvlserv_flag"`
  21857. CvlservPay float64 `json:"cvlserv_pay"`
  21858. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21859. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21860. Gend string `json:"gend"`
  21861. HifesPay float64 `json:"hifes_pay"`
  21862. HifmiPay float64 `json:"hifmi_pay"`
  21863. HifpPay float64 `json:"hifp_pay"`
  21864. HospPartAmt float64 `json:"hosp_part_amt"`
  21865. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21866. Insutype string `json:"insutype"`
  21867. MafPay float64 `json:"maf_pay"`
  21868. MdtrtCertType string `json:"mdtrt_cert_type"`
  21869. HifobPay float64 `json:"hifob_pay"`
  21870. MdtrtID string `json:"mdtrt_id"`
  21871. MedType string `json:"med_type"`
  21872. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21873. MedinsSetlID string `json:"medins_setl_id"`
  21874. Naty string `json:"naty"`
  21875. OthPay float64 `json:"oth_pay"`
  21876. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21877. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21878. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21879. PsnCashPay float64 `json:"psn_cash_pay"`
  21880. PsnCertType string `json:"psn_cert_type"`
  21881. PsnName string `json:"psn_name"`
  21882. PsnNo string `json:"psn_no"`
  21883. PsnPartAmt float64 `json:"psn_part_amt"`
  21884. PsnType string `json:"psn_type"`
  21885. SetlID string `json:"setl_id"`
  21886. SetlTime string `json:"setl_time"`
  21887. } `json:"setlinfo"`
  21888. Setldetail interface{} `json:"setldetail"`
  21889. } `json:"output"`
  21890. RefmsgTime string `json:"refmsg_time"`
  21891. RespondTime string `json:"respond_time"`
  21892. Signtype interface{} `json:"signtype"`
  21893. WarnMsg interface{} `json:"warn_msg"`
  21894. }
  21895. type ResultSeven10265Two struct {
  21896. Cainfo string `json:"cainfo"`
  21897. ErrMsg string `json:"err_msg"`
  21898. InfRefmsgid string `json:"inf_refmsgid"`
  21899. Infcode string `json:"infcode"`
  21900. Output struct {
  21901. Setlinfo struct {
  21902. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21903. AcctPay float64 `json:"acct_pay"`
  21904. ActPayDedc float64 `json:"act_pay_dedc"`
  21905. Age float64 `json:"age"`
  21906. Balc float64 `json:"balc"`
  21907. Certno string `json:"certno"`
  21908. ClrOptins string `json:"clr_optins"`
  21909. ClrType string `json:"clr_type"`
  21910. ClrWay string `json:"clr_way"`
  21911. CvlservFlag string `json:"cvlserv_flag"`
  21912. CvlservPay float64 `json:"cvlserv_pay"`
  21913. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21914. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21915. Gend string `json:"gend"`
  21916. HifesPay float64 `json:"hifes_pay"`
  21917. HifmiPay float64 `json:"hifmi_pay"`
  21918. HifpPay float64 `json:"hifp_pay"`
  21919. HospPartAmt string `json:"hosp_part_amt"`
  21920. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21921. Insutype string `json:"insutype"`
  21922. MafPay float64 `json:"maf_pay"`
  21923. MdtrtCertType string `json:"mdtrt_cert_type"`
  21924. HifobPay float64 `json:"hifob_pay"`
  21925. MdtrtID string `json:"mdtrt_id"`
  21926. MedType string `json:"med_type"`
  21927. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21928. MedinsSetlID string `json:"medins_setl_id"`
  21929. Naty string `json:"naty"`
  21930. OthPay float64 `json:"oth_pay"`
  21931. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21932. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21933. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21934. PsnCashPay float64 `json:"psn_cash_pay"`
  21935. PsnCertType string `json:"psn_cert_type"`
  21936. PsnName string `json:"psn_name"`
  21937. PsnNo string `json:"psn_no"`
  21938. PsnPartAmt float64 `json:"psn_part_amt"`
  21939. PsnType string `json:"psn_type"`
  21940. SetlID string `json:"setl_id"`
  21941. SetlTime string `json:"setl_time"`
  21942. } `json:"setlinfo"`
  21943. Setldetail interface{} `json:"setldetail"`
  21944. } `json:"output"`
  21945. RefmsgTime string `json:"refmsg_time"`
  21946. RespondTime string `json:"respond_time"`
  21947. Signtype interface{} `json:"signtype"`
  21948. WarnMsg interface{} `json:"warn_msg"`
  21949. }
  21950. type GZResultSeven10265Two struct {
  21951. Cainfo string `json:"cainfo"`
  21952. ErrMsg string `json:"err_msg"`
  21953. InfRefmsgid string `json:"inf_refmsgid"`
  21954. Infcode int64 `json:"infcode"`
  21955. Output struct {
  21956. Setlinfo struct {
  21957. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21958. AcctPay float64 `json:"acct_pay"`
  21959. ActPayDedc float64 `json:"act_pay_dedc"`
  21960. Age float64 `json:"age"`
  21961. Balc float64 `json:"balc"`
  21962. Certno string `json:"certno"`
  21963. ClrOptins string `json:"clr_optins"`
  21964. ClrType string `json:"clr_type"`
  21965. ClrWay string `json:"clr_way"`
  21966. CvlservFlag string `json:"cvlserv_flag"`
  21967. CvlservPay float64 `json:"cvlserv_pay"`
  21968. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21969. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21970. Gend string `json:"gend"`
  21971. HifesPay float64 `json:"hifes_pay"`
  21972. HifmiPay float64 `json:"hifmi_pay"`
  21973. HifpPay float64 `json:"hifp_pay"`
  21974. HospPartAmt float64 `json:"hosp_part_amt"`
  21975. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21976. Insutype string `json:"insutype"`
  21977. MafPay float64 `json:"maf_pay"`
  21978. MdtrtCertType string `json:"mdtrt_cert_type"`
  21979. HifobPay float64 `json:"hifob_pay"`
  21980. MdtrtID string `json:"mdtrt_id"`
  21981. MedType string `json:"med_type"`
  21982. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21983. MedinsSetlID string `json:"medins_setl_id"`
  21984. Naty string `json:"naty"`
  21985. OthPay float64 `json:"oth_pay"`
  21986. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21987. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21988. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21989. PsnCashPay float64 `json:"psn_cash_pay"`
  21990. PsnCertType string `json:"psn_cert_type"`
  21991. PsnName string `json:"psn_name"`
  21992. PsnNo string `json:"psn_no"`
  21993. PsnPartAmt float64 `json:"psn_part_amt"`
  21994. PsnType string `json:"psn_type"`
  21995. SetlID string `json:"setl_id"`
  21996. SetlTime string `json:"setl_time"`
  21997. } `json:"setlinfo"`
  21998. Setldetail interface{} `json:"setldetail"`
  21999. } `json:"output"`
  22000. RefmsgTime string `json:"refmsg_time"`
  22001. RespondTime string `json:"respond_time"`
  22002. Signtype interface{} `json:"signtype"`
  22003. WarnMsg interface{} `json:"warn_msg"`
  22004. }
  22005. type ResultEight struct {
  22006. Cainfo string `json:"cainfo"`
  22007. ErrMsg string `json:"err_msg"`
  22008. InfRefmsgid string `json:"inf_refmsgid"`
  22009. Infcode int64 `json:"infcode"`
  22010. Output struct {
  22011. Stmtinfo struct {
  22012. SetlOptins string `json:"setl_optins"`
  22013. StmtRslt string `json:"stmt_rslt"`
  22014. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22015. } `json:"stmtinfo"`
  22016. } `json:"output"`
  22017. RefmsgTime string `json:"refmsg_time"`
  22018. RespondTime string `json:"respond_time"`
  22019. Signtype interface{} `json:"signtype"`
  22020. WarnMsg interface{} `json:"warn_msg"`
  22021. }
  22022. type ResultEightFor10188 struct {
  22023. Cainfo string `json:"cainfo"`
  22024. ErrMsg string `json:"err_msg"`
  22025. InfRefmsgid string `json:"inf_refmsgid"`
  22026. Infcode string `json:"infcode"`
  22027. Output struct {
  22028. Stmtinfo struct {
  22029. SetlOptins string `json:"setl_optins"`
  22030. StmtRslt string `json:"stmt_rslt"`
  22031. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22032. } `json:"stmtinfo"`
  22033. } `json:"output"`
  22034. RefmsgTime string `json:"refmsg_time"`
  22035. RespondTime string `json:"respond_time"`
  22036. Signtype interface{} `json:"signtype"`
  22037. WarnMsg interface{} `json:"warn_msg"`
  22038. }
  22039. type ResultNine struct {
  22040. Cainfo string `json:"cainfo"`
  22041. ErrMsg string `json:"err_msg"`
  22042. InfRefmsgid string `json:"inf_refmsgid"`
  22043. Infcode int64 `json:"infcode"`
  22044. Output struct {
  22045. FileQuryNo string `json:"file_qury_no"`
  22046. } `json:"output"`
  22047. RefmsgTime string `json:"refmsg_time"`
  22048. RespondTime string `json:"respond_time"`
  22049. Signtype interface{} `json:"signtype"`
  22050. WarnMsg interface{} `json:"warn_msg"`
  22051. }
  22052. type ResultTen struct {
  22053. Cainfo string `json:"cainfo"`
  22054. ErrMsg string `json:"err_msg"`
  22055. InfRefmsgid string `json:"inf_refmsgid"`
  22056. Infcode int64 `json:"infcode"`
  22057. Output struct {
  22058. Fileinfo struct {
  22059. DldEndtime string `json:"dld_endtime"`
  22060. FileQuryNo string `json:"file_qury_no"`
  22061. Filename string `json:"filename"`
  22062. } `json:"fileinfo"`
  22063. } `json:"output"`
  22064. RefmsgTime string `json:"refmsg_time"`
  22065. RespondTime string `json:"respond_time"`
  22066. Signtype interface{} `json:"signtype"`
  22067. WarnMsg interface{} `json:"warn_msg"`
  22068. }
  22069. type Result5262 struct {
  22070. ErrMsg string `json:"err_msg"`
  22071. InfRefmsgid string `json:"inf_refmsgid"`
  22072. Infcode int64 `json:"infcode"`
  22073. Output struct {
  22074. PageInfo struct {
  22075. Size int `json:"size"`
  22076. RecordCounts int `json:"record_counts"`
  22077. } `json:"page_info"`
  22078. Idetinfo []interface{} `json:"idetinfo"`
  22079. Result []struct {
  22080. SetlID string `json:"setl_id"`
  22081. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22082. MdtrtID string `json:"mdtrt_id"`
  22083. InitSetlID string `json:"init_setl_id,omitempty"`
  22084. PsnNo string `json:"psn_no"`
  22085. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22086. PsnName string `json:"psn_name"`
  22087. PsnCertType string `json:"psn_cert_type"`
  22088. Certno string `json:"certno"`
  22089. Gend string `json:"gend,omitempty"`
  22090. Naty string `json:"naty,omitempty"`
  22091. Brdy string `json:"brdy,omitempty"`
  22092. Age float64 `json:"age,omitempty"`
  22093. Insutype string `json:"insutype,omitempty"`
  22094. PsnType string `json:"psn_type"`
  22095. CvlservFlag string `json:"cvlserv_flag"`
  22096. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22097. SpPsnType string `json:"sp_psn_type,omitempty"`
  22098. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22099. ClctGrde string `json:"clct_grde,omitempty"`
  22100. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22101. NwbFlag string `json:"nwb_flag,omitempty"`
  22102. InsuAdmdvs string `json:"insu_admdvs"`
  22103. EmpNo string `json:"emp_no,omitempty"`
  22104. EmpName string `json:"emp_name,omitempty"`
  22105. EmpType string `json:"emp_type,omitempty"`
  22106. EconType string `json:"econ_type,omitempty"`
  22107. AfilIndu string `json:"afil_indu,omitempty"`
  22108. AfilRlts string `json:"afil_rlts,omitempty"`
  22109. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22110. PayLoc string `json:"pay_loc,omitempty"`
  22111. FixmedinsCode string `json:"fixmedins_code"`
  22112. FixmedinsName string `json:"fixmedins_name"`
  22113. HospLv string `json:"hosp_lv,omitempty"`
  22114. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22115. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22116. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22117. Begndate string `json:"begndate"`
  22118. Enddate string `json:"enddate"`
  22119. SetlTime string `json:"setl_time"`
  22120. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22121. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22122. MedType string `json:"med_type"`
  22123. SetlType string `json:"setl_type,omitempty"`
  22124. ClrType string `json:"clr_type,omitempty"`
  22125. ClrWay string `json:"clr_way,omitempty"`
  22126. PsnSetlway string `json:"psn_setlway,omitempty"`
  22127. ClrOptins string `json:"clr_optins,omitempty"`
  22128. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22129. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22130. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22131. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22132. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22133. DedcStd float64 `json:"dedc_std,omitempty"`
  22134. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22135. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22136. HifpPay float64 `json:"hifp_pay,omitempty"`
  22137. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22138. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22139. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22140. HifesPay float64 `json:"hifes_pay,omitempty"`
  22141. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22142. HifobPay float64 `json:"hifob_pay,omitempty"`
  22143. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22144. MafPay float64 `json:"maf_pay,omitempty"`
  22145. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22146. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22147. PsnPay float64 `json:"psn_pay,omitempty"`
  22148. AcctPay float64 `json:"acct_pay,omitempty"`
  22149. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22150. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22151. Balc float64 `json:"balc,omitempty"`
  22152. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22153. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22154. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22155. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22156. Year string `json:"year,omitempty"`
  22157. DiseNo string `json:"dise_no,omitempty"`
  22158. DiseName string `json:"dise_name,omitempty"`
  22159. Invono string `json:"invono,omitempty"`
  22160. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22161. ValiFlag string `json:"vali_flag,omitempty"`
  22162. Memo string `json:"memo,omitempty"`
  22163. Rid string `json:"rid"`
  22164. UpdtTime string `json:"updt_time,omitempty"`
  22165. CrterID string `json:"crter_id,omitempty"`
  22166. CrterName string `json:"crter_name,omitempty"`
  22167. CrteTime string `json:"crte_time,omitempty"`
  22168. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22169. OpterID string `json:"opter_id,omitempty"`
  22170. OpterName string `json:"opter_name,omitempty"`
  22171. OptTime string `json:"opt_time,omitempty"`
  22172. OptinsNo string `json:"optins_no,omitempty"`
  22173. PoolareaNo string `json:"poolarea_no,omitempty"`
  22174. } `json:"result"`
  22175. } `json:"output"`
  22176. RefmsgTime string `json:"refmsg_time"`
  22177. RespondTime string `json:"respond_time"`
  22178. Signtype interface{} `json:"signtype"`
  22179. WarnInfo interface{} `json:"warn_info"`
  22180. }
  22181. type Result5267 struct {
  22182. ErrMsg string `json:"err_msg"`
  22183. InfRefmsgid string `json:"inf_refmsgid"`
  22184. Infcode int64 `json:"infcode"`
  22185. Output struct {
  22186. PageInfo struct {
  22187. Size int `json:"size"`
  22188. RecordCounts int `json:"record_counts"`
  22189. } `json:"pageinfo"`
  22190. Result []struct {
  22191. SetlID string `json:"setl_id"`
  22192. ClrOptins string `json:"clr_optins"`
  22193. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22194. MdtrtID string `json:"mdtrt_id"`
  22195. InitSetlID string `json:"init_setl_id,omitempty"`
  22196. PsnNo string `json:"psn_no"`
  22197. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22198. PsnName string `json:"psn_name"`
  22199. PsnCertType string `json:"psn_cert_type"`
  22200. Certno string `json:"certno"`
  22201. Gend string `json:"gend,omitempty"`
  22202. Naty string `json:"naty,omitempty"`
  22203. Brdy string `json:"brdy,omitempty"`
  22204. Age float64 `json:"age,omitempty"`
  22205. Insutype string `json:"insutype,omitempty"`
  22206. PsnType string `json:"psn_type"`
  22207. CvlservFlag string `json:"cvlserv_flag"`
  22208. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22209. SpPsnType string `json:"sp_psn_type,omitempty"`
  22210. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22211. ClctGrde string `json:"clct_grde,omitempty"`
  22212. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22213. NwbFlag string `json:"nwb_flag,omitempty"`
  22214. InsuAdmdvs string `json:"insu_admdvs"`
  22215. EmpNo string `json:"emp_no,omitempty"`
  22216. EmpName string `json:"emp_name,omitempty"`
  22217. EmpType string `json:"emp_type,omitempty"`
  22218. EconType string `json:"econ_type,omitempty"`
  22219. AfilIndu string `json:"afil_indu,omitempty"`
  22220. AfilRlts string `json:"afil_rlts,omitempty"`
  22221. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22222. PayLoc string `json:"pay_loc,omitempty"`
  22223. FixmedinsCode string `json:"fixmedins_code"`
  22224. FixmedinsName string `json:"fixmedins_name"`
  22225. HospLv string `json:"hosp_lv,omitempty"`
  22226. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22227. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22228. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22229. Begndate string `json:"begndate,omitempty"`
  22230. Enddate string `json:"enddate,omitempty"`
  22231. SetlTime string `json:"setl_time,omitempty"`
  22232. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22233. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22234. MedType string `json:"med_type"`
  22235. SetlType string `json:"setl_type,omitempty"`
  22236. ClrType string `json:"clr_type,omitempty"`
  22237. ClrWay string `json:"clr_way,omitempty"`
  22238. PsnSetlway string `json:"psn_setlway,omitempty"`
  22239. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22240. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22241. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22242. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22243. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22244. DedcStd float64 `json:"dedc_std,omitempty"`
  22245. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22246. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22247. HifpPay float64 `json:"hifp_pay,omitempty"`
  22248. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22249. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22250. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22251. HifesPay float64 `json:"hifes_pay,omitempty"`
  22252. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22253. HifobPay float64 `json:"hifob_pay,omitempty"`
  22254. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22255. MafPay float64 `json:"maf_pay,omitempty"`
  22256. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22257. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22258. PsnPay float64 `json:"psn_pay,omitempty"`
  22259. AcctPay float64 `json:"acct_pay,omitempty"`
  22260. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22261. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22262. Balc float64 `json:"balc,omitempty"`
  22263. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22264. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22265. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22266. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22267. Year string `json:"year,omitempty"`
  22268. DiseNo string `json:"dise_no,omitempty"`
  22269. DiseName string `json:"dise_name,omitempty"`
  22270. Invono string `json:"invono,omitempty"`
  22271. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22272. Memo string `json:"memo,omitempty"`
  22273. UpdtTime string `json:"updt_time,omitempty"`
  22274. OpterID string `json:"opter_id,omitempty"`
  22275. OpterName string `json:"opter_name,omitempty"`
  22276. OptTime string `json:"opt_time,omitempty"`
  22277. OptinsNo string `json:"optins_no,omitempty"`
  22278. PoolareaNo string `json:"poolarea_no,omitempty"`
  22279. } `json:"result"`
  22280. } `json:"output"`
  22281. RefmsgTime string `json:"refmsg_time"`
  22282. RespondTime string `json:"respond_time"`
  22283. Signtype interface{} `json:"signtype"`
  22284. WarnInfo interface{} `json:"warn_info"`
  22285. }
  22286. // type Autogenerated struct {
  22287. // Output struct {
  22288. // Setlinfo struct {
  22289. // SetlTime string `json:"setl_time"`
  22290. // CvlservPay float64 `json:"cvlserv_pay"`
  22291. // Year string `json:"year"`
  22292. // MedType string `json:"med_type"`
  22293. // PsnPay float64 `json:"psn_pay"`
  22294. // OpterID string `json:"opter_id"`
  22295. // Begndate string `json:"begndate"`
  22296. // FlxempeFlag string `json:"flxempe_flag"`
  22297. // HifmiPay float64 `json:"hifmi_pay"`
  22298. // PsnNo string `json:"psn_no"`
  22299. // ActPayDedc float64 `json:"act_pay_dedc"`
  22300. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22301. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22302. // ClrWay string `json:"clr_way"`
  22303. // OthPay float64 `json:"oth_pay"`
  22304. // Gend string `json:"gend"`
  22305. // MdtrtID string `json:"mdtrt_id"`
  22306. // AcctPay float64 `json:"acct_pay"`
  22307. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22308. // Insutype string `json:"insutype"`
  22309. // Invono interface{} `json:"invono"`
  22310. // Enddate string `json:"enddate"`
  22311. // CashPayamt float64 `json:"cash_payamt"`
  22312. // PsnType string `json:"psn_type"`
  22313. // FixmedinsName string `json:"fixmedins_name"`
  22314. // HifpPay float64 `json:"hifp_pay"`
  22315. // NewFlag interface{} `json:"new_flag"`
  22316. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22317. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22318. // PayLoc string `json:"pay_loc"`
  22319. // ClrType string `json:"clr_type"`
  22320. // RefdSetlFlag string `json:"refd_setl_flag"`
  22321. // CvlservFlag string `json:"cvlserv_flag"`
  22322. // EmpName string `json:"emp_name"`
  22323. // Brdy string `json:"brdy"`
  22324. // Naty string `json:"naty"`
  22325. // Certno string `json:"certno"`
  22326. // DiseCode string `json:"dise_code"`
  22327. // FixmedinsCode string `json:"fixmedins_code"`
  22328. // DedcHospLv string `json:"dedc_hosp_lv"`
  22329. // OpterName string `json:"opter_name"`
  22330. // Balc float64 `json:"balc"`
  22331. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22332. // PsnCertType string `json:"psn_cert_type"`
  22333. // HifobPay float64 `json:"hifob_pay"`
  22334. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22335. // HifesPay float64 `json:"hifes_pay"`
  22336. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22337. // OptTime string `json:"opt_time"`
  22338. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22339. // SetlID string `json:"setl_id"`
  22340. // MafPay float64 `json:"maf_pay"`
  22341. // PsnName string `json:"psn_name"`
  22342. // InsuOptins interface{} `json:"insu_optins"`
  22343. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22344. // ClrOptins string `json:"clr_optins"`
  22345. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22346. // DiseName string `json:"dise_name"`
  22347. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22348. // Age float64 `json:"age"`
  22349. // DtrtCertType string `json:"dtrt_cert_type"`
  22350. // HospLv string `json:"hosp_lv"`
  22351. // } `json:"setlinfo"`
  22352. // Setldetail []struct {
  22353. // FundPayType string `json:"fund_pay_type"`
  22354. // FundPayamt float64 `json:"fund_payamt"`
  22355. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22356. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22357. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22358. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22359. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22360. // } `json:"setldetail"`
  22361. // } `json:"output"`
  22362. // Infcode int `json:"infcode"`
  22363. // WarnMsg interface{} `json:"warn_msg"`
  22364. // Cainfo interface{} `json:"cainfo"`
  22365. // ErrMsg interface{} `json:"err_msg"`
  22366. // RefmsgTime string `json:"refmsg_time"`
  22367. // Signtype interface{} `json:"signtype"`
  22368. // RespondTime string `json:"respond_time"`
  22369. // InfRefmsgid string `json:"inf_refmsgid"`
  22370. // }
  22371. type Result002 struct {
  22372. Cainfo interface{} `json:"cainfo"`
  22373. ErrMsg string `json:"err_msg"`
  22374. InfRefmsgid string `json:"inf_refmsgid"`
  22375. Infcode int64 `json:"infcode"`
  22376. Output struct {
  22377. RxFile string `json:"rx_file"`
  22378. SignDigest string `json:"sign_digest"`
  22379. SignCertSn string `json:"sign_cert_sn"`
  22380. SignCertDn string `json:"sign_cert_dn"`
  22381. } `json:"output"`
  22382. RefmsgTime string `json:"refmsg_time"`
  22383. RespondTime string `json:"respond_time"`
  22384. Signtype interface{} `json:"signtype"`
  22385. WarnMsg interface{} `json:"warn_msg"`
  22386. }
  22387. type Result003 struct {
  22388. Cainfo interface{} `json:"cainfo"`
  22389. ErrMsg string `json:"err_msg"`
  22390. InfRefmsgid string `json:"inf_refmsgid"`
  22391. Infcode int64 `json:"infcode"`
  22392. Output struct {
  22393. HiRxno string `json:"hi_rxno"`
  22394. RxStasCodg string `json:"rx_stas_codg"`
  22395. RxStasName string `json:"rx_stas_name"`
  22396. } `json:"output"`
  22397. RefmsgTime string `json:"refmsg_time"`
  22398. RespondTime string `json:"respond_time"`
  22399. Signtype interface{} `json:"signtype"`
  22400. WarnMsg interface{} `json:"warn_msg"`
  22401. }
  22402. type ResultEleven struct {
  22403. Cainfo string `json:"cainfo"`
  22404. ErrMsg string `json:"err_msg"`
  22405. InfRefmsgid string `json:"inf_refmsgid"`
  22406. Infcode int64 `json:"infcode"`
  22407. Output struct {
  22408. Setlinfo struct {
  22409. SetlTime string `json:"setl_time"`
  22410. CvlservPay float64 `json:"cvlserv_pay"`
  22411. Year string `json:"year"`
  22412. MedType string `json:"med_type"`
  22413. PsnPay float64 `json:"psn_pay"`
  22414. OpterID string `json:"opter_id"`
  22415. Begndate string `json:"begndate"`
  22416. FlxempeFlag string `json:"flxempe_flag"`
  22417. HifmiPay float64 `json:"hifmi_pay"`
  22418. PsnNo string `json:"psn_no"`
  22419. ActPayDedc float64 `json:"act_pay_dedc"`
  22420. MedinsSetlID interface{} `json:"medins_setl_id"`
  22421. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22422. ClrWay string `json:"clr_way"`
  22423. OthPay float64 `json:"oth_pay"`
  22424. Gend string `json:"gend"`
  22425. MdtrtID string `json:"mdtrt_id"`
  22426. AcctPay float64 `json:"acct_pay"`
  22427. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22428. Insutype string `json:"insutype"`
  22429. Invono interface{} `json:"invono"`
  22430. Enddate string `json:"enddate"`
  22431. CashPayamt float64 `json:"cash_payamt"`
  22432. PsnType string `json:"psn_type"`
  22433. FixmedinsName string `json:"fixmedins_name"`
  22434. HifpPay float64 `json:"hifp_pay"`
  22435. NewFlag interface{} `json:"new_flag"`
  22436. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22437. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22438. PayLoc string `json:"pay_loc"`
  22439. ClrType string `json:"clr_type"`
  22440. RefdSetlFlag string `json:"refd_setl_flag"`
  22441. CvlservFlag string `json:"cvlserv_flag"`
  22442. EmpName string `json:"emp_name"`
  22443. Brdy string `json:"brdy"`
  22444. Naty string `json:"naty"`
  22445. Certno string `json:"certno"`
  22446. DiseCode string `json:"dise_code"`
  22447. FixmedinsCode string `json:"fixmedins_code"`
  22448. DedcHospLv string `json:"dedc_hosp_lv"`
  22449. OpterName string `json:"opter_name"`
  22450. Balc float64 `json:"balc"`
  22451. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22452. PsnCertType string `json:"psn_cert_type"`
  22453. HifobPay float64 `json:"hifob_pay"`
  22454. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22455. HifesPay float64 `json:"hifes_pay"`
  22456. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22457. OptTime string `json:"opt_time"`
  22458. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22459. SetlID string `json:"setl_id"`
  22460. MafPay float64 `json:"maf_pay"`
  22461. PsnName string `json:"psn_name"`
  22462. InsuOptins interface{} `json:"insu_optins"`
  22463. PrefFundPay interface{} `json:"pref_fund_pay"`
  22464. ClrOptins string `json:"clr_optins"`
  22465. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22466. DiseName string `json:"dise_name"`
  22467. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22468. Age float64 `json:"age"`
  22469. DtrtCertType string `json:"dtrt_cert_type"`
  22470. HospLv string `json:"hosp_lv"`
  22471. PsnCashPay float64 `json:"psn_cash_pay"`
  22472. } `json:"setlinfo"`
  22473. } `json:"output"`
  22474. RefmsgTime string `json:"refmsg_time"`
  22475. RespondTime string `json:"respond_time"`
  22476. Signtype interface{} `json:"signtype"`
  22477. WarnMsg interface{} `json:"warn_msg"`
  22478. }
  22479. type ResultElevenah struct {
  22480. Cainfo string `json:"cainfo"`
  22481. ErrMsg string `json:"err_msg"`
  22482. InfRefmsgid string `json:"inf_refmsgid"`
  22483. Infcode int64 `json:"infcode"`
  22484. Output struct {
  22485. Setlinfo struct {
  22486. SetlTime int64 `json:"setl_time"`
  22487. CvlservPay float64 `json:"cvlserv_pay"`
  22488. Year string `json:"year"`
  22489. MedType string `json:"med_type"`
  22490. PsnPay float64 `json:"psn_pay"`
  22491. OpterID string `json:"opter_id"`
  22492. Begndate int64 `json:"begndate"`
  22493. FlxempeFlag string `json:"flxempe_flag"`
  22494. HifmiPay float64 `json:"hifmi_pay"`
  22495. PsnNo string `json:"psn_no"`
  22496. ActPayDedc float64 `json:"act_pay_dedc"`
  22497. MedinsSetlID interface{} `json:"medins_setl_id"`
  22498. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22499. ClrWay string `json:"clr_way"`
  22500. OthPay float64 `json:"oth_pay"`
  22501. Gend string `json:"gend"`
  22502. MdtrtID string `json:"mdtrt_id"`
  22503. AcctPay float64 `json:"acct_pay"`
  22504. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22505. Insutype string `json:"insutype"`
  22506. Invono interface{} `json:"invono"`
  22507. Enddate int64 `json:"enddate"`
  22508. CashPayamt float64 `json:"cash_payamt"`
  22509. PsnType string `json:"psn_type"`
  22510. FixmedinsName string `json:"fixmedins_name"`
  22511. HifpPay float64 `json:"hifp_pay"`
  22512. NewFlag interface{} `json:"new_flag"`
  22513. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22514. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22515. PayLoc string `json:"pay_loc"`
  22516. ClrType string `json:"clr_type"`
  22517. RefdSetlFlag string `json:"refd_setl_flag"`
  22518. CvlservFlag string `json:"cvlserv_flag"`
  22519. EmpName string `json:"emp_name"`
  22520. Brdy int64 `json:"brdy"`
  22521. Naty string `json:"naty"`
  22522. Certno string `json:"certno"`
  22523. DiseCode string `json:"dise_code"`
  22524. FixmedinsCode string `json:"fixmedins_code"`
  22525. DedcHospLv string `json:"dedc_hosp_lv"`
  22526. OpterName string `json:"opter_name"`
  22527. Balc float64 `json:"balc"`
  22528. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22529. PsnCertType string `json:"psn_cert_type"`
  22530. HifobPay float64 `json:"hifob_pay"`
  22531. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22532. HifesPay float64 `json:"hifes_pay"`
  22533. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22534. OptTime int64 `json:"opt_time"`
  22535. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22536. SetlID string `json:"setl_id"`
  22537. MafPay float64 `json:"maf_pay"`
  22538. PsnName string `json:"psn_name"`
  22539. InsuOptins interface{} `json:"insu_optins"`
  22540. PrefFundPay interface{} `json:"pref_fund_pay"`
  22541. ClrOptins string `json:"clr_optins"`
  22542. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22543. DiseName string `json:"dise_name"`
  22544. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22545. Age float64 `json:"age"`
  22546. DtrtCertType string `json:"dtrt_cert_type"`
  22547. HospLv string `json:"hosp_lv"`
  22548. PsnCashPay float64 `json:"psn_cash_pay"`
  22549. } `json:"setlinfo"`
  22550. } `json:"output"`
  22551. RefmsgTime string `json:"refmsg_time"`
  22552. RespondTime string `json:"respond_time"`
  22553. Signtype interface{} `json:"signtype"`
  22554. WarnMsg interface{} `json:"warn_msg"`
  22555. }
  22556. type ResultEleven10265 struct {
  22557. Cainfo string `json:"cainfo"`
  22558. ErrMsg string `json:"err_msg"`
  22559. InfRefmsgid string `json:"inf_refmsgid"`
  22560. Infcode string `json:"infcode"`
  22561. Output struct {
  22562. Setlinfo struct {
  22563. SetlTime string `json:"setl_time"`
  22564. CvlservPay float64 `json:"cvlserv_pay"`
  22565. Year string `json:"year"`
  22566. MedType string `json:"med_type"`
  22567. PsnPay float64 `json:"psn_pay"`
  22568. OpterID string `json:"opter_id"`
  22569. Begndate string `json:"begndate"`
  22570. FlxempeFlag string `json:"flxempe_flag"`
  22571. HifmiPay float64 `json:"hifmi_pay"`
  22572. PsnNo string `json:"psn_no"`
  22573. ActPayDedc float64 `json:"act_pay_dedc"`
  22574. MedinsSetlID interface{} `json:"medins_setl_id"`
  22575. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22576. ClrWay string `json:"clr_way"`
  22577. OthPay float64 `json:"oth_pay"`
  22578. Gend string `json:"gend"`
  22579. MdtrtID string `json:"mdtrt_id"`
  22580. AcctPay float64 `json:"acct_pay"`
  22581. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22582. Insutype string `json:"insutype"`
  22583. Invono interface{} `json:"invono"`
  22584. Enddate string `json:"enddate"`
  22585. CashPayamt float64 `json:"cash_payamt"`
  22586. PsnType string `json:"psn_type"`
  22587. FixmedinsName string `json:"fixmedins_name"`
  22588. HifpPay float64 `json:"hifp_pay"`
  22589. NewFlag interface{} `json:"new_flag"`
  22590. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22591. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22592. PayLoc string `json:"pay_loc"`
  22593. ClrType string `json:"clr_type"`
  22594. RefdSetlFlag string `json:"refd_setl_flag"`
  22595. CvlservFlag string `json:"cvlserv_flag"`
  22596. EmpName string `json:"emp_name"`
  22597. Brdy string `json:"brdy"`
  22598. Naty string `json:"naty"`
  22599. Certno string `json:"certno"`
  22600. DiseCode string `json:"dise_code"`
  22601. FixmedinsCode string `json:"fixmedins_code"`
  22602. DedcHospLv string `json:"dedc_hosp_lv"`
  22603. OpterName string `json:"opter_name"`
  22604. Balc float64 `json:"balc"`
  22605. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22606. PsnCertType string `json:"psn_cert_type"`
  22607. HifobPay float64 `json:"hifob_pay"`
  22608. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22609. HifesPay float64 `json:"hifes_pay"`
  22610. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22611. OptTime string `json:"opt_time"`
  22612. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22613. SetlID string `json:"setl_id"`
  22614. MafPay float64 `json:"maf_pay"`
  22615. PsnName string `json:"psn_name"`
  22616. InsuOptins interface{} `json:"insu_optins"`
  22617. PrefFundPay interface{} `json:"pref_fund_pay"`
  22618. ClrOptins string `json:"clr_optins"`
  22619. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22620. DiseName string `json:"dise_name"`
  22621. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22622. Age float64 `json:"age"`
  22623. DtrtCertType string `json:"dtrt_cert_type"`
  22624. HospLv string `json:"hosp_lv"`
  22625. PsnCashPay float64 `json:"psn_cash_pay"`
  22626. } `json:"setlinfo"`
  22627. } `json:"output"`
  22628. RefmsgTime string `json:"refmsg_time"`
  22629. RespondTime string `json:"respond_time"`
  22630. Signtype interface{} `json:"signtype"`
  22631. WarnMsg interface{} `json:"warn_msg"`
  22632. }
  22633. type ResultTwelve struct {
  22634. Cainfo string `json:"cainfo"`
  22635. ErrMsg string `json:"err_msg"`
  22636. InfRefmsgid string `json:"inf_refmsgid"`
  22637. Infcode int64 `json:"infcode"`
  22638. Output struct {
  22639. MdtrtId string `json:"mdtrt_id"`
  22640. ChrgBchno string `json:"chrg_bchno"`
  22641. PsnNo string `json:"psn_no"`
  22642. } `json:"output"`
  22643. RefmsgTime string `json:"refmsg_time"`
  22644. RespondTime string `json:"respond_time"`
  22645. Signtype interface{} `json:"signtype"`
  22646. WarnMsg interface{} `json:"warn_msg"`
  22647. }
  22648. type ResultThirteen struct {
  22649. ErrMsg string `json:"err_msg"`
  22650. InfRefmsgid string `json:"inf_refmsgid"`
  22651. Infcode int64 `json:"infcode"`
  22652. Output struct {
  22653. Result struct {
  22654. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22655. } `json:"result"`
  22656. } `json:"output"`
  22657. RefmsgTime string `json:"refmsg_time"`
  22658. RespondTime string `json:"respond_time"`
  22659. Signtype interface{} `json:"signtype"`
  22660. WarnInfo interface{} `json:"warn_info"`
  22661. }
  22662. type ResultThirteen10265 struct {
  22663. ErrMsg string `json:"err_msg"`
  22664. InfRefmsgid string `json:"inf_refmsgid"`
  22665. Infcode string `json:"infcode"`
  22666. Output struct {
  22667. Result struct {
  22668. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22669. } `json:"result"`
  22670. } `json:"output"`
  22671. RefmsgTime string `json:"refmsg_time"`
  22672. RespondTime string `json:"respond_time"`
  22673. Signtype interface{} `json:"signtype"`
  22674. WarnInfo interface{} `json:"warn_info"`
  22675. }
  22676. type ResultFourteen struct {
  22677. ErrMsg string `json:"err_msg"`
  22678. InfRefmsgid string `json:"inf_refmsgid"`
  22679. Infcode int64 `json:"infcode"`
  22680. Output struct {
  22681. } `json:"output"`
  22682. RefmsgTime string `json:"refmsg_time"`
  22683. RespondTime string `json:"respond_time"`
  22684. Signtype interface{} `json:"signtype"`
  22685. WarnInfo interface{} `json:"warn_info"`
  22686. }
  22687. type ResultCFYLJG001 struct {
  22688. ErrMsg string `json:"err_msg"`
  22689. InfRefmsgid string `json:"inf_refmsgid"`
  22690. Infcode int64 `json:"infcode"`
  22691. Output struct {
  22692. RxTraceCode string `json:"rx_trace_code"`
  22693. HiRxno string `json:"hi_rxno"`
  22694. } `json:"output"`
  22695. RefmsgTime string `json:"refmsg_time"`
  22696. RespondTime string `json:"respond_time"`
  22697. Signtype interface{} `json:"signtype"`
  22698. WarnInfo interface{} `json:"warn_info"`
  22699. }
  22700. type ResultCFYLJG007 struct {
  22701. ErrMsg string `json:"err_msg"`
  22702. InfRefmsgid string `json:"inf_refmsgid"`
  22703. Infcode int64 `json:"infcode"`
  22704. Output struct {
  22705. HiRxno string `json:"hi_rxno"`
  22706. RxStasName string `json:"rx_stas_name"`
  22707. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22708. Seltdelts []interface{} `json:"seltdelts"`
  22709. RxUsedStasName string `json:"rx_used_stas_name"`
  22710. RxStasCodg string `json:"rx_stas_codg"`
  22711. } `json:"output"`
  22712. RefmsgTime string `json:"refmsg_time"`
  22713. RespondTime string `json:"respond_time"`
  22714. Signtype interface{} `json:"signtype"`
  22715. WarnInfo interface{} `json:"warn_info"`
  22716. }
  22717. type ResultCFYLJG002 struct {
  22718. ErrMsg string `json:"err_msg"`
  22719. InfRefmsgid string `json:"inf_refmsgid"`
  22720. Infcode int64 `json:"infcode"`
  22721. Output struct {
  22722. RxFile string `json:"rx_file"`
  22723. SignDigest string `json:"sign_digest"`
  22724. SignCertSn string `json:"sign_cert_sn"`
  22725. SignCertDn string `json:"sign_cert_dn"`
  22726. } `json:"output"`
  22727. RefmsgTime string `json:"refmsg_time"`
  22728. RespondTime string `json:"respond_time"`
  22729. Signtype interface{} `json:"signtype"`
  22730. WarnInfo interface{} `json:"warn_info"`
  22731. }
  22732. type ResultCFYLJG003 struct {
  22733. ErrMsg string `json:"err_msg"`
  22734. InfRefmsgid string `json:"inf_refmsgid"`
  22735. Infcode int64 `json:"infcode"`
  22736. Output struct {
  22737. HiRxno string `json:"hi_rxno"`
  22738. RxStasCodg string `json:"rx_stas_codg"`
  22739. RxStasName string `json:"rx_stas_name"`
  22740. } `json:"output"`
  22741. RefmsgTime string `json:"refmsg_time"`
  22742. RespondTime string `json:"respond_time"`
  22743. Signtype interface{} `json:"signtype"`
  22744. WarnInfo interface{} `json:"warn_info"`
  22745. }
  22746. type ResultCFYLJG004 struct {
  22747. ErrMsg string `json:"err_msg"`
  22748. InfRefmsgid string `json:"inf_refmsgid"`
  22749. Infcode int64 `json:"infcode"`
  22750. Output struct {
  22751. HiRxno string `json:"hi_rxno"`
  22752. RxStasCodg string `json:"rx_stas_codg"`
  22753. RxStasName string `json:"rx_stas_name"`
  22754. } `json:"output"`
  22755. RefmsgTime string `json:"refmsg_time"`
  22756. RespondTime string `json:"respond_time"`
  22757. Signtype interface{} `json:"signtype"`
  22758. WarnInfo interface{} `json:"warn_info"`
  22759. }
  22760. type ResultCFYLJG008 struct {
  22761. ErrMsg string `json:"err_msg"`
  22762. InfRefmsgid string `json:"inf_refmsgid"`
  22763. Infcode int64 `json:"infcode"`
  22764. Output struct {
  22765. PoolareaNo string `json:"poolareaNo"`
  22766. AdmdvsName string `json:"admdvsName"`
  22767. Count string `json:"count"`
  22768. } `json:"output"`
  22769. RefmsgTime string `json:"refmsg_time"`
  22770. RespondTime string `json:"respond_time"`
  22771. Signtype interface{} `json:"signtype"`
  22772. WarnInfo interface{} `json:"warn_info"`
  22773. }
  22774. type ResultCFYLJG005 struct {
  22775. ErrMsg string `json:"err_msg"`
  22776. InfRefmsgid string `json:"inf_refmsgid"`
  22777. Infcode int64 `json:"infcode"`
  22778. Output struct {
  22779. HiRxNo string `json:"hi_rxno"`
  22780. FixMedinsCode string `json:"fixmedins_code"`
  22781. FixMedinsName string `json:"fixmedins_name"`
  22782. RxStasCodg string `json:"rx_stas_codg"`
  22783. RxStasName string `json:"rx_stas_name"`
  22784. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22785. RxUserdStasName string `json:"rx_userd_stas_name"`
  22786. PrscTime string `json:"prsc_time"`
  22787. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22788. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22789. RxUsedWayName string `json:"rx_used_way_name"`
  22790. RxFrquCodg string `json:"rx_frqu_codg"`
  22791. RxFrquName string `json:"rx_frqu_name"`
  22792. RxDosunt string `json:"rx_dosunt"`
  22793. RxDoscnt float64 `json:"rx_doscnt"`
  22794. RxDrordDscr string `json:"rx_drord_dscr"`
  22795. ValiDays int64 `json:"vali_days"`
  22796. ValiEndTime string `json:"vali_end_time"`
  22797. ReptFlag string `json:"rept_flag"`
  22798. MaxReptCnt int64 `json:"max_rept_cnt"`
  22799. ReptdCnt int64 `json:"reptd_cnt"`
  22800. MinInrvDays int64 `json:"min_inrv_days"`
  22801. RxTypeCode string `json:"rx_type_code"`
  22802. RxTypeName string `json:"rx_type_name"`
  22803. LongRxFlag string `json:"long_rx_flag"`
  22804. RxDetlList []struct {
  22805. MedListCodg string `json:"med_list_codg"`
  22806. MedinsListCodg string `json:"medins_list_codg"`
  22807. HospPrepFlag string `json:"hosp_prep_flag"`
  22808. RxItemTypeCode string `json:"rx_item_type_code"`
  22809. RxItemTypeName string `json:"rx_item_type_name"`
  22810. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22811. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22812. TcmHerbFoote string `json:"tcmherb_foote"`
  22813. MednTypeCode string `json:"medn_type_code"`
  22814. MednTypeName string `json:"medn_type_name"`
  22815. MainMedcFlag string `json:"main_medc_flag"`
  22816. UrgtFlag string `json:"urgt_flag"`
  22817. BasMednFlag string `json:"bas_medn_flag"`
  22818. ImpDrugFlag string `json:"imp_drug_flag"`
  22819. ProdBarc string `json:"prod_barc"`
  22820. DrugProdname string `json:"drug_prodname"`
  22821. GennameCodg string `json:"genname_codg"`
  22822. DrugGenname string `json:"drug_genname"`
  22823. DrugDosform string `json:"drug_dosform"`
  22824. DrugSpec string `json:"drug_spec"`
  22825. PrdrName string `json:"prdr_name"`
  22826. MedcWayCodg string `json:"medc_way_codg"`
  22827. MedcWayDscr string `json:"medc_way_dscr"`
  22828. MedcBegntime string `json:"medc_begntime"`
  22829. MedcEndtime string `json:"medc_endtime"`
  22830. MedcDays float64 `json:"medc_days"`
  22831. DrugPric float64 `json:"drug_pric"`
  22832. DrugSumamt float64 `json:"drug_sumamt"`
  22833. DrugCnt float64 `json:"drug_cnt"`
  22834. DrugDosunt string `json:"drug_dosunt"`
  22835. SinDoscnt float64 `json:"sin_doscnt"`
  22836. SinDosunt string `json:"sin_dosunt"`
  22837. UsedFrquCodg string `json:"used_frqu_codg"`
  22838. UsedFrquName string `json:"used_frqu_name"`
  22839. DrugTotlcnt string `json:"drug_totlcnt"`
  22840. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22841. DiseCodg string `json:"dise_codg"`
  22842. HospApprFlag string `json:"hosp_appr_flag"`
  22843. } `json:"rx_detl_list"`
  22844. RxOtpinfo struct {
  22845. MedType string `json:"med_type"`
  22846. IptOtpNo string `json:"ipt_otp_no"`
  22847. OtpIptFlag string `json:"otp_ipt_flag"`
  22848. PatnName string `json:"patn_name"`
  22849. PatnAge float64 `json:"patn_age"`
  22850. PatnHgt float64 `json:"patn_hgt"`
  22851. PatnWt float64 `json:"patn_wt"`
  22852. Gend string `json:"gend"`
  22853. GesoVal float64 `json:"geso_val"`
  22854. NwbFlag string `json:"nwb_flag"`
  22855. NwbAge string `json:"nwb_age"`
  22856. SuckPrdFlag string `json:"suck_prd_flag"`
  22857. AlgsHis string `json:"algs_his"`
  22858. Insutype string `json:"insutype"`
  22859. PrscDeptName string `json:"prsc_dept_name"`
  22860. PrscDrName string `json:"prsc_dr_name"`
  22861. PharName string `json:"phar_name"`
  22862. PharChkTime string `json:"phar_chk_time"`
  22863. MdtrtTime string `json:"mdtrt_time"`
  22864. DiseCodg string `json:"dise_codg"`
  22865. DiseName string `json:"dise_name"`
  22866. SpDiseFlag string `json:"sp_dise_flag"`
  22867. MaindiagCode string `json:"maindiag_code"`
  22868. MaindiagName string `json:"maindiag_name"`
  22869. DiseCondDscr string `json:"dise_cond_dscr"`
  22870. FstdiagFlag string `json:"fstdiag_flag"`
  22871. } `json:"rx_otpinfo"`
  22872. RxDiseList []struct {
  22873. DiagType string `json:"diag_type"`
  22874. MaindiagFlag string `json:"maindiag_flag"`
  22875. DiagSrtNo string `json:"diag_srt_no"`
  22876. DiagCode string `json:"diag_code"`
  22877. DiagName string `json:"diag_name"`
  22878. DiagDept string `json:"diag_dept"`
  22879. DiagDrNo string `json:"diag_dr_no"`
  22880. DiagDrName string `json:"diag_dr_name"`
  22881. DiagTime string `json:"diag_time"`
  22882. TcmDiseCode string `json:"tcm_dise_code"`
  22883. TcmDiseName string `json:"tcm_dise_name"`
  22884. TcmSympCode string `json:"tcmsymp_code"`
  22885. TcmSymp string `json:"tcmsymp"`
  22886. } `json:"rx_dise_list"`
  22887. } `json:"output"`
  22888. RefmsgTime string `json:"refmsg_time"`
  22889. RespondTime string `json:"respond_time"`
  22890. Signtype interface{} `json:"signtype"`
  22891. WarnInfo interface{} `json:"warn_info"`
  22892. }
  22893. type ResultCFYLJG006 struct {
  22894. ErrMsg string `json:"err_msg"`
  22895. InfRefmsgid string `json:"inf_refmsgid"`
  22896. Infcode int64 `json:"infcode"`
  22897. Output struct {
  22898. HiRxNo string `json:"hi_rxno"`
  22899. PharCode string `json:"phar_code"`
  22900. PharName string `json:"phar_name"`
  22901. RxChkOpnn string `json:"rx_chk_opnn"`
  22902. RxChkTime string `json:"rx_chk_time"`
  22903. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22904. RxChkStasName string `json:"rx_chk_stas_name"`
  22905. RxStasCodg string `json:"rx_stas_codg"`
  22906. RxStasName string `json:"rx_stas_name"`
  22907. } `json:"output"`
  22908. RefmsgTime string `json:"refmsg_time"`
  22909. RespondTime string `json:"respond_time"`
  22910. Signtype interface{} `json:"signtype"`
  22911. WarnInfo interface{} `json:"warn_info"`
  22912. }
  22913. type ResultFourteen10265 struct {
  22914. ErrMsg string `json:"err_msg"`
  22915. InfRefmsgid string `json:"inf_refmsgid"`
  22916. Infcode string `json:"infcode"`
  22917. Output struct {
  22918. } `json:"output"`
  22919. RefmsgTime string `json:"refmsg_time"`
  22920. RespondTime string `json:"respond_time"`
  22921. Signtype interface{} `json:"signtype"`
  22922. WarnInfo interface{} `json:"warn_info"`
  22923. }
  22924. type ResultSixteen struct {
  22925. Cainfo string `json:"cainfo"`
  22926. ErrMsg string `json:"err_msg"`
  22927. InfRefmsgid string `json:"inf_refmsgid"`
  22928. Infcode int64 `json:"infcode"`
  22929. Output struct {
  22930. Setlinfo struct {
  22931. MdtrtID string `json:"mdtrt_id"`
  22932. SetlID string `json:"setl_id"`
  22933. ClrOptins string `json:"clr_optins"`
  22934. SetlTime string `json:"setl_time"`
  22935. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22936. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22937. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22938. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22939. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22940. ActPayDedc float64 `json:"act_pay_dedc"`
  22941. HifpPay float64 `json:"hifp_pay"`
  22942. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22943. Lfpay float64 `json:"selfpay"`
  22944. CvlservPay float64 `json:"cvlserv_pay"`
  22945. HifesPay float64 `json:"hifes_pay"`
  22946. HifmiPay float64 `json:"hifmi_pay"`
  22947. HifobPay float64 `json:"hifob_pay"`
  22948. MafPay float64 `json:"maf_pay"`
  22949. OthPay float64 `json:"oth_pay"`
  22950. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22951. PsnPartAmt float64 `json:"psn_part_amt"`
  22952. AcctPay float64 `json:"acct_pay"`
  22953. Balc float64 `json:"balc"`
  22954. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22955. HospPartAmt float64 `json:"hosp_part_amt"`
  22956. MedinsSetlID string `json:"medins_setl_id"`
  22957. PdnCashPay string `json:"pdn_cash_pay"`
  22958. } `json:"setlinfo"`
  22959. } `json:"output"`
  22960. RefmsgTime string `json:"refmsg_time"`
  22961. RespondTime string `json:"respond_time"`
  22962. Signtype interface{} `json:"signtype"`
  22963. WarnMsg interface{} `json:"warn_msg"`
  22964. }
  22965. type ResultSixteen10265 struct {
  22966. Cainfo string `json:"cainfo"`
  22967. ErrMsg string `json:"err_msg"`
  22968. InfRefmsgid string `json:"inf_refmsgid"`
  22969. Infcode string `json:"infcode"`
  22970. Output struct {
  22971. Setlinfo struct {
  22972. MdtrtID string `json:"mdtrt_id"`
  22973. SetlID string `json:"setl_id"`
  22974. ClrOptins string `json:"clr_optins"`
  22975. SetlTime string `json:"setl_time"`
  22976. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22977. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22978. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22979. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22980. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22981. ActPayDedc float64 `json:"act_pay_dedc"`
  22982. HifpPay float64 `json:"hifp_pay"`
  22983. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22984. Lfpay float64 `json:"selfpay"`
  22985. CvlservPay float64 `json:"cvlserv_pay"`
  22986. HifesPay float64 `json:"hifes_pay"`
  22987. HifmiPay float64 `json:"hifmi_pay"`
  22988. HifobPay float64 `json:"hifob_pay"`
  22989. MafPay float64 `json:"maf_pay"`
  22990. OthPay float64 `json:"oth_pay"`
  22991. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22992. PsnPartAmt float64 `json:"psn_part_amt"`
  22993. AcctPay float64 `json:"acct_pay"`
  22994. Balc float64 `json:"balc"`
  22995. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22996. HospPartAmt float64 `json:"hosp_part_amt"`
  22997. MedinsSetlID string `json:"medins_setl_id"`
  22998. PdnCashPay string `json:"pdn_cash_pay"`
  22999. } `json:"setlinfo"`
  23000. } `json:"output"`
  23001. RefmsgTime string `json:"refmsg_time"`
  23002. RespondTime string `json:"respond_time"`
  23003. Signtype interface{} `json:"signtype"`
  23004. WarnMsg interface{} `json:"warn_msg"`
  23005. }
  23006. type ResultSixteen10265Two struct {
  23007. Cainfo string `json:"cainfo"`
  23008. ErrMsg string `json:"err_msg"`
  23009. InfRefmsgid string `json:"inf_refmsgid"`
  23010. Infcode string `json:"infcode"`
  23011. Output struct {
  23012. Setlinfo interface{} `json:"setlinfo"`
  23013. } `json:"output"`
  23014. RefmsgTime string `json:"refmsg_time"`
  23015. RespondTime string `json:"respond_time"`
  23016. Signtype interface{} `json:"signtype"`
  23017. WarnMsg interface{} `json:"warn_msg"`
  23018. }
  23019. type ResultgzSixteen10265Two struct {
  23020. Cainfo string `json:"cainfo"`
  23021. ErrMsg string `json:"err_msg"`
  23022. InfRefmsgid string `json:"inf_refmsgid"`
  23023. Infcode int64 `json:"infcode"`
  23024. Output struct {
  23025. Setlinfo interface{} `json:"setlinfo"`
  23026. } `json:"output"`
  23027. RefmsgTime string `json:"refmsg_time"`
  23028. RespondTime string `json:"respond_time"`
  23029. Signtype interface{} `json:"signtype"`
  23030. WarnMsg interface{} `json:"warn_msg"`
  23031. }
  23032. type ResultSeventeen struct {
  23033. ErrMsg string `json:"err_msg"`
  23034. InfRefmsgid string `json:"inf_refmsgid"`
  23035. Infcode int64 `json:"infcode"`
  23036. Output struct {
  23037. SetlListId string `json:"setl_list_id"`
  23038. } `json:"output"`
  23039. RefmsgTime string `json:"refmsg_time"`
  23040. RespondTime string `json:"respond_time"`
  23041. Signtype string `json:"signtype"`
  23042. WarnInfo string `json:"warn_info"`
  23043. }
  23044. type ResultSeventeenOther struct {
  23045. ErrMsg string `json:"err_msg"`
  23046. InfRefmsgid string `json:"inf_refmsgid"`
  23047. Infcode string `json:"infcode"`
  23048. Output struct {
  23049. SetlListId string `json:"setl_list_id"`
  23050. } `json:"output"`
  23051. RefmsgTime string `json:"refmsg_time"`
  23052. RespondTime string `json:"respond_time"`
  23053. Signtype string `json:"signtype"`
  23054. WarnInfo string `json:"warn_info"`
  23055. }
  23056. type Result90991 struct {
  23057. ErrMsg string `json:"err_msg"`
  23058. InfRefmsgid string `json:"inf_refmsgid"`
  23059. Infcode int64 `json:"infcode"`
  23060. Output struct {
  23061. Result struct {
  23062. PsnNo string `json:"psn_no"`
  23063. CardStat string `json:"card_stat"`
  23064. Certno string `json:"certno"`
  23065. PsnName string `json:"psn_name"`
  23066. CheckStat string `json:"check_stat"`
  23067. SscnoCheckStat string `json:"sscno_check_stat"`
  23068. } `json:"result"`
  23069. } `json:"output"`
  23070. RefmsgTime string `json:"refmsg_time"`
  23071. RespondTime string `json:"respond_time"`
  23072. Signtype interface{} `json:"signtype"`
  23073. WarnInfo interface{} `json:"warn_info"`
  23074. }
  23075. type Result90100 struct {
  23076. ErrMsg string `json:"err_msg"`
  23077. InfRefmsgid string `json:"inf_refmsgid"`
  23078. Infcode int64 `json:"infcode"`
  23079. Output struct {
  23080. PoolareaNo string `json:"poolarea_no"`
  23081. PoolareaNoName string `json:"poolarea_no_name"`
  23082. Insutype string `json:"insutype"`
  23083. InsutypeName string `json:"insutype_name"`
  23084. ClctType string `json:"clct_type"`
  23085. ClctTypeName string `json:"clct_type_name"`
  23086. ClctFlag string `json:"clct_flag"`
  23087. ClctFlagName string `json:"clct_flag_name"`
  23088. AccrymBegn string `json:"accrym_begn"`
  23089. AccrymEnd string `json:"accrym_end"`
  23090. ClctTime string `json:"clct_time"`
  23091. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23092. } `json:"output"`
  23093. RefmsgTime string `json:"refmsg_time"`
  23094. RespondTime string `json:"respond_time"`
  23095. Signtype interface{} `json:"signtype"`
  23096. WarnInfo interface{} `json:"warn_info"`
  23097. }
  23098. type Custom struct {
  23099. DetItemFeeSumamt string
  23100. Cut string
  23101. FeedetlSn string
  23102. Price string
  23103. MedListCodg string
  23104. Type int64
  23105. AdviceId int64
  23106. ProjectId int64
  23107. ItemId int64
  23108. }
  23109. type Result5301 struct {
  23110. ErrMsg string `json:"err_msg"`
  23111. InfRefmsgid string `json:"inf_refmsgid"`
  23112. Infcode int64 `json:"infcode"`
  23113. Output struct {
  23114. Result []struct {
  23115. OpspDiseCode string `json:"opsp_dise_code"`
  23116. OpspDiseName string `json:"opsp_dise_name"`
  23117. Begndate string `json:"begndate"`
  23118. Enddate string `json:"enddate"`
  23119. } `json:"feedetail"`
  23120. } `json:"output"`
  23121. RefmsgTime string `json:"refmsg_time"`
  23122. RespondTime string `json:"respond_time"`
  23123. Signtype interface{} `json:"signtype"`
  23124. WarnInfo interface{} `json:"warn_info"`
  23125. }
  23126. type Result5301For10265 struct {
  23127. ErrMsg string `json:"err_msg"`
  23128. InfRefmsgid string `json:"inf_refmsgid"`
  23129. Infcode string `json:"infcode"`
  23130. Output struct {
  23131. Result []struct {
  23132. OpspDiseCode string `json:"opsp_dise_code"`
  23133. OpspDiseName string `json:"opsp_dise_name"`
  23134. Begndate string `json:"begndate"`
  23135. Enddate string `json:"enddate"`
  23136. } `json:"feedetail"`
  23137. } `json:"output"`
  23138. RefmsgTime string `json:"refmsg_time"`
  23139. RespondTime string `json:"respond_time"`
  23140. Signtype interface{} `json:"signtype"`
  23141. WarnInfo interface{} `json:"warn_info"`
  23142. }
  23143. //获取个人信息----挂号-----上传就诊信息
  23144. func (c *HisApiController) GetRegisterInfo() {
  23145. id, _ := c.GetInt64("id")
  23146. record_time := c.GetString("record_time")
  23147. settlementValue, _ := c.GetInt64("settlement_value")
  23148. medical_insurance_card := c.GetString("medical_insurance_card")
  23149. name := c.GetString("name")
  23150. id_card_type, _ := c.GetInt64("id_card_type")
  23151. certificates, _ := c.GetInt64("certificates")
  23152. medical_care, _ := c.GetInt64("medical_care")
  23153. birthday := c.GetString("birthday")
  23154. id_card := c.GetString("id_card")
  23155. register_type, _ := c.GetInt64("register")
  23156. doctor, _ := c.GetInt64("doctor")
  23157. department, _ := c.GetInt64("department")
  23158. gender, _ := c.GetInt64("sex")
  23159. registration_fee, _ := c.GetFloat("registration_fee")
  23160. medical_expenses, _ := c.GetFloat("medical_expenses")
  23161. social_type, _ := c.GetInt64("social_type")
  23162. admin_user_id, _ := c.GetInt64("admin_user_id")
  23163. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23164. mdtrt_type := c.GetString("mdtrt_type")
  23165. if id_card_type == 5 {
  23166. id_card_type = 4
  23167. }
  23168. timeLayout := "2006-01-02"
  23169. loc, _ := time.LoadLocation("Local")
  23170. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23171. birthUnix := birthdays.Unix()
  23172. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23173. if err != nil {
  23174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23175. return
  23176. }
  23177. recordDateTime := theTime.Unix()
  23178. adminInfo := c.GetAdminUserInfo()
  23179. var patient service.Patients
  23180. if id == 0 {
  23181. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23182. } else {
  23183. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23184. }
  23185. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23186. if patientPrescription.ID == 0 {
  23187. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23188. }
  23189. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23190. if patient.ID == 0 {
  23191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23192. return
  23193. }
  23194. if len(patient.IdCardNo) == 0 {
  23195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23196. return
  23197. }
  23198. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23199. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23200. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23201. //就诊结算未完成,不能进行二次挂号
  23202. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23203. if len(his) >= 1 {
  23204. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23205. if len(his) >= 1 && order.ID == 0 {
  23206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23207. return
  23208. }
  23209. }
  23210. //var register_log string
  23211. if config.IsOpen == 1 {
  23212. var res ResultTwo
  23213. var res10265 ResultTwo10265
  23214. var PsnNo string
  23215. var PsnCertType string
  23216. var Certno string
  23217. var PsnName string
  23218. var Gend string
  23219. var Naty string
  23220. var Brdy string
  23221. var Age float64
  23222. var infoStr string
  23223. var idetinfoStr string
  23224. var infocode int64
  23225. var verify_number string
  23226. fmt.Println(verify_number)
  23227. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23228. psn_info, _ := service.GetPsnByPatientId(id)
  23229. PsnNo = psn_info.PsnNo
  23230. PsnCertType = psn_info.PsnCertType
  23231. Certno = psn_info.Certno
  23232. PsnName = psn_info.PsnName
  23233. Gend = psn_info.Gend
  23234. Naty = psn_info.Naty
  23235. Brdy = psn_info.Brdy
  23236. Age = psn_info.Age
  23237. infoStr = psn_info.Insuinfo
  23238. idetinfoStr = psn_info.Idetinfo
  23239. infocode = 0
  23240. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23241. psn_info, _ := service.GetPsnByPatientId(id)
  23242. PsnNo = psn_info.PsnNo
  23243. PsnCertType = psn_info.PsnCertType
  23244. Certno = psn_info.Certno
  23245. PsnName = psn_info.PsnName
  23246. Gend = psn_info.Gend
  23247. Naty = psn_info.Naty
  23248. Brdy = psn_info.Brdy
  23249. Age = psn_info.Age
  23250. infoStr = psn_info.Insuinfo
  23251. idetinfoStr = psn_info.Idetinfo
  23252. infocode = 0
  23253. verify_number = psn_info.VerifyNumber
  23254. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23255. if id_card_type == 2 {
  23256. //请求内网数据
  23257. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23258. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23259. "&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
  23260. resp, requestErr := http.Get(api)
  23261. if requestErr != nil {
  23262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23263. return
  23264. }
  23265. body, ioErr := ioutil.ReadAll(resp.Body)
  23266. if ioErr != nil {
  23267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23269. return
  23270. }
  23271. var respJSON map[string]interface{}
  23272. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23275. return
  23276. }
  23277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23278. result_byte, _ := json.Marshal(respJSON)
  23279. result := string(result_byte)
  23280. var dat map[string]interface{}
  23281. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23282. fmt.Println(dat)
  23283. } else {
  23284. fmt.Println(err)
  23285. }
  23286. userJSONBytes, _ := json.Marshal(dat)
  23287. var res ResultTwo
  23288. var resTwo10265 ResultTwo10265
  23289. if miConfig.Code == "H15049901371" {
  23290. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23291. utils.ErrorLog("解析失败:%v", err)
  23292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23293. return
  23294. }
  23295. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23296. res.Infcode = Infcode
  23297. res.ErrMsg = resTwo10265.ErrMsg
  23298. res.Output = resTwo10265.Output
  23299. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23300. res.RespondTime = resTwo10265.RespondTime
  23301. res.WarnInfo = resTwo10265.WarnInfo
  23302. } else {
  23303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23304. utils.ErrorLog("解析失败:%v", err)
  23305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23306. return
  23307. }
  23308. }
  23309. //var insutypes []string
  23310. //var insutype string
  23311. //var is390 int = 0
  23312. //var is310 int = 0
  23313. //for _, item := range res.Output.Iinfo {
  23314. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23315. // insutypes = append(insutypes, item.Insutype)
  23316. // }
  23317. //}
  23318. //if len(insutypes) == 1 {
  23319. // insutype = insutypes[0]
  23320. //} else {
  23321. // for _, i := range insutypes {
  23322. // if i == "390" {
  23323. // is390 = 1
  23324. // }
  23325. //
  23326. // if i == "310" {
  23327. // is310 = 1
  23328. // }
  23329. // }
  23330. //}
  23331. //if is390 == 1 {
  23332. // insutype = "390"
  23333. //}
  23334. //if is310 == 1 {
  23335. // insutype = "310"
  23336. //}
  23337. //if len(insutypes) == 0 {
  23338. // insutype = "310"
  23339. //}
  23340. PsnNo = res.Output.Baseinfo.PsnNo
  23341. PsnCertType = res.Output.Baseinfo.PsnCertType
  23342. Certno = res.Output.Baseinfo.Certno
  23343. PsnName = res.Output.Baseinfo.PsnName
  23344. Gend = res.Output.Baseinfo.Gend
  23345. Naty = res.Output.Baseinfo.Naty
  23346. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23347. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23348. infoStr = string(Iinfos)
  23349. idetinfoStr = string(Idetinfos)
  23350. infocode = res.Infcode
  23351. //infocode = 0
  23352. //verify_number = psn_info.VerifyNumber
  23353. } else {
  23354. psn_info, _ := service.GetPsnByPatientId(id)
  23355. PsnNo = psn_info.PsnNo
  23356. PsnCertType = psn_info.PsnCertType
  23357. Certno = psn_info.Certno
  23358. PsnName = psn_info.PsnName
  23359. Gend = psn_info.Gend
  23360. Naty = psn_info.Naty
  23361. Brdy = psn_info.Brdy
  23362. Age = psn_info.Age
  23363. infoStr = psn_info.Insuinfo
  23364. idetinfoStr = psn_info.Idetinfo
  23365. infocode = 0
  23366. verify_number = psn_info.VerifyNumber
  23367. }
  23368. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23369. if id_card_type == 1 {
  23370. psn_info, _ := service.GetPsnByPatientId(id)
  23371. PsnNo = psn_info.PsnNo
  23372. PsnCertType = psn_info.PsnCertType
  23373. Certno = psn_info.Certno
  23374. PsnName = psn_info.PsnName
  23375. Gend = psn_info.Gend
  23376. Naty = psn_info.Naty
  23377. Brdy = psn_info.Brdy
  23378. Age = psn_info.Age
  23379. infoStr = psn_info.Insuinfo
  23380. idetinfoStr = psn_info.Idetinfo
  23381. infocode = 0
  23382. verify_number = psn_info.VerifyNumber
  23383. } else if id_card_type == 2 {
  23384. 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)
  23385. fmt.Println(errMsgLog)
  23386. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23387. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23388. utils.ErrorLog("解析失败:%v", err)
  23389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23390. return
  23391. }
  23392. PsnNo = res.Output.Baseinfo.PsnNo
  23393. PsnCertType = res.Output.Baseinfo.PsnCertType
  23394. Certno = res.Output.Baseinfo.Certno
  23395. PsnName = res.Output.Baseinfo.PsnName
  23396. Gend = res.Output.Baseinfo.Gend
  23397. Naty = res.Output.Baseinfo.Naty
  23398. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23399. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23400. infoStr = string(Iinfos)
  23401. idetinfoStr = string(Idetinfos)
  23402. infocode = res.Infcode
  23403. }
  23404. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23405. if id_card_type == 1 {
  23406. psn_info, _ := service.GetPsnByPatientId(id)
  23407. PsnNo = psn_info.PsnNo
  23408. PsnCertType = psn_info.PsnCertType
  23409. Certno = psn_info.Certno
  23410. PsnName = psn_info.PsnName
  23411. Gend = psn_info.Gend
  23412. Naty = psn_info.Naty
  23413. Brdy = psn_info.Brdy
  23414. Age = psn_info.Age
  23415. infoStr = psn_info.Insuinfo
  23416. idetinfoStr = psn_info.Idetinfo
  23417. infocode = 0
  23418. verify_number = psn_info.VerifyNumber
  23419. } else if id_card_type == 2 {
  23420. 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, "")
  23421. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23422. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23423. utils.ErrorLog("解析失败:%v", err)
  23424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23425. return
  23426. }
  23427. PsnNo = res.Output.Baseinfo.PsnNo
  23428. PsnCertType = res.Output.Baseinfo.PsnCertType
  23429. Certno = res.Output.Baseinfo.Certno
  23430. PsnName = res.Output.Baseinfo.PsnName
  23431. Gend = res.Output.Baseinfo.Gend
  23432. Naty = res.Output.Baseinfo.Naty
  23433. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23434. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23435. infoStr = string(Iinfos)
  23436. idetinfoStr = string(Idetinfos)
  23437. infocode = res.Infcode
  23438. } else {
  23439. psn_info, _ := service.GetPsnByPatientId(id)
  23440. PsnNo = psn_info.PsnNo
  23441. PsnCertType = psn_info.PsnCertType
  23442. Certno = psn_info.Certno
  23443. PsnName = psn_info.PsnName
  23444. Gend = psn_info.Gend
  23445. Naty = psn_info.Naty
  23446. Brdy = psn_info.Brdy
  23447. Age = psn_info.Age
  23448. infoStr = psn_info.Insuinfo
  23449. idetinfoStr = psn_info.Idetinfo
  23450. infocode = 0
  23451. verify_number = psn_info.VerifyNumber
  23452. }
  23453. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23454. if id_card_type == 1 {
  23455. psn_info, _ := service.GetPsnByPatientId(id)
  23456. PsnNo = psn_info.PsnNo
  23457. PsnCertType = psn_info.PsnCertType
  23458. Certno = psn_info.Certno
  23459. PsnName = psn_info.PsnName
  23460. Gend = psn_info.Gend
  23461. Naty = psn_info.Naty
  23462. Brdy = psn_info.Brdy
  23463. Age = psn_info.Age
  23464. infoStr = psn_info.Insuinfo
  23465. idetinfoStr = psn_info.Idetinfo
  23466. infocode = 0
  23467. verify_number = psn_info.VerifyNumber
  23468. } else if id_card_type == 2 {
  23469. psn_info, _ := service.GetPsnByPatientId(id)
  23470. PsnNo = psn_info.PsnNo
  23471. PsnCertType = psn_info.PsnCertType
  23472. Certno = psn_info.Certno
  23473. PsnName = psn_info.PsnName
  23474. Gend = psn_info.Gend
  23475. Naty = psn_info.Naty
  23476. Brdy = psn_info.Brdy
  23477. Age = psn_info.Age
  23478. infoStr = psn_info.Insuinfo
  23479. idetinfoStr = psn_info.Idetinfo
  23480. infocode = 0
  23481. verify_number = psn_info.VerifyNumber
  23482. } else {
  23483. psn_info, _ := service.GetPsnByPatientId(id)
  23484. PsnNo = psn_info.PsnNo
  23485. PsnCertType = psn_info.PsnCertType
  23486. Certno = psn_info.Certno
  23487. PsnName = psn_info.PsnName
  23488. Gend = psn_info.Gend
  23489. Naty = psn_info.Naty
  23490. Brdy = psn_info.Brdy
  23491. Age = psn_info.Age
  23492. infoStr = psn_info.Insuinfo
  23493. idetinfoStr = psn_info.Idetinfo
  23494. infocode = 0
  23495. verify_number = psn_info.VerifyNumber
  23496. }
  23497. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23498. psn_info, _ := service.GetPsnByPatientId(id)
  23499. PsnNo = psn_info.PsnNo
  23500. PsnCertType = psn_info.PsnCertType
  23501. Certno = psn_info.Certno
  23502. PsnName = psn_info.PsnName
  23503. Gend = psn_info.Gend
  23504. Naty = psn_info.Naty
  23505. Brdy = psn_info.Brdy
  23506. Age = psn_info.Age
  23507. infoStr = psn_info.Insuinfo
  23508. idetinfoStr = psn_info.Idetinfo
  23509. infocode = 0
  23510. verify_number = psn_info.VerifyNumber
  23511. idetinfoStr = psn_info.Idetinfo
  23512. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23513. if id_card_type == 1 {
  23514. psn_info, _ := service.GetPsnByPatientId(id)
  23515. PsnNo = psn_info.PsnNo
  23516. PsnCertType = psn_info.PsnCertType
  23517. Certno = psn_info.Certno
  23518. PsnName = psn_info.PsnName
  23519. Gend = psn_info.Gend
  23520. Naty = psn_info.Naty
  23521. Brdy = psn_info.Brdy
  23522. Age = psn_info.Age
  23523. infoStr = psn_info.Insuinfo
  23524. idetinfoStr = psn_info.Idetinfo
  23525. infocode = 0
  23526. verify_number = psn_info.VerifyNumber
  23527. } else if id_card_type == 2 {
  23528. 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)
  23529. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23530. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23531. utils.ErrorLog("解析失败:%v", err)
  23532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23533. return
  23534. }
  23535. PsnNo = res.Output.Baseinfo.PsnNo
  23536. PsnCertType = res.Output.Baseinfo.PsnCertType
  23537. Certno = res.Output.Baseinfo.Certno
  23538. PsnName = res.Output.Baseinfo.PsnName
  23539. Gend = res.Output.Baseinfo.Gend
  23540. Naty = res.Output.Baseinfo.Naty
  23541. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23542. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23543. infoStr = string(Iinfos)
  23544. idetinfoStr = string(Idetinfos)
  23545. infocode = res.Infcode
  23546. } else if id_card_type == 4 {
  23547. psn_info, _ := service.GetPsnByPatientId(id)
  23548. PsnNo = psn_info.PsnNo
  23549. PsnCertType = psn_info.PsnCertType
  23550. Certno = psn_info.Certno
  23551. PsnName = psn_info.PsnName
  23552. Gend = psn_info.Gend
  23553. Naty = psn_info.Naty
  23554. Brdy = psn_info.Brdy
  23555. Age = psn_info.Age
  23556. infoStr = psn_info.Insuinfo
  23557. idetinfoStr = psn_info.Idetinfo
  23558. infocode = 0
  23559. verify_number = psn_info.VerifyNumber
  23560. }
  23561. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23562. var result string
  23563. var requestLog string
  23564. 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), "")
  23565. if id_card_type == 4 {
  23566. psn_info, _ := service.GetPsnByPatientId(id)
  23567. PsnNo = psn_info.PsnNo
  23568. PsnCertType = psn_info.PsnCertType
  23569. Certno = psn_info.Certno
  23570. PsnName = psn_info.PsnName
  23571. Gend = psn_info.Gend
  23572. Naty = psn_info.Naty
  23573. Brdy = psn_info.Brdy
  23574. Age = psn_info.Age
  23575. infoStr = psn_info.Insuinfo
  23576. idetinfoStr = psn_info.Idetinfo
  23577. infocode = 0
  23578. verify_number = psn_info.VerifyNumber
  23579. } else {
  23580. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23581. if miConfig.Code == "H15049901371" {
  23582. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23583. utils.ErrorLog("解析失败:%v", err)
  23584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23585. return
  23586. }
  23587. res.ErrMsg = res10265.ErrMsg
  23588. res.Output = res10265.Output
  23589. res.InfRefmsgid = res10265.InfRefmsgid
  23590. } else {
  23591. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23592. utils.ErrorLog("解析失败:%v", err)
  23593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23594. return
  23595. }
  23596. }
  23597. PsnNo = res.Output.Baseinfo.PsnNo
  23598. PsnCertType = res.Output.Baseinfo.PsnCertType
  23599. Certno = res.Output.Baseinfo.Certno
  23600. PsnName = res.Output.Baseinfo.PsnName
  23601. Gend = res.Output.Baseinfo.Gend
  23602. Naty = res.Output.Baseinfo.Naty
  23603. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23604. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23605. infoStr = string(Iinfos)
  23606. idetinfoStr = string(Idetinfos)
  23607. if miConfig.Code == "H15049901371" {
  23608. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23609. } else {
  23610. infocode = res.Infcode
  23611. }
  23612. }
  23613. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23614. psn_info, _ := service.GetPsnByPatientId(id)
  23615. PsnNo = psn_info.PsnNo
  23616. PsnCertType = psn_info.PsnCertType
  23617. Certno = psn_info.Certno
  23618. PsnName = psn_info.PsnName
  23619. Gend = psn_info.Gend
  23620. Naty = psn_info.Naty
  23621. Brdy = psn_info.Brdy
  23622. Age = psn_info.Age
  23623. infoStr = psn_info.Insuinfo
  23624. idetinfoStr = psn_info.Idetinfo
  23625. infocode = 0
  23626. verify_number = psn_info.VerifyNumber
  23627. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23628. psn_info, _ := service.GetPsnByPatientId(id)
  23629. PsnNo = psn_info.PsnNo
  23630. PsnCertType = psn_info.PsnCertType
  23631. Certno = psn_info.Certno
  23632. PsnName = psn_info.PsnName
  23633. Gend = psn_info.Gend
  23634. Naty = psn_info.Naty
  23635. Brdy = psn_info.Brdy
  23636. Age = psn_info.Age
  23637. infoStr = psn_info.Insuinfo
  23638. idetinfoStr = psn_info.Idetinfo
  23639. infocode = 0
  23640. verify_number = psn_info.VerifyNumber
  23641. } else {
  23642. var result string
  23643. var requestLog string
  23644. //if miConfig.UserOrgId == 10138 {
  23645. if id_card_type != 4 || id_card_type != 1 {
  23646. var insa string
  23647. if len(patient.InsuplcAdmdvs) > 0 {
  23648. insa = patient.InsuplcAdmdvs
  23649. } else {
  23650. insa = miConfig.InsuplcAdmdvs
  23651. }
  23652. //psn_info, _ := service.GetPsnByPatientId(id)
  23653. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23654. 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)
  23655. }
  23656. //}
  23657. //else {
  23658. // var insa string
  23659. // if len(patient.InsuplcAdmdvs) > 0 {
  23660. // insa = patient.InsuplcAdmdvs
  23661. // } else {
  23662. // insa = miConfig.InsuplcAdmdvs
  23663. // }
  23664. // 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)
  23665. //}
  23666. if id_card_type == 4 || id_card_type == 1 {
  23667. psn_info, _ := service.GetPsnByPatientId(id)
  23668. PsnNo = psn_info.PsnNo
  23669. PsnCertType = psn_info.PsnCertType
  23670. Certno = psn_info.Certno
  23671. PsnName = psn_info.PsnName
  23672. Gend = psn_info.Gend
  23673. Naty = psn_info.Naty
  23674. Brdy = psn_info.Brdy
  23675. Age = psn_info.Age
  23676. infoStr = psn_info.Insuinfo
  23677. idetinfoStr = psn_info.Idetinfo
  23678. infocode = 0
  23679. verify_number = psn_info.VerifyNumber
  23680. } else {
  23681. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23682. if miConfig.Code == "H15049901371" {
  23683. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23684. utils.ErrorLog("解析失败:%v", err)
  23685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23686. return
  23687. }
  23688. res.ErrMsg = res10265.ErrMsg
  23689. res.Output = res10265.Output
  23690. res.InfRefmsgid = res10265.InfRefmsgid
  23691. } else {
  23692. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23693. utils.ErrorLog("解析失败:%v", err)
  23694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23695. return
  23696. }
  23697. }
  23698. PsnNo = res.Output.Baseinfo.PsnNo
  23699. PsnCertType = res.Output.Baseinfo.PsnCertType
  23700. Certno = res.Output.Baseinfo.Certno
  23701. PsnName = res.Output.Baseinfo.PsnName
  23702. Gend = res.Output.Baseinfo.Gend
  23703. Naty = res.Output.Baseinfo.Naty
  23704. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23705. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23706. infoStr = string(Iinfos)
  23707. idetinfoStr = string(Idetinfos)
  23708. if miConfig.Code == "H15049901371" {
  23709. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23710. } else {
  23711. infocode = res.Infcode
  23712. }
  23713. }
  23714. }
  23715. if infocode == 0 {
  23716. his := models.VMHisPatient{
  23717. Name: name,
  23718. Gender: gender,
  23719. Birthday: birthUnix,
  23720. MedicalTreatmentType: medical_care,
  23721. IdType: certificates,
  23722. IdCardNo: id_card,
  23723. BalanceAccountsType: settlementValue,
  23724. SocialType: social_type,
  23725. MedicalInsuranceNumber: medical_insurance_card,
  23726. RegisterType: register_type,
  23727. RegisterCost: registration_fee,
  23728. TreatmentCost: medical_expenses,
  23729. Status: 1,
  23730. Ctime: time.Now().Unix(),
  23731. Mtime: time.Now().Unix(),
  23732. PsnNo: PsnNo,
  23733. PsnCertType: PsnCertType,
  23734. Certno: Certno,
  23735. PsnName: PsnName,
  23736. Gend: Gend,
  23737. Naty: Naty,
  23738. Brdy: Brdy,
  23739. Age: Age,
  23740. Iinfo: infoStr,
  23741. Idetinfo: idetinfoStr,
  23742. PatientId: patient.ID,
  23743. RecordDate: theTime.Unix(),
  23744. UserOrgId: adminInfo.CurrentOrgId,
  23745. AdminUserId: admin_user_id,
  23746. IsReturn: 1,
  23747. IdCardType: id_card_type,
  23748. Doctor: doctor,
  23749. Departments: department,
  23750. MdtrtGrpType: mdtrt_type,
  23751. }
  23752. timestamp := time.Now().Unix()
  23753. tempTime := time.Unix(timestamp, 0)
  23754. timeFormat := tempTime.Format("20060102150405")
  23755. chrgBchno := rand.Intn(100000) + 10000
  23756. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23757. his.Number = ipt_otp_no
  23758. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23759. department, _ := service.GetDepartMentDetail(department)
  23760. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23761. IdCardNo := ""
  23762. if id_card_type == 1 {
  23763. // IdCardNo = medical_insurance_card
  23764. IdCardNo = patient.IdCardNo
  23765. } else {
  23766. IdCardNo = patient.IdCardNo
  23767. }
  23768. var rf []*ResultFive
  23769. json.Unmarshal([]byte(his.Iinfo), &rf)
  23770. var insutypes []*ResultFive
  23771. var insutype string
  23772. var insuplc_admdvs_temp string
  23773. var is390 int = 0
  23774. var is310 int = 0
  23775. for _, item := range rf {
  23776. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23777. insutypes = append(insutypes, item)
  23778. }
  23779. }
  23780. if len(insutypes) == 1 {
  23781. insutype = insutypes[0].Insutype
  23782. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23783. if insutype == "390" {
  23784. is390 = 1
  23785. }
  23786. if insutype == "310" {
  23787. is310 = 1
  23788. }
  23789. } else {
  23790. for _, i := range insutypes {
  23791. if i.Insutype == "390" {
  23792. is390 = 1
  23793. }
  23794. if i.Insutype == "310" {
  23795. is310 = 1
  23796. }
  23797. }
  23798. }
  23799. if is390 == 1 {
  23800. insutype = "390"
  23801. }
  23802. if is310 == 1 {
  23803. insutype = "310"
  23804. }
  23805. fmt.Println(social_type)
  23806. if social_type > 0 {
  23807. insutype = strconv.FormatInt(social_type, 10)
  23808. }
  23809. var infocode int64
  23810. var resThree ResultThree
  23811. var resThree10265 ResultThree10265
  23812. if len(insuplc_admdvs) == 0 {
  23813. psn_info, _ := service.GetPsnByPatientId(id)
  23814. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23815. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23816. //}
  23817. } else {
  23818. insuplc_admdvs_temp = insuplc_admdvs
  23819. }
  23820. if miConfig.MdtrtareaAdmvs == "421300" {
  23821. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23822. psn_info, _ := service.GetPsnByPatientId(id)
  23823. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23824. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23825. "&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
  23826. resp, requestErr := http.Get(api)
  23827. if requestErr != nil {
  23828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23829. return
  23830. }
  23831. body, ioErr := ioutil.ReadAll(resp.Body)
  23832. if ioErr != nil {
  23833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23835. return
  23836. }
  23837. var respJSON map[string]interface{}
  23838. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23841. return
  23842. }
  23843. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23844. result, _ := json.Marshal(respJSON)
  23845. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23846. utils.ErrorLog("解析失败:%v", err)
  23847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23848. return
  23849. }
  23850. infocode = resThree.Infcode
  23851. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23852. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23853. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23854. // insuplc_admdvs_temp =
  23855. //}
  23856. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23857. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23858. //}
  23859. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23860. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23861. "&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
  23862. resp, requestErr := http.Get(api)
  23863. if requestErr != nil {
  23864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23865. return
  23866. }
  23867. body, ioErr := ioutil.ReadAll(resp.Body)
  23868. if ioErr != nil {
  23869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23871. return
  23872. }
  23873. var respJSON map[string]interface{}
  23874. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23877. return
  23878. }
  23879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23880. result, _ := json.Marshal(respJSON)
  23881. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23882. utils.ErrorLog("解析失败:%v", err)
  23883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23884. return
  23885. }
  23886. infocode = resThree.Infcode
  23887. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23888. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23889. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23890. // insuplc_admdvs_temp =
  23891. //}
  23892. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23893. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23894. //}
  23895. utils.ErrorLog("解析失败:%v", insutype)
  23896. utils.ErrorLog("解析失败:%v", PsnNo)
  23897. utils.ErrorLog("解析失败:%v", Certno)
  23898. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23899. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23900. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23901. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23902. utils.ErrorLog("解析失败:%v", PsnNo)
  23903. utils.ErrorLog("解析失败:%v", department.Number)
  23904. utils.ErrorLog("解析失败:%v", department.Name)
  23905. utils.ErrorLog("解析失败:%v", roles.UserName)
  23906. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23907. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23908. "&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
  23909. resp, requestErr := http.Get(api)
  23910. if requestErr != nil {
  23911. utils.ErrorLog("解析失败:%v", requestErr)
  23912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23913. return
  23914. }
  23915. body, ioErr := ioutil.ReadAll(resp.Body)
  23916. if ioErr != nil {
  23917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23919. return
  23920. }
  23921. var respJSON map[string]interface{}
  23922. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23925. return
  23926. }
  23927. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23928. result, _ := json.Marshal(respJSON)
  23929. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23930. utils.ErrorLog("解析失败:%v", err)
  23931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23932. return
  23933. }
  23934. infocode = resThree.Infcode
  23935. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23936. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23937. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23938. // insuplc_admdvs_temp =
  23939. //}
  23940. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23941. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23942. //}
  23943. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23944. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23945. "&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
  23946. resp, requestErr := http.Get(api)
  23947. if requestErr != nil {
  23948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23949. return
  23950. }
  23951. body, ioErr := ioutil.ReadAll(resp.Body)
  23952. if ioErr != nil {
  23953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23955. return
  23956. }
  23957. var respJSON map[string]interface{}
  23958. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23961. return
  23962. }
  23963. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23964. result, _ := json.Marshal(respJSON)
  23965. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23966. utils.ErrorLog("解析失败:%v", err)
  23967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23968. return
  23969. }
  23970. infocode = resThree.Infcode
  23971. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23972. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23973. psn_info, _ := service.GetPsnByPatientId(id)
  23974. var verify_number string
  23975. if id_card_type == 4 {
  23976. verify_number = psn_info.VerifyNumber
  23977. } else if id_card_type == 1 {
  23978. bas := strings.Split(psn_info.CardInfo, "|")
  23979. cardNumber := bas[2]
  23980. verify_number = cardNumber
  23981. }
  23982. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23983. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23984. "&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
  23985. resp, requestErr := http.Get(api)
  23986. if requestErr != nil {
  23987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23988. return
  23989. }
  23990. body, ioErr := ioutil.ReadAll(resp.Body)
  23991. if ioErr != nil {
  23992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23994. return
  23995. }
  23996. var respJSON map[string]interface{}
  23997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24000. return
  24001. }
  24002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24003. result, _ := json.Marshal(respJSON)
  24004. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24005. // utils.ErrorLog("解析失败:%v", err)
  24006. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24007. // return
  24008. //}
  24009. //infocode = resThree.Infcode
  24010. //result, _ := json.Marshal(respJSON)
  24011. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24012. utils.ErrorLog("解析失败:%v", err)
  24013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24014. return
  24015. }
  24016. resThree.ErrMsg = resThree10265.ErrMsg
  24017. resThree.Output = resThree10265.Output
  24018. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24019. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24020. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24021. psn_info, _ := service.GetPsnByPatientId(id)
  24022. his.PsnNo = psn_info.PsnNo
  24023. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24024. var cert_no string
  24025. if id_card_type == 3 {
  24026. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  24027. cert_no = IdCardNo
  24028. } else if id_card_type == 4 {
  24029. cert_no = IdCardNo
  24030. psn_info.VerifyNumber = psn_info.VerifyNumber
  24031. } else {
  24032. bas := strings.Split(psn_info.CardInfo, "|")
  24033. cert_no = bas[2]
  24034. }
  24035. var hisPrescription []*models.HisPrescription
  24036. for _, item := range rf {
  24037. if item.Insutype == insutype {
  24038. //insuplc_admdvs = item.InsuplcAdmdvs
  24039. his.InsuplcAdmdvs = insuplc_admdvs
  24040. }
  24041. }
  24042. his.Insutype = insutype
  24043. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24044. fmt.Println(res3101)
  24045. fmt.Println(res3101.Infcode)
  24046. if res3101.Infcode == "0" {
  24047. fmt.Println("33333333")
  24048. if len(res3101.Output.Result) > 0 {
  24049. fmt.Println("222222")
  24050. for _, item := range res3101.Output.Result {
  24051. if len(res3101.ErrMsg) == 0 {
  24052. res3101.ErrMsg = item.VolaCont
  24053. } else {
  24054. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24055. }
  24056. }
  24057. c.ServeSuccessJSON(map[string]interface{}{
  24058. "failed_code": -10,
  24059. "msg": res3101.ErrMsg,
  24060. })
  24061. return
  24062. } else {
  24063. fmt.Println("11111")
  24064. var api string
  24065. if miConfig.MdtrtareaAdmvs == "320921" {
  24066. ipt_otp_no = timeFormat
  24067. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24068. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24069. "&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
  24070. } else {
  24071. ipt_otp_no = timeFormat
  24072. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24073. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24074. "&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
  24075. }
  24076. resp, requestErr := http.Get(api)
  24077. if requestErr != nil {
  24078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24079. return
  24080. }
  24081. body, ioErr := ioutil.ReadAll(resp.Body)
  24082. if ioErr != nil {
  24083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24085. return
  24086. }
  24087. var respJSON map[string]interface{}
  24088. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24091. return
  24092. }
  24093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24094. result, _ := json.Marshal(respJSON)
  24095. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24096. utils.ErrorLog("解析失败:%v", err)
  24097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24098. return
  24099. }
  24100. resThree.ErrMsg = resThree10265.ErrMsg
  24101. resThree.Output = resThree10265.Output
  24102. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24103. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24104. }
  24105. } else if res3101.Infcode != "0" {
  24106. c.ServeSuccessJSON(map[string]interface{}{
  24107. "failed_code": -10,
  24108. "msg": res3101.ErrMsg,
  24109. })
  24110. return
  24111. }
  24112. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24113. psn_info, _ := service.GetPsnByPatientId(id)
  24114. var cert_no string
  24115. if id_card_type == 1 {
  24116. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24117. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24118. } else if id_card_type == 4 {
  24119. cert_no = psn_info.VerifyNumber
  24120. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24121. } else {
  24122. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24123. cert_no = psn_info.VerifyNumber
  24124. }
  24125. 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)
  24126. saveLog(result, requestLog, "2201", "挂号")
  24127. if miConfig.Code == "H15049901371" {
  24128. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24129. utils.ErrorLog("解析失败:%v", err)
  24130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24131. return
  24132. }
  24133. resThree.ErrMsg = resThree10265.ErrMsg
  24134. resThree.Output = resThree10265.Output
  24135. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24136. } else {
  24137. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24138. utils.ErrorLog("解析失败:%v", err)
  24139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24140. return
  24141. }
  24142. }
  24143. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24144. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24145. psn_info, _ := service.GetPsnByPatientId(id)
  24146. var result string
  24147. var requestLog string
  24148. if id_card_type == 1 {
  24149. bas := strings.Split(psn_info.CardInfo, "|")
  24150. basNumber := bas[2]
  24151. card_sn := bas[3]
  24152. 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)
  24153. saveLog(result, requestLog, "2201A", "挂号")
  24154. } else if id_card_type == 2 {
  24155. 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, "", "", "", "", "", "")
  24156. saveLog(result, requestLog, "2201A", "挂号")
  24157. } else {
  24158. 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)
  24159. saveLog(result, requestLog, "2201A", "挂号")
  24160. }
  24161. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24162. utils.ErrorLog("解析失败:%v", err)
  24163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24164. return
  24165. }
  24166. infocode = resThree.Infcode
  24167. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24168. psn_info, _ := service.GetPsnByPatientId(id)
  24169. var result string
  24170. var requestLog string
  24171. if id_card_type == 1 {
  24172. bas := strings.Split(psn_info.CardInfo, "|")
  24173. basNumber := bas[2]
  24174. card_sn := ""
  24175. 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)
  24176. saveLog(result, requestLog, "2201A", "挂号")
  24177. } else if id_card_type == 2 {
  24178. 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, "", "", "", "", "", "")
  24179. saveLog(result, requestLog, "2201A", "挂号")
  24180. } else {
  24181. 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)
  24182. saveLog(result, requestLog, "2201A", "挂号")
  24183. }
  24184. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24185. utils.ErrorLog("解析失败:%v", err)
  24186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24187. return
  24188. }
  24189. infocode = resThree.Infcode
  24190. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24191. psn_info, _ := service.GetPsnByPatientId(id)
  24192. his.PsnNo = psn_info.PsnNo
  24193. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24194. var cert_no string
  24195. if id_card_type == 1 {
  24196. bas := strings.Split(psn_info.CardInfo, "|")
  24197. cert_no = bas[2]
  24198. } else if id_card_type == 4 {
  24199. cert_no = psn_info.VerifyNumber
  24200. psn_info.VerifyNumber = psn_info.VerifyNumber
  24201. IdCardNo = psn_info.VerifyNumber
  24202. } else {
  24203. cert_no = IdCardNo
  24204. psn_info.VerifyNumber = cert_no
  24205. }
  24206. for _, item := range rf {
  24207. if item.Insutype == insutype {
  24208. his.InsuplcAdmdvs = insuplc_admdvs
  24209. }
  24210. }
  24211. his.Insutype = insutype
  24212. var api string
  24213. ipt_otp_no = timeFormat
  24214. 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 +
  24215. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24216. "&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
  24217. resp, requestErr := http.Get(api)
  24218. if requestErr != nil {
  24219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24220. return
  24221. }
  24222. body, ioErr := ioutil.ReadAll(resp.Body)
  24223. if ioErr != nil {
  24224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24226. return
  24227. }
  24228. var respJSON map[string]interface{}
  24229. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24232. return
  24233. }
  24234. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24235. if status == "0" {
  24236. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24237. c.ServeSuccessJSON(map[string]interface{}{
  24238. "failed_code": -10,
  24239. "msg": err_msg,
  24240. })
  24241. return
  24242. }
  24243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24244. result, _ := json.Marshal(respJSON)
  24245. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24246. utils.ErrorLog("解析失败:%v", err)
  24247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24248. return
  24249. }
  24250. infocode = resThree.Infcode
  24251. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24252. psn_info, _ := service.GetPsnByPatientId(id)
  24253. his.PsnNo = psn_info.PsnNo
  24254. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24255. var cert_no string
  24256. if id_card_type == 1 {
  24257. bas := strings.Split(psn_info.CardInfo, "|")
  24258. cert_no = bas[2]
  24259. } else if id_card_type == 4 {
  24260. cert_no = psn_info.VerifyNumber
  24261. psn_info.VerifyNumber = psn_info.VerifyNumber
  24262. IdCardNo = psn_info.VerifyNumber
  24263. } else {
  24264. cert_no = IdCardNo
  24265. psn_info.VerifyNumber = cert_no
  24266. }
  24267. for _, item := range rf {
  24268. if item.Insutype == insutype {
  24269. his.InsuplcAdmdvs = insuplc_admdvs
  24270. patient.InsuplcAdmdvs = insuplc_admdvs
  24271. }
  24272. }
  24273. his.Insutype = insutype
  24274. var api string
  24275. ipt_otp_no = timeFormat
  24276. 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 +
  24277. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24278. "&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
  24279. resp, requestErr := http.Get(api)
  24280. if requestErr != nil {
  24281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24282. return
  24283. }
  24284. body, ioErr := ioutil.ReadAll(resp.Body)
  24285. if ioErr != nil {
  24286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24288. return
  24289. }
  24290. var respJSON map[string]interface{}
  24291. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24294. return
  24295. }
  24296. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24297. if status == "0" {
  24298. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24299. c.ServeSuccessJSON(map[string]interface{}{
  24300. "failed_code": -10,
  24301. "msg": err_msg,
  24302. })
  24303. return
  24304. }
  24305. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24306. result, _ := json.Marshal(respJSON)
  24307. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24308. utils.ErrorLog("解析失败:%v", err)
  24309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24310. return
  24311. }
  24312. infocode = resThree.Infcode
  24313. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24314. psn_info, _ := service.GetPsnByPatientId(id)
  24315. var result string
  24316. var requestLog string
  24317. if id_card_type == 1 {
  24318. bas := strings.Split(psn_info.CardInfo, "|")
  24319. basNumber := bas[2]
  24320. card_sn := bas[3]
  24321. 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)
  24322. saveLog(result, requestLog, "2201A", "挂号")
  24323. } else if id_card_type == 2 {
  24324. 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, "", "")
  24325. saveLog(result, requestLog, "2201A", "挂号")
  24326. } else {
  24327. 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, "", "")
  24328. saveLog(result, requestLog, "2201A", "挂号")
  24329. }
  24330. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24331. utils.ErrorLog("解析失败:%v", err)
  24332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24333. return
  24334. }
  24335. infocode = resThree.Infcode
  24336. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24337. psn_info, _ := service.GetPsnByPatientId(id)
  24338. 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)
  24339. saveLog(result, requestLog, "2201A", "挂号")
  24340. if miConfig.Code == "H15049901371" {
  24341. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24342. utils.ErrorLog("解析失败:%v", err)
  24343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24344. return
  24345. }
  24346. resThree.ErrMsg = resThree10265.ErrMsg
  24347. resThree.Output = resThree10265.Output
  24348. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24349. } else {
  24350. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24351. utils.ErrorLog("解析失败:%v", err)
  24352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24353. return
  24354. }
  24355. }
  24356. if miConfig.Code == "H15049901371" {
  24357. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24358. } else {
  24359. infocode = resThree.Infcode
  24360. }
  24361. } else {
  24362. psn_info, _ := service.GetPsnByPatientId(id)
  24363. if id_card_type == 4 || id_card_type == 1 {
  24364. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24365. }
  24366. var rf []*ResultFive
  24367. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24368. var insutypes []*ResultFive
  24369. var insutype string
  24370. var is390 int = 0
  24371. var is310 int = 0
  24372. for _, item := range rf {
  24373. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24374. insutypes = append(insutypes, item)
  24375. }
  24376. }
  24377. if len(insutypes) == 1 {
  24378. insutype = insutypes[0].Insutype
  24379. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24380. } else {
  24381. for _, i := range insutypes {
  24382. if i.Insutype == "390" {
  24383. is390 = 1
  24384. }
  24385. if i.Insutype == "310" {
  24386. is310 = 1
  24387. }
  24388. }
  24389. }
  24390. if is390 == 1 {
  24391. insutype = "390"
  24392. }
  24393. if is310 == 1 {
  24394. insutype = "310"
  24395. }
  24396. fmt.Println(len(insutypes))
  24397. if len(insutypes) == 0 {
  24398. for index, item := range rf {
  24399. if index == 0 {
  24400. insutype = item.Insutype
  24401. insuplc_admdvs = item.InsuplcAdmdvs
  24402. }
  24403. }
  24404. fmt.Println(insutype)
  24405. fmt.Println(insuplc_admdvs)
  24406. }
  24407. if social_type > 0 {
  24408. insutype = strconv.FormatInt(social_type, 10)
  24409. }
  24410. fmt.Println("--------")
  24411. fmt.Println(psn_info)
  24412. fmt.Println(psn_info.PsnNo)
  24413. if miConfig.MdtrtareaAdmvs == "441202" {
  24414. var hisPrescription []*models.HisPrescription
  24415. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24416. if res3101.Infcode == 0 {
  24417. fmt.Println("33333333")
  24418. if len(res3101.Output.Result) > 0 {
  24419. fmt.Println("222222")
  24420. for _, item := range res3101.Output.Result {
  24421. if len(res3101.ErrMsg) == 0 {
  24422. res3101.ErrMsg = item.VolaCont
  24423. } else {
  24424. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24425. }
  24426. }
  24427. c.ServeSuccessJSON(map[string]interface{}{
  24428. "failed_code": -10,
  24429. "msg": res3101.ErrMsg,
  24430. })
  24431. return
  24432. } else {
  24433. hour := time.Now().Format("15")
  24434. min := time.Now().Format("04")
  24435. sec := time.Now().Format("05")
  24436. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24437. fmt.Println(record_time_two)
  24438. 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)
  24439. saveLog(result, requestLog, "2201A", "挂号")
  24440. if miConfig.Code == "H15049901371" {
  24441. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24442. utils.ErrorLog("解析失败:%v", err)
  24443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24444. return
  24445. }
  24446. resThree.ErrMsg = resThree10265.ErrMsg
  24447. resThree.Output = resThree10265.Output
  24448. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24449. } else {
  24450. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24451. utils.ErrorLog("解析失败:%v", err)
  24452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24453. return
  24454. }
  24455. }
  24456. if miConfig.Code == "H15049901371" {
  24457. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24458. } else {
  24459. infocode = resThree.Infcode
  24460. }
  24461. }
  24462. } else if res3101.Infcode != 0 {
  24463. c.ServeSuccessJSON(map[string]interface{}{
  24464. "failed_code": -10,
  24465. "msg": res3101.ErrMsg,
  24466. })
  24467. return
  24468. }
  24469. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24470. var hisPrescription []*models.HisPrescription
  24471. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24472. if res3101.Infcode == 0 {
  24473. fmt.Println("33333333")
  24474. if len(res3101.Output.Result) > 0 {
  24475. fmt.Println("222222")
  24476. for _, item := range res3101.Output.Result {
  24477. if len(res3101.ErrMsg) == 0 {
  24478. res3101.ErrMsg = item.VolaCont
  24479. } else {
  24480. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24481. }
  24482. }
  24483. c.ServeSuccessJSON(map[string]interface{}{
  24484. "failed_code": -10,
  24485. "msg": res3101.ErrMsg,
  24486. })
  24487. return
  24488. } else {
  24489. hour := time.Now().Format("15")
  24490. min := time.Now().Format("04")
  24491. sec := time.Now().Format("05")
  24492. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24493. fmt.Println(record_time_two)
  24494. 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)
  24495. saveLog(result, requestLog, "2201A", "挂号")
  24496. if miConfig.Code == "H15049901371" {
  24497. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24498. utils.ErrorLog("解析失败:%v", err)
  24499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24500. return
  24501. }
  24502. resThree.ErrMsg = resThree10265.ErrMsg
  24503. resThree.Output = resThree10265.Output
  24504. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24505. } else {
  24506. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24507. utils.ErrorLog("解析失败:%v", err)
  24508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24509. return
  24510. }
  24511. }
  24512. if miConfig.Code == "H15049901371" {
  24513. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24514. } else {
  24515. infocode = resThree.Infcode
  24516. }
  24517. }
  24518. } else if res3101.Infcode != 0 {
  24519. c.ServeSuccessJSON(map[string]interface{}{
  24520. "failed_code": -10,
  24521. "msg": res3101.ErrMsg,
  24522. })
  24523. return
  24524. }
  24525. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24526. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24527. psn_info, _ := service.GetPsnByPatientId(id)
  24528. var verify_number string
  24529. if id_card_type == 4 {
  24530. verify_number = psn_info.VerifyNumber
  24531. } else if id_card_type == 1 {
  24532. bas := strings.Split(psn_info.CardInfo, "|")
  24533. cardNumber := bas[2]
  24534. verify_number = cardNumber
  24535. } else {
  24536. verify_number = psn_info.Certno
  24537. }
  24538. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24539. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24540. "&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
  24541. resp, requestErr := http.Get(api)
  24542. if requestErr != nil {
  24543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24544. return
  24545. }
  24546. body, ioErr := ioutil.ReadAll(resp.Body)
  24547. if ioErr != nil {
  24548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24550. return
  24551. }
  24552. var respJSON map[string]interface{}
  24553. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24556. return
  24557. }
  24558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24559. result, _ := json.Marshal(respJSON)
  24560. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24561. utils.ErrorLog("解析失败:%v", err)
  24562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24563. return
  24564. }
  24565. infocode = resThree.Infcode
  24566. } else {
  24567. hour := time.Now().Format("15")
  24568. min := time.Now().Format("04")
  24569. sec := time.Now().Format("05")
  24570. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24571. if id_card_type == 1 {
  24572. for _, item := range rf {
  24573. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24574. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24575. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24576. } else if strconv.FormatInt(social_type, 10) == "390" {
  24577. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24578. } else {
  24579. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24580. }
  24581. }
  24582. }
  24583. }
  24584. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24585. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24586. }
  24587. if id_card_type == 1 {
  24588. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24589. bas := strings.Split(psn_info.CardInfo, "|")
  24590. basNumber := bas[1]
  24591. IdCardNo = basNumber
  24592. }
  24593. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24594. IdCardNo = psn_info.VerifyNumber
  24595. }
  24596. if len(insuplc_admdvs_temp) == 0 {
  24597. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24598. }
  24599. var result string
  24600. var requestLog string
  24601. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  24602. var hisPrescription []*models.HisPrescription
  24603. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24604. if res3101.Infcode == 0 {
  24605. if len(res3101.Output.Result) > 0 {
  24606. for _, item := range res3101.Output.Result {
  24607. if len(res3101.ErrMsg) == 0 {
  24608. res3101.ErrMsg = item.VolaCont
  24609. } else {
  24610. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24611. }
  24612. }
  24613. c.ServeSuccessJSON(map[string]interface{}{
  24614. "failed_code": -10,
  24615. "msg": res3101.ErrMsg,
  24616. })
  24617. return
  24618. } else {
  24619. hour := time.Now().Format("15")
  24620. min := time.Now().Format("04")
  24621. sec := time.Now().Format("05")
  24622. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24623. fmt.Println(record_time_two)
  24624. if his.IdCardType == 2 {
  24625. IdCardNo = psn_info.Certno
  24626. psn_info.VerifyNumber = psn_info.Certno
  24627. } else if his.IdCardType == 4 {
  24628. IdCardNo = psn_info.Certno
  24629. } else {
  24630. bas := strings.Split(psn_info.CardInfo, "|")
  24631. IdCardNo = bas[2]
  24632. }
  24633. 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)
  24634. saveLog(result, requestLog, "2201A", "挂号")
  24635. if miConfig.Code == "H15049901371" {
  24636. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24637. utils.ErrorLog("解析失败:%v", err)
  24638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24639. return
  24640. }
  24641. resThree.ErrMsg = resThree10265.ErrMsg
  24642. resThree.Output = resThree10265.Output
  24643. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24644. } else {
  24645. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24646. utils.ErrorLog("解析失败:%v", err)
  24647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24648. return
  24649. }
  24650. }
  24651. if miConfig.Code == "H15049901371" {
  24652. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24653. } else {
  24654. infocode = resThree.Infcode
  24655. }
  24656. }
  24657. } else if res3101.Infcode != 0 {
  24658. c.ServeSuccessJSON(map[string]interface{}{
  24659. "failed_code": -10,
  24660. "msg": res3101.ErrMsg,
  24661. })
  24662. return
  24663. }
  24664. } else {
  24665. psn_info, _ := service.GetPsnByPatientId(id)
  24666. var rf []*ResultFive
  24667. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24668. //var insutypes []*ResultFive
  24669. var insutype string
  24670. var insutypes []*ResultFive
  24671. var is390 int = 0
  24672. var is310 int = 0
  24673. for _, item := range rf {
  24674. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24675. insutypes = append(insutypes, item)
  24676. }
  24677. }
  24678. if len(insutypes) == 1 {
  24679. insutype = insutypes[0].Insutype
  24680. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24681. } else {
  24682. for _, i := range insutypes {
  24683. if i.Insutype == "390" {
  24684. is390 = 1
  24685. }
  24686. if i.Insutype == "310" {
  24687. is310 = 1
  24688. }
  24689. }
  24690. }
  24691. if is390 == 1 {
  24692. insutype = "390"
  24693. }
  24694. if is310 == 1 {
  24695. insutype = "310"
  24696. }
  24697. if len(insutypes) == 0 {
  24698. insutype = "310"
  24699. }
  24700. if social_type > 0 {
  24701. insutype = strconv.FormatInt(social_type, 10)
  24702. }
  24703. for _, item := range rf {
  24704. utils.ErrorLog("解析失败:%v", item.Insutype)
  24705. utils.ErrorLog("解析失败:%v", insutype)
  24706. if item.Insutype == insutype {
  24707. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24708. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  24709. }
  24710. }
  24711. 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)
  24712. saveLog(result, requestLog, "2201A", "挂号")
  24713. }
  24714. if miConfig.Code == "H15049901371" {
  24715. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24716. utils.ErrorLog("解析失败:%v", err)
  24717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24718. return
  24719. }
  24720. resThree.ErrMsg = resThree10265.ErrMsg
  24721. resThree.Output = resThree10265.Output
  24722. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24723. } else {
  24724. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24725. utils.ErrorLog("解析失败:%v", err)
  24726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24727. return
  24728. }
  24729. }
  24730. if miConfig.Code == "H15049901371" {
  24731. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24732. } else {
  24733. infocode = resThree.Infcode
  24734. }
  24735. }
  24736. }
  24737. if infocode == -1 {
  24738. adminUser := c.GetAdminUserInfo()
  24739. errlog := &models.HisOrderError{
  24740. UserOrgId: adminUser.CurrentOrgId,
  24741. Ctime: time.Now().Unix(),
  24742. Mtime: time.Now().Unix(),
  24743. ErrMsg: resThree.ErrMsg,
  24744. Status: 1,
  24745. PatientId: id,
  24746. RecordTime: recordDateTime,
  24747. Stage: 2,
  24748. }
  24749. service.CreateErrMsgLog(errlog)
  24750. c.ServeSuccessJSON(map[string]interface{}{
  24751. "failed_code": -10,
  24752. "msg": resThree.ErrMsg,
  24753. })
  24754. return
  24755. }
  24756. his.Number = resThree.Output.Data.MdtrtID
  24757. his.PsnNo = resThree.Output.Data.PsnNo
  24758. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24759. his.IdCardNo = patient.IdCardNo
  24760. his.PhoneNumber = patient.Phone
  24761. his.UserOrgId = adminInfo.CurrentOrgId
  24762. his.Insutype = insutype
  24763. his.Ctime = time.Now().Unix()
  24764. his.Mtime = time.Now().Unix()
  24765. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24766. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24767. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24768. }
  24769. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24770. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24771. }
  24772. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24773. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24774. }
  24775. his.Status = 1
  24776. his.MdtrtGrpType = mdtrt_type
  24777. service.UpdateHisPatientStatus(&his)
  24778. service.UpdateHisPatient123(&patient)
  24779. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24780. c.ServeSuccessJSON(map[string]interface{}{
  24781. "his_info": his,
  24782. })
  24783. } else {
  24784. adminUser := c.GetAdminUserInfo()
  24785. errlog := &models.HisOrderError{
  24786. UserOrgId: adminUser.CurrentOrgId,
  24787. Ctime: time.Now().Unix(),
  24788. Mtime: time.Now().Unix(),
  24789. ErrMsg: res.ErrMsg,
  24790. Status: 1,
  24791. PatientId: id,
  24792. RecordTime: recordDateTime,
  24793. Stage: 1,
  24794. }
  24795. service.CreateErrMsgLog(errlog)
  24796. c.ServeSuccessJSON(map[string]interface{}{
  24797. "failed_code": -10,
  24798. "msg": res.ErrMsg,
  24799. })
  24800. return
  24801. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24802. }
  24803. }
  24804. }
  24805. func (c *HisApiController) GetUploadInfo() {
  24806. id, _ := c.GetInt64("id")
  24807. record_time := c.GetString("record_time")
  24808. his_patient_id, _ := c.GetInt64("his_patient_id")
  24809. order_id, _ := c.GetInt64("order_id")
  24810. pay_way, _ := c.GetInt64("pay_way")
  24811. pay_ways := c.GetString("pay_ways")
  24812. oth_desc := c.GetString("oth_desc")
  24813. pay_price, _ := c.GetFloat("pay_price")
  24814. pay_card_no := c.GetString("pay_card_no")
  24815. discount_price, _ := c.GetFloat("discount_price")
  24816. preferential_price, _ := c.GetFloat("preferential_price")
  24817. reality_price, _ := c.GetFloat("reality_price")
  24818. found_price, _ := c.GetFloat("found_price")
  24819. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24820. private_price, _ := c.GetFloat("private_price")
  24821. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24822. admin_user_id, _ := c.GetInt64("admin_user_id")
  24823. fapiao_code := c.GetString("fapiao_code")
  24824. fapiao_number := c.GetString("fapiao_number")
  24825. diagnosis_id := c.GetString("diagnosis")
  24826. sick_type, _ := c.GetInt64("sick_type")
  24827. reg_type, _ := c.GetInt64("p_type")
  24828. begin_time := c.GetString("begin_time")
  24829. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24830. cash_pay := c.GetString("cash_pay")
  24831. band_card_pay := c.GetString("band_card_pay")
  24832. wechat_pay := c.GetString("wechat_pay")
  24833. ali_pay := c.GetString("ali_pay")
  24834. jifen_pay := c.GetString("jifen_pay")
  24835. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24836. fmt.Println(acct_used_flag)
  24837. id_str := c.GetString("ids")
  24838. ids_arr := strings.Split(id_str, ",")
  24839. timeLayout := "2006-01-02"
  24840. loc, _ := time.LoadLocation("Local")
  24841. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24842. if err != nil {
  24843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24844. return
  24845. }
  24846. recordDateTime := theTime.Unix()
  24847. adminUser := c.GetAdminUserInfo()
  24848. var tempOrder models.HisOrder
  24849. tempOrder, _ = service.GetHisOrderByID(order_id)
  24850. var prescriptions []*models.HisPrescription
  24851. var start_time int64
  24852. var end_time int64
  24853. //押金模块
  24854. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24855. tmp_decimal := c.GetString("tmp_decimal")
  24856. var decimal float64 //本次使用的押金
  24857. var errmsg error
  24858. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24859. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24860. return
  24861. }
  24862. if len(tmp_decimal) > 0 {
  24863. if tmp_decimal[0] == 45 {
  24864. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24865. return
  24866. }
  24867. }
  24868. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24869. fmt.Println(errs)
  24870. decimal = tt
  24871. //if adminUser.CurrentOrgId == 10106{
  24872. // if len(fapiao_code) == 0{
  24873. // fapiao_code = "144072080589"
  24874. // }
  24875. // if len(fapiao_number) == 0{
  24876. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24877. // if order.ID == 0{
  24878. // fapiao_number = "00001520"
  24879. // }else{
  24880. // //fapiao_code = "00001520"
  24881. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24882. // var zero string
  24883. // if fpNumber >= 1000{
  24884. // zero = "0000" + strconv.Itoa(fpNumber)
  24885. // }else if fpNumber >= 10000{
  24886. // zero = "000" + strconv.Itoa(fpNumber)
  24887. // } else if fpNumber >= 100000{
  24888. // zero = "00" + strconv.Itoa(fpNumber)
  24889. // } else if fpNumber >= 1000000{
  24890. // zero = "0" + strconv.Itoa(fpNumber)
  24891. // }else {
  24892. // zero = strconv.Itoa(fpNumber)
  24893. // }
  24894. // fapiao_number = zero
  24895. // }
  24896. // }
  24897. //}
  24898. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24899. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24900. var patientPrescription models.HisPrescriptionInfo
  24901. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24902. if patientPrescription.ID == 0 {
  24903. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24904. }
  24905. //if patientPrescription.Do
  24906. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24907. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24908. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24909. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24910. var config []*models.HisXtDiagnoseConfig
  24911. for _, item := range diagnosis_ids {
  24912. id, _ := strconv.ParseInt(item, 10, 64)
  24913. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24914. config = append(config, &diagnosisConfig)
  24915. }
  24916. sickConfig, _ := service.FindSickById(sick_type)
  24917. //if tempOrder.ID == 0 {
  24918. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24919. //}
  24920. if tempOrder.ID == 0 {
  24921. var result string
  24922. var requestLog string
  24923. var res2 ResultSix
  24924. var res3 GZResultSix
  24925. var ressix10265 ResultSix10265
  24926. if miConfig.MdtrtareaAdmvs == "421300" {
  24927. data := make(map[string]interface{})
  24928. client := &http.Client{}
  24929. data["psn_no"] = his.PsnNo
  24930. data["mdtrt_id"] = his.Number
  24931. data["opter"] = roles.UserName
  24932. data["org_name"] = miConfig.OrgName
  24933. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24934. data["doctor_id"] = doctor_info.DoctorNumber
  24935. data["doctor_name"] = doctor_info.UserName
  24936. data["department"] = department.Name
  24937. data["fixmedins_code"] = miConfig.Code
  24938. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24939. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24940. data["secret_key"] = miConfig.SecretKey
  24941. data["sick_code"] = sickConfig.CountryCode
  24942. data["sick_name"] = sickConfig.ClassName
  24943. data["dept"] = strconv.FormatInt(department.ID, 10)
  24944. data["config"] = config
  24945. data["begin_time"] = begin_time
  24946. bytesData, _ := json.Marshal(data)
  24947. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24948. resp, _ := client.Do(req)
  24949. defer resp.Body.Close()
  24950. body, ioErr := ioutil.ReadAll(resp.Body)
  24951. if ioErr != nil {
  24952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24954. return
  24955. }
  24956. var respJSON map[string]interface{}
  24957. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24960. return
  24961. }
  24962. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24963. userJSONBytes, _ := json.Marshal(respJSON)
  24964. fmt.Println("log")
  24965. fmt.Println(string(userJSONBytes))
  24966. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24967. utils.ErrorLog("解析失败:%v", err)
  24968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24969. return
  24970. }
  24971. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24972. data := make(map[string]interface{})
  24973. client := &http.Client{}
  24974. data["psn_no"] = his.PsnNo
  24975. data["mdtrt_id"] = his.Number
  24976. data["opter"] = roles.UserName
  24977. data["org_name"] = miConfig.OrgName
  24978. if reg_type == 11 && his.Insutype == "390" {
  24979. data["med_type"] = "110104"
  24980. } else {
  24981. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24982. }
  24983. data["doctor_id"] = doctor_info.DoctorNumber
  24984. data["doctor_name"] = doctor_info.UserName
  24985. data["department"] = department.Name
  24986. data["fixmedins_code"] = miConfig.Code
  24987. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24988. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24989. data["secret_key"] = miConfig.SecretKey
  24990. data["sick_code"] = sickConfig.CountryCode
  24991. data["sick_name"] = sickConfig.ClassName
  24992. data["dept"] = strconv.FormatInt(department.ID, 10)
  24993. data["config"] = config
  24994. data["begin_time"] = begin_time
  24995. bytesData, _ := json.Marshal(data)
  24996. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24997. resp, _ := client.Do(req)
  24998. defer resp.Body.Close()
  24999. body, ioErr := ioutil.ReadAll(resp.Body)
  25000. if ioErr != nil {
  25001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25003. return
  25004. }
  25005. var respJSON map[string]interface{}
  25006. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25009. return
  25010. }
  25011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25012. userJSONBytes, _ := json.Marshal(respJSON)
  25013. fmt.Println("log")
  25014. fmt.Println(string(userJSONBytes))
  25015. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25016. utils.ErrorLog("解析失败:%v", err)
  25017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25018. return
  25019. }
  25020. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25021. data := make(map[string]interface{})
  25022. client := &http.Client{}
  25023. data["psn_no"] = his.PsnNo
  25024. data["mdtrt_id"] = his.Number
  25025. data["opter"] = roles.UserName
  25026. data["org_name"] = miConfig.OrgName
  25027. if reg_type == 11 && his.Insutype == "390" {
  25028. data["med_type"] = "110104"
  25029. } else {
  25030. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25031. }
  25032. data["doctor_id"] = doctor_info.DoctorNumber
  25033. data["doctor_name"] = doctor_info.UserName
  25034. data["department"] = department.Name
  25035. data["fixmedins_code"] = miConfig.Code
  25036. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25037. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25038. data["secret_key"] = miConfig.SecretKey
  25039. data["sick_code"] = sickConfig.CountryCode
  25040. data["sick_name"] = sickConfig.ClassName
  25041. data["dept"] = strconv.FormatInt(department.ID, 10)
  25042. data["config"] = config
  25043. data["begin_time"] = begin_time
  25044. bytesData, _ := json.Marshal(data)
  25045. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25046. resp, _ := client.Do(req)
  25047. defer resp.Body.Close()
  25048. body, ioErr := ioutil.ReadAll(resp.Body)
  25049. if ioErr != nil {
  25050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25052. return
  25053. }
  25054. var respJSON map[string]interface{}
  25055. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25058. return
  25059. }
  25060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25061. userJSONBytes, _ := json.Marshal(respJSON)
  25062. fmt.Println("log")
  25063. fmt.Println(string(userJSONBytes))
  25064. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25065. utils.ErrorLog("解析失败:%v", err)
  25066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25067. return
  25068. }
  25069. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25070. data := make(map[string]interface{})
  25071. client := &http.Client{}
  25072. data["psn_no"] = his.PsnNo
  25073. data["mdtrt_id"] = his.Number
  25074. data["opter"] = roles.UserName
  25075. data["org_name"] = miConfig.OrgName
  25076. if reg_type == 11 && his.Insutype == "390" {
  25077. data["med_type"] = "110104"
  25078. } else {
  25079. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25080. }
  25081. data["doctor_id"] = doctor_info.DoctorNumber
  25082. data["doctor_name"] = doctor_info.UserName
  25083. data["department"] = department.Name
  25084. data["fixmedins_code"] = miConfig.Code
  25085. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25086. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25087. data["secret_key"] = miConfig.SecretKey
  25088. data["sick_code"] = sickConfig.CountryCode
  25089. data["sick_name"] = sickConfig.ClassName
  25090. data["dept"] = strconv.FormatInt(department.ID, 10)
  25091. data["config"] = config
  25092. data["begin_time"] = begin_time
  25093. bytesData, _ := json.Marshal(data)
  25094. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25095. resp, _ := client.Do(req)
  25096. defer resp.Body.Close()
  25097. body, ioErr := ioutil.ReadAll(resp.Body)
  25098. if ioErr != nil {
  25099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25101. return
  25102. }
  25103. var respJSON map[string]interface{}
  25104. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25107. return
  25108. }
  25109. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25110. userJSONBytes, _ := json.Marshal(respJSON)
  25111. fmt.Println("log")
  25112. fmt.Println(string(userJSONBytes))
  25113. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25114. utils.ErrorLog("解析失败:%v", err)
  25115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25116. return
  25117. }
  25118. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25119. data := make(map[string]interface{})
  25120. client := &http.Client{}
  25121. data["psn_no"] = his.PsnNo
  25122. data["mdtrt_id"] = his.Number
  25123. data["doctor"] = roles.UserName
  25124. data["department"] = department.Name
  25125. data["org_name"] = miConfig.OrgName
  25126. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25127. data["doctor_id"] = doctor_info.DoctorNumber
  25128. data["new_doctor_name"] = doctor_info.UserName
  25129. data["fixmedins_code"] = miConfig.Code
  25130. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25131. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25132. data["secret_key"] = miConfig.SecretKey
  25133. data["sick_code"] = sickConfig.CountryCode
  25134. data["sick_name"] = sickConfig.ClassName
  25135. data["url"] = miConfig.Url
  25136. data["ak"] = miConfig.AccessKey
  25137. data["begin_time"] = begin_time
  25138. data["cainfo"] = miConfig.Cainfo
  25139. data["dept"] = strconv.FormatInt(department.ID, 10)
  25140. data["config"] = config
  25141. bytesData, _ := json.Marshal(data)
  25142. var req *http.Request
  25143. if miConfig.MdtrtareaAdmvs == "320921" {
  25144. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25145. //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 +
  25146. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25147. } else {
  25148. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25149. }
  25150. resp, _ := client.Do(req)
  25151. defer resp.Body.Close()
  25152. body, ioErr := ioutil.ReadAll(resp.Body)
  25153. if ioErr != nil {
  25154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25156. return
  25157. }
  25158. var respJSON map[string]interface{}
  25159. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25162. return
  25163. }
  25164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25165. userJSONBytes, _ := json.Marshal(respJSON)
  25166. fmt.Println("log")
  25167. fmt.Println(string(userJSONBytes))
  25168. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25169. utils.ErrorLog("解析失败:%v", err)
  25170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25171. return
  25172. }
  25173. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25174. res2.Output = ressix10265.Output
  25175. res2.ErrMsg = ressix10265.ErrMsg
  25176. res2.Cainfo = ressix10265.Cainfo
  25177. res2.WarnMsg = ressix10265.WarnMsg
  25178. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25179. res2.Infcode = infocode
  25180. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25181. data := make(map[string]interface{})
  25182. client := &http.Client{}
  25183. data["psn_no"] = his.PsnNo
  25184. data["mdtrt_id"] = his.Number
  25185. data["doctor"] = roles.UserName
  25186. data["department"] = department.Name
  25187. data["org_name"] = miConfig.OrgName
  25188. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25189. data["doctor_id"] = doctor_info.DoctorNumber
  25190. data["new_doctor_name"] = doctor_info.UserName
  25191. data["fixmedins_code"] = miConfig.Code
  25192. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25193. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25194. data["secret_key"] = miConfig.SecretKey
  25195. data["sick_code"] = sickConfig.CountryCode
  25196. data["sick_name"] = sickConfig.ClassName
  25197. data["url"] = miConfig.Url
  25198. data["ak"] = miConfig.AccessKey
  25199. data["begin_time"] = begin_time
  25200. data["cainfo"] = miConfig.Cainfo
  25201. data["dept"] = strconv.FormatInt(department.ID, 10)
  25202. data["config"] = config
  25203. bytesData, _ := json.Marshal(data)
  25204. var req *http.Request
  25205. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25206. resp, _ := client.Do(req)
  25207. defer resp.Body.Close()
  25208. body, ioErr := ioutil.ReadAll(resp.Body)
  25209. if ioErr != nil {
  25210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25212. return
  25213. }
  25214. var respJSON map[string]interface{}
  25215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25218. return
  25219. }
  25220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25221. userJSONBytes, _ := json.Marshal(respJSON)
  25222. fmt.Println("log")
  25223. fmt.Println(string(userJSONBytes))
  25224. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25225. utils.ErrorLog("解析失败:%v", err)
  25226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25227. return
  25228. }
  25229. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25230. res2.Output = ressix10265.Output
  25231. res2.ErrMsg = ressix10265.ErrMsg
  25232. res2.Cainfo = ressix10265.Cainfo
  25233. res2.WarnMsg = ressix10265.WarnMsg
  25234. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25235. res2.Infcode = infocode
  25236. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25237. 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)
  25238. saveLog(result, requestLog, "2203", "上传就诊信息")
  25239. var respJSON2 map[string]interface{}
  25240. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25243. return
  25244. }
  25245. userJSONBytes2, _ := json.Marshal(respJSON2)
  25246. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25247. utils.ErrorLog("解析失败:%v", err)
  25248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25249. return
  25250. }
  25251. 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)
  25252. fmt.Println(result2)
  25253. fmt.Println(src_request)
  25254. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25255. data := make(map[string]interface{})
  25256. client := &http.Client{}
  25257. data["psn_no"] = his.PsnNo
  25258. data["mdtrt_id"] = his.Number
  25259. data["doctor"] = roles.UserName
  25260. data["department"] = department.Name
  25261. data["org_name"] = miConfig.OrgName
  25262. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25263. data["doctor_id"] = doctor_info.DoctorNumber
  25264. data["new_doctor_name"] = doctor_info.UserName
  25265. data["fixmedins_code"] = miConfig.Code
  25266. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25267. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25268. data["secret_key"] = miConfig.SecretKey
  25269. data["sick_code"] = sickConfig.CountryCode
  25270. data["sick_name"] = sickConfig.ClassName
  25271. data["url"] = miConfig.Url
  25272. data["ak"] = miConfig.AccessKey
  25273. data["begin_time"] = begin_time
  25274. data["cainfo"] = miConfig.Cainfo
  25275. data["dept"] = strconv.FormatInt(department.ID, 10)
  25276. data["config"] = config
  25277. bytesData, _ := json.Marshal(data)
  25278. var req *http.Request
  25279. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25280. resp, _ := client.Do(req)
  25281. defer resp.Body.Close()
  25282. body, ioErr := ioutil.ReadAll(resp.Body)
  25283. if ioErr != nil {
  25284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25286. return
  25287. }
  25288. var respJSON map[string]interface{}
  25289. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25292. return
  25293. }
  25294. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25295. userJSONBytes, _ := json.Marshal(respJSON)
  25296. fmt.Println("log")
  25297. fmt.Println(string(userJSONBytes))
  25298. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25299. utils.ErrorLog("解析失败:%v", err)
  25300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25301. return
  25302. }
  25303. } else {
  25304. if miConfig.MdtrtareaAdmvs == "440781" { //
  25305. 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)
  25306. } else {
  25307. if miConfig.Code == "H15049901371" {
  25308. //赤峰地区国家医保医疗类别
  25309. //职工透析:医疗类别选特殊情况门诊990502
  25310. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25311. var med_type string
  25312. if his.Insutype == "390" {
  25313. if reg_type == 14 {
  25314. med_type = "9933"
  25315. } else if reg_type == 11 {
  25316. med_type = "11"
  25317. }
  25318. } else if his.Insutype == "310" {
  25319. if reg_type == 14 {
  25320. med_type = "990502"
  25321. } else if reg_type == 11 {
  25322. med_type = "11"
  25323. }
  25324. }
  25325. 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)
  25326. } else {
  25327. 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)
  25328. }
  25329. }
  25330. saveLog(result, requestLog, "2203", "上传就诊信息")
  25331. var respJSON2 map[string]interface{}
  25332. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25335. return
  25336. }
  25337. userJSONBytes2, _ := json.Marshal(respJSON2)
  25338. if miConfig.Code == "H15049901371" {
  25339. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25340. utils.ErrorLog("解析失败:%v", err)
  25341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25342. return
  25343. }
  25344. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25345. res2.Output = ressix10265.Output
  25346. res2.ErrMsg = ressix10265.ErrMsg
  25347. res2.Cainfo = ressix10265.Cainfo
  25348. res2.WarnMsg = ressix10265.WarnMsg
  25349. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25350. res2.Infcode = infocode
  25351. } else {
  25352. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25353. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25354. utils.ErrorLog("解析失败:%v", err)
  25355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25356. return
  25357. }
  25358. res2.Infcode = res3.Infcode
  25359. } else {
  25360. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25361. utils.ErrorLog("解析失败:%v", err)
  25362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25363. return
  25364. }
  25365. }
  25366. }
  25367. }
  25368. if res2.Infcode == -1 {
  25369. adminUser := c.GetAdminUserInfo()
  25370. errlog := &models.HisOrderError{
  25371. UserOrgId: adminUser.CurrentOrgId,
  25372. Ctime: time.Now().Unix(),
  25373. Mtime: time.Now().Unix(),
  25374. ErrMsg: res2.ErrMsg,
  25375. Status: 1,
  25376. PatientId: id,
  25377. RecordTime: recordDateTime,
  25378. Stage: 3,
  25379. }
  25380. service.CreateErrMsgLog(errlog)
  25381. c.ServeSuccessJSON(map[string]interface{}{
  25382. "failed_code": -10,
  25383. "msg": res2.ErrMsg,
  25384. })
  25385. return
  25386. } else {
  25387. his.Diagnosis = diagnosis_id
  25388. his.SickType = sickConfig.ID
  25389. //var p_type int64
  25390. //if reg_type == 1111 || reg_type == 1112 {
  25391. // p_type = 11
  25392. //
  25393. //}
  25394. his.PType = fmt.Sprintf("%d", reg_type)
  25395. service.UpdateHisPatientThree(&his)
  25396. data := make(map[string]interface{})
  25397. if settle_accounts_type == 1 { //日结
  25398. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25399. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25400. } else {
  25401. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25402. }
  25403. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25404. data["pre"] = prescriptions
  25405. } else { //月结
  25406. start_time_str := c.GetString("start_time")
  25407. end_time_str := c.GetString("end_time")
  25408. timeLayout := "2006-01-02"
  25409. loc, _ := time.LoadLocation("Local")
  25410. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25411. if err != nil {
  25412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25413. return
  25414. }
  25415. recordStartTime := theStartTime.Unix()
  25416. start_time = recordStartTime
  25417. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25418. if err != nil {
  25419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25420. return
  25421. }
  25422. recordEndTime := theEndTime.Unix()
  25423. end_time = recordEndTime
  25424. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25425. data["pre"] = prescriptions
  25426. }
  25427. timestamp := time.Now().Unix()
  25428. tempTime := time.Unix(timestamp, 0)
  25429. timeFormat := tempTime.Format("20060102150405")
  25430. chrgBchno := rand.Intn(100000) + 10000
  25431. new_chrg_bchno := ""
  25432. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25433. new_chrg_bchno = chrg_bchno
  25434. strconv.FormatInt(his.PatientId, 10)
  25435. client := &http.Client{}
  25436. if adminUser.CurrentOrgId == 10265 {
  25437. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25438. new_chrg_bchno = "0000"
  25439. }
  25440. }
  25441. data["psn_no"] = his.PsnNo
  25442. data["mdtrt_id"] = his.Number
  25443. data["chrg_bchno"] = new_chrg_bchno
  25444. data["org_name"] = miConfig.OrgName
  25445. data["doctor"] = doctor_info.UserName
  25446. data["doctor_id"] = doctor_info.DoctorNumber
  25447. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25448. data["fixmedins_code"] = miConfig.Code
  25449. data["dept_code"] = department.Number
  25450. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25451. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25452. data["secret_key"] = miConfig.SecretKey
  25453. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25454. data["url"] = miConfig.Url
  25455. data["ak"] = miConfig.AccessKey
  25456. data["new_doctor_name"] = patientPrescription.Doctor
  25457. data["diag_code"] = sickConfig.CountryCode
  25458. data["cainfo"] = miConfig.Cainfo
  25459. data["opter"] = roles.UserName
  25460. var ids []int64
  25461. for _, item := range prescriptions {
  25462. ids = append(ids, item.ID)
  25463. }
  25464. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25465. if config.IsOpen == 1 { //对接了医保,走医保流程
  25466. var res ResultFour
  25467. var resFour10265 ResultFour10265
  25468. if miConfig.MdtrtareaAdmvs == "421300" {
  25469. bytesData, _ := json.Marshal(data)
  25470. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25471. resp, _ := client.Do(req)
  25472. defer resp.Body.Close()
  25473. body, ioErr := ioutil.ReadAll(resp.Body)
  25474. if ioErr != nil {
  25475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25477. return
  25478. }
  25479. var respJSON map[string]interface{}
  25480. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25483. return
  25484. }
  25485. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25486. userJSONBytes, _ := json.Marshal(respJSON)
  25487. fmt.Println("log")
  25488. fmt.Println(string(userJSONBytes))
  25489. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25490. utils.ErrorLog("解析失败:%v", err)
  25491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25492. return
  25493. }
  25494. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25495. bytesData, _ := json.Marshal(data)
  25496. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25497. resp, _ := client.Do(req)
  25498. defer resp.Body.Close()
  25499. body, ioErr := ioutil.ReadAll(resp.Body)
  25500. if ioErr != nil {
  25501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25503. return
  25504. }
  25505. var respJSON map[string]interface{}
  25506. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25509. return
  25510. }
  25511. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25512. userJSONBytes, _ := json.Marshal(respJSON)
  25513. fmt.Println("log")
  25514. fmt.Println(string(userJSONBytes))
  25515. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25516. utils.ErrorLog("解析失败:%v", err)
  25517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25518. return
  25519. }
  25520. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25521. bytesData, _ := json.Marshal(data)
  25522. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25523. resp, _ := client.Do(req)
  25524. defer resp.Body.Close()
  25525. body, ioErr := ioutil.ReadAll(resp.Body)
  25526. if ioErr != nil {
  25527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25529. return
  25530. }
  25531. var respJSON map[string]interface{}
  25532. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25535. return
  25536. }
  25537. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25538. userJSONBytes, _ := json.Marshal(respJSON)
  25539. fmt.Println("log")
  25540. fmt.Println(string(userJSONBytes))
  25541. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25542. utils.ErrorLog("解析失败:%v", err)
  25543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25544. return
  25545. }
  25546. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25547. bytesData, _ := json.Marshal(data)
  25548. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25549. resp, _ := client.Do(req)
  25550. defer resp.Body.Close()
  25551. body, ioErr := ioutil.ReadAll(resp.Body)
  25552. if ioErr != nil {
  25553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25555. return
  25556. }
  25557. var respJSON map[string]interface{}
  25558. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25561. return
  25562. }
  25563. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25564. userJSONBytes, _ := json.Marshal(respJSON)
  25565. fmt.Println("log")
  25566. fmt.Println(string(userJSONBytes))
  25567. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25568. utils.ErrorLog("解析失败:%v", err)
  25569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25570. return
  25571. }
  25572. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25573. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25574. if result3101.Infcode == "0" {
  25575. if len(result3101.Output.Result) > 0 {
  25576. var errMsgs []string
  25577. for _, item := range result3101.Output.Result {
  25578. errMsgs = append(errMsgs, item.VolaCont)
  25579. }
  25580. c.ServeSuccessJSON(map[string]interface{}{
  25581. "failed_code": -10,
  25582. "msg": errMsgs,
  25583. })
  25584. return
  25585. }
  25586. }
  25587. bytesData, _ := json.Marshal(data)
  25588. var req *http.Request
  25589. if miConfig.MdtrtareaAdmvs == "320921" {
  25590. data["diag_code"] = sickConfig.CountryCode
  25591. fmt.Println(data)
  25592. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25593. } else {
  25594. data["diag_code"] = sickConfig.CountryCode
  25595. fmt.Println(data)
  25596. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25597. }
  25598. resp, _ := client.Do(req)
  25599. defer resp.Body.Close()
  25600. body, ioErr := ioutil.ReadAll(resp.Body)
  25601. if ioErr != nil {
  25602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25604. return
  25605. }
  25606. var respJSON map[string]interface{}
  25607. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25610. return
  25611. }
  25612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25613. userJSONBytes, _ := json.Marshal(respJSON)
  25614. fmt.Println("log")
  25615. fmt.Println(string(userJSONBytes))
  25616. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25617. utils.ErrorLog("解析失败:%v", err)
  25618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25619. return
  25620. }
  25621. res.InfRefmsgid = resFour10265.InfRefmsgid
  25622. res.Output = resFour10265.Output
  25623. res.ErrMsg = resFour10265.ErrMsg
  25624. res.Cainfo = resFour10265.Cainfo
  25625. res.WarnMsg = resFour10265.WarnMsg
  25626. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25627. res.Infcode = infocode
  25628. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25629. var pagesize int = 2
  25630. var start int = 1
  25631. var stop int
  25632. var pagecount int
  25633. var curpage int
  25634. var isSuccess bool = true
  25635. data["doctor_id"] = doctor_info.DoctorNumber
  25636. //总页数,向上取整,注意除之前要先转换类型为float64
  25637. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25638. for curpage = 1; curpage <= pagecount; curpage++ {
  25639. if curpage == 1 {
  25640. start = 1
  25641. } else {
  25642. start = (curpage-1)*pagesize + 1
  25643. }
  25644. stop = curpage * pagesize
  25645. if stop > len(prescriptions) {
  25646. stop = len(prescriptions)
  25647. }
  25648. //var requestLog string
  25649. data["pre"] = prescriptions[start-1 : stop]
  25650. fmt.Println(data["pre"])
  25651. bytesData, _ := json.Marshal(data)
  25652. var req *http.Request
  25653. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25654. resp, _ := client.Do(req)
  25655. defer resp.Body.Close()
  25656. body, ioErr := ioutil.ReadAll(resp.Body)
  25657. if ioErr != nil {
  25658. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25660. return
  25661. }
  25662. var respJSON map[string]interface{}
  25663. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25664. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25666. return
  25667. }
  25668. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25669. userJSONBytes, _ := json.Marshal(respJSON)
  25670. fmt.Println("log")
  25671. fmt.Println(string(userJSONBytes))
  25672. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25673. utils.ErrorLog("解析失败:%v", err)
  25674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25675. return
  25676. }
  25677. res.InfRefmsgid = resFour10265.InfRefmsgid
  25678. res.Output = resFour10265.Output
  25679. res.ErrMsg = resFour10265.ErrMsg
  25680. res.Cainfo = resFour10265.Cainfo
  25681. res.WarnMsg = resFour10265.WarnMsg
  25682. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25683. res.Infcode = infocode
  25684. if infocode == 0 {
  25685. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25686. } else {
  25687. isSuccess = false
  25688. errlog := &models.HisOrderError{
  25689. UserOrgId: adminUser.CurrentOrgId,
  25690. Ctime: time.Now().Unix(),
  25691. Mtime: time.Now().Unix(),
  25692. Number: chrg_bchno,
  25693. ErrMsg: "",
  25694. Status: 1,
  25695. PatientId: id,
  25696. RecordTime: recordDateTime,
  25697. Stage: 4,
  25698. }
  25699. service.CreateErrMsgLog(errlog)
  25700. c.ServeSuccessJSON(map[string]interface{}{
  25701. "failed_code": -10,
  25702. "msg": res.ErrMsg,
  25703. })
  25704. return
  25705. }
  25706. }
  25707. if isSuccess {
  25708. res.Infcode = 0
  25709. }
  25710. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25711. 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)
  25712. var dat map[string]interface{}
  25713. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25714. fmt.Println(dat)
  25715. } else {
  25716. fmt.Println(err)
  25717. }
  25718. saveLog(result, request_log, "2204", "上传费用明细")
  25719. userJSONBytes, _ := json.Marshal(dat)
  25720. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25721. utils.ErrorLog("解析失败:%v", err)
  25722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25723. return
  25724. }
  25725. res.InfRefmsgid = resFour10265.InfRefmsgid
  25726. res.Output = resFour10265.Output
  25727. res.ErrMsg = resFour10265.ErrMsg
  25728. res.Cainfo = resFour10265.Cainfo
  25729. res.WarnMsg = resFour10265.WarnMsg
  25730. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25731. res.Infcode = infocode
  25732. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25733. bytesData, _ := json.Marshal(data)
  25734. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25735. resp, _ := client.Do(req)
  25736. defer resp.Body.Close()
  25737. body, ioErr := ioutil.ReadAll(resp.Body)
  25738. if ioErr != nil {
  25739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25741. return
  25742. }
  25743. var respJSON map[string]interface{}
  25744. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25747. return
  25748. }
  25749. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25750. userJSONBytes, _ := json.Marshal(respJSON)
  25751. fmt.Println("log")
  25752. fmt.Println(string(userJSONBytes))
  25753. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25754. utils.ErrorLog("解析失败:%v", err)
  25755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25756. return
  25757. }
  25758. } else {
  25759. if miConfig.Code == "H15049901371" {
  25760. 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)
  25761. var dat map[string]interface{}
  25762. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25763. fmt.Println(dat)
  25764. } else {
  25765. fmt.Println(err)
  25766. }
  25767. saveLog(result, request_log, "2204", "上传费用明细")
  25768. userJSONBytes, _ := json.Marshal(dat)
  25769. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25770. utils.ErrorLog("解析失败:%v", err)
  25771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25772. return
  25773. }
  25774. res.InfRefmsgid = resFour10265.InfRefmsgid
  25775. res.Output = resFour10265.Output
  25776. res.ErrMsg = resFour10265.ErrMsg
  25777. res.Cainfo = resFour10265.Cainfo
  25778. res.WarnMsg = resFour10265.WarnMsg
  25779. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25780. res.Infcode = infocode
  25781. } else {
  25782. 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)
  25783. var dat map[string]interface{}
  25784. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25785. fmt.Println(dat)
  25786. } else {
  25787. fmt.Println(err)
  25788. }
  25789. saveLog(result, request_log, "2204", "上传费用明细")
  25790. userJSONBytes, _ := json.Marshal(dat)
  25791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25792. utils.ErrorLog("解析失败:%v", err)
  25793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25794. return
  25795. }
  25796. }
  25797. }
  25798. if res.Infcode == 0 {
  25799. order := &models.HisOrder{
  25800. UserOrgId: adminUser.CurrentOrgId,
  25801. HisPatientId: his.ID,
  25802. PatientId: his.PatientId,
  25803. SettleAccountsDate: recordDateTime,
  25804. MdtrtId: his.Number,
  25805. PsnNo: his.PsnNo,
  25806. MedType: strconv.FormatInt(reg_type, 10),
  25807. Ctime: time.Now().Unix(),
  25808. Mtime: time.Now().Unix(),
  25809. Status: 1,
  25810. Number: chrg_bchno,
  25811. Infcode: res.Infcode,
  25812. WarnMsg: res.WarnMsg,
  25813. Cainfo: res.Cainfo,
  25814. ErrMsg: res.ErrMsg,
  25815. RespondTime: res.RefmsgTime,
  25816. InfRefmsgid: res.InfRefmsgid,
  25817. OrderStatus: 1,
  25818. PayWay: pay_way,
  25819. PayWays: pay_ways,
  25820. OthDesc: oth_desc,
  25821. PayPrice: pay_price,
  25822. PayCardNo: pay_card_no,
  25823. DiscountPrice: discount_price,
  25824. PreferentialPrice: preferential_price,
  25825. RealityPrice: reality_price,
  25826. FoundPrice: found_price,
  25827. MedicalInsurancePrice: medical_insurance_price,
  25828. PrivatePrice: private_price,
  25829. IsMedicineInsurance: 1,
  25830. SettleType: settle_accounts_type,
  25831. SettleStartTime: start_time,
  25832. SettleEndTime: end_time,
  25833. Creator: roles.AdminUserId,
  25834. Modify: roles.AdminUserId,
  25835. FaPiaoNumber: fapiao_number,
  25836. FaPiaoCode: fapiao_code,
  25837. PType: 2,
  25838. Diagnosis: diagnosis_id,
  25839. CashPay: cash_pay,
  25840. WechatPay: wechat_pay,
  25841. AliPay: ali_pay,
  25842. JifenPay: jifen_pay,
  25843. BandCardPay: band_card_pay,
  25844. }
  25845. err = service.CreateOrder(order)
  25846. if err != nil {
  25847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25848. return
  25849. }
  25850. for _, item := range res.Output.Result {
  25851. temp := strings.Split(item.FeedetlSn, "-")
  25852. var advice_id int64 = 0
  25853. var project_id int64 = 0
  25854. var types int64 = 0
  25855. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25856. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25857. if temp[1] == "1" {
  25858. advice_id = id
  25859. project_id = 0
  25860. } else if temp[1] == "2" {
  25861. advice_id = 0
  25862. project_id = id
  25863. }
  25864. if item.MedChrgitmType == "9" {
  25865. item.MedChrgitmType = "09"
  25866. }
  25867. info := &models.HisOrderInfo{
  25868. OrderNumber: order.Number,
  25869. FeedetlSn: item.FeedetlSn,
  25870. UploadDate: time.Now().Unix(),
  25871. AdviceId: advice_id,
  25872. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25873. Cnt: item.Cnt,
  25874. Pric: float64(item.Pric),
  25875. PatientId: his.PatientId,
  25876. PricUplmtAmt: item.PricUplmtAmt,
  25877. SelfpayProp: item.SelfpayProp,
  25878. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25879. OverlmtAmt: item.OverlmtAmt,
  25880. PreselfpayAmt: item.PreselfpayAmt,
  25881. BasMednFlag: item.BasMednFlag,
  25882. MedChrgitmType: item.MedChrgitmType,
  25883. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25884. Status: 1,
  25885. Memo: item.Memo,
  25886. Mtime: time.Now().Unix(),
  25887. InscpScpAmt: item.InscpScpAmt,
  25888. DrtReimFlag: item.DrtReimFlag,
  25889. Ctime: time.Now().Unix(),
  25890. ListSpItemFlag: item.ListSpItemFlag,
  25891. ChldMedcFlag: item.ChldMedcFlag,
  25892. LmtUsedFlag: item.LmtUsedFlag,
  25893. ChrgitmLv: item.ChrgitmLv,
  25894. UserOrgId: adminUser.CurrentOrgId,
  25895. HisPatientId: his.ID,
  25896. OrderId: order.ID,
  25897. ProjectId: project_id,
  25898. Type: types,
  25899. }
  25900. service.CreateOrderInfo(info)
  25901. }
  25902. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25903. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25904. var total float64
  25905. for _, item := range prescriptions {
  25906. if item.Type == 1 { //药品
  25907. for _, subItem := range item.HisDoctorAdviceInfo {
  25908. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25909. total_one := price * subItem.PrescribingNumber
  25910. total = total + total_one
  25911. }
  25912. }
  25913. if item.Type == 2 { //项目
  25914. for _, subItem := range item.HisPrescriptionProject {
  25915. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25916. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25917. total_one := price * cnt
  25918. total = total + total_one
  25919. }
  25920. }
  25921. }
  25922. allTotal := fmt.Sprintf("%.2f", total)
  25923. //if adminUser.CurrentOrgId == 9919 {
  25924. //
  25925. // allTotal = fmt.Sprintf("%.2f", total)
  25926. //
  25927. //} else {
  25928. //
  25929. // allTotal = fmt.Sprintf("%.2f", total)
  25930. //
  25931. //}
  25932. if res.Infcode == 0 {
  25933. var rf []*ResultFive
  25934. json.Unmarshal([]byte(his.Iinfo), &rf)
  25935. chrg_bchno := chrg_bchno
  25936. cert_no := his.Certno
  25937. var insutypes []string
  25938. var insutype string
  25939. var is390 int = 0
  25940. var is310 int = 0
  25941. for _, item := range rf {
  25942. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25943. insutypes = append(insutypes, item.Insutype)
  25944. }
  25945. }
  25946. if len(insutypes) == 1 {
  25947. insutype = insutypes[0]
  25948. } else {
  25949. for _, i := range insutypes {
  25950. if i == "390" {
  25951. is390 = 1
  25952. }
  25953. if i == "310" {
  25954. is310 = 1
  25955. }
  25956. }
  25957. }
  25958. if is390 == 1 {
  25959. insutype = "390"
  25960. }
  25961. if is310 == 1 {
  25962. insutype = "310"
  25963. }
  25964. if len(insutypes) == 0 {
  25965. insutype = "310"
  25966. }
  25967. if len(insutypes) == 2 {
  25968. insutype = strconv.FormatInt(his.SocialType, 10)
  25969. }
  25970. insutype = strconv.FormatInt(his.SocialType, 10)
  25971. //insutype = "390"
  25972. if his.IdCardType == 1 {
  25973. // cert_no = his.MedicalInsuranceNumber
  25974. cert_no = his.Certno
  25975. } else {
  25976. cert_no = his.Certno
  25977. }
  25978. var res ResultSeven
  25979. var resSeven10265 ResultSeven10265
  25980. var gzresSeven10265Two GZResultSeven10265Two
  25981. var src_resquest string
  25982. var result2 string
  25983. if miConfig.MdtrtareaAdmvs == "421300" {
  25984. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25985. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25986. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25987. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25988. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25989. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25990. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25991. resp, requestErr := http.Get(api)
  25992. if requestErr != nil {
  25993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25994. return
  25995. }
  25996. body, ioErr := ioutil.ReadAll(resp.Body)
  25997. if ioErr != nil {
  25998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26000. return
  26001. }
  26002. var respJSON map[string]interface{}
  26003. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26006. return
  26007. }
  26008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26009. result, _ := json.Marshal(respJSON)
  26010. if miConfig.Code == "H15049901371" {
  26011. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26012. utils.ErrorLog("解析失败:%v", err)
  26013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26014. return
  26015. }
  26016. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26017. res.Output = resSeven10265.Output
  26018. res.ErrMsg = resSeven10265.ErrMsg
  26019. res.Cainfo = resSeven10265.Cainfo
  26020. res.WarnMsg = resSeven10265.WarnMsg
  26021. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26022. res.Infcode = infocode
  26023. } else {
  26024. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26025. utils.ErrorLog("解析失败:%v", err)
  26026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26027. return
  26028. }
  26029. }
  26030. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26031. if reg_type == 11 && his.Insutype == "390" {
  26032. reg_type = 110104
  26033. }
  26034. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26035. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26036. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26037. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26038. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26039. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26040. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26041. resp, requestErr := http.Get(api)
  26042. if requestErr != nil {
  26043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26044. return
  26045. }
  26046. body, ioErr := ioutil.ReadAll(resp.Body)
  26047. if ioErr != nil {
  26048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26050. return
  26051. }
  26052. var respJSON map[string]interface{}
  26053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26056. return
  26057. }
  26058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26059. result, _ := json.Marshal(respJSON)
  26060. if miConfig.Code == "H15049901371" {
  26061. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26062. utils.ErrorLog("解析失败:%v", err)
  26063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26064. return
  26065. }
  26066. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26067. res.Output = resSeven10265.Output
  26068. res.ErrMsg = resSeven10265.ErrMsg
  26069. res.Cainfo = resSeven10265.Cainfo
  26070. res.WarnMsg = resSeven10265.WarnMsg
  26071. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26072. res.Infcode = infocode
  26073. } else {
  26074. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26075. utils.ErrorLog("解析失败:%v", err)
  26076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26077. return
  26078. }
  26079. }
  26080. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26081. if reg_type == 11 && his.Insutype == "390" {
  26082. reg_type = 110104
  26083. }
  26084. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26085. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26086. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26087. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26088. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26089. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26090. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26091. resp, requestErr := http.Get(api)
  26092. if requestErr != nil {
  26093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26094. return
  26095. }
  26096. body, ioErr := ioutil.ReadAll(resp.Body)
  26097. if ioErr != nil {
  26098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26100. return
  26101. }
  26102. var respJSON map[string]interface{}
  26103. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26106. return
  26107. }
  26108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26109. result, _ := json.Marshal(respJSON)
  26110. if miConfig.Code == "H15049901371" {
  26111. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26112. utils.ErrorLog("解析失败:%v", err)
  26113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26114. return
  26115. }
  26116. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26117. res.Output = resSeven10265.Output
  26118. res.ErrMsg = resSeven10265.ErrMsg
  26119. res.Cainfo = resSeven10265.Cainfo
  26120. res.WarnMsg = resSeven10265.WarnMsg
  26121. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26122. res.Infcode = infocode
  26123. } else {
  26124. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26125. utils.ErrorLog("解析失败:%v", err)
  26126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26127. return
  26128. }
  26129. }
  26130. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26131. if reg_type == 11 && his.Insutype == "390" {
  26132. reg_type = 110104
  26133. }
  26134. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26135. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26136. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26137. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26138. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26139. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26140. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26141. resp, requestErr := http.Get(api)
  26142. if requestErr != nil {
  26143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26144. return
  26145. }
  26146. body, ioErr := ioutil.ReadAll(resp.Body)
  26147. if ioErr != nil {
  26148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26150. return
  26151. }
  26152. var respJSON map[string]interface{}
  26153. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26156. return
  26157. }
  26158. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26159. result, _ := json.Marshal(respJSON)
  26160. if miConfig.Code == "H15049901371" {
  26161. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26162. utils.ErrorLog("解析失败:%v", err)
  26163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26164. return
  26165. }
  26166. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26167. res.Output = resSeven10265.Output
  26168. res.ErrMsg = resSeven10265.ErrMsg
  26169. res.Cainfo = resSeven10265.Cainfo
  26170. res.WarnMsg = resSeven10265.WarnMsg
  26171. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26172. res.Infcode = infocode
  26173. } else {
  26174. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26175. utils.ErrorLog("解析失败:%v", err)
  26176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26177. return
  26178. }
  26179. }
  26180. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26181. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26182. if result3101.Infcode == "0" {
  26183. if len(result3101.Output.Result) > 0 {
  26184. var errMsgs []string
  26185. for _, item := range result3101.Output.Result {
  26186. errMsgs = append(errMsgs, item.VolaCont)
  26187. }
  26188. c.ServeSuccessJSON(map[string]interface{}{
  26189. "failed_code": -10,
  26190. "msg": errMsgs,
  26191. })
  26192. return
  26193. } else {
  26194. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26195. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26196. bas := strings.Split(psn_info.CardInfo, "|")
  26197. if his.IdCardType == 1 {
  26198. cert_no = bas[2]
  26199. } else if his.IdCardType == 3 {
  26200. cert_no = his.Certno
  26201. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26202. } else if his.IdCardType == 4 {
  26203. cert_no = his.Certno
  26204. psn_info.VerifyNumber = psn_info.VerifyNumber
  26205. }
  26206. var api string
  26207. if miConfig.MdtrtareaAdmvs == "320921" {
  26208. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26209. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26210. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26211. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26212. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26213. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26214. "&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
  26215. } else {
  26216. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26217. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26218. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26219. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26220. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26221. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26222. "&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
  26223. }
  26224. resp, requestErr := http.Get(api)
  26225. if requestErr != nil {
  26226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26227. return
  26228. }
  26229. body, ioErr := ioutil.ReadAll(resp.Body)
  26230. if ioErr != nil {
  26231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26233. return
  26234. }
  26235. var respJSON map[string]interface{}
  26236. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26239. return
  26240. }
  26241. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26242. result, _ := json.Marshal(respJSON)
  26243. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26244. utils.ErrorLog("解析失败:%v", err)
  26245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26246. return
  26247. }
  26248. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26249. res.Output = resSeven10265.Output
  26250. res.ErrMsg = resSeven10265.ErrMsg
  26251. res.Cainfo = resSeven10265.Cainfo
  26252. res.WarnMsg = resSeven10265.WarnMsg
  26253. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26254. res.Infcode = infocode
  26255. }
  26256. }
  26257. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26258. psn_info, _ := service.GetPsnByPatientId(id)
  26259. var verify_number string
  26260. if psn_info.IdCardType == 4 {
  26261. verify_number = psn_info.VerifyNumber
  26262. } else if psn_info.IdCardType == 1 {
  26263. bas := strings.Split(psn_info.CardInfo, "|")
  26264. cardNumber := bas[2]
  26265. verify_number = cardNumber
  26266. } else {
  26267. psn_info.IdCardType = 2
  26268. verify_number = psn_info.Certno
  26269. }
  26270. var api string
  26271. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26272. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26273. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26274. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26275. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26276. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26277. "&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
  26278. resp, requestErr := http.Get(api)
  26279. if requestErr != nil {
  26280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26281. return
  26282. }
  26283. body, ioErr := ioutil.ReadAll(resp.Body)
  26284. if ioErr != nil {
  26285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26287. return
  26288. }
  26289. var respJSON map[string]interface{}
  26290. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26293. return
  26294. }
  26295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26296. result, _ := json.Marshal(respJSON)
  26297. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26298. utils.ErrorLog("解析失败:%v", err)
  26299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26300. return
  26301. }
  26302. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26303. res.Output = resSeven10265.Output
  26304. res.ErrMsg = resSeven10265.ErrMsg
  26305. res.Cainfo = resSeven10265.Cainfo
  26306. res.WarnMsg = resSeven10265.WarnMsg
  26307. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26308. res.Infcode = infocode
  26309. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26310. var cert_no string
  26311. if his.IdCardType == 4 {
  26312. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26313. cert_no = psn_info.VerifyNumber
  26314. 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)
  26315. } else if his.IdCardType == 1 {
  26316. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26317. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26318. 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)
  26319. }
  26320. //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)
  26321. var dat map[string]interface{}
  26322. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26323. fmt.Println(dat)
  26324. } else {
  26325. fmt.Println(err)
  26326. }
  26327. saveLog(result2, src_resquest, "2207", "结算")
  26328. userJSONBytes, _ := json.Marshal(dat)
  26329. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26330. utils.ErrorLog("解析失败:%v", err)
  26331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26332. return
  26333. }
  26334. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26335. res.Output = resSeven10265.Output
  26336. res.ErrMsg = resSeven10265.ErrMsg
  26337. res.Cainfo = resSeven10265.Cainfo
  26338. res.WarnMsg = resSeven10265.WarnMsg
  26339. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26340. res.Infcode = infocode
  26341. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26342. res2 := c.GetoleInfo()
  26343. if res2.Infcode == 0 {
  26344. var result string
  26345. var request_log string
  26346. var result_log string
  26347. if res2.Output.MdtrtCertType == "02" {
  26348. 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)
  26349. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26350. } else if res2.Output.MdtrtCertType == "01" {
  26351. 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)
  26352. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26353. } else {
  26354. 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)
  26355. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26356. }
  26357. var dat map[string]interface{}
  26358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26359. fmt.Println(dat)
  26360. } else {
  26361. fmt.Println(err)
  26362. }
  26363. userJSONBytes, _ := json.Marshal(dat)
  26364. var res5 ResultTwo
  26365. //var resTwo10265 ResultTwo10265
  26366. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26367. utils.ErrorLog("解析失败:%v", err)
  26368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26369. return
  26370. }
  26371. if res5.Infcode == -1 {
  26372. c.ServeSuccessJSON(map[string]interface{}{
  26373. "failed_code": -10,
  26374. "msg": res5.ErrMsg,
  26375. })
  26376. return
  26377. }
  26378. var insutypes []string
  26379. var insutype string
  26380. var is390 int = 0
  26381. var is310 int = 0
  26382. for _, item := range res5.Output.Iinfo {
  26383. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26384. insutypes = append(insutypes, item.Insutype)
  26385. }
  26386. }
  26387. if len(insutypes) == 1 {
  26388. insutype = insutypes[0]
  26389. } else {
  26390. for _, i := range insutypes {
  26391. if i == "390" {
  26392. is390 = 1
  26393. }
  26394. if i == "310" {
  26395. is310 = 1
  26396. }
  26397. }
  26398. }
  26399. if is390 == 1 {
  26400. insutype = "390"
  26401. }
  26402. if is310 == 1 {
  26403. insutype = "310"
  26404. }
  26405. if len(insutypes) == 0 {
  26406. insutype = "310"
  26407. }
  26408. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26409. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26410. infoStr := string(Iinfos)
  26411. idetinfoStr := string(Idetinfos)
  26412. psn := &models.HisPsn{
  26413. PsnNo: res5.Output.Baseinfo.PsnNo,
  26414. PatientId: id,
  26415. Certno: res5.Output.Baseinfo.Certno,
  26416. Gend: res5.Output.Baseinfo.Gend,
  26417. Naty: res5.Output.Baseinfo.Naty,
  26418. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26419. PsnName: res5.Output.Baseinfo.PsnName,
  26420. Idetinfo: idetinfoStr,
  26421. Insuinfo: infoStr,
  26422. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26423. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26424. VerifyNumber: res2.Output.EcToken,
  26425. }
  26426. if res2.Output.MdtrtCertType == "01" {
  26427. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26428. psn.VerifyNumber = res2.Output.EcToken
  26429. } else if res2.Output.MdtrtCertType == "02" {
  26430. psn.VerifyNumber = res2.Output.CardNo
  26431. } else {
  26432. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26433. }
  26434. service.CreateHisPsn(psn)
  26435. if res2.Output.MdtrtCertType == "01" {
  26436. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26437. token := res2.Output.EcToken
  26438. 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, 4, acct_used_flag, token, admin_user_id)
  26439. } else if res2.Output.MdtrtCertType == "02" {
  26440. 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, 2, acct_used_flag, "", admin_user_id)
  26441. } else {
  26442. 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, 1, acct_used_flag, "", admin_user_id)
  26443. }
  26444. var dat2 map[string]interface{}
  26445. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26446. fmt.Println(dat2)
  26447. } else {
  26448. fmt.Println(err)
  26449. }
  26450. userJSONBytes3, _ := json.Marshal(dat2)
  26451. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26452. utils.ErrorLog("解析失败:%v", err)
  26453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26454. return
  26455. }
  26456. saveLog(result2, src_resquest, "2207", "结算")
  26457. } else {
  26458. c.ServeSuccessJSON(map[string]interface{}{
  26459. "failed_code": -10,
  26460. "msg": res2.ErrMsg,
  26461. })
  26462. return
  26463. }
  26464. } else {
  26465. if miConfig.Code == "H15049901371" {
  26466. //赤峰地区国家医保医疗类别
  26467. //职工透析:医疗类别选特殊情况门诊990502
  26468. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26469. var med_type string
  26470. if his.Insutype == "390" {
  26471. if reg_type == 14 {
  26472. med_type = "9933"
  26473. } else if reg_type == 11 {
  26474. med_type = "11"
  26475. }
  26476. } else if his.Insutype == "310" {
  26477. if reg_type == 14 {
  26478. med_type = "990502"
  26479. } else if reg_type == 11 {
  26480. med_type = "11"
  26481. }
  26482. }
  26483. 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)
  26484. } else {
  26485. if his.IdCardType == 4 {
  26486. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26487. var token string
  26488. token = psn_info.VerifyNumber
  26489. 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)
  26490. } else {
  26491. if his.IdCardType == 1 {
  26492. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26493. bas := strings.Split(psn_info.CardInfo, "|")
  26494. basNumber := bas[2]
  26495. cert_no = basNumber
  26496. }
  26497. 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)
  26498. }
  26499. }
  26500. //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)
  26501. var dat map[string]interface{}
  26502. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26503. fmt.Println(dat)
  26504. } else {
  26505. fmt.Println(err)
  26506. }
  26507. saveLog(result2, src_resquest, "2207", "结算")
  26508. userJSONBytes, _ := json.Marshal(dat)
  26509. if miConfig.Code == "H15049901371" {
  26510. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26511. utils.ErrorLog("解析失败:%v", err)
  26512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26513. return
  26514. }
  26515. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26516. res.Output = resSeven10265.Output
  26517. res.ErrMsg = resSeven10265.ErrMsg
  26518. res.Cainfo = resSeven10265.Cainfo
  26519. res.WarnMsg = resSeven10265.WarnMsg
  26520. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26521. res.Infcode = infocode
  26522. } else {
  26523. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26524. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26525. utils.ErrorLog("解析失败:%v", err)
  26526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26527. return
  26528. }
  26529. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26530. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26531. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26532. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26533. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26534. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26535. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26536. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26537. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26538. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26539. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26540. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26541. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26542. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26543. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26544. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26545. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26546. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26547. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26548. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26549. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26550. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26551. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26552. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26553. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26554. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26555. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26556. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26557. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26558. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26559. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26560. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26561. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26562. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26563. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26564. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26565. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26566. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26567. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26568. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26569. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26570. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26571. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26572. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26573. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26574. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26575. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26576. res.Cainfo = gzresSeven10265Two.Cainfo
  26577. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26578. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26579. //res.Infcode = infocode
  26580. } else {
  26581. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26582. utils.ErrorLog("解析失败:%v", err)
  26583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26584. return
  26585. }
  26586. }
  26587. }
  26588. }
  26589. if res.Infcode == -1 {
  26590. errlog := &models.HisOrderError{
  26591. UserOrgId: adminUser.CurrentOrgId,
  26592. Ctime: time.Now().Unix(),
  26593. Mtime: time.Now().Unix(),
  26594. Number: chrg_bchno,
  26595. ErrMsg: res.ErrMsg,
  26596. Status: 1,
  26597. PatientId: id,
  26598. RecordTime: recordDateTime,
  26599. Stage: 6,
  26600. }
  26601. service.CreateErrMsgLog(errlog)
  26602. c.ServeSuccessJSON(map[string]interface{}{
  26603. "failed_code": -10,
  26604. "msg": res.ErrMsg,
  26605. })
  26606. return
  26607. } else {
  26608. sickConfig, _ := service.FindSickById(his.SickType)
  26609. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26610. order.OrderStatus = 2
  26611. order.Status = 1
  26612. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26613. order.SetlId = res.Output.Setlinfo.SetlID
  26614. order.PsnNo = res.Output.Setlinfo.PsnNo
  26615. order.PsnName = res.Output.Setlinfo.PsnName
  26616. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26617. order.Certno = res.Output.Setlinfo.Certno
  26618. order.Gend = res.Output.Setlinfo.Gend
  26619. order.Naty = res.Output.Setlinfo.Naty
  26620. order.Age = res.Output.Setlinfo.Age
  26621. order.Insutype = res.Output.Setlinfo.Insutype
  26622. order.PsnType = res.Output.Setlinfo.PsnType
  26623. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26624. order.SetlTime = res.Output.Setlinfo.SetlTime
  26625. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26626. if res.Output.Setlinfo.MedType == "140101" {
  26627. order.MedType = "14"
  26628. } else {
  26629. if res.Output.Setlinfo.MedType == "110104" {
  26630. order.MedType = "11"
  26631. } else {
  26632. order.MedType = res.Output.Setlinfo.MedType
  26633. }
  26634. }
  26635. if reg_type == 1112 {
  26636. order.MedType = "1112"
  26637. }
  26638. if reg_type == 1111 {
  26639. order.MedType = "1111"
  26640. }
  26641. order.ClrType = res.Output.Setlinfo.ClrType
  26642. if adminUser.CurrentOrgId == 10480 {
  26643. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26644. order.ClrType = "11"
  26645. } else {
  26646. order.ClrType = "9903"
  26647. }
  26648. }
  26649. if adminUser.CurrentOrgId == 10721 {
  26650. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26651. order.ClrType = "11"
  26652. } else {
  26653. order.ClrType = "9903"
  26654. }
  26655. }
  26656. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26657. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26658. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26659. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26660. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26661. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26662. order.HifpPay = res.Output.Setlinfo.HifpPay
  26663. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26664. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26665. order.HifesPay = res.Output.Setlinfo.HifesPay
  26666. order.HifobPay = res.Output.Setlinfo.HifobPay
  26667. order.MafPay = res.Output.Setlinfo.MafPay
  26668. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26669. order.OthPay = res.Output.Setlinfo.OthPay
  26670. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26671. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26672. order.AcctPay = res.Output.Setlinfo.AcctPay
  26673. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26674. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26675. order.Balc = res.Output.Setlinfo.Balc
  26676. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26677. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26678. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26679. //order.ClrType = res.Output.Setlinfo.ClrType
  26680. order.ClrWay = res.Output.Setlinfo.ClrWay
  26681. order.Creator = order.Creator
  26682. order.Modify = roles.AdminUserId
  26683. order.RequestLog = src_resquest
  26684. order.FaPiaoNumber = fapiao_number
  26685. order.FaPiaoCode = fapiao_code
  26686. order.SickName = sickConfig.ClassName
  26687. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26688. //detailStr := string(setlDetail)
  26689. //order.SetlDetail = detailStr
  26690. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26691. err = service.UpDateOrder(order)
  26692. if err == nil {
  26693. //判断是否使用了押金
  26694. if dec_way == "true" {
  26695. tmpstring := strconv.FormatInt(order.ID, 10)
  26696. order.Decimal = decimal
  26697. service.UpDateOrder(order)
  26698. //扣押金
  26699. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26700. if errmsg != nil {
  26701. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26702. return
  26703. }
  26704. }
  26705. c.ServeSuccessJSON(map[string]interface{}{
  26706. "msg": "结算成功",
  26707. })
  26708. } else {
  26709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26710. return
  26711. }
  26712. }
  26713. } else {
  26714. adminUser := c.GetAdminUserInfo()
  26715. errlog := &models.HisOrderError{
  26716. UserOrgId: adminUser.CurrentOrgId,
  26717. Ctime: time.Now().Unix(),
  26718. Mtime: time.Now().Unix(),
  26719. ErrMsg: res.ErrMsg,
  26720. Status: 1,
  26721. PatientId: id,
  26722. RecordTime: recordDateTime,
  26723. Stage: 4,
  26724. }
  26725. service.CreateErrMsgLog(errlog)
  26726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26727. return
  26728. }
  26729. } else {
  26730. adminUser := c.GetAdminUserInfo()
  26731. errlog := &models.HisOrderError{
  26732. UserOrgId: adminUser.CurrentOrgId,
  26733. Ctime: time.Now().Unix(),
  26734. Mtime: time.Now().Unix(),
  26735. ErrMsg: res.ErrMsg,
  26736. Status: 1,
  26737. PatientId: id,
  26738. RecordTime: recordDateTime,
  26739. Stage: 4,
  26740. }
  26741. service.CreateErrMsgLog(errlog)
  26742. c.ServeSuccessJSON(map[string]interface{}{
  26743. "failed_code": -10,
  26744. "msg": res.ErrMsg,
  26745. })
  26746. return
  26747. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26748. //return
  26749. }
  26750. }
  26751. }
  26752. } else if tempOrder.ID > 0 {
  26753. if tempOrder.IsPre == 1 {
  26754. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26755. var rf []*ResultFive
  26756. json.Unmarshal([]byte(his.Iinfo), &rf)
  26757. chrg_bchno := tempOrder.Number
  26758. cert_no := his.Certno
  26759. var insutypes []string
  26760. var insutype string
  26761. var is390 int = 0
  26762. var is310 int = 0
  26763. for _, item := range rf {
  26764. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26765. insutypes = append(insutypes, item.Insutype)
  26766. }
  26767. }
  26768. if len(insutypes) == 1 {
  26769. insutype = insutypes[0]
  26770. } else {
  26771. for _, i := range insutypes {
  26772. if i == "390" {
  26773. is390 = 1
  26774. }
  26775. if i == "310" {
  26776. is310 = 1
  26777. }
  26778. }
  26779. }
  26780. if is390 == 1 {
  26781. insutype = "390"
  26782. }
  26783. if is310 == 1 {
  26784. insutype = "310"
  26785. }
  26786. if len(insutypes) == 0 {
  26787. insutype = "310"
  26788. }
  26789. if len(insutypes) == 2 {
  26790. insutype = strconv.FormatInt(his.SocialType, 10)
  26791. }
  26792. //insutype = "390"
  26793. if his.IdCardType == 1 {
  26794. // cert_no = his.MedicalInsuranceNumber
  26795. cert_no = his.Certno
  26796. } else {
  26797. cert_no = his.Certno
  26798. }
  26799. var res ResultSeven
  26800. var ahres ResultSevenAH
  26801. var resSeven10265 ResultSeven10265
  26802. var gzresSeven10265Two GZResultSeven10265Two
  26803. var src_resquest string
  26804. var result2 string
  26805. if miConfig.MdtrtareaAdmvs == "450721" {
  26806. res2 := c.GetoleInfo()
  26807. if res2.Infcode == 0 {
  26808. var result string
  26809. var request_log string
  26810. var result_log string
  26811. if res2.Output.MdtrtCertType == "02" {
  26812. 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)
  26813. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26814. } else if res2.Output.MdtrtCertType == "01" {
  26815. 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)
  26816. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26817. } else {
  26818. 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)
  26819. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26820. }
  26821. var dat map[string]interface{}
  26822. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26823. fmt.Println(dat)
  26824. } else {
  26825. fmt.Println(err)
  26826. }
  26827. userJSONBytes, _ := json.Marshal(dat)
  26828. var res5 ResultTwo
  26829. //var resTwo10265 ResultTwo10265
  26830. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26831. utils.ErrorLog("解析失败:%v", err)
  26832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26833. return
  26834. }
  26835. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26836. if res5.Infcode == -1 {
  26837. c.ServeSuccessJSON(map[string]interface{}{
  26838. "failed_code": -10,
  26839. "msg": res5.ErrMsg,
  26840. })
  26841. return
  26842. }
  26843. var insutypes []string
  26844. var insutype string
  26845. var is390 int = 0
  26846. var is310 int = 0
  26847. for _, item := range res5.Output.Iinfo {
  26848. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26849. insutypes = append(insutypes, item.Insutype)
  26850. }
  26851. }
  26852. if len(insutypes) == 1 {
  26853. insutype = insutypes[0]
  26854. } else {
  26855. for _, i := range insutypes {
  26856. if i == "390" {
  26857. is390 = 1
  26858. }
  26859. if i == "310" {
  26860. is310 = 1
  26861. }
  26862. }
  26863. }
  26864. if is390 == 1 {
  26865. insutype = "390"
  26866. }
  26867. if is310 == 1 {
  26868. insutype = "310"
  26869. }
  26870. if len(insutypes) == 0 {
  26871. insutype = "310"
  26872. }
  26873. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26874. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26875. infoStr := string(Iinfos)
  26876. idetinfoStr := string(Idetinfos)
  26877. psn := &models.HisPsn{
  26878. PsnNo: res5.Output.Baseinfo.PsnNo,
  26879. PatientId: id,
  26880. Certno: res5.Output.Baseinfo.Certno,
  26881. Gend: res5.Output.Baseinfo.Gend,
  26882. Naty: res5.Output.Baseinfo.Naty,
  26883. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26884. PsnName: res5.Output.Baseinfo.PsnName,
  26885. Idetinfo: idetinfoStr,
  26886. Insuinfo: infoStr,
  26887. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26888. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26889. VerifyNumber: res2.Output.EcToken,
  26890. }
  26891. service.CreateHisPsn(psn)
  26892. if res2.Output.MdtrtCertType == "01" {
  26893. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26894. token := res2.Output.EcToken
  26895. 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)
  26896. } else if res2.Output.MdtrtCertType == "02" {
  26897. 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)
  26898. } else {
  26899. 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)
  26900. }
  26901. var dat2 map[string]interface{}
  26902. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26903. fmt.Println(dat2)
  26904. } else {
  26905. fmt.Println(err)
  26906. }
  26907. userJSONBytes3, _ := json.Marshal(dat2)
  26908. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26909. utils.ErrorLog("解析失败:%v", err)
  26910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26911. return
  26912. }
  26913. saveLog(result2, src_resquest, "2207", "结算")
  26914. } else {
  26915. c.ServeSuccessJSON(map[string]interface{}{
  26916. "failed_code": -10,
  26917. "msg": res2.ErrMsg,
  26918. })
  26919. return
  26920. }
  26921. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26922. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26923. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26924. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26925. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26926. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26927. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26928. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26929. resp, requestErr := http.Get(api)
  26930. if requestErr != nil {
  26931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26932. return
  26933. }
  26934. body, ioErr := ioutil.ReadAll(resp.Body)
  26935. if ioErr != nil {
  26936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26938. return
  26939. }
  26940. var respJSON map[string]interface{}
  26941. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26944. return
  26945. }
  26946. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26947. result, _ := json.Marshal(respJSON)
  26948. fmt.Println("log")
  26949. fmt.Println(string(result))
  26950. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26951. utils.ErrorLog("解析失败:%v", err)
  26952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26953. return
  26954. }
  26955. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26956. if reg_type == 11 && his.Insutype == "390" {
  26957. reg_type = 110104
  26958. }
  26959. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26960. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26961. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26962. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26963. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26964. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26965. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26966. resp, requestErr := http.Get(api)
  26967. if requestErr != nil {
  26968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26969. return
  26970. }
  26971. body, ioErr := ioutil.ReadAll(resp.Body)
  26972. if ioErr != nil {
  26973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26975. return
  26976. }
  26977. var respJSON map[string]interface{}
  26978. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26981. return
  26982. }
  26983. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26984. result, _ := json.Marshal(respJSON)
  26985. fmt.Println("log")
  26986. fmt.Println(string(result))
  26987. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26988. utils.ErrorLog("解析失败:%v", err)
  26989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26990. return
  26991. }
  26992. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26993. if reg_type == 11 && his.Insutype == "390" {
  26994. reg_type = 110104
  26995. }
  26996. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26997. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26998. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26999. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27000. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27001. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27002. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27003. resp, requestErr := http.Get(api)
  27004. if requestErr != nil {
  27005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27006. return
  27007. }
  27008. body, ioErr := ioutil.ReadAll(resp.Body)
  27009. if ioErr != nil {
  27010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27012. return
  27013. }
  27014. var respJSON map[string]interface{}
  27015. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27018. return
  27019. }
  27020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27021. result, _ := json.Marshal(respJSON)
  27022. fmt.Println("log")
  27023. fmt.Println(string(result))
  27024. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27025. utils.ErrorLog("解析失败:%v", err)
  27026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27027. return
  27028. }
  27029. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27030. if reg_type == 11 && his.Insutype == "390" {
  27031. reg_type = 110104
  27032. }
  27033. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27034. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27035. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27036. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27037. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27038. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27039. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27040. resp, requestErr := http.Get(api)
  27041. if requestErr != nil {
  27042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27043. return
  27044. }
  27045. body, ioErr := ioutil.ReadAll(resp.Body)
  27046. if ioErr != nil {
  27047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27049. return
  27050. }
  27051. var respJSON map[string]interface{}
  27052. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27055. return
  27056. }
  27057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27058. result, _ := json.Marshal(respJSON)
  27059. fmt.Println("log")
  27060. fmt.Println(string(result))
  27061. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27062. utils.ErrorLog("解析失败:%v", err)
  27063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27064. return
  27065. }
  27066. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27067. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27068. if result3101.Infcode == "0" {
  27069. if len(result3101.Output.Result) > 0 {
  27070. var errMsgs []string
  27071. for _, item := range result3101.Output.Result {
  27072. errMsgs = append(errMsgs, item.VolaCont)
  27073. }
  27074. c.ServeSuccessJSON(map[string]interface{}{
  27075. "failed_code": -10,
  27076. "msg": errMsgs,
  27077. })
  27078. return
  27079. } else {
  27080. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27081. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27082. bas := strings.Split(psn_info.CardInfo, "|")
  27083. if his.IdCardType == 1 {
  27084. cert_no = bas[2]
  27085. } else if his.IdCardType == 3 {
  27086. cert_no = his.Certno
  27087. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27088. } else if his.IdCardType == 4 {
  27089. cert_no = his.Certno
  27090. psn_info.VerifyNumber = psn_info.VerifyNumber
  27091. }
  27092. //江苏地区国家医保医疗类别
  27093. //职工透析:医疗类别选特殊情况门诊9933
  27094. //居民血透门慢: 医疗类别选门诊慢病1402
  27095. //var med_type string
  27096. //if his.Insutype == "310" {
  27097. // if reg_type == 14 {
  27098. // med_type = "9933"
  27099. // } else if reg_type == 11 {
  27100. // med_type = "11"
  27101. //
  27102. // }
  27103. //} else if his.Insutype == "390" {
  27104. // if reg_type == 14 {
  27105. // med_type = "1402"
  27106. // } else if reg_type == 11 {
  27107. // med_type = "11"
  27108. // }
  27109. //}
  27110. var api string
  27111. if miConfig.MdtrtareaAdmvs == "320921" {
  27112. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27113. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27114. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27115. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27116. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27117. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27118. "&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
  27119. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27120. } else {
  27121. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27122. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27123. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27124. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27125. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27126. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27127. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27128. "&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
  27129. }
  27130. resp, requestErr := http.Get(api)
  27131. if requestErr != nil {
  27132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27133. return
  27134. }
  27135. body, ioErr := ioutil.ReadAll(resp.Body)
  27136. if ioErr != nil {
  27137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27139. return
  27140. }
  27141. var respJSON map[string]interface{}
  27142. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27145. return
  27146. }
  27147. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27148. result, _ := json.Marshal(respJSON)
  27149. fmt.Println("log")
  27150. fmt.Println(string(result))
  27151. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27152. utils.ErrorLog("解析失败:%v", err)
  27153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27154. return
  27155. }
  27156. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27157. res.Output = resSeven10265.Output
  27158. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27159. res.ErrMsg = resSeven10265.ErrMsg
  27160. res.Cainfo = resSeven10265.Cainfo
  27161. res.WarnMsg = resSeven10265.WarnMsg
  27162. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27163. res.Infcode = infocode
  27164. }
  27165. }
  27166. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27167. psn_info, _ := service.GetPsnByPatientId(id)
  27168. var verify_number string
  27169. if psn_info.IdCardType == 4 {
  27170. verify_number = psn_info.VerifyNumber
  27171. } else if psn_info.IdCardType == 1 {
  27172. bas := strings.Split(psn_info.CardInfo, "|")
  27173. cardNumber := bas[2]
  27174. verify_number = cardNumber
  27175. } else {
  27176. verify_number = psn_info.Certno
  27177. psn_info.IdCardType = 2
  27178. }
  27179. var api string
  27180. new_chrg_bchno := chrg_bchno
  27181. if adminUser.CurrentOrgId == 10265 {
  27182. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27183. new_chrg_bchno = "0000"
  27184. }
  27185. }
  27186. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27187. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27188. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27189. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27190. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27191. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27192. "&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
  27193. resp, requestErr := http.Get(api)
  27194. if requestErr != nil {
  27195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27196. return
  27197. }
  27198. body, ioErr := ioutil.ReadAll(resp.Body)
  27199. if ioErr != nil {
  27200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27202. return
  27203. }
  27204. var respJSON map[string]interface{}
  27205. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27208. return
  27209. }
  27210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27211. result, _ := json.Marshal(respJSON)
  27212. fmt.Println("log")
  27213. fmt.Println(string(result))
  27214. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27215. utils.ErrorLog("解析失败:%v", err)
  27216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27217. return
  27218. }
  27219. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27220. res.Output = resSeven10265.Output
  27221. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27222. res.ErrMsg = resSeven10265.ErrMsg
  27223. res.Cainfo = resSeven10265.Cainfo
  27224. res.WarnMsg = resSeven10265.WarnMsg
  27225. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27226. res.Infcode = infocode
  27227. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27228. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27229. var cert_no string
  27230. if his.IdCardType == 1 {
  27231. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27232. } else {
  27233. cert_no = psn_info.VerifyNumber
  27234. }
  27235. 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)
  27236. var dat map[string]interface{}
  27237. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27238. fmt.Println(dat)
  27239. } else {
  27240. fmt.Println(err)
  27241. }
  27242. saveLog(result2, src_resquest, "2207", "结算")
  27243. userJSONBytes, _ := json.Marshal(dat)
  27244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27245. utils.ErrorLog("解析失败:%v", err)
  27246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27247. return
  27248. }
  27249. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27250. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27251. var cert_no string
  27252. var card_sn string
  27253. if his.IdCardType == 1 {
  27254. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27255. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27256. bas := strings.Split(psn_info.CardInfo, "|")
  27257. card_sn = bas[3]
  27258. } else if his.IdCardType == 2 {
  27259. cert_no = his.IdCardNo
  27260. } else {
  27261. cert_no = psn_info.VerifyNumber
  27262. }
  27263. var rf []*ResultFive
  27264. json.Unmarshal([]byte(his.Iinfo), &rf)
  27265. var psn_type string
  27266. for _, item := range rf {
  27267. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27268. psn_type = item.PsnType
  27269. }
  27270. }
  27271. 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)
  27272. var dat map[string]interface{}
  27273. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27274. fmt.Println(dat)
  27275. } else {
  27276. fmt.Println(err)
  27277. }
  27278. saveLog(result2, src_resquest, "2207", "结算")
  27279. userJSONBytes, _ := json.Marshal(dat)
  27280. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27281. utils.ErrorLog("解析失败:%v", err)
  27282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27283. return
  27284. }
  27285. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27286. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27287. var cert_no string
  27288. var card_sn string
  27289. if his.IdCardType == 1 {
  27290. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27291. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27292. //bas := strings.Split(psn_info.CardInfo, "|")
  27293. card_sn = ""
  27294. } else if his.IdCardType == 2 {
  27295. cert_no = his.IdCardNo
  27296. } else {
  27297. cert_no = psn_info.VerifyNumber
  27298. }
  27299. var rf []*ResultFive
  27300. json.Unmarshal([]byte(his.Iinfo), &rf)
  27301. var psn_type string
  27302. for _, item := range rf {
  27303. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27304. psn_type = item.PsnType
  27305. }
  27306. }
  27307. 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)
  27308. var dat map[string]interface{}
  27309. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27310. fmt.Println(dat)
  27311. } else {
  27312. fmt.Println(err)
  27313. }
  27314. saveLog(result2, src_resquest, "2207", "结算")
  27315. userJSONBytes, _ := json.Marshal(dat)
  27316. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27317. utils.ErrorLog("解析失败:%v", err)
  27318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27319. return
  27320. }
  27321. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27322. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27323. if his.IdCardType == 1 {
  27324. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27325. bas := strings.Split(psn_info.CardInfo, "|")
  27326. cert_no = bas[2]
  27327. } else if his.IdCardType == 3 {
  27328. cert_no = his.Certno
  27329. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27330. } else if his.IdCardType == 4 {
  27331. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27332. cert_no = psn_info.VerifyNumber
  27333. psn_info.VerifyNumber = psn_info.VerifyNumber
  27334. } else {
  27335. cert_no = his.Certno
  27336. psn_info.VerifyNumber = his.Certno
  27337. }
  27338. var api string
  27339. var med_type string
  27340. if his.Insutype == "390" {
  27341. if reg_type == 992102 {
  27342. med_type = "992102"
  27343. }
  27344. if reg_type == 140104 {
  27345. med_type = "140104"
  27346. }
  27347. if reg_type == 140201 {
  27348. med_type = "140201"
  27349. }
  27350. if reg_type == 14 {
  27351. med_type = "14"
  27352. }
  27353. } else if his.Insutype == "310" {
  27354. if reg_type == 992102 {
  27355. med_type = "992102"
  27356. }
  27357. if reg_type == 140104 {
  27358. med_type = "140104"
  27359. }
  27360. if reg_type == 140201 {
  27361. med_type = "140201"
  27362. }
  27363. if reg_type == 14 {
  27364. med_type = "14"
  27365. }
  27366. }
  27367. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27368. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27369. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27370. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27371. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27372. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27373. "&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
  27374. resp, requestErr := http.Get(api)
  27375. if requestErr != nil {
  27376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27377. return
  27378. }
  27379. body, ioErr := ioutil.ReadAll(resp.Body)
  27380. if ioErr != nil {
  27381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27383. return
  27384. }
  27385. var respJSON map[string]interface{}
  27386. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27389. return
  27390. }
  27391. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27392. if status == "0" {
  27393. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27394. c.ServeSuccessJSON(map[string]interface{}{
  27395. "failed_code": -10,
  27396. "msg": err_msg,
  27397. })
  27398. return
  27399. }
  27400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27401. result, _ := json.Marshal(respJSON)
  27402. fmt.Println("log")
  27403. fmt.Println(string(result))
  27404. if err := json.Unmarshal(result, &ahres); err != nil {
  27405. utils.ErrorLog("解析失败:%v", err)
  27406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27407. return
  27408. }
  27409. res.InfRefmsgid = ahres.InfRefmsgid
  27410. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27411. // 创建对应的Time类型
  27412. t := time.UnixMilli(timestamp)
  27413. // 格式化成指定的日期字符串
  27414. str := t.Format("2006-01-02 15:04:05")
  27415. res.Output.Setlinfo.SetlTime = str
  27416. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27417. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27418. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27419. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27420. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27421. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27422. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27423. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27424. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27425. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27426. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27427. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27428. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27429. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27430. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27431. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27432. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27433. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27434. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27435. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27436. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27437. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27438. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27439. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27440. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27441. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27442. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27443. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27444. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27445. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27446. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27447. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27448. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27449. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27450. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27451. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27452. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27453. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27454. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27455. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27456. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27457. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27458. res.Output.Setldetail = ahres.Output.Setldetail
  27459. res.ErrMsg = ahres.ErrMsg
  27460. res.Cainfo = ahres.Cainfo
  27461. res.WarnMsg = ahres.WarnMsg
  27462. res.Infcode = ahres.Infcode
  27463. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27464. res.Output.Setlinfo.ClrType = "11"
  27465. } else {
  27466. res.Output.Setlinfo.ClrType = "9903"
  27467. }
  27468. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27469. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27470. if his.IdCardType == 1 {
  27471. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27472. bas := strings.Split(psn_info.CardInfo, "|")
  27473. cert_no = bas[2]
  27474. } else if his.IdCardType == 3 {
  27475. cert_no = his.Certno
  27476. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27477. } else if his.IdCardType == 4 {
  27478. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27479. cert_no = his.Certno
  27480. psn_info.VerifyNumber = psn_info.VerifyNumber
  27481. } else {
  27482. cert_no = his.Certno
  27483. psn_info.VerifyNumber = his.Certno
  27484. }
  27485. var api string
  27486. var med_type string
  27487. if his.Insutype == "390" {
  27488. if reg_type == 992102 {
  27489. med_type = "992102"
  27490. }
  27491. if reg_type == 140104 {
  27492. med_type = "140104"
  27493. }
  27494. if reg_type == 14 {
  27495. med_type = "14"
  27496. }
  27497. if reg_type == 140201 {
  27498. med_type = "140201"
  27499. }
  27500. } else if his.Insutype == "310" {
  27501. if reg_type == 992102 {
  27502. med_type = "992102"
  27503. }
  27504. if reg_type == 14 {
  27505. med_type = "14"
  27506. }
  27507. if reg_type == 140104 {
  27508. med_type = "140104"
  27509. }
  27510. if reg_type == 140201 {
  27511. med_type = "140201"
  27512. }
  27513. }
  27514. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27515. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27516. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27517. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27518. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27519. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27520. "&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
  27521. resp, requestErr := http.Get(api)
  27522. if requestErr != nil {
  27523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27524. return
  27525. }
  27526. body, ioErr := ioutil.ReadAll(resp.Body)
  27527. if ioErr != nil {
  27528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27530. return
  27531. }
  27532. var respJSON map[string]interface{}
  27533. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27536. return
  27537. }
  27538. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27539. if status == "0" {
  27540. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27541. c.ServeSuccessJSON(map[string]interface{}{
  27542. "failed_code": -10,
  27543. "msg": err_msg,
  27544. })
  27545. return
  27546. }
  27547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27548. result, _ := json.Marshal(respJSON)
  27549. fmt.Println("log")
  27550. fmt.Println(string(result))
  27551. if err := json.Unmarshal(result, &ahres); err != nil {
  27552. utils.ErrorLog("解析失败:%v", err)
  27553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27554. return
  27555. }
  27556. res.InfRefmsgid = ahres.InfRefmsgid
  27557. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27558. // 创建对应的Time类型
  27559. t := time.UnixMilli(timestamp)
  27560. // 格式化成指定的日期字符串
  27561. str := t.Format("2006-01-02 15:04:05")
  27562. res.Output.Setlinfo.SetlTime = str
  27563. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27564. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27565. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27566. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27567. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27568. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27569. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27570. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27571. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27572. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27573. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27574. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27575. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27576. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27577. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27578. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27579. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27580. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27581. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27582. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27583. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27584. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27585. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27586. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27587. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27588. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27589. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27590. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27591. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27592. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27593. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27594. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27595. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27596. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27597. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27598. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27599. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27600. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27601. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27602. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27603. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27604. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27605. res.Output.Setldetail = ahres.Output.Setldetail
  27606. res.ErrMsg = ahres.ErrMsg
  27607. res.Cainfo = ahres.Cainfo
  27608. res.WarnMsg = ahres.WarnMsg
  27609. res.Infcode = ahres.Infcode
  27610. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27611. res.Output.Setlinfo.ClrType = "11"
  27612. } else {
  27613. res.Output.Setlinfo.ClrType = "9903"
  27614. }
  27615. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27616. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27617. var cert_no string
  27618. if his.IdCardType == 1 {
  27619. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27620. } else if his.IdCardType == 2 {
  27621. cert_no = his.IdCardNo
  27622. } else {
  27623. cert_no = psn_info.VerifyNumber
  27624. }
  27625. 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, "")
  27626. var dat map[string]interface{}
  27627. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27628. fmt.Println(dat)
  27629. } else {
  27630. fmt.Println(err)
  27631. }
  27632. saveLog(result2, src_resquest, "2207", "结算")
  27633. userJSONBytes, _ := json.Marshal(dat)
  27634. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27635. utils.ErrorLog("解析失败:%v", err)
  27636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27637. return
  27638. }
  27639. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27640. psn_info, _ := service.GetPsnByPatientId(id)
  27641. var verify_number string
  27642. if psn_info.IdCardType == 4 {
  27643. verify_number = psn_info.VerifyNumber
  27644. } else if psn_info.IdCardType == 1 {
  27645. bas := strings.Split(psn_info.CardInfo, "|")
  27646. cardNumber := bas[2]
  27647. verify_number = cardNumber
  27648. } else {
  27649. verify_number = psn_info.Certno
  27650. psn_info.IdCardType = 2
  27651. }
  27652. var api string
  27653. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27654. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27655. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27656. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27657. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27658. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27659. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27660. resp, requestErr := http.Get(api)
  27661. if requestErr != nil {
  27662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27663. return
  27664. }
  27665. body, ioErr := ioutil.ReadAll(resp.Body)
  27666. if ioErr != nil {
  27667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27669. return
  27670. }
  27671. var respJSON map[string]interface{}
  27672. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27675. return
  27676. }
  27677. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27678. result, _ := json.Marshal(respJSON)
  27679. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27680. utils.ErrorLog("解析失败:%v", err)
  27681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27682. return
  27683. }
  27684. } else {
  27685. var src_resquest string
  27686. if miConfig.Code == "H15049901371" {
  27687. //赤峰地区国家医保医疗类别
  27688. //职工透析:医疗类别选特殊情况门诊990502
  27689. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27690. var med_type string
  27691. if his.Insutype == "390" {
  27692. if reg_type == 14 {
  27693. med_type = "9933"
  27694. } else if reg_type == 11 {
  27695. med_type = "11"
  27696. }
  27697. } else if his.Insutype == "310" {
  27698. if reg_type == 14 {
  27699. med_type = "990502"
  27700. } else if reg_type == 11 {
  27701. med_type = "11"
  27702. }
  27703. }
  27704. 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)
  27705. } else {
  27706. if his.IdCardType == 4 {
  27707. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27708. token := psn_info.VerifyNumber
  27709. 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)
  27710. } else {
  27711. 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)
  27712. }
  27713. }
  27714. var dat map[string]interface{}
  27715. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27716. fmt.Println(dat)
  27717. } else {
  27718. fmt.Println(err)
  27719. }
  27720. saveLog(result2, src_resquest, "2207", "结算")
  27721. userJSONBytes, _ := json.Marshal(dat)
  27722. if miConfig.Code == "H15049901371" {
  27723. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27724. utils.ErrorLog("解析失败:%v", err)
  27725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27726. return
  27727. }
  27728. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27729. res.Output = resSeven10265.Output
  27730. res.ErrMsg = resSeven10265.ErrMsg
  27731. res.Cainfo = resSeven10265.Cainfo
  27732. res.WarnMsg = resSeven10265.WarnMsg
  27733. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27734. res.Infcode = infocode
  27735. } else {
  27736. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27737. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27738. utils.ErrorLog("解析失败:%v", err)
  27739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27740. return
  27741. }
  27742. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27743. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27744. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27745. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27746. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27747. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27748. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27749. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27750. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27751. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27752. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27753. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27754. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27755. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27756. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27757. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27758. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27759. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27760. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27761. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27762. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27763. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27764. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27765. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27766. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27767. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27768. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27769. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27770. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27771. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27772. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27773. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27774. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27775. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27776. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27777. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27778. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27779. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27780. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27781. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27782. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27783. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27784. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27785. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27786. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27787. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27788. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27789. res.Cainfo = gzresSeven10265Two.Cainfo
  27790. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27791. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27792. //res.Infcode = infocode
  27793. } else {
  27794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27795. utils.ErrorLog("解析失败:%v", err)
  27796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27797. return
  27798. }
  27799. }
  27800. }
  27801. }
  27802. if res.Infcode == -1 {
  27803. errlog := &models.HisOrderError{
  27804. UserOrgId: adminUser.CurrentOrgId,
  27805. Ctime: time.Now().Unix(),
  27806. Mtime: time.Now().Unix(),
  27807. Number: chrg_bchno,
  27808. ErrMsg: res.ErrMsg,
  27809. Status: 1,
  27810. PatientId: id,
  27811. RecordTime: recordDateTime,
  27812. Stage: 6,
  27813. }
  27814. service.CreateErrMsgLog(errlog)
  27815. c.ServeSuccessJSON(map[string]interface{}{
  27816. "failed_code": -10,
  27817. "msg": res.ErrMsg,
  27818. })
  27819. return
  27820. } else {
  27821. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27822. order.OrderStatus = 2
  27823. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27824. order.SetlId = res.Output.Setlinfo.SetlID
  27825. order.PsnNo = res.Output.Setlinfo.PsnNo
  27826. order.PsnName = res.Output.Setlinfo.PsnName
  27827. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27828. order.Certno = res.Output.Setlinfo.Certno
  27829. order.Gend = res.Output.Setlinfo.Gend
  27830. order.Naty = res.Output.Setlinfo.Naty
  27831. order.Age = res.Output.Setlinfo.Age
  27832. order.Insutype = res.Output.Setlinfo.Insutype
  27833. order.PsnType = res.Output.Setlinfo.PsnType
  27834. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27835. order.SetlTime = res.Output.Setlinfo.SetlTime
  27836. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27837. order.PayWays = pay_ways
  27838. order.AcctUsedFlag = acct_used_flag
  27839. order.WechatPay = wechat_pay
  27840. order.AliPay = ali_pay
  27841. order.JifenPay = jifen_pay
  27842. order.BandCardPay = band_card_pay
  27843. order.CashPay = cash_pay
  27844. order.OthDesc = oth_desc
  27845. //order.MedType = res.Output.Setlinfo.MedType
  27846. if reg_type == 1112 {
  27847. order.MedType = "1112"
  27848. }
  27849. if reg_type == 1111 {
  27850. order.MedType = "1111"
  27851. }
  27852. order.ClrType = res.Output.Setlinfo.ClrType
  27853. if adminUser.CurrentOrgId == 10480 {
  27854. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27855. order.ClrType = "11"
  27856. } else {
  27857. order.ClrType = "9903"
  27858. }
  27859. }
  27860. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27861. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27862. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27863. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27864. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27865. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27866. order.HifpPay = res.Output.Setlinfo.HifpPay
  27867. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27868. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27869. order.HifesPay = res.Output.Setlinfo.HifesPay
  27870. order.HifobPay = res.Output.Setlinfo.HifobPay
  27871. order.MafPay = res.Output.Setlinfo.MafPay
  27872. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27873. order.OthPay = res.Output.Setlinfo.OthPay
  27874. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27875. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27876. order.AcctPay = res.Output.Setlinfo.AcctPay
  27877. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27878. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27879. order.Balc = res.Output.Setlinfo.Balc
  27880. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27881. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27882. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27883. order.ClrWay = res.Output.Setlinfo.ClrWay
  27884. order.Creator = order.Creator
  27885. order.Modify = roles.AdminUserId
  27886. order.RequestLog = src_resquest
  27887. order.Diagnosis = diagnosis_id
  27888. order.FaPiaoNumber = fapiao_number
  27889. order.FaPiaoCode = fapiao_code
  27890. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27891. detailStr := string(setlDetail)
  27892. order.SetlDetail = detailStr
  27893. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27894. err = service.UpDateOrder(order)
  27895. if err == nil {
  27896. //判断是否使用了押金
  27897. if dec_way == "true" {
  27898. tmpstring := strconv.FormatInt(order.ID, 10)
  27899. //扣押金
  27900. order.Decimal = decimal
  27901. service.UpDateOrder(order)
  27902. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27903. if errmsg != nil {
  27904. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27905. return
  27906. }
  27907. }
  27908. c.ServeSuccessJSON(map[string]interface{}{
  27909. "msg": "结算成功",
  27910. })
  27911. } else {
  27912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27913. return
  27914. }
  27915. }
  27916. }
  27917. }
  27918. }
  27919. // 上传明细-预结算-
  27920. func (c *HisApiController) GetPreUploadInfo() {
  27921. id, _ := c.GetInt64("id")
  27922. record_time := c.GetString("record_time")
  27923. his_patient_id, _ := c.GetInt64("his_patient_id")
  27924. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27925. admin_user_id, _ := c.GetInt64("admin_user_id")
  27926. diagnosis_id := c.GetString("diagnosis")
  27927. sick_type, _ := c.GetInt64("sick_type")
  27928. reg_type, _ := c.GetInt64("p_type")
  27929. begin_time := c.GetString("begin_time")
  27930. acct_used_flag := c.GetString("acct_used_flag")
  27931. id_str := c.GetString("ids")
  27932. ids_arr := strings.Split(id_str, ",")
  27933. timeLayout := "2006-01-02"
  27934. loc, _ := time.LoadLocation("Local")
  27935. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27936. if err != nil {
  27937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27938. return
  27939. }
  27940. recordDateTime := theTime.Unix()
  27941. adminUser := c.GetAdminUserInfo()
  27942. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27943. var config []*models.HisXtDiagnoseConfig
  27944. for _, item := range diagnosis_ids {
  27945. id, _ := strconv.ParseInt(item, 10, 64)
  27946. if id > 0 {
  27947. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27948. config = append(config, &diagnosisConfig)
  27949. }
  27950. }
  27951. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27952. sickConfig, _ := service.FindSickById(sick_type)
  27953. var prescriptions []*models.HisPrescription
  27954. var start_time int64
  27955. var end_time int64
  27956. var isSuccess bool = true
  27957. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27958. fmt.Println(his_patient_id)
  27959. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27960. timestamp := time.Now().Unix()
  27961. tempTime := time.Unix(timestamp, 0)
  27962. timeFormat := tempTime.Format("20060102150405")
  27963. chrgBchno := rand.Intn(100000) + 10000
  27964. new_chrg_bchno := ""
  27965. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27966. new_chrg_bchno = chrg_bchno
  27967. if adminUser.CurrentOrgId == 10265 {
  27968. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27969. new_chrg_bchno = "0000"
  27970. }
  27971. }
  27972. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27973. var patientPrescription models.HisPrescriptionInfo
  27974. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27975. if patientPrescription.ID == 0 {
  27976. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27977. }
  27978. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27979. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27980. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27981. strconv.FormatInt(his.PatientId, 10)
  27982. var res2406 Result2406
  27983. //安徽单病种处理
  27984. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27985. data := make(map[string]interface{})
  27986. client := &http.Client{}
  27987. data["psn_no"] = his.PsnNo
  27988. data["mdtrt_id"] = his.Number
  27989. data["operator"] = roles.UserName
  27990. data["cert_no"] = his.IdCardNo
  27991. data["org_name"] = miConfig.OrgName
  27992. data["psn_name"] = his.Name
  27993. data["ipt_otp_no"] = his.IptOtpNo
  27994. data["ipt_psn_sp_flag_type"] = "0901"
  27995. data["ipt_psn_sp_flag"] = "1"
  27996. data["fixmedins_code"] = miConfig.Code
  27997. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27998. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27999. data["url"] = miConfig.Url
  28000. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28001. bytesData, _ := json.Marshal(data)
  28002. var req *http.Request
  28003. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28004. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28005. resp, _ := client.Do(req)
  28006. defer resp.Body.Close()
  28007. body, ioErr := ioutil.ReadAll(resp.Body)
  28008. if ioErr != nil {
  28009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28011. return
  28012. }
  28013. var respJSON map[string]interface{}
  28014. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28017. return
  28018. }
  28019. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28020. if status == "0" {
  28021. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28022. c.ServeSuccessJSON(map[string]interface{}{
  28023. "failed_code": -10,
  28024. "msg": err_msg,
  28025. })
  28026. return
  28027. }
  28028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28029. userJSONBytes, _ := json.Marshal(respJSON)
  28030. fmt.Println("log")
  28031. fmt.Println(string(userJSONBytes))
  28032. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28033. utils.ErrorLog("解析失败:%v", err)
  28034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28035. return
  28036. }
  28037. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  28038. data := make(map[string]interface{})
  28039. client := &http.Client{}
  28040. data["psn_no"] = his.PsnNo
  28041. data["mdtrt_id"] = his.Number
  28042. data["operator"] = roles.UserName
  28043. data["cert_no"] = his.IdCardNo
  28044. data["org_name"] = miConfig.OrgName
  28045. data["psn_name"] = his.Name
  28046. data["ipt_otp_no"] = his.IptOtpNo
  28047. data["ipt_psn_sp_flag_type"] = "0901"
  28048. data["ipt_psn_sp_flag"] = "1"
  28049. data["fixmedins_code"] = miConfig.Code
  28050. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28051. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28052. data["url"] = miConfig.Url
  28053. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28054. bytesData, _ := json.Marshal(data)
  28055. var req *http.Request
  28056. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28057. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28058. resp, _ := client.Do(req)
  28059. defer resp.Body.Close()
  28060. body, ioErr := ioutil.ReadAll(resp.Body)
  28061. if ioErr != nil {
  28062. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28064. return
  28065. }
  28066. var respJSON map[string]interface{}
  28067. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28068. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28070. return
  28071. }
  28072. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28073. if status == "0" {
  28074. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28075. c.ServeSuccessJSON(map[string]interface{}{
  28076. "failed_code": -10,
  28077. "msg": err_msg,
  28078. })
  28079. return
  28080. }
  28081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28082. userJSONBytes, _ := json.Marshal(respJSON)
  28083. fmt.Println("log")
  28084. fmt.Println(string(userJSONBytes))
  28085. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28086. utils.ErrorLog("解析失败:%v", err)
  28087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28088. return
  28089. }
  28090. }
  28091. if res2406.Infcode != 0 {
  28092. adminUser := c.GetAdminUserInfo()
  28093. errlog := &models.HisOrderError{
  28094. UserOrgId: adminUser.CurrentOrgId,
  28095. Ctime: time.Now().Unix(),
  28096. Mtime: time.Now().Unix(),
  28097. ErrMsg: res2406.ErrMsg,
  28098. Status: 1,
  28099. PatientId: id,
  28100. RecordTime: recordDateTime,
  28101. Stage: 3,
  28102. }
  28103. service.CreateErrMsgLog(errlog)
  28104. c.ServeSuccessJSON(map[string]interface{}{
  28105. "failed_code": -10,
  28106. "msg": res2406.ErrMsg,
  28107. })
  28108. return
  28109. }
  28110. var res2 ResultSix
  28111. var res3 GZResultSix
  28112. var resSix10265 ResultSix10265
  28113. //var time_stamp string
  28114. if miConfig.MdtrtareaAdmvs == "421300" {
  28115. data := make(map[string]interface{})
  28116. client := &http.Client{}
  28117. data["psn_no"] = his.PsnNo
  28118. data["mdtrt_id"] = his.Number
  28119. data["department"] = department.Name
  28120. data["org_name"] = miConfig.OrgName
  28121. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28122. data["doctor_id"] = doctor_info.DoctorNumber
  28123. data["doctor_name"] = roles.UserName
  28124. data["fixmedins_code"] = miConfig.Code
  28125. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28126. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28127. data["secret_key"] = miConfig.SecretKey
  28128. data["sick_code"] = sickConfig.CountryCode
  28129. data["sick_name"] = sickConfig.ClassName
  28130. data["begin_time"] = begin_time
  28131. data["dept"] = strconv.FormatInt(department.ID, 10)
  28132. data["config"] = config
  28133. data["opter"] = roles.UserName
  28134. fmt.Println(data)
  28135. bytesData, _ := json.Marshal(data)
  28136. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28137. resp, _ := client.Do(req)
  28138. defer resp.Body.Close()
  28139. body, ioErr := ioutil.ReadAll(resp.Body)
  28140. if ioErr != nil {
  28141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28143. return
  28144. }
  28145. var respJSON map[string]interface{}
  28146. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28149. return
  28150. }
  28151. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28152. userJSONBytes, _ := json.Marshal(respJSON)
  28153. fmt.Println("log")
  28154. fmt.Println(string(userJSONBytes))
  28155. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28156. utils.ErrorLog("解析失败:%v", err)
  28157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28158. return
  28159. }
  28160. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28161. data := make(map[string]interface{})
  28162. client := &http.Client{}
  28163. data["psn_no"] = his.PsnNo
  28164. data["mdtrt_id"] = his.Number
  28165. data["department"] = department.Name
  28166. data["org_name"] = miConfig.OrgName
  28167. if reg_type == 11 && his.Insutype == "390" {
  28168. data["med_type"] = "110104"
  28169. } else {
  28170. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28171. }
  28172. data["doctor_id"] = doctor_info.DoctorNumber
  28173. data["doctor_name"] = roles.UserName
  28174. data["fixmedins_code"] = miConfig.Code
  28175. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28176. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28177. data["secret_key"] = miConfig.SecretKey
  28178. data["sick_code"] = sickConfig.CountryCode
  28179. data["sick_name"] = sickConfig.ClassName
  28180. data["begin_time"] = begin_time
  28181. data["dept"] = strconv.FormatInt(department.ID, 10)
  28182. data["config"] = config
  28183. data["opter"] = roles.UserName
  28184. fmt.Println(data)
  28185. bytesData, _ := json.Marshal(data)
  28186. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28187. resp, _ := client.Do(req)
  28188. defer resp.Body.Close()
  28189. body, ioErr := ioutil.ReadAll(resp.Body)
  28190. if ioErr != nil {
  28191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28193. return
  28194. }
  28195. var respJSON map[string]interface{}
  28196. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28199. return
  28200. }
  28201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28202. userJSONBytes, _ := json.Marshal(respJSON)
  28203. fmt.Println("log")
  28204. fmt.Println(string(userJSONBytes))
  28205. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28206. utils.ErrorLog("解析失败:%v", err)
  28207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28208. return
  28209. }
  28210. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28211. data := make(map[string]interface{})
  28212. client := &http.Client{}
  28213. data["psn_no"] = his.PsnNo
  28214. data["mdtrt_id"] = his.Number
  28215. data["department"] = department.Name
  28216. data["org_name"] = miConfig.OrgName
  28217. if reg_type == 11 && his.Insutype == "390" {
  28218. data["med_type"] = "110104"
  28219. } else {
  28220. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28221. }
  28222. data["doctor_id"] = doctor_info.DoctorNumber
  28223. data["doctor_name"] = roles.UserName
  28224. data["fixmedins_code"] = miConfig.Code
  28225. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28226. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28227. data["secret_key"] = miConfig.SecretKey
  28228. data["sick_code"] = sickConfig.CountryCode
  28229. data["sick_name"] = sickConfig.ClassName
  28230. data["begin_time"] = begin_time
  28231. data["dept"] = strconv.FormatInt(department.ID, 10)
  28232. data["config"] = config
  28233. data["opter"] = roles.UserName
  28234. fmt.Println(data)
  28235. bytesData, _ := json.Marshal(data)
  28236. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28237. resp, _ := client.Do(req)
  28238. defer resp.Body.Close()
  28239. body, ioErr := ioutil.ReadAll(resp.Body)
  28240. if ioErr != nil {
  28241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28243. return
  28244. }
  28245. var respJSON map[string]interface{}
  28246. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28249. return
  28250. }
  28251. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28252. userJSONBytes, _ := json.Marshal(respJSON)
  28253. fmt.Println("log")
  28254. fmt.Println(string(userJSONBytes))
  28255. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28256. utils.ErrorLog("解析失败:%v", err)
  28257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28258. return
  28259. }
  28260. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28261. data := make(map[string]interface{})
  28262. client := &http.Client{}
  28263. data["psn_no"] = his.PsnNo
  28264. data["mdtrt_id"] = his.Number
  28265. data["department"] = department.Name
  28266. data["org_name"] = miConfig.OrgName
  28267. if reg_type == 11 && his.Insutype == "390" {
  28268. data["med_type"] = "110104"
  28269. } else {
  28270. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28271. }
  28272. data["doctor_id"] = doctor_info.DoctorNumber
  28273. data["doctor_name"] = roles.UserName
  28274. data["fixmedins_code"] = miConfig.Code
  28275. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28276. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28277. data["secret_key"] = miConfig.SecretKey
  28278. data["sick_code"] = sickConfig.CountryCode
  28279. data["sick_name"] = sickConfig.ClassName
  28280. data["begin_time"] = begin_time
  28281. data["dept"] = strconv.FormatInt(department.ID, 10)
  28282. data["config"] = config
  28283. data["opter"] = roles.UserName
  28284. fmt.Println(data)
  28285. bytesData, _ := json.Marshal(data)
  28286. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28287. resp, _ := client.Do(req)
  28288. defer resp.Body.Close()
  28289. body, ioErr := ioutil.ReadAll(resp.Body)
  28290. if ioErr != nil {
  28291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28293. return
  28294. }
  28295. var respJSON map[string]interface{}
  28296. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28299. return
  28300. }
  28301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28302. userJSONBytes, _ := json.Marshal(respJSON)
  28303. fmt.Println("log")
  28304. fmt.Println(string(userJSONBytes))
  28305. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28306. utils.ErrorLog("解析失败:%v", err)
  28307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28308. return
  28309. }
  28310. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28311. data := make(map[string]interface{})
  28312. client := &http.Client{}
  28313. data["psn_no"] = his.PsnNo
  28314. data["mdtrt_id"] = his.Number
  28315. data["doctor"] = roles.UserName
  28316. data["department"] = department.Name
  28317. data["org_name"] = miConfig.OrgName
  28318. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28319. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28320. data["fixmedins_code"] = miConfig.Code
  28321. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28322. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28323. data["secret_key"] = miConfig.SecretKey
  28324. data["sick_code"] = sickConfig.CountryCode
  28325. data["sick_name"] = sickConfig.ClassName
  28326. data["begin_time"] = begin_time
  28327. data["dept"] = strconv.FormatInt(department.ID, 10)
  28328. data["config"] = config
  28329. data["url"] = miConfig.Url
  28330. data["ak"] = miConfig.AccessKey
  28331. data["cainfo"] = miConfig.Cainfo
  28332. bytesData, _ := json.Marshal(data)
  28333. var req *http.Request
  28334. if miConfig.MdtrtareaAdmvs == "320921" {
  28335. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28336. } else {
  28337. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28338. }
  28339. resp, _ := client.Do(req)
  28340. defer resp.Body.Close()
  28341. body, ioErr := ioutil.ReadAll(resp.Body)
  28342. if ioErr != nil {
  28343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28345. return
  28346. }
  28347. var respJSON map[string]interface{}
  28348. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28351. return
  28352. }
  28353. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28354. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28355. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28357. userJSONBytes, _ := json.Marshal(respJSON)
  28358. fmt.Println("log")
  28359. fmt.Println(string(userJSONBytes))
  28360. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28361. utils.ErrorLog("解析失败:%v", err)
  28362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28363. return
  28364. }
  28365. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28366. res2.Output = resSix10265.Output
  28367. res2.ErrMsg = resSix10265.ErrMsg
  28368. res2.Cainfo = resSix10265.Cainfo
  28369. res2.WarnMsg = resSix10265.WarnMsg
  28370. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28371. res2.Infcode = infocode
  28372. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28373. data := make(map[string]interface{})
  28374. client := &http.Client{}
  28375. data["psn_no"] = his.PsnNo
  28376. data["mdtrt_id"] = his.Number
  28377. data["doctor"] = roles.UserName
  28378. data["department"] = department.Name
  28379. data["org_name"] = miConfig.OrgName
  28380. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28381. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28382. data["fixmedins_code"] = miConfig.Code
  28383. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28384. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28385. data["secret_key"] = miConfig.SecretKey
  28386. data["sick_code"] = sickConfig.CountryCode
  28387. data["sick_name"] = sickConfig.ClassName
  28388. data["begin_time"] = begin_time
  28389. data["dept"] = strconv.FormatInt(department.ID, 10)
  28390. data["config"] = config
  28391. //data["url"] = miConfig.Url
  28392. //data["ak"] = miConfig.AccessKey
  28393. data["cainfo"] = miConfig.Cainfo
  28394. fmt.Println(data)
  28395. bytesData, _ := json.Marshal(data)
  28396. var req *http.Request
  28397. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28398. resp, _ := client.Do(req)
  28399. defer resp.Body.Close()
  28400. body, ioErr := ioutil.ReadAll(resp.Body)
  28401. if ioErr != nil {
  28402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28404. return
  28405. }
  28406. var respJSON map[string]interface{}
  28407. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28410. return
  28411. }
  28412. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28413. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28414. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28415. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28416. userJSONBytes, _ := json.Marshal(respJSON)
  28417. fmt.Println("log")
  28418. fmt.Println(string(userJSONBytes))
  28419. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28420. utils.ErrorLog("解析失败:%v", err)
  28421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28422. return
  28423. }
  28424. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28425. res2.Output = resSix10265.Output
  28426. res2.ErrMsg = resSix10265.ErrMsg
  28427. res2.Cainfo = resSix10265.Cainfo
  28428. res2.WarnMsg = resSix10265.WarnMsg
  28429. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28430. res2.Infcode = infocode
  28431. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28432. 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)
  28433. saveLog(result, requestLog, "2203", "上传就诊信息")
  28434. var respJSON2 map[string]interface{}
  28435. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28438. return
  28439. }
  28440. userJSONBytes2, _ := json.Marshal(respJSON2)
  28441. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28442. utils.ErrorLog("解析失败:%v", err)
  28443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28444. return
  28445. }
  28446. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28447. var result string
  28448. var requestLog string
  28449. 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, "")
  28450. saveLog(result, requestLog, "2203", "上传就诊信息")
  28451. var respJSON2 map[string]interface{}
  28452. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28455. return
  28456. }
  28457. userJSONBytes2, _ := json.Marshal(respJSON2)
  28458. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28459. utils.ErrorLog("解析失败:%v", err)
  28460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28461. return
  28462. }
  28463. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28464. var result string
  28465. var requestLog string
  28466. 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, "")
  28467. saveLog(result, requestLog, "2203", "上传就诊信息")
  28468. var respJSON2 map[string]interface{}
  28469. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28472. return
  28473. }
  28474. userJSONBytes2, _ := json.Marshal(respJSON2)
  28475. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28476. utils.ErrorLog("解析失败:%v", err)
  28477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28478. return
  28479. }
  28480. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28481. data := make(map[string]interface{})
  28482. client := &http.Client{}
  28483. data["psn_no"] = his.PsnNo
  28484. data["mdtrt_id"] = his.Number
  28485. data["operator"] = roles.UserName
  28486. data["department"] = department.Name
  28487. data["org_name"] = miConfig.OrgName
  28488. var med_type string
  28489. if his.Insutype == "390" {
  28490. if reg_type == 992102 {
  28491. med_type = "992102"
  28492. data["sick_code"] = "ZDZ940"
  28493. data["sick_name"] = "慢性肾衰竭"
  28494. }
  28495. if reg_type == 140104 {
  28496. med_type = "140104"
  28497. data["sick_code"] = sickConfig.CountryCode
  28498. data["sick_name"] = sickConfig.ClassName
  28499. }
  28500. if reg_type == 14 {
  28501. med_type = "140104"
  28502. data["sick_code"] = sickConfig.CountryCode
  28503. data["sick_name"] = sickConfig.ClassName
  28504. }
  28505. } else if his.Insutype == "310" {
  28506. if reg_type == 992102 {
  28507. med_type = "992102"
  28508. data["sick_code"] = "ZDZ940"
  28509. data["sick_name"] = "慢性肾衰竭"
  28510. }
  28511. if reg_type == 140104 {
  28512. med_type = "140104"
  28513. data["sick_code"] = sickConfig.CountryCode
  28514. data["sick_name"] = sickConfig.ClassName
  28515. }
  28516. if reg_type == 14 {
  28517. med_type = "14"
  28518. data["sick_code"] = sickConfig.CountryCode
  28519. data["sick_name"] = sickConfig.ClassName
  28520. }
  28521. }
  28522. data["med_type"] = med_type
  28523. data["doctor_number"] = doctor_info.DoctorNumber
  28524. data["doctor_name"] = doctor_info.UserName
  28525. data["fixmedins_code"] = miConfig.Code
  28526. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28527. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28528. data["secret_key"] = miConfig.SecretKey
  28529. data["begin_time"] = begin_time
  28530. data["dept"] = strconv.FormatInt(department.ID, 10)
  28531. data["config"] = config
  28532. data["url"] = miConfig.Url
  28533. data["ak"] = miConfig.AccessKey
  28534. data["cainfo"] = miConfig.Cainfo
  28535. bytesData, _ := json.Marshal(data)
  28536. var req *http.Request
  28537. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28538. resp, _ := client.Do(req)
  28539. defer resp.Body.Close()
  28540. body, ioErr := ioutil.ReadAll(resp.Body)
  28541. if ioErr != nil {
  28542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28544. return
  28545. }
  28546. var respJSON map[string]interface{}
  28547. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28550. return
  28551. }
  28552. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28553. if status == "0" {
  28554. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28555. c.ServeSuccessJSON(map[string]interface{}{
  28556. "failed_code": -10,
  28557. "msg": err_msg,
  28558. })
  28559. return
  28560. }
  28561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28562. userJSONBytes, _ := json.Marshal(respJSON)
  28563. fmt.Println("log")
  28564. fmt.Println(string(userJSONBytes))
  28565. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28566. utils.ErrorLog("解析失败:%v", err)
  28567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28568. return
  28569. }
  28570. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28571. data := make(map[string]interface{})
  28572. client := &http.Client{}
  28573. data["psn_no"] = his.PsnNo
  28574. data["mdtrt_id"] = his.Number
  28575. data["operator"] = roles.UserName
  28576. data["department"] = department.Name
  28577. data["org_name"] = miConfig.OrgName
  28578. var med_type string
  28579. if his.Insutype == "390" {
  28580. if reg_type == 992102 {
  28581. med_type = "992102"
  28582. data["sick_code"] = sickConfig.CountryCode
  28583. data["sick_name"] = sickConfig.ClassName
  28584. }
  28585. if reg_type == 140104 {
  28586. med_type = "140104"
  28587. data["sick_code"] = sickConfig.CountryCode
  28588. data["sick_name"] = sickConfig.ClassName
  28589. }
  28590. if reg_type == 140201 {
  28591. med_type = "140201"
  28592. data["sick_code"] = sickConfig.CountryCode
  28593. data["sick_name"] = sickConfig.ClassName
  28594. }
  28595. if reg_type == 14 {
  28596. med_type = "14"
  28597. data["sick_code"] = sickConfig.CountryCode
  28598. data["sick_name"] = sickConfig.ClassName
  28599. }
  28600. } else if his.Insutype == "310" {
  28601. if reg_type == 992102 {
  28602. med_type = "992102"
  28603. data["sick_code"] = sickConfig.CountryCode
  28604. data["sick_name"] = sickConfig.ClassName
  28605. }
  28606. if reg_type == 140104 {
  28607. med_type = "140104"
  28608. data["sick_code"] = sickConfig.CountryCode
  28609. data["sick_name"] = sickConfig.ClassName
  28610. }
  28611. if reg_type == 140201 {
  28612. med_type = "140201"
  28613. data["sick_code"] = sickConfig.CountryCode
  28614. data["sick_name"] = sickConfig.ClassName
  28615. }
  28616. if reg_type == 14 {
  28617. med_type = "14"
  28618. data["sick_code"] = sickConfig.CountryCode
  28619. data["sick_name"] = sickConfig.ClassName
  28620. }
  28621. }
  28622. data["med_type"] = med_type
  28623. data["doctor_number"] = doctor_info.DoctorNumber
  28624. data["doctor_name"] = doctor_info.UserName
  28625. data["fixmedins_code"] = miConfig.Code
  28626. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28627. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28628. data["secret_key"] = miConfig.SecretKey
  28629. data["begin_time"] = begin_time
  28630. data["dept"] = strconv.FormatInt(department.ID, 10)
  28631. data["config"] = config
  28632. data["url"] = miConfig.Url
  28633. data["ak"] = miConfig.AccessKey
  28634. data["cainfo"] = miConfig.Cainfo
  28635. bytesData, _ := json.Marshal(data)
  28636. var req *http.Request
  28637. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28638. resp, _ := client.Do(req)
  28639. defer resp.Body.Close()
  28640. body, ioErr := ioutil.ReadAll(resp.Body)
  28641. if ioErr != nil {
  28642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28644. return
  28645. }
  28646. var respJSON map[string]interface{}
  28647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28650. return
  28651. }
  28652. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28653. if status == "0" {
  28654. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28655. c.ServeSuccessJSON(map[string]interface{}{
  28656. "failed_code": -10,
  28657. "msg": err_msg,
  28658. })
  28659. return
  28660. }
  28661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28662. userJSONBytes, _ := json.Marshal(respJSON)
  28663. fmt.Println("log")
  28664. fmt.Println(string(userJSONBytes))
  28665. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28666. utils.ErrorLog("解析失败:%v", err)
  28667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28668. return
  28669. }
  28670. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28671. var result string
  28672. var requestLog string
  28673. 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, "")
  28674. saveLog(result, requestLog, "2203", "上传就诊信息")
  28675. var respJSON2 map[string]interface{}
  28676. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28679. return
  28680. }
  28681. userJSONBytes2, _ := json.Marshal(respJSON2)
  28682. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28683. utils.ErrorLog("解析失败:%v", err)
  28684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28685. return
  28686. }
  28687. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28688. data := make(map[string]interface{})
  28689. client := &http.Client{}
  28690. data["psn_no"] = his.PsnNo
  28691. data["mdtrt_id"] = his.Number
  28692. data["doctor"] = roles.UserName
  28693. data["department"] = department.Name
  28694. data["org_name"] = miConfig.OrgName
  28695. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28696. data["doctor_id"] = doctor_info.DoctorNumber
  28697. data["fixmedins_code"] = miConfig.Code
  28698. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28699. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28700. data["secret_key"] = miConfig.SecretKey
  28701. data["sick_code"] = sickConfig.CountryCode
  28702. data["sick_name"] = sickConfig.ClassName
  28703. data["begin_time"] = begin_time
  28704. data["new_doctor_name"] = doctor_info.UserName
  28705. data["dept"] = strconv.FormatInt(department.ID, 10)
  28706. data["config"] = config
  28707. bytesData, _ := json.Marshal(data)
  28708. var req *http.Request
  28709. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28710. resp, _ := client.Do(req)
  28711. defer resp.Body.Close()
  28712. body, ioErr := ioutil.ReadAll(resp.Body)
  28713. if ioErr != nil {
  28714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28716. return
  28717. }
  28718. var respJSON map[string]interface{}
  28719. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28722. return
  28723. }
  28724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28725. userJSONBytes, _ := json.Marshal(respJSON)
  28726. fmt.Println("log")
  28727. fmt.Println(string(userJSONBytes))
  28728. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28729. utils.ErrorLog("解析失败:%v", err)
  28730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28731. return
  28732. }
  28733. } else {
  28734. var result string
  28735. var requestLog string
  28736. if miConfig.MdtrtareaAdmvs == "440781" { //
  28737. 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)
  28738. } else {
  28739. if miConfig.Code == "H15049901371" {
  28740. //赤峰地区国家医保医疗类别
  28741. //职工透析:医疗类别选特殊情况门诊990502
  28742. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28743. var med_type string
  28744. if his.Insutype == "390" {
  28745. if reg_type == 14 {
  28746. med_type = "9933"
  28747. } else if reg_type == 11 {
  28748. med_type = "11"
  28749. }
  28750. } else if his.Insutype == "310" {
  28751. if reg_type == 14 {
  28752. med_type = "990502"
  28753. } else if reg_type == 11 {
  28754. med_type = "11"
  28755. }
  28756. }
  28757. 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)
  28758. } else {
  28759. 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)
  28760. }
  28761. saveLog(result, requestLog, "2203", "上传就诊信息")
  28762. var respJSON2 map[string]interface{}
  28763. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28766. return
  28767. }
  28768. userJSONBytes2, _ := json.Marshal(respJSON2)
  28769. if miConfig.Code == "H15049901371" {
  28770. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28771. utils.ErrorLog("解析失败:%v", err)
  28772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28773. return
  28774. }
  28775. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28776. res2.Output = resSix10265.Output
  28777. res2.ErrMsg = resSix10265.ErrMsg
  28778. res2.Cainfo = resSix10265.Cainfo
  28779. res2.WarnMsg = resSix10265.WarnMsg
  28780. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28781. res2.Infcode = infocode
  28782. } else {
  28783. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28784. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28785. utils.ErrorLog("解析失败:%v", err)
  28786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28787. return
  28788. }
  28789. res2.Infcode = res3.Infcode
  28790. } else {
  28791. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28792. utils.ErrorLog("解析失败:%v", err)
  28793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28794. return
  28795. }
  28796. }
  28797. }
  28798. }
  28799. }
  28800. if res2.Infcode == -1 {
  28801. adminUser := c.GetAdminUserInfo()
  28802. errlog := &models.HisOrderError{
  28803. UserOrgId: adminUser.CurrentOrgId,
  28804. Ctime: time.Now().Unix(),
  28805. Mtime: time.Now().Unix(),
  28806. ErrMsg: res2.ErrMsg,
  28807. Status: 1,
  28808. PatientId: id,
  28809. RecordTime: recordDateTime,
  28810. Stage: 3,
  28811. }
  28812. service.CreateErrMsgLog(errlog)
  28813. c.ServeSuccessJSON(map[string]interface{}{
  28814. "failed_code": -10,
  28815. "msg": res2.ErrMsg,
  28816. })
  28817. return
  28818. }
  28819. if res2.Infcode != 0 {
  28820. adminUser := c.GetAdminUserInfo()
  28821. errlog := &models.HisOrderError{
  28822. UserOrgId: adminUser.CurrentOrgId,
  28823. Ctime: time.Now().Unix(),
  28824. Mtime: time.Now().Unix(),
  28825. ErrMsg: res2.ErrMsg,
  28826. Status: 1,
  28827. PatientId: id,
  28828. RecordTime: recordDateTime,
  28829. Stage: 3,
  28830. }
  28831. service.CreateErrMsgLog(errlog)
  28832. c.ServeSuccessJSON(map[string]interface{}{
  28833. "failed_code": -10,
  28834. "msg": res2.ErrMsg,
  28835. })
  28836. return
  28837. } else {
  28838. his.Diagnosis = diagnosis_id
  28839. his.SickType = sickConfig.ID
  28840. his.PType = fmt.Sprintf("%d", reg_type)
  28841. service.UpdateHisPatientThree(&his)
  28842. data := make(map[string]interface{})
  28843. if settle_accounts_type == 1 { //日结
  28844. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28845. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28846. } else {
  28847. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28848. }
  28849. data["pre"] = prescriptions
  28850. } else { //月结
  28851. start_time_str := c.GetString("start_time")
  28852. end_time_str := c.GetString("end_time")
  28853. timeLayout := "2006-01-02"
  28854. loc, _ := time.LoadLocation("Local")
  28855. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28856. if err != nil {
  28857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28858. return
  28859. }
  28860. recordStartTime := theStartTime.Unix()
  28861. start_time = recordStartTime
  28862. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28863. if err != nil {
  28864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28865. return
  28866. }
  28867. recordEndTime := theEndTime.Unix()
  28868. end_time = recordEndTime
  28869. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28870. data["pre"] = prescriptions
  28871. }
  28872. client := &http.Client{}
  28873. data["psn_no"] = his.PsnNo
  28874. data["mdtrt_id"] = his.Number
  28875. data["chrg_bchno"] = new_chrg_bchno
  28876. data["org_name"] = miConfig.OrgName
  28877. data["doctor"] = doctor_info.UserName
  28878. data["doctor_id"] = doctor_info.DoctorNumber
  28879. data["dept"] = department.Name
  28880. data["fixmedins_code"] = miConfig.Code
  28881. data["opter"] = roles.UserName
  28882. data["dept_code"] = department.Number
  28883. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28884. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28885. data["secret_key"] = miConfig.SecretKey
  28886. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28887. data["url"] = miConfig.Url
  28888. data["ak"] = miConfig.AccessKey
  28889. data["new_doctor_name"] = patientPrescription.Doctor
  28890. if his.Insutype == "390" {
  28891. if reg_type == 992102 {
  28892. data["diag_code"] = "ZDZ940"
  28893. }
  28894. if reg_type == 140104 {
  28895. data["diag_code"] = sickConfig.CountryCode
  28896. }
  28897. if reg_type == 140201 {
  28898. data["diag_code"] = sickConfig.CountryCode
  28899. }
  28900. if reg_type == 14 {
  28901. data["diag_code"] = sickConfig.CountryCode
  28902. }
  28903. } else if his.Insutype == "310" {
  28904. if miConfig.MdtrtareaAdmvs == "341203" {
  28905. if reg_type == 992102 {
  28906. data["diag_code"] = "ZDZ940"
  28907. }
  28908. if reg_type != 992102 {
  28909. data["diag_code"] = sickConfig.CountryCode
  28910. }
  28911. } else {
  28912. data["diag_code"] = sickConfig.CountryCode
  28913. }
  28914. }
  28915. data["cainfo"] = miConfig.Cainfo
  28916. data["opter"] = roles.UserName
  28917. var ids []int64
  28918. for _, item := range prescriptions {
  28919. ids = append(ids, item.ID)
  28920. }
  28921. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28922. if config.IsOpen == 1 { //对接了医保,走医保流程
  28923. var res ResultFour
  28924. var resFour10265 ResultFour10265
  28925. if miConfig.MdtrtareaAdmvs == "421300" {
  28926. bytesData, _ := json.Marshal(data)
  28927. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28928. resp, _ := client.Do(req)
  28929. defer resp.Body.Close()
  28930. body, ioErr := ioutil.ReadAll(resp.Body)
  28931. if ioErr != nil {
  28932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28934. return
  28935. }
  28936. var respJSON map[string]interface{}
  28937. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28940. return
  28941. }
  28942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28943. userJSONBytes, _ := json.Marshal(respJSON)
  28944. fmt.Println("log")
  28945. fmt.Println(string(userJSONBytes))
  28946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28947. utils.ErrorLog("解析失败:%v", err)
  28948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28949. return
  28950. }
  28951. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28952. bytesData, _ := json.Marshal(data)
  28953. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28954. resp, _ := client.Do(req)
  28955. defer resp.Body.Close()
  28956. body, ioErr := ioutil.ReadAll(resp.Body)
  28957. if ioErr != nil {
  28958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28960. return
  28961. }
  28962. var respJSON map[string]interface{}
  28963. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28966. return
  28967. }
  28968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28969. userJSONBytes, _ := json.Marshal(respJSON)
  28970. fmt.Println("log")
  28971. fmt.Println(string(userJSONBytes))
  28972. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28973. utils.ErrorLog("解析失败:%v", err)
  28974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28975. return
  28976. }
  28977. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28978. bytesData, _ := json.Marshal(data)
  28979. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28980. resp, _ := client.Do(req)
  28981. defer resp.Body.Close()
  28982. body, ioErr := ioutil.ReadAll(resp.Body)
  28983. if ioErr != nil {
  28984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28986. return
  28987. }
  28988. var respJSON map[string]interface{}
  28989. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28992. return
  28993. }
  28994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28995. userJSONBytes, _ := json.Marshal(respJSON)
  28996. fmt.Println("log")
  28997. fmt.Println(string(userJSONBytes))
  28998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28999. utils.ErrorLog("解析失败:%v", err)
  29000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29001. return
  29002. }
  29003. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29004. bytesData, _ := json.Marshal(data)
  29005. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29006. resp, _ := client.Do(req)
  29007. defer resp.Body.Close()
  29008. body, ioErr := ioutil.ReadAll(resp.Body)
  29009. if ioErr != nil {
  29010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29012. return
  29013. }
  29014. var respJSON map[string]interface{}
  29015. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29018. return
  29019. }
  29020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29021. userJSONBytes, _ := json.Marshal(respJSON)
  29022. fmt.Println("log")
  29023. fmt.Println(string(userJSONBytes))
  29024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29025. utils.ErrorLog("解析失败:%v", err)
  29026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29027. return
  29028. }
  29029. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29030. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29031. if result3101.Infcode == "0" {
  29032. if len(result3101.Output.Result) > 0 {
  29033. var errMsgs []string
  29034. for _, item := range result3101.Output.Result {
  29035. errMsgs = append(errMsgs, item.VolaCont)
  29036. }
  29037. c.ServeSuccessJSON(map[string]interface{}{
  29038. "failed_code": -10,
  29039. "msg": errMsgs,
  29040. })
  29041. return
  29042. } else {
  29043. if miConfig.MdtrtareaAdmvs == "320921" {
  29044. data["doctor_id"] = "D320923012139"
  29045. } else {
  29046. data["doctor_id"] = "D371621008686"
  29047. }
  29048. bytesData, _ := json.Marshal(data)
  29049. var req *http.Request
  29050. if miConfig.MdtrtareaAdmvs == "320921" {
  29051. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29052. } else {
  29053. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29054. }
  29055. resp, _ := client.Do(req)
  29056. defer resp.Body.Close()
  29057. body, ioErr := ioutil.ReadAll(resp.Body)
  29058. if ioErr != nil {
  29059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29061. return
  29062. }
  29063. var respJSON map[string]interface{}
  29064. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29067. return
  29068. }
  29069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29070. userJSONBytes, _ := json.Marshal(respJSON)
  29071. fmt.Println("log")
  29072. fmt.Println(string(userJSONBytes))
  29073. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29074. utils.ErrorLog("解析失败:%v", err)
  29075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29076. return
  29077. }
  29078. res.InfRefmsgid = resFour10265.InfRefmsgid
  29079. res.Output = resFour10265.Output
  29080. res.ErrMsg = resFour10265.ErrMsg
  29081. res.Cainfo = resFour10265.Cainfo
  29082. res.WarnMsg = resFour10265.WarnMsg
  29083. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29084. res.Infcode = infocode
  29085. }
  29086. }
  29087. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29088. var pagesize int = 5
  29089. var start int = 1
  29090. var stop int
  29091. var pagecount int
  29092. var curpage int
  29093. data["doctor_id"] = doctor_info.DoctorNumber
  29094. var res2 ResultFour
  29095. //var result res.
  29096. //总页数,向上取整,注意除之前要先转换类型为float64
  29097. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29098. for curpage = 1; curpage <= pagecount; curpage++ {
  29099. if curpage == 1 {
  29100. start = 1
  29101. } else {
  29102. start = (curpage-1)*pagesize + 1
  29103. }
  29104. stop = curpage * pagesize
  29105. if stop > len(prescriptions) {
  29106. stop = len(prescriptions)
  29107. }
  29108. //var requestLog string
  29109. data["pre"] = prescriptions[start-1 : stop]
  29110. fmt.Println(data["pre"])
  29111. bytesData, _ := json.Marshal(data)
  29112. var req *http.Request
  29113. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29114. resp, _ := client.Do(req)
  29115. defer resp.Body.Close()
  29116. body, ioErr := ioutil.ReadAll(resp.Body)
  29117. if ioErr != nil {
  29118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29120. return
  29121. }
  29122. var respJSON map[string]interface{}
  29123. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29126. return
  29127. }
  29128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29129. userJSONBytes, _ := json.Marshal(respJSON)
  29130. fmt.Println("log")
  29131. fmt.Println(string(userJSONBytes))
  29132. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29133. utils.ErrorLog("解析失败:%v", err)
  29134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29135. return
  29136. }
  29137. res.InfRefmsgid = resFour10265.InfRefmsgid
  29138. res.Output = resFour10265.Output
  29139. res.ErrMsg = resFour10265.ErrMsg
  29140. res.Cainfo = resFour10265.Cainfo
  29141. res.WarnMsg = resFour10265.WarnMsg
  29142. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29143. res.Infcode = infocode
  29144. if infocode == 0 {
  29145. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29146. } else {
  29147. isSuccess = false
  29148. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29149. res.Infcode = -1
  29150. res.ErrMsg = resFour10265.ErrMsg
  29151. errlog := &models.HisOrderError{
  29152. UserOrgId: adminUser.CurrentOrgId,
  29153. Ctime: time.Now().Unix(),
  29154. Mtime: time.Now().Unix(),
  29155. Number: chrg_bchno,
  29156. ErrMsg: "",
  29157. Status: 1,
  29158. PatientId: id,
  29159. RecordTime: recordDateTime,
  29160. Stage: 4,
  29161. }
  29162. service.CreateErrMsgLog(errlog)
  29163. }
  29164. }
  29165. if isSuccess {
  29166. res.Infcode = 0
  29167. res.Output.Result = res2.Output.Result
  29168. } else {
  29169. order := &models.HisOrder{
  29170. UserOrgId: adminUser.CurrentOrgId,
  29171. HisPatientId: his.ID,
  29172. PatientId: his.PatientId,
  29173. SettleAccountsDate: recordDateTime,
  29174. Ctime: time.Now().Unix(),
  29175. Mtime: time.Now().Unix(),
  29176. MdtrtId: his.Number,
  29177. PsnNo: his.PsnNo,
  29178. MedType: strconv.FormatInt(reg_type, 10),
  29179. Status: 1,
  29180. Number: chrg_bchno,
  29181. Infcode: res.Infcode,
  29182. WarnMsg: res.WarnMsg,
  29183. Cainfo: res.Cainfo,
  29184. ErrMsg: res.ErrMsg,
  29185. RespondTime: res.RefmsgTime,
  29186. InfRefmsgid: res.InfRefmsgid,
  29187. OrderStatus: 1,
  29188. IsMedicineInsurance: 1,
  29189. SettleType: settle_accounts_type,
  29190. SettleStartTime: start_time,
  29191. SettleEndTime: end_time,
  29192. Creator: roles.AdminUserId,
  29193. Modify: roles.AdminUserId,
  29194. PType: 2,
  29195. Diagnosis: diagnosis_id,
  29196. }
  29197. err = service.CreateOrder(order)
  29198. if err != nil {
  29199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29200. return
  29201. }
  29202. c.ServeSuccessJSON(map[string]interface{}{
  29203. "failed_code": -10,
  29204. "msg": res2.ErrMsg,
  29205. })
  29206. return
  29207. }
  29208. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29209. 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)
  29210. var dat map[string]interface{}
  29211. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29212. fmt.Println(dat)
  29213. } else {
  29214. fmt.Println(err)
  29215. }
  29216. saveLog(result, request_log, "2204", "上传费用明细")
  29217. userJSONBytes, _ := json.Marshal(dat)
  29218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29219. utils.ErrorLog("解析失败:%v", err)
  29220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29221. return
  29222. }
  29223. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29224. 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, "", "")
  29225. var dat map[string]interface{}
  29226. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29227. fmt.Println(dat)
  29228. } else {
  29229. fmt.Println(err)
  29230. }
  29231. saveLog(result, request_log, "2204", "上传费用明细")
  29232. userJSONBytes, _ := json.Marshal(dat)
  29233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29234. utils.ErrorLog("解析失败:%v", err)
  29235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29236. return
  29237. }
  29238. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29239. 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, "", "")
  29240. var dat map[string]interface{}
  29241. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29242. fmt.Println(dat)
  29243. } else {
  29244. fmt.Println(err)
  29245. }
  29246. saveLog(result, request_log, "2204", "上传费用明细")
  29247. userJSONBytes, _ := json.Marshal(dat)
  29248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29249. utils.ErrorLog("解析失败:%v", err)
  29250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29251. return
  29252. }
  29253. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29254. bytesData, _ := json.Marshal(data)
  29255. var req *http.Request
  29256. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29257. resp, _ := client.Do(req)
  29258. defer resp.Body.Close()
  29259. body, ioErr := ioutil.ReadAll(resp.Body)
  29260. if ioErr != nil {
  29261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29263. return
  29264. }
  29265. var respJSON map[string]interface{}
  29266. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29269. return
  29270. }
  29271. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29272. if status == "0" {
  29273. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29274. c.ServeSuccessJSON(map[string]interface{}{
  29275. "failed_code": -10,
  29276. "msg": err_msg,
  29277. })
  29278. return
  29279. }
  29280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29281. userJSONBytes, _ := json.Marshal(respJSON)
  29282. fmt.Println("log")
  29283. fmt.Println(string(userJSONBytes))
  29284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29285. utils.ErrorLog("解析失败:%v", err)
  29286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29287. return
  29288. }
  29289. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29290. bytesData, _ := json.Marshal(data)
  29291. var req *http.Request
  29292. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29293. resp, _ := client.Do(req)
  29294. defer resp.Body.Close()
  29295. body, ioErr := ioutil.ReadAll(resp.Body)
  29296. if ioErr != nil {
  29297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29299. return
  29300. }
  29301. var respJSON map[string]interface{}
  29302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29305. return
  29306. }
  29307. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29308. if status == "0" {
  29309. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29310. c.ServeSuccessJSON(map[string]interface{}{
  29311. "failed_code": -10,
  29312. "msg": err_msg,
  29313. })
  29314. return
  29315. }
  29316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29317. userJSONBytes, _ := json.Marshal(respJSON)
  29318. fmt.Println("log")
  29319. fmt.Println(string(userJSONBytes))
  29320. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29321. utils.ErrorLog("解析失败:%v", err)
  29322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29323. return
  29324. }
  29325. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29326. 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, "", "")
  29327. var dat map[string]interface{}
  29328. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29329. fmt.Println(dat)
  29330. } else {
  29331. fmt.Println(err)
  29332. }
  29333. saveLog(result, request_log, "2204", "上传费用明细")
  29334. userJSONBytes, _ := json.Marshal(dat)
  29335. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29336. utils.ErrorLog("解析失败:%v", err)
  29337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29338. return
  29339. }
  29340. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29341. bytesData, _ := json.Marshal(data)
  29342. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29343. resp, _ := client.Do(req)
  29344. defer resp.Body.Close()
  29345. body, ioErr := ioutil.ReadAll(resp.Body)
  29346. if ioErr != nil {
  29347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29349. return
  29350. }
  29351. var respJSON map[string]interface{}
  29352. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29355. return
  29356. }
  29357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29358. userJSONBytes, _ := json.Marshal(respJSON)
  29359. fmt.Println("log")
  29360. fmt.Println(string(userJSONBytes))
  29361. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29362. utils.ErrorLog("解析失败:%v", err)
  29363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29364. return
  29365. }
  29366. } else {
  29367. if miConfig.MdtrtareaAdmvs == "441202" {
  29368. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29369. if result3101.Infcode == 0 {
  29370. if len(result3101.Output.Result) > 0 {
  29371. var errMsgs []string
  29372. for _, item := range result3101.Output.Result {
  29373. errMsgs = append(errMsgs, item.VolaCont)
  29374. }
  29375. c.ServeSuccessJSON(map[string]interface{}{
  29376. "failed_code": -10,
  29377. "msg": errMsgs,
  29378. })
  29379. return
  29380. } else {
  29381. 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)
  29382. var dat map[string]interface{}
  29383. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29384. fmt.Println(dat)
  29385. } else {
  29386. fmt.Println(err)
  29387. }
  29388. saveLog(result, request_log, "2204", "上传费用明细")
  29389. userJSONBytes, _ := json.Marshal(dat)
  29390. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29391. utils.ErrorLog("解析失败:%v", err)
  29392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29393. return
  29394. }
  29395. }
  29396. } else {
  29397. c.ServeSuccessJSON(map[string]interface{}{
  29398. "failed_code": -10,
  29399. "msg": result3101.ErrMsg,
  29400. })
  29401. return
  29402. }
  29403. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29404. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29405. if result3101.Infcode == 0 {
  29406. if len(result3101.Output.Result) > 0 {
  29407. var errMsgs []string
  29408. for _, item := range result3101.Output.Result {
  29409. errMsgs = append(errMsgs, item.VolaCont)
  29410. }
  29411. c.ServeSuccessJSON(map[string]interface{}{
  29412. "failed_code": -10,
  29413. "msg": errMsgs,
  29414. })
  29415. return
  29416. } else {
  29417. 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)
  29418. var dat map[string]interface{}
  29419. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29420. fmt.Println(dat)
  29421. } else {
  29422. fmt.Println(err)
  29423. }
  29424. saveLog(result, request_log, "2204", "上传费用明细")
  29425. userJSONBytes, _ := json.Marshal(dat)
  29426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29427. utils.ErrorLog("解析失败:%v", err)
  29428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29429. return
  29430. }
  29431. }
  29432. } else {
  29433. c.ServeSuccessJSON(map[string]interface{}{
  29434. "failed_code": -10,
  29435. "msg": result3101.ErrMsg,
  29436. })
  29437. return
  29438. }
  29439. } else {
  29440. if miConfig.Code == "H15049901371" {
  29441. 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)
  29442. var dat map[string]interface{}
  29443. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29444. fmt.Println(dat)
  29445. } else {
  29446. fmt.Println(err)
  29447. }
  29448. saveLog(result, request_log, "2204", "上传费用明细")
  29449. userJSONBytes, _ := json.Marshal(dat)
  29450. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29451. utils.ErrorLog("解析失败:%v", err)
  29452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29453. return
  29454. }
  29455. res.InfRefmsgid = resFour10265.InfRefmsgid
  29456. res.Output = resFour10265.Output
  29457. res.ErrMsg = resFour10265.ErrMsg
  29458. res.Cainfo = resFour10265.Cainfo
  29459. res.WarnMsg = resFour10265.WarnMsg
  29460. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29461. res.Infcode = infocode
  29462. } else {
  29463. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" {
  29464. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29465. if result3101.Infcode == 0 {
  29466. if len(result3101.Output.Result) > 0 {
  29467. c.ServeSuccessJSON(map[string]interface{}{
  29468. "failed_code": -10,
  29469. "failed_type": 100,
  29470. "msg": result3101.Output.Result,
  29471. })
  29472. return
  29473. } else {
  29474. 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)
  29475. var dat map[string]interface{}
  29476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29477. fmt.Println(dat)
  29478. } else {
  29479. fmt.Println(err)
  29480. }
  29481. saveLog(result, request_log, "2204", "上传费用明细")
  29482. userJSONBytes, _ := json.Marshal(dat)
  29483. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29484. utils.ErrorLog("解析失败:%v", err)
  29485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29486. return
  29487. }
  29488. }
  29489. } else {
  29490. c.ServeSuccessJSON(map[string]interface{}{
  29491. "failed_code": -10,
  29492. "msg": result3101.ErrMsg,
  29493. })
  29494. return
  29495. }
  29496. } else {
  29497. 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)
  29498. var dat map[string]interface{}
  29499. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29500. fmt.Println(dat)
  29501. } else {
  29502. fmt.Println(err)
  29503. }
  29504. saveLog(result, request_log, "2204", "上传费用明细")
  29505. userJSONBytes, _ := json.Marshal(dat)
  29506. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29507. utils.ErrorLog("解析失败:%v", err)
  29508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29509. return
  29510. }
  29511. }
  29512. }
  29513. }
  29514. }
  29515. var total_two float64
  29516. if res.Infcode == -1 {
  29517. errlog := &models.HisOrderError{
  29518. UserOrgId: adminUser.CurrentOrgId,
  29519. Ctime: time.Now().Unix(),
  29520. Mtime: time.Now().Unix(),
  29521. Number: chrg_bchno,
  29522. ErrMsg: res.ErrMsg,
  29523. Status: 1,
  29524. PatientId: id,
  29525. RecordTime: recordDateTime,
  29526. Stage: 4,
  29527. }
  29528. service.CreateErrMsgLog(errlog)
  29529. c.ServeSuccessJSON(map[string]interface{}{
  29530. "failed_code": -10,
  29531. "msg": res.ErrMsg,
  29532. })
  29533. return
  29534. }
  29535. if res.Infcode == 0 {
  29536. order := &models.HisOrder{
  29537. UserOrgId: adminUser.CurrentOrgId,
  29538. HisPatientId: his.ID,
  29539. PatientId: his.PatientId,
  29540. SettleAccountsDate: recordDateTime,
  29541. Ctime: time.Now().Unix(),
  29542. Mtime: time.Now().Unix(),
  29543. MdtrtId: his.Number,
  29544. PsnNo: his.PsnNo,
  29545. MedType: strconv.FormatInt(reg_type, 10),
  29546. Status: 1,
  29547. Number: chrg_bchno,
  29548. Infcode: res.Infcode,
  29549. WarnMsg: res.WarnMsg,
  29550. Cainfo: res.Cainfo,
  29551. ErrMsg: res.ErrMsg,
  29552. RespondTime: res.RefmsgTime,
  29553. InfRefmsgid: res.InfRefmsgid,
  29554. OrderStatus: 1,
  29555. IsMedicineInsurance: 1,
  29556. SettleType: settle_accounts_type,
  29557. SettleStartTime: start_time,
  29558. SettleEndTime: end_time,
  29559. Creator: roles.AdminUserId,
  29560. Modify: roles.AdminUserId,
  29561. PType: 2,
  29562. Diagnosis: diagnosis_id,
  29563. }
  29564. err = service.CreateOrder(order)
  29565. if err != nil {
  29566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29567. return
  29568. }
  29569. for _, item := range res.Output.Result {
  29570. temp := strings.Split(item.FeedetlSn, "-")
  29571. var advice_id int64 = 0
  29572. var project_id int64 = 0
  29573. var types int64 = 0
  29574. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29575. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29576. if temp[1] == "1" {
  29577. advice_id = id
  29578. project_id = 0
  29579. } else if temp[1] == "2" {
  29580. advice_id = 0
  29581. project_id = id
  29582. }
  29583. total_two = total_two + item.DetItemFeeSumamt
  29584. info := &models.HisOrderInfo{
  29585. OrderNumber: order.Number,
  29586. FeedetlSn: item.FeedetlSn,
  29587. UploadDate: time.Now().Unix(),
  29588. AdviceId: advice_id,
  29589. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29590. Cnt: item.Cnt,
  29591. Pric: float64(item.Pric),
  29592. PatientId: his.PatientId,
  29593. PricUplmtAmt: item.PricUplmtAmt,
  29594. SelfpayProp: item.SelfpayProp,
  29595. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29596. OverlmtAmt: item.OverlmtAmt,
  29597. PreselfpayAmt: item.PreselfpayAmt,
  29598. BasMednFlag: item.BasMednFlag,
  29599. MedChrgitmType: item.MedChrgitmType,
  29600. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29601. Status: 1,
  29602. Memo: item.Memo,
  29603. Mtime: time.Now().Unix(),
  29604. InscpScpAmt: item.InscpScpAmt,
  29605. DrtReimFlag: item.DrtReimFlag,
  29606. Ctime: time.Now().Unix(),
  29607. ListSpItemFlag: item.ListSpItemFlag,
  29608. ChldMedcFlag: item.ChldMedcFlag,
  29609. LmtUsedFlag: item.LmtUsedFlag,
  29610. ChrgitmLv: item.ChrgitmLv,
  29611. UserOrgId: adminUser.CurrentOrgId,
  29612. HisPatientId: his.ID,
  29613. OrderId: order.ID,
  29614. ProjectId: project_id,
  29615. Type: types,
  29616. }
  29617. service.CreateOrderInfo(info)
  29618. }
  29619. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29620. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29621. var total float64
  29622. for _, item := range prescriptions {
  29623. if item.Type == 1 { //药品
  29624. for _, subItem := range item.HisDoctorAdviceInfo {
  29625. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29626. total_one := price * subItem.PrescribingNumber
  29627. fmt.Println("subItem")
  29628. fmt.Println(subItem.Price)
  29629. fmt.Println("price")
  29630. fmt.Println(price)
  29631. fmt.Println("total_one")
  29632. fmt.Println(total_one)
  29633. total = total + total_one
  29634. fmt.Println(total)
  29635. }
  29636. }
  29637. if item.Type == 2 { //项目
  29638. for _, subItem := range item.HisPrescriptionProject {
  29639. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29640. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29641. total_one := price * cnt
  29642. total = total + total_one
  29643. }
  29644. }
  29645. }
  29646. allTotal := fmt.Sprintf("%.2f", total)
  29647. if res.Infcode == 0 {
  29648. var rf []*ResultFive
  29649. json.Unmarshal([]byte(his.Iinfo), &rf)
  29650. chrg_bchno := chrg_bchno
  29651. cert_no := his.Certno
  29652. var insutypes []string
  29653. var insutype string
  29654. var is390 int = 0
  29655. var is310 int = 0
  29656. for _, item := range rf {
  29657. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29658. insutypes = append(insutypes, item.Insutype)
  29659. }
  29660. }
  29661. if len(insutypes) == 1 {
  29662. insutype = insutypes[0]
  29663. } else {
  29664. for _, i := range insutypes {
  29665. if i == "390" {
  29666. is390 = 1
  29667. }
  29668. if i == "310" {
  29669. is310 = 1
  29670. }
  29671. }
  29672. }
  29673. if is390 == 1 {
  29674. insutype = "390"
  29675. }
  29676. if is310 == 1 {
  29677. insutype = "310"
  29678. }
  29679. if len(insutypes) == 0 {
  29680. insutype = "390"
  29681. }
  29682. if len(insutypes) == 2 {
  29683. insutype = strconv.FormatInt(his.SocialType, 10)
  29684. }
  29685. //insutype = "390"
  29686. if his.IdCardType == 1 {
  29687. cert_no = his.MedicalInsuranceNumber
  29688. } else {
  29689. cert_no = his.Certno
  29690. }
  29691. var res ResultSeven
  29692. var ahres ResultSevenAH
  29693. var resSeven10265 ResultSeven10265
  29694. var resSeven10265Two ResultSeven10265Two
  29695. var gzresSeven10265Two GZResultSeven10265Two
  29696. if miConfig.MdtrtareaAdmvs == "421300" {
  29697. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29698. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29699. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29700. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29701. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29702. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29703. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29704. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29705. resp, requestErr := http.Get(api)
  29706. if requestErr != nil {
  29707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29708. return
  29709. }
  29710. body, ioErr := ioutil.ReadAll(resp.Body)
  29711. if ioErr != nil {
  29712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29714. return
  29715. }
  29716. var respJSON map[string]interface{}
  29717. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29720. return
  29721. }
  29722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29723. result, _ := json.Marshal(respJSON)
  29724. fmt.Println("log")
  29725. fmt.Println(string(result))
  29726. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29727. utils.ErrorLog("解析失败:%v", err)
  29728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29729. return
  29730. }
  29731. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29732. if reg_type == 11 && his.Insutype == "390" {
  29733. reg_type = 110104
  29734. }
  29735. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29736. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29737. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29738. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29739. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29740. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29741. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29742. resp, requestErr := http.Get(api)
  29743. if requestErr != nil {
  29744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29745. return
  29746. }
  29747. body, ioErr := ioutil.ReadAll(resp.Body)
  29748. if ioErr != nil {
  29749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29751. return
  29752. }
  29753. var respJSON map[string]interface{}
  29754. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29757. return
  29758. }
  29759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29760. result, _ := json.Marshal(respJSON)
  29761. fmt.Println("log")
  29762. fmt.Println(string(result))
  29763. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29764. utils.ErrorLog("解析失败:%v", err)
  29765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29766. return
  29767. }
  29768. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29769. if reg_type == 11 && his.Insutype == "390" {
  29770. reg_type = 110104
  29771. }
  29772. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29773. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29774. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29775. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29776. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29777. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29778. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29779. resp, requestErr := http.Get(api)
  29780. if requestErr != nil {
  29781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29782. return
  29783. }
  29784. body, ioErr := ioutil.ReadAll(resp.Body)
  29785. if ioErr != nil {
  29786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29788. return
  29789. }
  29790. var respJSON map[string]interface{}
  29791. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29794. return
  29795. }
  29796. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29797. result, _ := json.Marshal(respJSON)
  29798. fmt.Println("log")
  29799. fmt.Println(string(result))
  29800. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29801. utils.ErrorLog("解析失败:%v", err)
  29802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29803. return
  29804. }
  29805. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29806. if reg_type == 11 && his.Insutype == "390" {
  29807. reg_type = 110104
  29808. }
  29809. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29810. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29811. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29812. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29813. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29814. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29815. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29816. resp, requestErr := http.Get(api)
  29817. if requestErr != nil {
  29818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29819. return
  29820. }
  29821. body, ioErr := ioutil.ReadAll(resp.Body)
  29822. if ioErr != nil {
  29823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29825. return
  29826. }
  29827. var respJSON map[string]interface{}
  29828. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29831. return
  29832. }
  29833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29834. result, _ := json.Marshal(respJSON)
  29835. fmt.Println("log")
  29836. fmt.Println(string(result))
  29837. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29838. utils.ErrorLog("解析失败:%v", err)
  29839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29840. return
  29841. }
  29842. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29843. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29844. if result3101.Infcode == "0" {
  29845. if len(result3101.Output.Result) > 0 {
  29846. var errMsgs []string
  29847. for _, item := range result3101.Output.Result {
  29848. errMsgs = append(errMsgs, item.VolaCont)
  29849. }
  29850. c.ServeSuccessJSON(map[string]interface{}{
  29851. "failed_code": -10,
  29852. "msg": errMsgs,
  29853. })
  29854. return
  29855. } else {
  29856. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29857. if his.IdCardType != 4 {
  29858. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29859. bas := strings.Split(psn_info.CardInfo, "|")
  29860. if his.IdCardType == 1 {
  29861. cert_no = bas[2]
  29862. } else {
  29863. cert_no = bas[1]
  29864. }
  29865. } else {
  29866. cert_no = his.Certno
  29867. }
  29868. //江苏地区国家医保医疗类别
  29869. //职工透析:医疗类别选特殊情况门诊9933
  29870. //居民血透门慢: 医疗类别选门诊慢病1402
  29871. //var med_type string
  29872. //if his.Insutype == "310" {
  29873. // if reg_type == 14 {
  29874. // med_type = "9933"
  29875. // } else if reg_type == 11 {
  29876. // med_type = "11"
  29877. //
  29878. // }
  29879. //} else if his.Insutype == "390" {
  29880. // if reg_type == 14 {
  29881. // med_type = "1402"
  29882. // } else if reg_type == 11 {
  29883. // med_type = "11"
  29884. // }
  29885. //}
  29886. var api string
  29887. if miConfig.MdtrtareaAdmvs == "320921" {
  29888. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29889. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29890. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29891. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29892. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29893. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29894. "&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
  29895. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29896. } else {
  29897. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29898. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29899. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29900. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29901. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29902. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29903. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29904. "&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
  29905. }
  29906. resp, requestErr := http.Get(api)
  29907. if requestErr != nil {
  29908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29909. return
  29910. }
  29911. body, ioErr := ioutil.ReadAll(resp.Body)
  29912. if ioErr != nil {
  29913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29915. return
  29916. }
  29917. var respJSON map[string]interface{}
  29918. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29921. return
  29922. }
  29923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29924. result, _ := json.Marshal(respJSON)
  29925. fmt.Println("log")
  29926. fmt.Println(string(result))
  29927. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29928. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29929. utils.ErrorLog("解析失败:%v", err)
  29930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29931. return
  29932. }
  29933. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29934. res.Output = resSeven10265.Output
  29935. res.ErrMsg = resSeven10265.ErrMsg
  29936. res.Cainfo = resSeven10265.Cainfo
  29937. res.WarnMsg = resSeven10265.WarnMsg
  29938. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29939. res.Infcode = infocode
  29940. } else {
  29941. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29942. utils.ErrorLog("解析失败:%v", err)
  29943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29944. return
  29945. }
  29946. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29947. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29948. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29949. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29950. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29951. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29952. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29953. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29954. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29955. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29956. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29957. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29958. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29959. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29960. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29961. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29962. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29963. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29964. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29965. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29966. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29967. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29968. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29969. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29970. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29971. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29972. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29973. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29974. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29975. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29976. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29977. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29978. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29979. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29980. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29981. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29982. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29983. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29984. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29985. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29986. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  29987. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  29988. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  29989. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  29990. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  29991. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  29992. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  29993. res.ErrMsg = resSeven10265Two.ErrMsg
  29994. res.Cainfo = resSeven10265Two.Cainfo
  29995. res.WarnMsg = resSeven10265Two.WarnMsg
  29996. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29997. res.Infcode = infocode
  29998. }
  29999. }
  30000. }
  30001. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30002. psn_info, _ := service.GetPsnByPatientId(id)
  30003. var verify_number string
  30004. if psn_info.IdCardType == 4 {
  30005. verify_number = psn_info.VerifyNumber
  30006. } else if psn_info.IdCardType == 1 {
  30007. bas := strings.Split(psn_info.CardInfo, "|")
  30008. cardNumber := bas[2]
  30009. verify_number = cardNumber
  30010. } else {
  30011. psn_info.IdCardType = 2
  30012. verify_number = psn_info.Certno
  30013. }
  30014. var api string
  30015. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30016. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  30017. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30018. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30019. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  30020. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30021. "&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
  30022. resp, requestErr := http.Get(api)
  30023. if requestErr != nil {
  30024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30025. return
  30026. }
  30027. body, ioErr := ioutil.ReadAll(resp.Body)
  30028. if ioErr != nil {
  30029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30031. return
  30032. }
  30033. var respJSON map[string]interface{}
  30034. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30037. return
  30038. }
  30039. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30040. result, _ := json.Marshal(respJSON)
  30041. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30042. utils.ErrorLog("解析失败:%v", err)
  30043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30044. return
  30045. }
  30046. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30047. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  30048. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  30049. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30050. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  30051. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  30052. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  30053. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  30054. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  30055. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  30056. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  30057. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  30058. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  30059. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30060. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  30061. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  30062. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  30063. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  30064. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  30065. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  30066. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30067. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  30068. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  30069. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  30070. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  30071. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  30072. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  30073. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  30074. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  30075. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  30076. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  30077. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  30078. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  30079. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  30080. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30081. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  30082. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  30083. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  30084. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  30085. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  30086. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  30087. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30088. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30089. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30090. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30091. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30092. res.ErrMsg = resSeven10265.ErrMsg
  30093. res.Cainfo = resSeven10265.Cainfo
  30094. res.WarnMsg = resSeven10265.WarnMsg
  30095. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30096. res.Infcode = infocode
  30097. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30098. acct_used_flag := "1"
  30099. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30100. var result string
  30101. var request_log string
  30102. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30103. 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)
  30104. } else {
  30105. 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)
  30106. }
  30107. var dat map[string]interface{}
  30108. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30109. fmt.Println(dat)
  30110. } else {
  30111. fmt.Println(err)
  30112. }
  30113. saveLog(result, request_log, "2206", "预结算")
  30114. userJSONBytes, _ := json.Marshal(dat)
  30115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30116. utils.ErrorLog("解析失败:%v", err)
  30117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30118. return
  30119. }
  30120. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30121. var result string
  30122. var request_log string
  30123. if his.IdCardType == 2 {
  30124. insutype = strconv.FormatInt(his.SocialType, 10)
  30125. 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, "")
  30126. } else if his.IdCardType == 1 {
  30127. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30128. bas := strings.Split(psn_info.CardInfo, "|")
  30129. basNumber := bas[2]
  30130. card_sn := bas[3]
  30131. var rf []*ResultFive
  30132. json.Unmarshal([]byte(his.Iinfo), &rf)
  30133. var psn_type string
  30134. for _, item := range rf {
  30135. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30136. psn_type = item.PsnType
  30137. }
  30138. }
  30139. insutype = strconv.FormatInt(his.SocialType, 10)
  30140. 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)
  30141. } else {
  30142. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30143. //bas := strings.Split(psn_info.CardInfo, "|")
  30144. //basNumber := bas[2]
  30145. //card_sn := bas[3]
  30146. var rf []*ResultFive
  30147. json.Unmarshal([]byte(his.Iinfo), &rf)
  30148. var psn_type string
  30149. for _, item := range rf {
  30150. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30151. psn_type = item.PsnType
  30152. }
  30153. }
  30154. insutype = strconv.FormatInt(his.SocialType, 10)
  30155. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30156. 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)
  30157. }
  30158. var dat map[string]interface{}
  30159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30160. fmt.Println(dat)
  30161. } else {
  30162. fmt.Println(err)
  30163. }
  30164. saveLog(result, request_log, "2206", "预结算")
  30165. userJSONBytes, _ := json.Marshal(dat)
  30166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30167. utils.ErrorLog("解析失败:%v", err)
  30168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30169. return
  30170. }
  30171. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30172. var result string
  30173. var request_log string
  30174. if his.IdCardType == 2 {
  30175. insutype = strconv.FormatInt(his.SocialType, 10)
  30176. 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, "")
  30177. } else if his.IdCardType == 1 {
  30178. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30179. bas := strings.Split(psn_info.CardInfo, "|")
  30180. basNumber := bas[0]
  30181. card_sn := ""
  30182. var rf []*ResultFive
  30183. json.Unmarshal([]byte(his.Iinfo), &rf)
  30184. var psn_type string
  30185. for _, item := range rf {
  30186. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30187. psn_type = item.PsnType
  30188. }
  30189. }
  30190. insutype = strconv.FormatInt(his.SocialType, 10)
  30191. 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)
  30192. } else {
  30193. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30194. //bas := strings.Split(psn_info.CardInfo, "|")
  30195. //basNumber := bas[2]
  30196. //card_sn := bas[3]
  30197. var rf []*ResultFive
  30198. json.Unmarshal([]byte(his.Iinfo), &rf)
  30199. var psn_type string
  30200. for _, item := range rf {
  30201. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30202. psn_type = item.PsnType
  30203. }
  30204. }
  30205. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30206. 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)
  30207. }
  30208. var dat map[string]interface{}
  30209. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30210. fmt.Println(dat)
  30211. } else {
  30212. fmt.Println(err)
  30213. }
  30214. saveLog(result, request_log, "2206", "预结算")
  30215. userJSONBytes, _ := json.Marshal(dat)
  30216. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30217. utils.ErrorLog("解析失败:%v", err)
  30218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30219. return
  30220. }
  30221. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30222. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30223. if his.IdCardType == 4 {
  30224. psn_info.VerifyNumber = psn_info.VerifyNumber
  30225. cert_no = psn_info.VerifyNumber
  30226. } else if his.IdCardType == 2 {
  30227. cert_no = psn_info.Certno
  30228. psn_info.VerifyNumber = psn_info.Certno
  30229. } else {
  30230. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30231. bas := strings.Split(psn_info.CardInfo, "|")
  30232. if his.IdCardType == 1 {
  30233. cert_no = bas[2]
  30234. } else {
  30235. cert_no = bas[1]
  30236. }
  30237. }
  30238. var api string
  30239. var med_type string
  30240. if his.Insutype == "390" {
  30241. if reg_type == 992102 {
  30242. med_type = "992102"
  30243. }
  30244. if reg_type == 140104 {
  30245. med_type = "140104"
  30246. }
  30247. if reg_type == 140201 {
  30248. med_type = "140201"
  30249. }
  30250. if reg_type == 14 {
  30251. med_type = "140104"
  30252. }
  30253. } else if his.Insutype == "310" {
  30254. if reg_type == 992102 {
  30255. med_type = "992102"
  30256. }
  30257. if reg_type == 140104 {
  30258. med_type = "140104"
  30259. }
  30260. if reg_type == 140201 {
  30261. med_type = "140201"
  30262. }
  30263. if reg_type == 14 {
  30264. med_type = "140104"
  30265. }
  30266. }
  30267. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30268. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30269. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30270. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30271. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30272. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30273. "&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
  30274. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30275. resp, requestErr := http.Get(api)
  30276. if requestErr != nil {
  30277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30278. return
  30279. }
  30280. body, ioErr := ioutil.ReadAll(resp.Body)
  30281. if ioErr != nil {
  30282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30284. return
  30285. }
  30286. var respJSON map[string]interface{}
  30287. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30290. return
  30291. }
  30292. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30293. if status == "0" {
  30294. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30295. c.ServeSuccessJSON(map[string]interface{}{
  30296. "failed_code": -10,
  30297. "msg": err_msg,
  30298. })
  30299. return
  30300. }
  30301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30302. result, _ := json.Marshal(respJSON)
  30303. fmt.Println("log")
  30304. fmt.Println(string(result))
  30305. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30306. utils.ErrorLog("解析失败:%v", err)
  30307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30308. return
  30309. }
  30310. res.InfRefmsgid = ahres.InfRefmsgid
  30311. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30312. // 创建对应的Time类型
  30313. t := time.UnixMilli(timestamp)
  30314. // 格式化成指定的日期字符串
  30315. str := t.Format("2006-01-02 15:04:05")
  30316. res.Output.Setlinfo.SetlTime = str
  30317. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30318. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30319. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30320. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30321. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30322. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30323. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30324. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30325. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30326. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30327. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30328. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30329. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30330. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30331. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30332. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30333. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30334. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30335. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30336. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30337. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30338. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30339. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30340. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30341. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30342. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30343. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30344. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30345. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30346. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30347. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30348. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30349. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30350. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30351. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30352. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30353. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30354. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30355. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30356. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30357. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30358. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30359. //res.Output.Setldetail = ahres.Output.Setldetail
  30360. res.ErrMsg = ahres.ErrMsg
  30361. res.Cainfo = ahres.Cainfo
  30362. res.WarnMsg = ahres.WarnMsg
  30363. res.Infcode = ahres.Infcode
  30364. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30365. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30366. if his.IdCardType == 4 {
  30367. psn_info.VerifyNumber = psn_info.VerifyNumber
  30368. cert_no = psn_info.Certno
  30369. } else if his.IdCardType == 2 {
  30370. cert_no = psn_info.Certno
  30371. psn_info.VerifyNumber = psn_info.Certno
  30372. } else {
  30373. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30374. bas := strings.Split(psn_info.CardInfo, "|")
  30375. if his.IdCardType == 1 {
  30376. cert_no = bas[2]
  30377. } else {
  30378. cert_no = bas[1]
  30379. }
  30380. }
  30381. var api string
  30382. var med_type string
  30383. if his.Insutype == "390" {
  30384. if reg_type == 992102 {
  30385. med_type = "992102"
  30386. }
  30387. if reg_type == 140104 {
  30388. med_type = "140104"
  30389. }
  30390. if reg_type == 140201 {
  30391. med_type = "140201"
  30392. }
  30393. if reg_type == 14 {
  30394. med_type = "14"
  30395. }
  30396. } else if his.Insutype == "310" {
  30397. if reg_type == 992102 {
  30398. med_type = "992102"
  30399. }
  30400. if reg_type == 140104 {
  30401. med_type = "140104"
  30402. }
  30403. if reg_type == 140201 {
  30404. med_type = "140201"
  30405. }
  30406. if reg_type == 14 {
  30407. med_type = "14"
  30408. }
  30409. }
  30410. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30411. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30412. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30413. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30414. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30415. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30416. "&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
  30417. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30418. resp, requestErr := http.Get(api)
  30419. if requestErr != nil {
  30420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30421. return
  30422. }
  30423. body, ioErr := ioutil.ReadAll(resp.Body)
  30424. if ioErr != nil {
  30425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30427. return
  30428. }
  30429. var respJSON map[string]interface{}
  30430. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30433. return
  30434. }
  30435. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30436. if status == "0" {
  30437. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30438. c.ServeSuccessJSON(map[string]interface{}{
  30439. "failed_code": -10,
  30440. "msg": err_msg,
  30441. })
  30442. return
  30443. }
  30444. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30445. result, _ := json.Marshal(respJSON)
  30446. fmt.Println("log")
  30447. fmt.Println(string(result))
  30448. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30449. utils.ErrorLog("解析失败:%v", err)
  30450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30451. return
  30452. }
  30453. res.InfRefmsgid = ahres.InfRefmsgid
  30454. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30455. // 创建对应的Time类型
  30456. t := time.UnixMilli(timestamp)
  30457. // 格式化成指定的日期字符串
  30458. str := t.Format("2006-01-02 15:04:05")
  30459. res.Output.Setlinfo.SetlTime = str
  30460. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30461. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30462. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30463. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30464. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30465. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30466. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30467. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30468. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30469. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30470. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30471. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30472. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30473. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30474. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30475. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30476. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30477. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30478. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30479. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30480. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30481. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30482. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30483. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30484. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30485. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30486. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30487. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30488. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30489. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30490. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30491. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30492. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30493. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30494. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30495. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30496. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30497. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30498. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30499. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30500. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30501. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30502. //res.Output.Setldetail = ahres.Output.Setldetail
  30503. res.ErrMsg = ahres.ErrMsg
  30504. res.Cainfo = ahres.Cainfo
  30505. res.WarnMsg = ahres.WarnMsg
  30506. res.Infcode = ahres.Infcode
  30507. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30508. var result string
  30509. var request_log string
  30510. if his.IdCardType == 2 {
  30511. 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")
  30512. } else if his.IdCardType == 1 {
  30513. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30514. bas := strings.Split(psn_info.CardInfo, "|")
  30515. basNumber := bas[2]
  30516. card_sn := bas[3]
  30517. 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")
  30518. } else {
  30519. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30520. 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")
  30521. }
  30522. var dat map[string]interface{}
  30523. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30524. fmt.Println(dat)
  30525. } else {
  30526. fmt.Println(err)
  30527. }
  30528. saveLog(result, request_log, "2206", "预结算")
  30529. userJSONBytes, _ := json.Marshal(dat)
  30530. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30531. utils.ErrorLog("解析失败:%v", err)
  30532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30533. return
  30534. }
  30535. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30536. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30537. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30538. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30539. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30540. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30541. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30542. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30543. resp, requestErr := http.Get(api)
  30544. if requestErr != nil {
  30545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30546. return
  30547. }
  30548. body, ioErr := ioutil.ReadAll(resp.Body)
  30549. if ioErr != nil {
  30550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30552. return
  30553. }
  30554. var respJSON map[string]interface{}
  30555. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30558. return
  30559. }
  30560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30561. result, _ := json.Marshal(respJSON)
  30562. fmt.Println("log")
  30563. fmt.Println(string(result))
  30564. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30565. utils.ErrorLog("解析失败:%v", err)
  30566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30567. return
  30568. }
  30569. } else {
  30570. if miConfig.MdtrtareaAdmvs == "441202" {
  30571. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30572. if result3101.Infcode == 0 {
  30573. if len(result3101.Output.Result) > 0 {
  30574. c.ServeSuccessJSON(map[string]interface{}{
  30575. "failed_code": -10,
  30576. "failed_type": 100,
  30577. "msg": result3101.Output.Result,
  30578. })
  30579. return
  30580. } else {
  30581. var result string
  30582. var request_log string
  30583. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30584. allTotal = fmt.Sprintf("%.2f", total_two)
  30585. if his.IdCardType == 4 {
  30586. 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)
  30587. } else {
  30588. 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)
  30589. }
  30590. var dat map[string]interface{}
  30591. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30592. fmt.Println(dat)
  30593. } else {
  30594. fmt.Println(err)
  30595. }
  30596. saveLog(result, request_log, "2206", "预结算")
  30597. //userJSONBytes, _ := json.Marshal(dat)
  30598. //
  30599. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30600. // utils.ErrorLog("解析失败:%v", err)
  30601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30602. // return
  30603. //}
  30604. userJSONBytes, _ := json.Marshal(dat)
  30605. if miConfig.Code == "H15049901371" {
  30606. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30607. utils.ErrorLog("解析失败:%v", err)
  30608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30609. return
  30610. }
  30611. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30612. res.Output = resSeven10265.Output
  30613. res.ErrMsg = resSeven10265.ErrMsg
  30614. res.Cainfo = resSeven10265.Cainfo
  30615. res.WarnMsg = resSeven10265.WarnMsg
  30616. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30617. res.Infcode = infocode
  30618. } else {
  30619. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30620. utils.ErrorLog("解析失败:%v", err)
  30621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30622. return
  30623. }
  30624. }
  30625. }
  30626. } else {
  30627. c.ServeSuccessJSON(map[string]interface{}{
  30628. "failed_code": -10,
  30629. "msg": result3101.ErrMsg,
  30630. })
  30631. return
  30632. }
  30633. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30634. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30635. if result3101.Infcode == 0 {
  30636. if len(result3101.Output.Result) > 0 {
  30637. var errMsgs []string
  30638. for _, item := range result3101.Output.Result {
  30639. errMsgs = append(errMsgs, item.VolaCont)
  30640. }
  30641. c.ServeSuccessJSON(map[string]interface{}{
  30642. "failed_code": -10,
  30643. "msg": errMsgs,
  30644. })
  30645. return
  30646. } else {
  30647. var result string
  30648. var request_log string
  30649. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30650. allTotal = fmt.Sprintf("%.2f", total_two)
  30651. if his.IdCardType == 4 {
  30652. 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)
  30653. } else {
  30654. 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)
  30655. }
  30656. var dat map[string]interface{}
  30657. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30658. fmt.Println(dat)
  30659. } else {
  30660. fmt.Println(err)
  30661. }
  30662. saveLog(result, request_log, "2206", "预结算")
  30663. //userJSONBytes, _ := json.Marshal(dat)
  30664. //
  30665. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30666. // utils.ErrorLog("解析失败:%v", err)
  30667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30668. // return
  30669. //}
  30670. userJSONBytes, _ := json.Marshal(dat)
  30671. if miConfig.Code == "H15049901371" {
  30672. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30673. utils.ErrorLog("解析失败:%v", err)
  30674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30675. return
  30676. }
  30677. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30678. res.Output = resSeven10265.Output
  30679. res.ErrMsg = resSeven10265.ErrMsg
  30680. res.Cainfo = resSeven10265.Cainfo
  30681. res.WarnMsg = resSeven10265.WarnMsg
  30682. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30683. res.Infcode = infocode
  30684. } else {
  30685. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30686. utils.ErrorLog("解析失败:%v", err)
  30687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30688. return
  30689. }
  30690. }
  30691. }
  30692. } else {
  30693. c.ServeSuccessJSON(map[string]interface{}{
  30694. "failed_code": -10,
  30695. "msg": result3101.ErrMsg,
  30696. })
  30697. return
  30698. }
  30699. } else {
  30700. var result string
  30701. var request_log string
  30702. var dat map[string]interface{}
  30703. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30704. allTotal = fmt.Sprintf("%.2f", total_two)
  30705. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  30706. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30707. if result3101.Infcode == 0 {
  30708. if len(result3101.Output.Result) > 0 {
  30709. c.ServeSuccessJSON(map[string]interface{}{
  30710. "failed_code": -10,
  30711. "failed_type": 100,
  30712. "msg": result3101.Output.Result,
  30713. })
  30714. return
  30715. } else {
  30716. var result string
  30717. var request_log string
  30718. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30719. allTotal = fmt.Sprintf("%.2f", total_two)
  30720. if his.IdCardType == 4 {
  30721. 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)
  30722. } else {
  30723. if his.IdCardType == 2 {
  30724. cert_no = psn_info.Certno
  30725. psn_info.VerifyNumber = psn_info.Certno
  30726. } else {
  30727. bas := strings.Split(psn_info.CardInfo, "|")
  30728. cert_no = bas[2]
  30729. }
  30730. 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)
  30731. }
  30732. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30733. fmt.Println(dat)
  30734. } else {
  30735. fmt.Println(err)
  30736. }
  30737. saveLog(result, request_log, "2206", "预结算")
  30738. }
  30739. } else {
  30740. c.ServeSuccessJSON(map[string]interface{}{
  30741. "failed_code": -10,
  30742. "msg": result3101.ErrMsg,
  30743. })
  30744. return
  30745. }
  30746. } else {
  30747. if his.IdCardType == 4 {
  30748. 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)
  30749. } else {
  30750. if his.IdCardType == 2 {
  30751. cert_no = psn_info.Certno
  30752. psn_info.VerifyNumber = psn_info.Certno
  30753. } else {
  30754. bas := strings.Split(psn_info.CardInfo, "|")
  30755. cert_no = bas[2]
  30756. }
  30757. 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)
  30758. }
  30759. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30760. fmt.Println(dat)
  30761. } else {
  30762. fmt.Println(err)
  30763. }
  30764. saveLog(result, request_log, "2206", "预结算")
  30765. }
  30766. //userJSONBytes, _ := json.Marshal(dat)
  30767. //
  30768. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30769. // utils.ErrorLog("解析失败:%v", err)
  30770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30771. // return
  30772. //}
  30773. userJSONBytes, _ := json.Marshal(dat)
  30774. if miConfig.Code == "H15049901371" {
  30775. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30776. utils.ErrorLog("解析失败:%v", err)
  30777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30778. return
  30779. }
  30780. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30781. res.Output = resSeven10265.Output
  30782. res.ErrMsg = resSeven10265.ErrMsg
  30783. res.Cainfo = resSeven10265.Cainfo
  30784. res.WarnMsg = resSeven10265.WarnMsg
  30785. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30786. res.Infcode = infocode
  30787. } else {
  30788. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30789. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30790. utils.ErrorLog("解析失败:%v", err)
  30791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30792. return
  30793. }
  30794. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30795. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30796. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30797. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30798. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30799. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30800. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30801. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30802. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30803. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30804. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30805. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30806. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30807. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30808. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30809. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30810. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30811. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30812. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30813. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30814. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30815. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30816. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30817. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30818. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30819. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30820. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30821. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30822. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30823. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30824. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30825. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30826. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30827. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30828. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30829. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30830. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30831. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30832. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30833. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30834. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30835. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30836. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30837. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30838. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30839. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30840. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30841. res.Cainfo = gzresSeven10265Two.Cainfo
  30842. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30843. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30844. //res.Infcode = infocode
  30845. } else {
  30846. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30847. utils.ErrorLog("解析失败:%v", err)
  30848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30849. return
  30850. }
  30851. }
  30852. }
  30853. }
  30854. }
  30855. utils.ErrorLog("解析失败:%v", res.Infcode)
  30856. if res.Infcode == -1 {
  30857. errlog := &models.HisOrderError{
  30858. UserOrgId: adminUser.CurrentOrgId,
  30859. Ctime: time.Now().Unix(),
  30860. Mtime: time.Now().Unix(),
  30861. Number: chrg_bchno,
  30862. ErrMsg: res.ErrMsg,
  30863. Status: 1,
  30864. PatientId: id,
  30865. RecordTime: recordDateTime,
  30866. Stage: 20,
  30867. }
  30868. service.CreateErrMsgLog(errlog)
  30869. c.ServeSuccessJSON(map[string]interface{}{
  30870. "failed_code": -10,
  30871. "msg": res.ErrMsg,
  30872. })
  30873. return
  30874. }
  30875. if res.Infcode != 0 {
  30876. errlog := &models.HisOrderError{
  30877. UserOrgId: adminUser.CurrentOrgId,
  30878. Ctime: time.Now().Unix(),
  30879. Mtime: time.Now().Unix(),
  30880. Number: chrg_bchno,
  30881. ErrMsg: res.ErrMsg,
  30882. Status: 1,
  30883. PatientId: id,
  30884. RecordTime: recordDateTime,
  30885. Stage: 20,
  30886. }
  30887. service.CreateErrMsgLog(errlog)
  30888. c.ServeSuccessJSON(map[string]interface{}{
  30889. "failed_code": -10,
  30890. "msg": res.ErrMsg,
  30891. })
  30892. return
  30893. } else {
  30894. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30895. order.OrderStatus = 1
  30896. order.IsPre = 1
  30897. order.Status = 1
  30898. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30899. order.SetlId = res.Output.Setlinfo.SetlID
  30900. order.PsnNo = res.Output.Setlinfo.PsnNo
  30901. order.PsnName = res.Output.Setlinfo.PsnName
  30902. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30903. order.Certno = res.Output.Setlinfo.Certno
  30904. order.Gend = res.Output.Setlinfo.Gend
  30905. order.Naty = res.Output.Setlinfo.Naty
  30906. order.Age = res.Output.Setlinfo.Age
  30907. order.Insutype = res.Output.Setlinfo.Insutype
  30908. order.PsnType = res.Output.Setlinfo.PsnType
  30909. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30910. order.SetlTime = res.Output.Setlinfo.SetlTime
  30911. order.AcctUsedFlag = acct_used_flag
  30912. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30913. if res.Output.Setlinfo.MedType == "140101" {
  30914. order.MedType = "14"
  30915. } else {
  30916. if res.Output.Setlinfo.MedType == "110104" {
  30917. order.MedType = "11"
  30918. } else {
  30919. order.MedType = res.Output.Setlinfo.MedType
  30920. }
  30921. }
  30922. if res.Output.Setlinfo.MedType == "992102" {
  30923. order.MedType = "992102"
  30924. }
  30925. if res.Output.Setlinfo.MedType == "140104" {
  30926. order.MedType = "140104"
  30927. }
  30928. if res.Output.Setlinfo.MedType == "140201" {
  30929. order.MedType = "140201"
  30930. }
  30931. if res.Output.Setlinfo.MedType == "14" {
  30932. order.MedType = "14"
  30933. }
  30934. if reg_type == 1112 {
  30935. order.MedType = "1112"
  30936. }
  30937. if reg_type == 1111 {
  30938. order.MedType = "1111"
  30939. }
  30940. order.ClrType = res.Output.Setlinfo.ClrType
  30941. if adminUser.CurrentOrgId == 10480 {
  30942. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30943. order.ClrType = "11"
  30944. } else {
  30945. order.ClrType = "9903"
  30946. }
  30947. }
  30948. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30949. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30950. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30951. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30952. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30953. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30954. order.HifpPay = res.Output.Setlinfo.HifpPay
  30955. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30956. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30957. order.HifesPay = res.Output.Setlinfo.HifesPay
  30958. order.HifobPay = res.Output.Setlinfo.HifobPay
  30959. order.MafPay = res.Output.Setlinfo.MafPay
  30960. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30961. order.OthPay = res.Output.Setlinfo.OthPay
  30962. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30963. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30964. order.AcctPay = res.Output.Setlinfo.AcctPay
  30965. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30966. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30967. order.Balc = res.Output.Setlinfo.Balc
  30968. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30969. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30970. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30971. order.ClrWay = res.Output.Setlinfo.ClrWay
  30972. order.Creator = order.Creator
  30973. order.Modify = roles.AdminUserId
  30974. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30975. //detailStr := string(setlDetail)
  30976. //order.SetlDetail = detailStr
  30977. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30978. err = service.UpDateOrder(order)
  30979. if err == nil {
  30980. c.ServeSuccessJSON(map[string]interface{}{
  30981. "msg": "预结算成功",
  30982. })
  30983. } else {
  30984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30985. return
  30986. }
  30987. }
  30988. } else {
  30989. adminUser := c.GetAdminUserInfo()
  30990. errlog := &models.HisOrderError{
  30991. UserOrgId: adminUser.CurrentOrgId,
  30992. Ctime: time.Now().Unix(),
  30993. Mtime: time.Now().Unix(),
  30994. ErrMsg: res.ErrMsg,
  30995. Status: 1,
  30996. PatientId: id,
  30997. RecordTime: recordDateTime,
  30998. Stage: 4,
  30999. }
  31000. service.CreateErrMsgLog(errlog)
  31001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  31002. return
  31003. }
  31004. } else {
  31005. if miConfig.MdtrtareaAdmvs == "150499" {
  31006. order := &models.HisOrder{
  31007. UserOrgId: adminUser.CurrentOrgId,
  31008. HisPatientId: his.ID,
  31009. PatientId: his.PatientId,
  31010. SettleAccountsDate: recordDateTime,
  31011. Ctime: time.Now().Unix(),
  31012. Mtime: time.Now().Unix(),
  31013. MdtrtId: his.Number,
  31014. PsnNo: his.PsnNo,
  31015. MedType: strconv.FormatInt(reg_type, 10),
  31016. Status: 1,
  31017. Number: chrg_bchno,
  31018. Infcode: res.Infcode,
  31019. WarnMsg: res.WarnMsg,
  31020. Cainfo: res.Cainfo,
  31021. ErrMsg: res.ErrMsg,
  31022. RespondTime: res.RefmsgTime,
  31023. InfRefmsgid: res.InfRefmsgid,
  31024. OrderStatus: 1,
  31025. IsMedicineInsurance: 1,
  31026. SettleType: settle_accounts_type,
  31027. SettleStartTime: start_time,
  31028. SettleEndTime: end_time,
  31029. Creator: roles.AdminUserId,
  31030. Modify: roles.AdminUserId,
  31031. PType: 2,
  31032. Diagnosis: diagnosis_id,
  31033. }
  31034. err = service.CreateOrder(order)
  31035. if err != nil {
  31036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31037. return
  31038. }
  31039. }
  31040. adminUser := c.GetAdminUserInfo()
  31041. errlog := &models.HisOrderError{
  31042. UserOrgId: adminUser.CurrentOrgId,
  31043. Ctime: time.Now().Unix(),
  31044. Mtime: time.Now().Unix(),
  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. }
  31059. }
  31060. }
  31061. // 退款
  31062. func (c *HisApiController) Refund() {
  31063. order_id, _ := c.GetInt64("order_id")
  31064. admin_user_id, _ := c.GetInt64("admin_user_id")
  31065. adminUser := c.GetAdminUserInfo()
  31066. var order models.HisOrder
  31067. order, _ = service.GetHisOrderByID(order_id)
  31068. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  31069. if fapiao.ID > 0 {
  31070. c.ServeSuccessJSON(map[string]interface{}{
  31071. "failed_code": -10,
  31072. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  31073. })
  31074. return
  31075. }
  31076. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31077. if order.ID == 0 {
  31078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31079. return
  31080. }
  31081. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31082. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31083. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31084. if config.IsOpen == 1 { //对接了医保,走医保流程
  31085. var res ResultSixteen
  31086. var ahres ResultSevenAH
  31087. var resSixteen10265 ResultSixteen10265
  31088. var resSixteen10265Two ResultSixteen10265Two
  31089. var gz ResultgzSixteen10265Two
  31090. var src_resquest string
  31091. var result string
  31092. if miConfig.MdtrtareaAdmvs == "421300" {
  31093. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31094. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31095. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31096. resp3, requestErr3 := http.Get(api3)
  31097. if requestErr3 != nil {
  31098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31099. return
  31100. }
  31101. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31102. if ioErr3 != nil {
  31103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31105. return
  31106. }
  31107. var respJSON3 map[string]interface{}
  31108. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31111. return
  31112. }
  31113. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31114. userJSONBytes3, _ := json.Marshal(respJSON3)
  31115. fmt.Println("log")
  31116. fmt.Println(string(userJSONBytes3))
  31117. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31118. utils.ErrorLog("解析失败:%v", err)
  31119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31120. return
  31121. }
  31122. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31123. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31124. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31125. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31126. resp3, requestErr3 := http.Get(api3)
  31127. if requestErr3 != nil {
  31128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31129. return
  31130. }
  31131. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31132. if ioErr3 != nil {
  31133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31135. return
  31136. }
  31137. var respJSON3 map[string]interface{}
  31138. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31141. return
  31142. }
  31143. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31144. userJSONBytes3, _ := json.Marshal(respJSON3)
  31145. fmt.Println("log")
  31146. fmt.Println(string(userJSONBytes3))
  31147. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31148. utils.ErrorLog("解析失败:%v", err)
  31149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31150. return
  31151. }
  31152. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31153. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31154. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31155. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31156. resp3, requestErr3 := http.Get(api3)
  31157. if requestErr3 != nil {
  31158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31159. return
  31160. }
  31161. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31162. if ioErr3 != nil {
  31163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31165. return
  31166. }
  31167. var respJSON3 map[string]interface{}
  31168. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31171. return
  31172. }
  31173. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31174. userJSONBytes3, _ := json.Marshal(respJSON3)
  31175. fmt.Println("log")
  31176. fmt.Println(string(userJSONBytes3))
  31177. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31178. utils.ErrorLog("解析失败:%v", err)
  31179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31180. return
  31181. }
  31182. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31183. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31184. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31185. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31186. resp3, requestErr3 := http.Get(api3)
  31187. if requestErr3 != nil {
  31188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31189. return
  31190. }
  31191. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31192. if ioErr3 != nil {
  31193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31195. return
  31196. }
  31197. var respJSON3 map[string]interface{}
  31198. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31201. return
  31202. }
  31203. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31204. userJSONBytes3, _ := json.Marshal(respJSON3)
  31205. fmt.Println("log")
  31206. fmt.Println(string(userJSONBytes3))
  31207. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31208. utils.ErrorLog("解析失败:%v", err)
  31209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31210. return
  31211. }
  31212. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31213. var api3 string
  31214. if miConfig.MdtrtareaAdmvs == "320921" {
  31215. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31216. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31217. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31218. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31219. } else {
  31220. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31221. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31222. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31223. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31224. }
  31225. resp3, requestErr3 := http.Get(api3)
  31226. if requestErr3 != nil {
  31227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31228. return
  31229. }
  31230. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31231. if ioErr3 != nil {
  31232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31234. return
  31235. }
  31236. var respJSON3 map[string]interface{}
  31237. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31240. return
  31241. }
  31242. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31243. userJSONBytes3, _ := json.Marshal(respJSON3)
  31244. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31245. utils.ErrorLog("解析失败:%v", err)
  31246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31247. return
  31248. }
  31249. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31250. res.Output = resSixteen10265.Output
  31251. res.ErrMsg = resSixteen10265.ErrMsg
  31252. res.Cainfo = resSixteen10265.Cainfo
  31253. res.WarnMsg = resSixteen10265.WarnMsg
  31254. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31255. res.Infcode = infocode
  31256. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31257. var api3 string
  31258. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31259. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31260. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31261. resp3, requestErr3 := http.Get(api3)
  31262. if requestErr3 != nil {
  31263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31264. return
  31265. }
  31266. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31267. if ioErr3 != nil {
  31268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31270. return
  31271. }
  31272. var respJSON3 map[string]interface{}
  31273. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31276. return
  31277. }
  31278. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31279. userJSONBytes3, _ := json.Marshal(respJSON3)
  31280. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31281. utils.ErrorLog("解析失败:%v", err)
  31282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31283. return
  31284. }
  31285. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31286. res.Output = resSixteen10265.Output
  31287. res.ErrMsg = resSixteen10265.ErrMsg
  31288. res.Cainfo = resSixteen10265.Cainfo
  31289. res.WarnMsg = resSixteen10265.WarnMsg
  31290. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31291. res.Infcode = infocode
  31292. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31293. 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)
  31294. var dat map[string]interface{}
  31295. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31296. fmt.Println(dat)
  31297. } else {
  31298. fmt.Println(err)
  31299. }
  31300. saveLog(result, src_resquest, "2208", "退费")
  31301. userJSONBytes, _ := json.Marshal(dat)
  31302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31303. utils.ErrorLog("解析失败:%v", err)
  31304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31305. return
  31306. }
  31307. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31308. 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, "")
  31309. var dat map[string]interface{}
  31310. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31311. fmt.Println(dat)
  31312. } else {
  31313. fmt.Println(err)
  31314. }
  31315. saveLog(result, src_resquest, "2208", "退费")
  31316. userJSONBytes, _ := json.Marshal(dat)
  31317. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31318. utils.ErrorLog("解析失败:%v", err)
  31319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31320. return
  31321. }
  31322. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31323. 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, "")
  31324. var dat map[string]interface{}
  31325. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31326. fmt.Println(dat)
  31327. } else {
  31328. fmt.Println(err)
  31329. }
  31330. saveLog(result, src_resquest, "2208", "退费")
  31331. userJSONBytes, _ := json.Marshal(dat)
  31332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31333. utils.ErrorLog("解析失败:%v", err)
  31334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31335. return
  31336. }
  31337. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31338. var api3 string
  31339. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31340. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31341. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31342. resp3, requestErr3 := http.Get(api3)
  31343. if requestErr3 != nil {
  31344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31345. return
  31346. }
  31347. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31348. if ioErr3 != nil {
  31349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31351. return
  31352. }
  31353. var respJSON3 map[string]interface{}
  31354. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31357. return
  31358. }
  31359. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31360. if status == "0" {
  31361. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31362. c.ServeSuccessJSON(map[string]interface{}{
  31363. "failed_code": -10,
  31364. "msg": err_msg,
  31365. })
  31366. return
  31367. }
  31368. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31369. userJSONBytes3, _ := json.Marshal(respJSON3)
  31370. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31371. // utils.ErrorLog("解析失败:%v", err)
  31372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31373. // return
  31374. //}
  31375. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31376. utils.ErrorLog("解析失败:%v", err)
  31377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31378. return
  31379. }
  31380. res.InfRefmsgid = ahres.InfRefmsgid
  31381. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31382. // 创建对应的Time类型
  31383. t := time.UnixMilli(timestamp)
  31384. // 格式化成指定的日期字符串
  31385. str := t.Format("2006-01-02 15:04:05")
  31386. res.Output.Setlinfo.SetlTime = str
  31387. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31388. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31389. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31390. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31391. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31392. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31393. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31394. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31395. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31396. //
  31397. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31398. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31399. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31400. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31401. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31402. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31403. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31404. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31405. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31406. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31407. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31408. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31409. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31410. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31411. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31412. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31413. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31414. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31415. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31416. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31417. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31418. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31419. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31420. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31421. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31422. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31423. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31424. //res.Output.Setldetail = ahres.Output.Setldetail
  31425. res.ErrMsg = ahres.ErrMsg
  31426. res.Cainfo = ahres.Cainfo
  31427. res.WarnMsg = ahres.WarnMsg
  31428. res.Infcode = ahres.Infcode
  31429. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31430. var api3 string
  31431. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31432. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31433. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31434. resp3, requestErr3 := http.Get(api3)
  31435. if requestErr3 != nil {
  31436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31437. return
  31438. }
  31439. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31440. if ioErr3 != nil {
  31441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31443. return
  31444. }
  31445. var respJSON3 map[string]interface{}
  31446. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31449. return
  31450. }
  31451. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31452. if status == "0" {
  31453. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31454. c.ServeSuccessJSON(map[string]interface{}{
  31455. "failed_code": -10,
  31456. "msg": err_msg,
  31457. })
  31458. return
  31459. }
  31460. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31461. userJSONBytes3, _ := json.Marshal(respJSON3)
  31462. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31463. // utils.ErrorLog("解析失败:%v", err)
  31464. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31465. // return
  31466. //}
  31467. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31468. utils.ErrorLog("解析失败:%v", err)
  31469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31470. return
  31471. }
  31472. res.InfRefmsgid = ahres.InfRefmsgid
  31473. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31474. // 创建对应的Time类型
  31475. t := time.UnixMilli(timestamp)
  31476. // 格式化成指定的日期字符串
  31477. str := t.Format("2006-01-02 15:04:05")
  31478. res.Output.Setlinfo.SetlTime = str
  31479. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31480. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31481. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31482. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31483. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31484. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31485. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31486. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31487. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31488. //
  31489. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31490. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31491. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31492. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31493. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31494. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31495. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31496. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31497. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31498. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31499. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31500. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31501. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31502. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31503. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31504. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31505. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31506. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31507. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31508. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31509. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31510. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31511. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31512. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31513. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31514. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31515. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31516. //res.Output.Setldetail = ahres.Output.Setldetail
  31517. res.ErrMsg = ahres.ErrMsg
  31518. res.Cainfo = ahres.Cainfo
  31519. res.WarnMsg = ahres.WarnMsg
  31520. res.Infcode = ahres.Infcode
  31521. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31522. 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, "")
  31523. var dat map[string]interface{}
  31524. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31525. fmt.Println(dat)
  31526. } else {
  31527. fmt.Println(err)
  31528. }
  31529. saveLog(result, src_resquest, "2208", "退费")
  31530. userJSONBytes, _ := json.Marshal(dat)
  31531. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31532. utils.ErrorLog("解析失败:%v", err)
  31533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31534. return
  31535. }
  31536. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31537. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31538. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31539. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31540. resp3, requestErr3 := http.Get(api3)
  31541. if requestErr3 != nil {
  31542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31543. return
  31544. }
  31545. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31546. if ioErr3 != nil {
  31547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31549. return
  31550. }
  31551. var respJSON3 map[string]interface{}
  31552. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31555. return
  31556. }
  31557. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31558. userJSONBytes3, _ := json.Marshal(respJSON3)
  31559. fmt.Println("log")
  31560. fmt.Println(string(userJSONBytes3))
  31561. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31562. utils.ErrorLog("解析失败:%v", err)
  31563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31564. return
  31565. }
  31566. } else {
  31567. if miConfig.Code == "H15049901371" {
  31568. 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)
  31569. var dat map[string]interface{}
  31570. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31571. fmt.Println(dat)
  31572. } else {
  31573. fmt.Println(err)
  31574. }
  31575. saveLog(result, src_resquest, "2208", "退费")
  31576. if strings.Contains(result, "Post") {
  31577. res.Infcode = -1
  31578. res.ErrMsg = result
  31579. }
  31580. userJSONBytes, _ := json.Marshal(dat)
  31581. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31582. utils.ErrorLog("解析失败:%v", err)
  31583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31584. return
  31585. }
  31586. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31587. res.Output = resSixteen10265.Output
  31588. res.ErrMsg = resSixteen10265.ErrMsg
  31589. res.Cainfo = resSixteen10265.Cainfo
  31590. res.WarnMsg = resSixteen10265.WarnMsg
  31591. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31592. res.Infcode = infocode
  31593. } else {
  31594. 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)
  31595. var dat map[string]interface{}
  31596. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31597. fmt.Println(dat)
  31598. } else {
  31599. fmt.Println(err)
  31600. }
  31601. saveLog(result, src_resquest, "2208", "退费")
  31602. userJSONBytes, _ := json.Marshal(dat)
  31603. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31604. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31605. utils.ErrorLog("解析失败:%v", err)
  31606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31607. return
  31608. }
  31609. res.Infcode = gz.Infcode
  31610. } else {
  31611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31612. utils.ErrorLog("解析失败:%v", err)
  31613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31614. return
  31615. }
  31616. }
  31617. if strings.Contains(result, "Post") {
  31618. res.Infcode = -1
  31619. res.ErrMsg = result
  31620. }
  31621. }
  31622. }
  31623. if res.Infcode == -1 {
  31624. c.ServeSuccessJSON(map[string]interface{}{
  31625. "failed_code": -10,
  31626. "msg": res.ErrMsg,
  31627. })
  31628. return
  31629. }
  31630. if res.Infcode != -1 {
  31631. var res2 ResultSix
  31632. var resSix10265 ResultSix10265
  31633. if miConfig.MdtrtareaAdmvs == "421300" {
  31634. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31635. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31636. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31637. resp3, requestErr3 := http.Get(api3)
  31638. if requestErr3 != nil {
  31639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31640. return
  31641. }
  31642. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31643. if ioErr3 != nil {
  31644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31646. return
  31647. }
  31648. var respJSON3 map[string]interface{}
  31649. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31652. return
  31653. }
  31654. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31655. userJSONBytes3, _ := json.Marshal(respJSON3)
  31656. fmt.Println("log")
  31657. fmt.Println(string(userJSONBytes3))
  31658. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31659. utils.ErrorLog("解析失败:%v", err)
  31660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31661. return
  31662. }
  31663. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31664. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31665. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31666. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31667. resp3, requestErr3 := http.Get(api3)
  31668. if requestErr3 != nil {
  31669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31670. return
  31671. }
  31672. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31673. if ioErr3 != nil {
  31674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31676. return
  31677. }
  31678. var respJSON3 map[string]interface{}
  31679. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31682. return
  31683. }
  31684. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31685. userJSONBytes3, _ := json.Marshal(respJSON3)
  31686. fmt.Println("log")
  31687. fmt.Println(string(userJSONBytes3))
  31688. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31689. utils.ErrorLog("解析失败:%v", err)
  31690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31691. return
  31692. }
  31693. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31694. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31695. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31696. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31697. resp3, requestErr3 := http.Get(api3)
  31698. if requestErr3 != nil {
  31699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31700. return
  31701. }
  31702. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31703. if ioErr3 != nil {
  31704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31706. return
  31707. }
  31708. var respJSON3 map[string]interface{}
  31709. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31712. return
  31713. }
  31714. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31715. userJSONBytes3, _ := json.Marshal(respJSON3)
  31716. fmt.Println("log")
  31717. fmt.Println(string(userJSONBytes3))
  31718. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31719. utils.ErrorLog("解析失败:%v", err)
  31720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31721. return
  31722. }
  31723. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31724. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31725. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31726. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31727. resp3, requestErr3 := http.Get(api3)
  31728. if requestErr3 != nil {
  31729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31730. return
  31731. }
  31732. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31733. if ioErr3 != nil {
  31734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31736. return
  31737. }
  31738. var respJSON3 map[string]interface{}
  31739. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31742. return
  31743. }
  31744. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31745. userJSONBytes3, _ := json.Marshal(respJSON3)
  31746. fmt.Println("log")
  31747. fmt.Println(string(userJSONBytes3))
  31748. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31749. utils.ErrorLog("解析失败:%v", err)
  31750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31751. return
  31752. }
  31753. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31754. var api3 string
  31755. if miConfig.MdtrtareaAdmvs == "320921" {
  31756. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31757. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31758. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31759. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31760. } else {
  31761. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31762. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31763. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31764. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31765. }
  31766. resp3, requestErr3 := http.Get(api3)
  31767. if requestErr3 != nil {
  31768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31769. return
  31770. }
  31771. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31772. if ioErr3 != nil {
  31773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31775. return
  31776. }
  31777. var respJSON3 map[string]interface{}
  31778. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31781. return
  31782. }
  31783. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31784. userJSONBytes3, _ := json.Marshal(respJSON3)
  31785. fmt.Println("log")
  31786. fmt.Println(string(userJSONBytes3))
  31787. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31788. utils.ErrorLog("解析失败:%v", err)
  31789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31790. return
  31791. }
  31792. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31793. res2.Output = resSix10265.Output
  31794. res2.ErrMsg = resSix10265.ErrMsg
  31795. res2.Cainfo = resSix10265.Cainfo
  31796. res2.WarnMsg = resSix10265.WarnMsg
  31797. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31798. res2.Infcode = infocode
  31799. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31800. var api3 string
  31801. new_chrg_bchno := order.Number
  31802. if adminUser.CurrentOrgId == 10265 {
  31803. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31804. new_chrg_bchno = "0000"
  31805. }
  31806. }
  31807. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31808. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31809. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31810. resp3, requestErr3 := http.Get(api3)
  31811. if requestErr3 != nil {
  31812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31813. return
  31814. }
  31815. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31816. if ioErr3 != nil {
  31817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31819. return
  31820. }
  31821. var respJSON3 map[string]interface{}
  31822. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31825. return
  31826. }
  31827. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31828. userJSONBytes3, _ := json.Marshal(respJSON3)
  31829. fmt.Println("log")
  31830. fmt.Println(string(userJSONBytes3))
  31831. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31832. utils.ErrorLog("解析失败:%v", err)
  31833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31834. return
  31835. }
  31836. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31837. res2.Output = resSix10265.Output
  31838. res2.ErrMsg = resSix10265.ErrMsg
  31839. res2.Cainfo = resSix10265.Cainfo
  31840. res2.WarnMsg = resSix10265.WarnMsg
  31841. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31842. res2.Infcode = infocode
  31843. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31844. 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)
  31845. var dat map[string]interface{}
  31846. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31847. fmt.Println(dat)
  31848. } else {
  31849. fmt.Println(err)
  31850. }
  31851. saveLog(result2, src_request, "2205", "撤销明细")
  31852. userJSONBytes, _ := json.Marshal(dat)
  31853. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31854. utils.ErrorLog("解析失败:%v", err)
  31855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31856. return
  31857. }
  31858. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31859. 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, "")
  31860. var dat map[string]interface{}
  31861. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31862. fmt.Println(dat)
  31863. } else {
  31864. fmt.Println(err)
  31865. }
  31866. saveLog(result2, src_request, "2205", "撤销明细")
  31867. userJSONBytes, _ := json.Marshal(dat)
  31868. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31869. utils.ErrorLog("解析失败:%v", err)
  31870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31871. return
  31872. }
  31873. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31874. 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, "")
  31875. var dat map[string]interface{}
  31876. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31877. fmt.Println(dat)
  31878. } else {
  31879. fmt.Println(err)
  31880. }
  31881. saveLog(result2, src_request, "2205", "撤销明细")
  31882. userJSONBytes, _ := json.Marshal(dat)
  31883. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31884. utils.ErrorLog("解析失败:%v", err)
  31885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31886. return
  31887. }
  31888. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31889. var api3 string
  31890. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31891. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31892. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31893. resp3, requestErr3 := http.Get(api3)
  31894. if requestErr3 != nil {
  31895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31896. return
  31897. }
  31898. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31899. if ioErr3 != nil {
  31900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31902. return
  31903. }
  31904. var respJSON3 map[string]interface{}
  31905. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31908. return
  31909. }
  31910. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31911. if status == "0" {
  31912. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31913. c.ServeSuccessJSON(map[string]interface{}{
  31914. "failed_code": -10,
  31915. "msg": err_msg,
  31916. })
  31917. return
  31918. }
  31919. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31920. userJSONBytes3, _ := json.Marshal(respJSON3)
  31921. fmt.Println("log")
  31922. fmt.Println(string(userJSONBytes3))
  31923. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31924. utils.ErrorLog("解析失败:%v", err)
  31925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31926. return
  31927. }
  31928. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31929. 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, "")
  31930. var dat map[string]interface{}
  31931. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31932. fmt.Println(dat)
  31933. } else {
  31934. fmt.Println(err)
  31935. }
  31936. saveLog(result2, src_request, "2205", "撤销明细")
  31937. userJSONBytes, _ := json.Marshal(dat)
  31938. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31939. utils.ErrorLog("解析失败:%v", err)
  31940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31941. return
  31942. }
  31943. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31944. 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, "")
  31945. var dat map[string]interface{}
  31946. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31947. fmt.Println(dat)
  31948. } else {
  31949. fmt.Println(err)
  31950. }
  31951. saveLog(result2, src_request, "2205", "撤销明细")
  31952. userJSONBytes, _ := json.Marshal(dat)
  31953. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31954. utils.ErrorLog("解析失败:%v", err)
  31955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31956. return
  31957. }
  31958. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31959. var api3 string
  31960. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31961. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31962. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31963. resp3, requestErr3 := http.Get(api3)
  31964. if requestErr3 != nil {
  31965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31966. return
  31967. }
  31968. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31969. if ioErr3 != nil {
  31970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31972. return
  31973. }
  31974. var respJSON3 map[string]interface{}
  31975. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31978. return
  31979. }
  31980. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31981. if status == "0" {
  31982. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31983. c.ServeSuccessJSON(map[string]interface{}{
  31984. "failed_code": -10,
  31985. "msg": err_msg,
  31986. })
  31987. return
  31988. }
  31989. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31990. userJSONBytes3, _ := json.Marshal(respJSON3)
  31991. fmt.Println("log")
  31992. fmt.Println(string(userJSONBytes3))
  31993. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31994. utils.ErrorLog("解析失败:%v", err)
  31995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31996. return
  31997. }
  31998. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31999. 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, "")
  32000. var dat map[string]interface{}
  32001. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32002. fmt.Println(dat)
  32003. } else {
  32004. fmt.Println(err)
  32005. }
  32006. saveLog(result2, src_request, "2205", "撤销明细")
  32007. userJSONBytes, _ := json.Marshal(dat)
  32008. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32009. utils.ErrorLog("解析失败:%v", err)
  32010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32011. return
  32012. }
  32013. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32014. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  32015. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32016. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32017. resp3, requestErr3 := http.Get(api3)
  32018. if requestErr3 != nil {
  32019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32020. return
  32021. }
  32022. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32023. if ioErr3 != nil {
  32024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32026. return
  32027. }
  32028. var respJSON3 map[string]interface{}
  32029. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32032. return
  32033. }
  32034. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32035. userJSONBytes3, _ := json.Marshal(respJSON3)
  32036. fmt.Println("log")
  32037. fmt.Println(string(userJSONBytes3))
  32038. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32039. utils.ErrorLog("解析失败:%v", err)
  32040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32041. return
  32042. }
  32043. } else {
  32044. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32045. res2.Infcode = 0
  32046. } else {
  32047. 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)
  32048. var dat map[string]interface{}
  32049. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32050. fmt.Println(dat)
  32051. } else {
  32052. fmt.Println(err)
  32053. }
  32054. saveLog(result2, src_request, "2205", "撤销明细")
  32055. userJSONBytes, _ := json.Marshal(dat)
  32056. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32057. utils.ErrorLog("解析失败:%v", err)
  32058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32059. return
  32060. }
  32061. }
  32062. }
  32063. if res2.Infcode == -1 {
  32064. c.ServeSuccessJSON(map[string]interface{}{
  32065. "failed_code": -10,
  32066. "msg": res2.ErrMsg,
  32067. })
  32068. return
  32069. }
  32070. if res2.Infcode == 0 {
  32071. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  32072. if err == nil {
  32073. //当押金不为零时产生退费记录
  32074. if order.Decimal != 0 {
  32075. tmp := strconv.FormatInt(order.ID, 10)
  32076. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  32077. if err != nil {
  32078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32079. return
  32080. }
  32081. }
  32082. c.ServeSuccessJSON(map[string]interface{}{
  32083. "msg": "退费成功",
  32084. })
  32085. } else {
  32086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32087. return
  32088. }
  32089. } else {
  32090. c.ServeSuccessJSON(map[string]interface{}{
  32091. "failed_code": -10,
  32092. "msg": res2.ErrMsg,
  32093. })
  32094. }
  32095. } else {
  32096. c.ServeSuccessJSON(map[string]interface{}{
  32097. "failed_code": -10,
  32098. "msg": res.ErrMsg,
  32099. })
  32100. }
  32101. }
  32102. }
  32103. func (c *HisApiController) RefundNumber() {
  32104. record_time := c.GetString("record_time")
  32105. //patient_id, _ := c.GetInt64("patient_id")
  32106. admin_user_id, _ := c.GetInt64("admin_user_id")
  32107. his_patient_id, _ := c.GetInt64("id")
  32108. timeLayout := "2006-01-02"
  32109. loc, _ := time.LoadLocation("Local")
  32110. adminUser := c.GetAdminUserInfo()
  32111. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32112. fmt.Println(err)
  32113. if err != nil {
  32114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32115. return
  32116. }
  32117. recordDateTime := theTime.Unix()
  32118. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32119. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32120. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32121. //order, _ := service.GetHisOrderByID(order_id)
  32122. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32123. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32124. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32125. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32126. if count > 0 {
  32127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32128. return
  32129. }
  32130. if config.IsOpen == 1 { //对接了医保,走医保流程
  32131. var res2 ResultSix
  32132. var res3 GZResultSix
  32133. var resSix10265 ResultSix10265
  32134. if miConfig.MdtrtareaAdmvs == "421300" {
  32135. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32136. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32137. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32138. resp3, requestErr3 := http.Get(api3)
  32139. if requestErr3 != nil {
  32140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32141. return
  32142. }
  32143. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32144. if ioErr3 != nil {
  32145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32147. return
  32148. }
  32149. var respJSON3 map[string]interface{}
  32150. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32153. return
  32154. }
  32155. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32156. userJSONBytes3, _ := json.Marshal(respJSON3)
  32157. fmt.Println("log")
  32158. fmt.Println(string(userJSONBytes3))
  32159. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32160. utils.ErrorLog("解析失败:%v", err)
  32161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32162. return
  32163. }
  32164. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32165. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32166. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32167. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32168. resp3, requestErr3 := http.Get(api3)
  32169. if requestErr3 != nil {
  32170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32171. return
  32172. }
  32173. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32174. if ioErr3 != nil {
  32175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32177. return
  32178. }
  32179. var respJSON3 map[string]interface{}
  32180. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32183. return
  32184. }
  32185. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32186. userJSONBytes3, _ := json.Marshal(respJSON3)
  32187. fmt.Println("log")
  32188. fmt.Println(string(userJSONBytes3))
  32189. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32190. utils.ErrorLog("解析失败:%v", err)
  32191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32192. return
  32193. }
  32194. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32195. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32196. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32197. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32198. resp3, requestErr3 := http.Get(api3)
  32199. if requestErr3 != nil {
  32200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32201. return
  32202. }
  32203. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32204. if ioErr3 != nil {
  32205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32207. return
  32208. }
  32209. var respJSON3 map[string]interface{}
  32210. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32213. return
  32214. }
  32215. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32216. userJSONBytes3, _ := json.Marshal(respJSON3)
  32217. fmt.Println("log")
  32218. fmt.Println(string(userJSONBytes3))
  32219. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32220. utils.ErrorLog("解析失败:%v", err)
  32221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32222. return
  32223. }
  32224. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32225. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32226. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32227. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32228. resp3, requestErr3 := http.Get(api3)
  32229. if requestErr3 != nil {
  32230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32231. return
  32232. }
  32233. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32234. if ioErr3 != nil {
  32235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32237. return
  32238. }
  32239. var respJSON3 map[string]interface{}
  32240. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32243. return
  32244. }
  32245. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32246. userJSONBytes3, _ := json.Marshal(respJSON3)
  32247. fmt.Println("log")
  32248. fmt.Println(string(userJSONBytes3))
  32249. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32250. utils.ErrorLog("解析失败:%v", err)
  32251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32252. return
  32253. }
  32254. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32255. var api3 string
  32256. if miConfig.MdtrtareaAdmvs == "320921" {
  32257. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32258. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32259. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32260. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32261. } else {
  32262. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32263. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32264. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32265. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32266. }
  32267. resp3, requestErr3 := http.Get(api3)
  32268. if requestErr3 != nil {
  32269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32270. return
  32271. }
  32272. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32273. if ioErr3 != nil {
  32274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32276. return
  32277. }
  32278. var respJSON3 map[string]interface{}
  32279. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32282. return
  32283. }
  32284. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32285. userJSONBytes3, _ := json.Marshal(respJSON3)
  32286. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32287. utils.ErrorLog("解析失败:%v", err)
  32288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32289. return
  32290. }
  32291. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32292. res2.Output = resSix10265.Output
  32293. res2.ErrMsg = resSix10265.ErrMsg
  32294. res2.Cainfo = resSix10265.Cainfo
  32295. res2.WarnMsg = resSix10265.WarnMsg
  32296. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32297. res2.Infcode = infocode
  32298. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32299. var api3 string
  32300. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32301. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32302. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32303. resp3, requestErr3 := http.Get(api3)
  32304. if requestErr3 != nil {
  32305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32306. return
  32307. }
  32308. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32309. if ioErr3 != nil {
  32310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32312. return
  32313. }
  32314. var respJSON3 map[string]interface{}
  32315. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32318. return
  32319. }
  32320. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32321. userJSONBytes3, _ := json.Marshal(respJSON3)
  32322. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32323. utils.ErrorLog("解析失败:%v", err)
  32324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32325. return
  32326. }
  32327. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32328. res2.Output = resSix10265.Output
  32329. res2.ErrMsg = resSix10265.ErrMsg
  32330. res2.Cainfo = resSix10265.Cainfo
  32331. res2.WarnMsg = resSix10265.WarnMsg
  32332. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32333. res2.Infcode = infocode
  32334. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32335. 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)
  32336. var dat map[string]interface{}
  32337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32338. fmt.Println(dat)
  32339. } else {
  32340. fmt.Println(err)
  32341. }
  32342. saveLog(result, request, "2202", "退号")
  32343. userJSONBytes, _ := json.Marshal(dat)
  32344. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32345. utils.ErrorLog("解析失败:%v", err)
  32346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32347. return
  32348. }
  32349. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32350. 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, "")
  32351. var dat map[string]interface{}
  32352. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32353. fmt.Println(dat)
  32354. } else {
  32355. fmt.Println(err)
  32356. }
  32357. saveLog(result, request, "2202", "退号")
  32358. userJSONBytes, _ := json.Marshal(dat)
  32359. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32360. utils.ErrorLog("解析失败:%v", err)
  32361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32362. return
  32363. }
  32364. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32365. 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, "")
  32366. var dat map[string]interface{}
  32367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32368. fmt.Println(dat)
  32369. } else {
  32370. fmt.Println(err)
  32371. }
  32372. saveLog(result, request, "2202", "退号")
  32373. userJSONBytes, _ := json.Marshal(dat)
  32374. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32375. utils.ErrorLog("解析失败:%v", err)
  32376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32377. return
  32378. }
  32379. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32380. var api3 string
  32381. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32382. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32383. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32384. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32385. resp3, requestErr3 := http.Get(api3)
  32386. if requestErr3 != nil {
  32387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32388. return
  32389. }
  32390. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32391. if ioErr3 != nil {
  32392. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32394. return
  32395. }
  32396. var respJSON3 map[string]interface{}
  32397. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32400. return
  32401. }
  32402. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32403. if status == "0" {
  32404. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32405. c.ServeSuccessJSON(map[string]interface{}{
  32406. "failed_code": -10,
  32407. "msg": err_msg,
  32408. })
  32409. return
  32410. }
  32411. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32412. userJSONBytes3, _ := json.Marshal(respJSON3)
  32413. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32414. utils.ErrorLog("解析失败:%v", err)
  32415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32416. return
  32417. }
  32418. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32419. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32420. var api3 string
  32421. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32422. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32423. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32424. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32425. resp3, requestErr3 := http.Get(api3)
  32426. if requestErr3 != nil {
  32427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32428. return
  32429. }
  32430. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32431. if ioErr3 != nil {
  32432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32434. return
  32435. }
  32436. var respJSON3 map[string]interface{}
  32437. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32440. return
  32441. }
  32442. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32443. if status == "0" {
  32444. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32445. c.ServeSuccessJSON(map[string]interface{}{
  32446. "failed_code": -10,
  32447. "msg": err_msg,
  32448. })
  32449. return
  32450. }
  32451. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32452. userJSONBytes3, _ := json.Marshal(respJSON3)
  32453. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32454. utils.ErrorLog("解析失败:%v", err)
  32455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32456. return
  32457. }
  32458. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32459. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32460. 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, "")
  32461. var dat map[string]interface{}
  32462. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32463. fmt.Println(dat)
  32464. } else {
  32465. fmt.Println(err)
  32466. }
  32467. saveLog(result, request, "2202", "退号")
  32468. userJSONBytes, _ := json.Marshal(dat)
  32469. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32470. utils.ErrorLog("解析失败:%v", err)
  32471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32472. return
  32473. }
  32474. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32475. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32476. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32477. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32478. resp3, requestErr3 := http.Get(api3)
  32479. if requestErr3 != nil {
  32480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32481. return
  32482. }
  32483. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32484. if ioErr3 != nil {
  32485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32487. return
  32488. }
  32489. var respJSON3 map[string]interface{}
  32490. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32493. return
  32494. }
  32495. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32496. userJSONBytes3, _ := json.Marshal(respJSON3)
  32497. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32498. utils.ErrorLog("解析失败:%v", err)
  32499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32500. return
  32501. }
  32502. } else {
  32503. var api3 string
  32504. if miConfig.Code == "H15049901371" {
  32505. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32506. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32507. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32508. } else {
  32509. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32510. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32511. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32512. }
  32513. resp3, requestErr3 := http.Get(api3)
  32514. if requestErr3 != nil {
  32515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32516. return
  32517. }
  32518. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32519. if ioErr3 != nil {
  32520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32522. return
  32523. }
  32524. var respJSON3 map[string]interface{}
  32525. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32528. return
  32529. }
  32530. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32531. userJSONBytes3, _ := json.Marshal(respJSON3)
  32532. if miConfig.Code == "H15049901371" {
  32533. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32534. utils.ErrorLog("解析失败:%v", err)
  32535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32536. return
  32537. }
  32538. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32539. res2.Output = resSix10265.Output
  32540. res2.ErrMsg = resSix10265.ErrMsg
  32541. res2.Cainfo = resSix10265.Cainfo
  32542. res2.WarnMsg = resSix10265.WarnMsg
  32543. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32544. res2.Infcode = infocode
  32545. } else {
  32546. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32547. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32548. utils.ErrorLog("解析失败:%v", err)
  32549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32550. return
  32551. }
  32552. res2.Infcode = res3.Infcode
  32553. } else {
  32554. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32555. utils.ErrorLog("解析失败:%v", err)
  32556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32557. return
  32558. }
  32559. }
  32560. }
  32561. }
  32562. if res2.Infcode == -1 {
  32563. c.ServeSuccessJSON(map[string]interface{}{
  32564. "failed_code": -10,
  32565. "msg": res2.ErrMsg,
  32566. })
  32567. return
  32568. }
  32569. if res2.Infcode == 0 {
  32570. if err == nil {
  32571. c.ServeSuccessJSON(map[string]interface{}{
  32572. "msg": "退号成功",
  32573. })
  32574. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32575. } else {
  32576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32577. return
  32578. }
  32579. }
  32580. } else {
  32581. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32582. //if err == nil {
  32583. // c.ServeSuccessJSON(map[string]interface{}{
  32584. // "msg": "退费成功",
  32585. // })
  32586. //} else {
  32587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32588. // return
  32589. //}
  32590. }
  32591. }
  32592. func (c *HisApiController) RefundDetail() {
  32593. order_id, _ := c.GetInt64("order_id")
  32594. admin_user_id, _ := c.GetInt64("admin_user_id")
  32595. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32596. number := c.GetString("number")
  32597. record_time := c.GetString("record_time")
  32598. patient_id, _ := c.GetInt64("patient_id")
  32599. //med_type, _ := c.GetInt64("med_type")
  32600. timeLayout := "2006-01-02"
  32601. loc, _ := time.LoadLocation("Local")
  32602. adminUser := c.GetAdminUserInfo()
  32603. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32604. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32605. fmt.Println(err)
  32606. if err != nil {
  32607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32608. return
  32609. }
  32610. recordDateTime := theTime.Unix()
  32611. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32612. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32613. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32614. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32615. var order models.HisOrder
  32616. order, _ = service.GetHisOrderByID(order_id)
  32617. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32618. if config.IsOpen == 1 { //对接了医保,走医保流程
  32619. var res2 ResultSix
  32620. if miConfig.MdtrtareaAdmvs == "421300" {
  32621. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32622. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32623. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32624. resp3, requestErr3 := http.Get(api3)
  32625. if requestErr3 != nil {
  32626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32627. return
  32628. }
  32629. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32630. if ioErr3 != nil {
  32631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32633. return
  32634. }
  32635. var respJSON3 map[string]interface{}
  32636. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32639. return
  32640. }
  32641. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32642. userJSONBytes3, _ := json.Marshal(respJSON3)
  32643. fmt.Println("log")
  32644. fmt.Println(string(userJSONBytes3))
  32645. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32646. utils.ErrorLog("解析失败:%v", err)
  32647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32648. return
  32649. }
  32650. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32651. if err == nil {
  32652. c.ServeSuccessJSON(map[string]interface{}{
  32653. "msg": "撤销明细成功",
  32654. })
  32655. return
  32656. } else {
  32657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32658. return
  32659. }
  32660. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32661. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32662. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32663. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32664. resp3, requestErr3 := http.Get(api3)
  32665. if requestErr3 != nil {
  32666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32667. return
  32668. }
  32669. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32670. if ioErr3 != nil {
  32671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32673. return
  32674. }
  32675. var respJSON3 map[string]interface{}
  32676. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32679. return
  32680. }
  32681. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32682. userJSONBytes3, _ := json.Marshal(respJSON3)
  32683. fmt.Println("log")
  32684. fmt.Println(string(userJSONBytes3))
  32685. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32686. utils.ErrorLog("解析失败:%v", err)
  32687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32688. return
  32689. }
  32690. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32691. if err == nil {
  32692. c.ServeSuccessJSON(map[string]interface{}{
  32693. "msg": "撤销明细成功",
  32694. })
  32695. return
  32696. } else {
  32697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32698. return
  32699. }
  32700. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32701. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32702. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32703. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32704. resp3, requestErr3 := http.Get(api3)
  32705. if requestErr3 != nil {
  32706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32707. return
  32708. }
  32709. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32710. if ioErr3 != nil {
  32711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32713. return
  32714. }
  32715. var respJSON3 map[string]interface{}
  32716. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32719. return
  32720. }
  32721. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32722. userJSONBytes3, _ := json.Marshal(respJSON3)
  32723. fmt.Println("log")
  32724. fmt.Println(string(userJSONBytes3))
  32725. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32726. utils.ErrorLog("解析失败:%v", err)
  32727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32728. return
  32729. }
  32730. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32731. if err == nil {
  32732. c.ServeSuccessJSON(map[string]interface{}{
  32733. "msg": "撤销明细成功",
  32734. })
  32735. return
  32736. } else {
  32737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32738. return
  32739. }
  32740. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32741. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32742. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32743. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32744. resp3, requestErr3 := http.Get(api3)
  32745. if requestErr3 != nil {
  32746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32747. return
  32748. }
  32749. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32750. if ioErr3 != nil {
  32751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32753. return
  32754. }
  32755. var respJSON3 map[string]interface{}
  32756. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32759. return
  32760. }
  32761. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32762. userJSONBytes3, _ := json.Marshal(respJSON3)
  32763. fmt.Println("log")
  32764. fmt.Println(string(userJSONBytes3))
  32765. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32766. utils.ErrorLog("解析失败:%v", err)
  32767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32768. return
  32769. }
  32770. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32771. if err == nil {
  32772. c.ServeSuccessJSON(map[string]interface{}{
  32773. "msg": "撤销明细成功",
  32774. })
  32775. return
  32776. } else {
  32777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32778. return
  32779. }
  32780. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32781. var resSix10265 ResultSix10265
  32782. var api3 string
  32783. if miConfig.MdtrtareaAdmvs == "320921" {
  32784. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32785. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32786. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32787. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32788. } else {
  32789. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32790. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32791. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32792. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32793. }
  32794. resp3, requestErr3 := http.Get(api3)
  32795. utils.ErrorLog("接口: %v", requestErr3)
  32796. if requestErr3 != nil {
  32797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32798. return
  32799. }
  32800. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32801. if ioErr3 != nil {
  32802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32804. return
  32805. }
  32806. var respJSON3 map[string]interface{}
  32807. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32810. return
  32811. }
  32812. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32813. userJSONBytes3, _ := json.Marshal(respJSON3)
  32814. fmt.Println("log")
  32815. fmt.Println(string(userJSONBytes3))
  32816. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32817. utils.ErrorLog("解析失败:%v", err)
  32818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32819. return
  32820. }
  32821. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32822. res2.Output = resSix10265.Output
  32823. res2.ErrMsg = resSix10265.ErrMsg
  32824. res2.Cainfo = resSix10265.Cainfo
  32825. res2.WarnMsg = resSix10265.WarnMsg
  32826. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32827. res2.Infcode = infocode
  32828. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32829. if err == nil {
  32830. c.ServeSuccessJSON(map[string]interface{}{
  32831. "msg": "撤销明细成功",
  32832. })
  32833. return
  32834. } else {
  32835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32836. return
  32837. }
  32838. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32839. var api3 string
  32840. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32841. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32842. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32843. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32844. resp3, requestErr3 := http.Get(api3)
  32845. utils.ErrorLog("接口: %v", requestErr3)
  32846. if requestErr3 != nil {
  32847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32848. return
  32849. }
  32850. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32851. if ioErr3 != nil {
  32852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32854. return
  32855. }
  32856. var respJSON3 map[string]interface{}
  32857. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32860. return
  32861. }
  32862. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32863. if status == "0" {
  32864. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32865. c.ServeSuccessJSON(map[string]interface{}{
  32866. "failed_code": -10,
  32867. "msg": err_msg,
  32868. })
  32869. return
  32870. }
  32871. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32872. userJSONBytes3, _ := json.Marshal(respJSON3)
  32873. fmt.Println("log")
  32874. fmt.Println(string(userJSONBytes3))
  32875. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32876. utils.ErrorLog("解析失败:%v", err)
  32877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32878. return
  32879. }
  32880. fmt.Println(res2.Infcode)
  32881. if res2.Infcode == -1 {
  32882. c.ServeSuccessJSON(map[string]interface{}{
  32883. "failed_code": -10,
  32884. "msg": res2.ErrMsg,
  32885. })
  32886. return
  32887. }
  32888. if res2.Infcode == 0 {
  32889. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32890. if err == nil {
  32891. c.ServeSuccessJSON(map[string]interface{}{
  32892. "msg": "撤销明细成功",
  32893. })
  32894. return
  32895. } else {
  32896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32897. return
  32898. }
  32899. } else {
  32900. c.ServeSuccessJSON(map[string]interface{}{
  32901. "failed_code": -10,
  32902. "msg": res2.ErrMsg,
  32903. })
  32904. }
  32905. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32906. if err == nil {
  32907. c.ServeSuccessJSON(map[string]interface{}{
  32908. "msg": "撤销明细成功",
  32909. })
  32910. return
  32911. } else {
  32912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32913. return
  32914. }
  32915. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32916. var api3 string
  32917. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32918. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32919. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32920. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32921. resp3, requestErr3 := http.Get(api3)
  32922. utils.ErrorLog("接口: %v", requestErr3)
  32923. if requestErr3 != nil {
  32924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32925. return
  32926. }
  32927. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32928. if ioErr3 != nil {
  32929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32931. return
  32932. }
  32933. var respJSON3 map[string]interface{}
  32934. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32937. return
  32938. }
  32939. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32940. if status == "0" {
  32941. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32942. c.ServeSuccessJSON(map[string]interface{}{
  32943. "failed_code": -10,
  32944. "msg": err_msg,
  32945. })
  32946. return
  32947. }
  32948. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32949. userJSONBytes3, _ := json.Marshal(respJSON3)
  32950. fmt.Println("log")
  32951. fmt.Println(string(userJSONBytes3))
  32952. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32953. utils.ErrorLog("解析失败:%v", err)
  32954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32955. return
  32956. }
  32957. fmt.Println(res2.Infcode)
  32958. if res2.Infcode == -1 {
  32959. c.ServeSuccessJSON(map[string]interface{}{
  32960. "failed_code": -10,
  32961. "msg": res2.ErrMsg,
  32962. })
  32963. return
  32964. }
  32965. if res2.Infcode == 0 {
  32966. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32967. if err == nil {
  32968. c.ServeSuccessJSON(map[string]interface{}{
  32969. "msg": "撤销明细成功",
  32970. })
  32971. return
  32972. } else {
  32973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32974. return
  32975. }
  32976. } else {
  32977. c.ServeSuccessJSON(map[string]interface{}{
  32978. "failed_code": -10,
  32979. "msg": res2.ErrMsg,
  32980. })
  32981. }
  32982. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32983. if err == nil {
  32984. c.ServeSuccessJSON(map[string]interface{}{
  32985. "msg": "撤销明细成功",
  32986. })
  32987. return
  32988. } else {
  32989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32990. return
  32991. }
  32992. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32993. var resSix10265 ResultSix10265
  32994. new_chrg_bchno := order.Number
  32995. if adminUser.CurrentOrgId == 10265 {
  32996. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32997. new_chrg_bchno = "0000"
  32998. }
  32999. }
  33000. var api3 string
  33001. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33002. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33003. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33004. resp3, requestErr3 := http.Get(api3)
  33005. if requestErr3 != nil {
  33006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33007. return
  33008. }
  33009. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33010. if ioErr3 != nil {
  33011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33013. return
  33014. }
  33015. var respJSON3 map[string]interface{}
  33016. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33019. return
  33020. }
  33021. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33022. userJSONBytes3, _ := json.Marshal(respJSON3)
  33023. fmt.Println("log")
  33024. fmt.Println(string(userJSONBytes3))
  33025. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33026. utils.ErrorLog("解析失败:%v", err)
  33027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33028. return
  33029. }
  33030. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33031. res2.Output = resSix10265.Output
  33032. res2.ErrMsg = resSix10265.ErrMsg
  33033. res2.Cainfo = resSix10265.Cainfo
  33034. res2.WarnMsg = resSix10265.WarnMsg
  33035. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33036. res2.Infcode = infocode
  33037. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33038. if err == nil {
  33039. c.ServeSuccessJSON(map[string]interface{}{
  33040. "msg": "撤销明细成功",
  33041. })
  33042. return
  33043. } else {
  33044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33045. return
  33046. }
  33047. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33048. 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)
  33049. var dat map[string]interface{}
  33050. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33051. fmt.Println(dat)
  33052. } else {
  33053. fmt.Println(err)
  33054. }
  33055. saveLog(result2, src_request, "2205", "撤销明细")
  33056. userJSONBytes, _ := json.Marshal(dat)
  33057. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33058. utils.ErrorLog("解析失败:%v", err)
  33059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33060. return
  33061. }
  33062. if res2.Infcode == 0 {
  33063. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33064. if err == nil {
  33065. c.ServeSuccessJSON(map[string]interface{}{
  33066. "msg": "撤销明细成功",
  33067. })
  33068. return
  33069. } else {
  33070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33071. return
  33072. }
  33073. } else {
  33074. c.ServeSuccessJSON(map[string]interface{}{
  33075. "failed_code": -10,
  33076. "msg": res2.ErrMsg,
  33077. })
  33078. }
  33079. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33080. 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, "")
  33081. var dat map[string]interface{}
  33082. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33083. fmt.Println(dat)
  33084. } else {
  33085. fmt.Println(err)
  33086. }
  33087. saveLog(result2, src_request, "2205", "撤销明细")
  33088. userJSONBytes, _ := json.Marshal(dat)
  33089. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33090. utils.ErrorLog("解析失败:%v", err)
  33091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33092. return
  33093. }
  33094. if res2.Infcode == 0 {
  33095. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33096. if err == nil {
  33097. c.ServeSuccessJSON(map[string]interface{}{
  33098. "msg": "撤销明细成功",
  33099. })
  33100. return
  33101. } else {
  33102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33103. return
  33104. }
  33105. } else {
  33106. c.ServeSuccessJSON(map[string]interface{}{
  33107. "failed_code": -10,
  33108. "msg": res2.ErrMsg,
  33109. })
  33110. }
  33111. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33112. 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, "")
  33113. var dat map[string]interface{}
  33114. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33115. fmt.Println(dat)
  33116. } else {
  33117. fmt.Println(err)
  33118. }
  33119. saveLog(result2, src_request, "2205", "撤销明细")
  33120. userJSONBytes, _ := json.Marshal(dat)
  33121. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33122. utils.ErrorLog("解析失败:%v", err)
  33123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33124. return
  33125. }
  33126. if res2.Infcode == 0 {
  33127. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33128. if err == nil {
  33129. c.ServeSuccessJSON(map[string]interface{}{
  33130. "msg": "撤销明细成功",
  33131. })
  33132. return
  33133. } else {
  33134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33135. return
  33136. }
  33137. } else {
  33138. c.ServeSuccessJSON(map[string]interface{}{
  33139. "failed_code": -10,
  33140. "msg": res2.ErrMsg,
  33141. })
  33142. }
  33143. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33144. 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, "")
  33145. var dat map[string]interface{}
  33146. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33147. fmt.Println(dat)
  33148. } else {
  33149. fmt.Println(err)
  33150. }
  33151. saveLog(result2, src_request, "2205", "撤销明细")
  33152. userJSONBytes, _ := json.Marshal(dat)
  33153. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33154. utils.ErrorLog("解析失败:%v", err)
  33155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33156. return
  33157. }
  33158. if res2.Infcode == 0 {
  33159. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33160. if err == nil {
  33161. c.ServeSuccessJSON(map[string]interface{}{
  33162. "msg": "撤销明细成功",
  33163. })
  33164. return
  33165. } else {
  33166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33167. return
  33168. }
  33169. } else {
  33170. c.ServeSuccessJSON(map[string]interface{}{
  33171. "failed_code": -10,
  33172. "msg": res2.ErrMsg,
  33173. })
  33174. }
  33175. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33176. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33177. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33178. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33179. resp2, requestErr2 := http.Get(api2)
  33180. if requestErr2 != nil {
  33181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33182. return
  33183. }
  33184. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33185. if ioErr2 != nil {
  33186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33188. return
  33189. }
  33190. var respJSON2 map[string]interface{}
  33191. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33194. return
  33195. }
  33196. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33197. userJSONBytes3, _ := json.Marshal(respJSON2)
  33198. fmt.Println("log")
  33199. fmt.Println(string(userJSONBytes3))
  33200. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33201. utils.ErrorLog("解析失败:%v", err)
  33202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33203. return
  33204. }
  33205. if res2.Infcode == 0 {
  33206. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33207. if err == nil {
  33208. c.ServeSuccessJSON(map[string]interface{}{
  33209. "msg": "撤销明细成功",
  33210. })
  33211. return
  33212. } else {
  33213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33214. return
  33215. }
  33216. } else {
  33217. c.ServeSuccessJSON(map[string]interface{}{
  33218. "failed_code": -10,
  33219. "msg": res2.ErrMsg,
  33220. })
  33221. }
  33222. } else {
  33223. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33224. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33225. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33226. resp2, requestErr2 := http.Get(api2)
  33227. if requestErr2 != nil {
  33228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33229. return
  33230. }
  33231. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33232. if ioErr2 != nil {
  33233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33235. return
  33236. }
  33237. var respJSON2 map[string]interface{}
  33238. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33241. return
  33242. }
  33243. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33244. userJSONBytes3, _ := json.Marshal(respJSON2)
  33245. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33246. utils.ErrorLog("解析失败:%v", err)
  33247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33248. return
  33249. }
  33250. if res2.Infcode == -1 {
  33251. c.ServeSuccessJSON(map[string]interface{}{
  33252. "failed_code": -10,
  33253. "msg": res2.ErrMsg,
  33254. })
  33255. return
  33256. } else {
  33257. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33258. if err == nil {
  33259. c.ServeSuccessJSON(map[string]interface{}{
  33260. "msg": "撤销明细成功",
  33261. })
  33262. return
  33263. } else {
  33264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33265. return
  33266. }
  33267. }
  33268. }
  33269. } else {
  33270. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33271. if err == nil {
  33272. c.ServeSuccessJSON(map[string]interface{}{
  33273. "msg": "退费成功",
  33274. })
  33275. } else {
  33276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33277. return
  33278. }
  33279. }
  33280. }
  33281. // 对账
  33282. func (c *HisApiController) GetCheckAccount() {
  33283. start_time := c.GetString("start_time")
  33284. end_time := c.GetString("end_time")
  33285. insutype := c.GetString("insutype")
  33286. clr_type := c.GetString("clr_type")
  33287. clr_org := c.GetString("clr_optins")
  33288. admin_user_id, _ := c.GetInt64("admin_user_id")
  33289. adminUser := c.GetAdminUserInfo()
  33290. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33291. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33292. if len(clr_org) == 0 {
  33293. clr_org = miConfig.InsuplcAdmdvs
  33294. }
  33295. timeLayout := "2006-01-02"
  33296. loc, _ := time.LoadLocation("Local")
  33297. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33298. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33299. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33300. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33301. fixmedins_setl_cnt := int64(len(orders))
  33302. var medfee_sumamt float64
  33303. var acct_pay float64
  33304. var fund_pay_sumamt float64
  33305. for _, item := range orders {
  33306. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33307. acct_pay = acct_pay + item.AcctPay
  33308. if miConfig.MdtrtareaAdmvs == "361025" {
  33309. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  33310. } else {
  33311. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33312. }
  33313. }
  33314. var user_name string
  33315. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33316. if role.ID == 0 {
  33317. user_name = "xxx"
  33318. } else {
  33319. user_name = role.UserName
  33320. }
  33321. var res ResultEight
  33322. var res10188 ResultEightFor10188
  33323. if config.IsOpen == 1 {
  33324. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33325. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33326. "insutype=" + insutype +
  33327. "&clr_type=" + clr_type +
  33328. "&setl_optins=" + clr_org +
  33329. "&stmt_begndate=" + start_time +
  33330. "&stm_enddate=" + end_time +
  33331. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33332. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33333. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33334. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33335. "&fixmedins_code=" + miConfig.Code +
  33336. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33337. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33338. "&secret_key=" + miConfig.SecretKey +
  33339. "&org_name=" + miConfig.OrgName +
  33340. "&doctor=" + user_name +
  33341. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33342. fmt.Println(api)
  33343. resp, requestErr := http.Get(api)
  33344. if requestErr != nil {
  33345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33346. return
  33347. }
  33348. body, ioErr := ioutil.ReadAll(resp.Body)
  33349. fmt.Println(body)
  33350. if ioErr != nil {
  33351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33353. return
  33354. }
  33355. var respJSON map[string]interface{}
  33356. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33359. return
  33360. }
  33361. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33362. userJSONBytes, _ := json.Marshal(respJSON)
  33363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33364. utils.ErrorLog("解析失败:%v", err)
  33365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33366. return
  33367. }
  33368. res.InfRefmsgid = res10188.InfRefmsgid
  33369. res.Output = res10188.Output
  33370. res.ErrMsg = res10188.ErrMsg
  33371. res.Cainfo = res10188.Cainfo
  33372. res.WarnMsg = res10188.WarnMsg
  33373. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33374. res.Infcode = infocode
  33375. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33376. if clr_type != "9903" {
  33377. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33378. }
  33379. if clr_type == "9903" {
  33380. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33381. }
  33382. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33383. "insutype=" + insutype +
  33384. "&clr_type=" + clr_type +
  33385. "&setl_optins=" + clr_org +
  33386. "&stmt_begndate=" + start_time +
  33387. "&stm_enddate=" + end_time +
  33388. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33389. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33390. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33391. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33392. "&fixmedins_code=" + miConfig.Code +
  33393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33394. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33395. "&secret_key=" + miConfig.SecretKey +
  33396. "&org_name=" + miConfig.OrgName +
  33397. "&doctor=" + user_name
  33398. resp, requestErr := http.Get(api)
  33399. if requestErr != nil {
  33400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33401. return
  33402. }
  33403. body, ioErr := ioutil.ReadAll(resp.Body)
  33404. if ioErr != nil {
  33405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33407. return
  33408. }
  33409. var respJSON map[string]interface{}
  33410. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33413. return
  33414. }
  33415. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33416. result, _ := json.Marshal(respJSON)
  33417. fmt.Println("log")
  33418. fmt.Println(string(result))
  33419. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33420. utils.ErrorLog("解析失败:%v", err)
  33421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33422. return
  33423. }
  33424. res.InfRefmsgid = res10188.InfRefmsgid
  33425. res.Output = res10188.Output
  33426. res.ErrMsg = res10188.ErrMsg
  33427. res.Cainfo = res10188.Cainfo
  33428. res.WarnMsg = res10188.WarnMsg
  33429. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33430. res.Infcode = infocode
  33431. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33432. var baseParams models.BaseParams
  33433. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33434. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33435. baseParams.SecretKey = miConfig.SecretKey
  33436. baseParams.OrgName = miConfig.OrgName
  33437. baseParams.FixmedinsCode = miConfig.Code
  33438. baseParams.EncKey = miConfig.EncKey
  33439. baseParams.AppSecret = miConfig.AppSecret
  33440. baseParams.SignKey = miConfig.SignKey
  33441. baseParams.AppID = miConfig.Code
  33442. baseParams.Doctor = role.UserName
  33443. baseParams.RequestUrl = miConfig.Url
  33444. businessParams := models.BusinessParams{
  33445. Insutype: insutype,
  33446. ClrType: clr_type,
  33447. SetlOptins: clr_org,
  33448. StmtBegndate: start_time,
  33449. StmtEnddate: end_time,
  33450. MedfeeSumamt: medfee_sumamt,
  33451. FundPaySumamt: fund_pay_sumamt,
  33452. AcctPay: acct_pay,
  33453. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33454. }
  33455. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33456. fmt.Println(requestLog)
  33457. fmt.Println(result)
  33458. fmt.Println(err_msg)
  33459. var dat map[string]interface{}
  33460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33461. fmt.Println(dat)
  33462. } else {
  33463. fmt.Println(err)
  33464. }
  33465. userJSONBytes, _ := json.Marshal(dat)
  33466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33467. utils.ErrorLog("解析失败:%v", err)
  33468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33469. return
  33470. }
  33471. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33472. var baseParams models.BaseParams
  33473. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33474. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33475. baseParams.SecretKey = miConfig.SecretKey
  33476. baseParams.OrgName = miConfig.OrgName
  33477. baseParams.FixmedinsCode = miConfig.Code
  33478. baseParams.EncKey = miConfig.EncKey
  33479. baseParams.AppSecret = miConfig.AppSecret
  33480. baseParams.SignKey = miConfig.SignKey
  33481. baseParams.AppID = miConfig.Code
  33482. baseParams.Doctor = role.UserName
  33483. baseParams.RequestUrl = miConfig.Url
  33484. baseParams.AccessKey = miConfig.AccessKey
  33485. businessParams := models.BusinessParams{
  33486. Insutype: insutype,
  33487. ClrType: clr_type,
  33488. SetlOptins: "430822",
  33489. StmtBegndate: start_time,
  33490. StmtEnddate: end_time,
  33491. MedfeeSumamt: medfee_sumamt,
  33492. FundPaySumamt: fund_pay_sumamt,
  33493. AcctPay: acct_pay,
  33494. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33495. }
  33496. 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)
  33497. fmt.Println(requestLog)
  33498. fmt.Println(result)
  33499. var dat map[string]interface{}
  33500. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33501. fmt.Println(dat)
  33502. } else {
  33503. fmt.Println(err)
  33504. }
  33505. userJSONBytes, _ := json.Marshal(dat)
  33506. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33507. utils.ErrorLog("解析失败:%v", err)
  33508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33509. return
  33510. }
  33511. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33512. var baseParams models.BaseParams
  33513. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33514. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33515. baseParams.SecretKey = miConfig.SecretKey
  33516. baseParams.OrgName = miConfig.OrgName
  33517. baseParams.FixmedinsCode = miConfig.Code
  33518. baseParams.EncKey = miConfig.EncKey
  33519. baseParams.AppSecret = miConfig.AppSecret
  33520. baseParams.SignKey = miConfig.SignKey
  33521. baseParams.AppID = miConfig.Code
  33522. baseParams.Doctor = role.UserName
  33523. baseParams.RequestUrl = miConfig.Url
  33524. businessParams := models.BusinessParams{
  33525. Insutype: insutype,
  33526. ClrType: clr_type,
  33527. SetlOptins: clr_org,
  33528. StmtBegndate: start_time,
  33529. StmtEnddate: end_time,
  33530. MedfeeSumamt: medfee_sumamt,
  33531. FundPaySumamt: fund_pay_sumamt,
  33532. AcctPay: acct_pay,
  33533. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33534. }
  33535. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33536. fmt.Println(requestLog)
  33537. fmt.Println(result)
  33538. fmt.Println(err_msg)
  33539. var dat map[string]interface{}
  33540. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33541. fmt.Println(dat)
  33542. } else {
  33543. fmt.Println(err)
  33544. }
  33545. userJSONBytes, _ := json.Marshal(dat)
  33546. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33547. utils.ErrorLog("解析失败:%v", err)
  33548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33549. return
  33550. }
  33551. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33552. if len(clr_type) == 0 {
  33553. clr_type = "11"
  33554. }
  33555. api := miConfig.Url + "gdyb/ten?" +
  33556. "insutype=" + insutype +
  33557. "&clr_type=" + clr_type +
  33558. "&setl_optins=" + clr_org +
  33559. "&stmt_begndate=" + start_time +
  33560. "&stm_enddate=" + end_time +
  33561. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33562. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33563. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33564. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33565. "&fixmedins_code=" + miConfig.Code +
  33566. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33567. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33568. "&secret_key=" + miConfig.SecretKey +
  33569. "&org_name=" + miConfig.OrgName +
  33570. "&doctor=" + user_name
  33571. fmt.Println(api)
  33572. resp, requestErr := http.Get(api)
  33573. if requestErr != nil {
  33574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33575. return
  33576. }
  33577. body, ioErr := ioutil.ReadAll(resp.Body)
  33578. fmt.Println(body)
  33579. if ioErr != nil {
  33580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33582. return
  33583. }
  33584. var respJSON map[string]interface{}
  33585. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33588. return
  33589. }
  33590. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33591. userJSONBytes, _ := json.Marshal(respJSON)
  33592. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33593. utils.ErrorLog("解析失败:%v", err)
  33594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33595. return
  33596. }
  33597. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33598. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33599. //fixmedins_setl_cnt := int64(len(orders_two))
  33600. //var medfee_sumamt float64
  33601. //var acct_pay float64
  33602. //var fund_pay_sumamt float64
  33603. //for _, item := range orders_two {
  33604. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33605. // acct_pay = acct_pay + item.AcctPay
  33606. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33607. //}
  33608. var baseParams models.BaseParams
  33609. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33610. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33611. baseParams.SecretKey = miConfig.SecretKey
  33612. baseParams.OrgName = miConfig.OrgName
  33613. baseParams.FixmedinsCode = miConfig.Code
  33614. baseParams.EncKey = miConfig.EncKey
  33615. baseParams.AppSecret = miConfig.AppSecret
  33616. baseParams.SignKey = miConfig.SignKey
  33617. baseParams.AppID = miConfig.Code
  33618. baseParams.Doctor = role.UserName
  33619. baseParams.RequestUrl = miConfig.Url
  33620. if clr_type == "9903" {
  33621. clr_type = "9994"
  33622. }
  33623. businessParams := models.BusinessParams{
  33624. Insutype: insutype,
  33625. ClrType: clr_type,
  33626. SetlOptins: "360302",
  33627. StmtBegndate: start_time,
  33628. StmtEnddate: end_time,
  33629. MedfeeSumamt: 0,
  33630. FundPaySumamt: 0,
  33631. AcctPay: 0,
  33632. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33633. }
  33634. 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))
  33635. fmt.Println(requestLog)
  33636. fmt.Println(result)
  33637. var dat map[string]interface{}
  33638. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33639. fmt.Println(dat)
  33640. } else {
  33641. fmt.Println(err)
  33642. }
  33643. userJSONBytes, _ := json.Marshal(dat)
  33644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33645. utils.ErrorLog("解析失败:%v", err)
  33646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33647. return
  33648. }
  33649. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33650. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33651. //fixmedins_setl_cnt := int64(len(orders_two))
  33652. //var medfee_sumamt float64
  33653. //var acct_pay float64
  33654. //var fund_pay_sumamt float64
  33655. //for _, item := range orders_two {
  33656. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33657. // acct_pay = acct_pay + item.AcctPay
  33658. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33659. //}
  33660. var baseParams models.BaseParams
  33661. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33662. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33663. baseParams.SecretKey = miConfig.SecretKey
  33664. baseParams.OrgName = miConfig.OrgName
  33665. baseParams.FixmedinsCode = miConfig.Code
  33666. baseParams.EncKey = miConfig.EncKey
  33667. baseParams.AppSecret = miConfig.AppSecret
  33668. baseParams.SignKey = miConfig.SignKey
  33669. baseParams.AppID = miConfig.Code
  33670. baseParams.Doctor = role.UserName
  33671. baseParams.RequestUrl = miConfig.Url
  33672. if clr_type == "9903" {
  33673. clr_type = "9994"
  33674. }
  33675. businessParams := models.BusinessParams{
  33676. Insutype: insutype,
  33677. ClrType: clr_type,
  33678. SetlOptins: "361025",
  33679. StmtBegndate: start_time,
  33680. StmtEnddate: end_time,
  33681. MedfeeSumamt: 0,
  33682. FundPaySumamt: 0,
  33683. AcctPay: 0,
  33684. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33685. }
  33686. 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))
  33687. fmt.Println(requestLog)
  33688. fmt.Println(result)
  33689. var dat map[string]interface{}
  33690. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33691. fmt.Println(dat)
  33692. } else {
  33693. fmt.Println(err)
  33694. }
  33695. userJSONBytes, _ := json.Marshal(dat)
  33696. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33697. utils.ErrorLog("解析失败:%v", err)
  33698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33699. return
  33700. }
  33701. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33702. var api string
  33703. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33704. "&clr_type=" + clr_type +
  33705. "&setl_optins=" + clr_org +
  33706. "&stmt_begndate=" + start_time +
  33707. "&stm_enddate=" + end_time +
  33708. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33709. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33710. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33711. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33712. "&fixmedins_code=" + miConfig.Code +
  33713. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33714. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33715. "&secret_key=" + miConfig.SecretKey +
  33716. "&org_name=" + miConfig.OrgName +
  33717. "&doctor=" + user_name + "&url=" + miConfig.Url
  33718. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33719. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33720. resp, requestErr := http.Get(api)
  33721. if requestErr != nil {
  33722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33723. return
  33724. }
  33725. body, ioErr := ioutil.ReadAll(resp.Body)
  33726. if ioErr != nil {
  33727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33729. return
  33730. }
  33731. var respJSON map[string]interface{}
  33732. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33735. return
  33736. }
  33737. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33738. if status == "0" {
  33739. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33740. c.ServeSuccessJSON(map[string]interface{}{
  33741. "failed_code": -10,
  33742. "msg": err_msg,
  33743. })
  33744. return
  33745. }
  33746. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33747. userJSONBytes, _ := json.Marshal(respJSON)
  33748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33749. utils.ErrorLog("解析失败:%v", err)
  33750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33751. return
  33752. }
  33753. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33754. var api string
  33755. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33756. "&clr_type=" + clr_type +
  33757. "&setl_optins=" + clr_org +
  33758. "&stmt_begndate=" + start_time +
  33759. "&stm_enddate=" + end_time +
  33760. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33761. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33762. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33763. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33764. "&fixmedins_code=" + miConfig.Code +
  33765. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33766. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33767. "&secret_key=" + miConfig.SecretKey +
  33768. "&org_name=" + miConfig.OrgName +
  33769. "&doctor=" + user_name + "&url=" + miConfig.Url
  33770. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33771. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33772. resp, requestErr := http.Get(api)
  33773. if requestErr != nil {
  33774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33775. return
  33776. }
  33777. body, ioErr := ioutil.ReadAll(resp.Body)
  33778. if ioErr != nil {
  33779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33781. return
  33782. }
  33783. var respJSON map[string]interface{}
  33784. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33787. return
  33788. }
  33789. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33790. if status == "0" {
  33791. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33792. c.ServeSuccessJSON(map[string]interface{}{
  33793. "failed_code": -10,
  33794. "msg": err_msg,
  33795. })
  33796. return
  33797. }
  33798. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33799. userJSONBytes, _ := json.Marshal(respJSON)
  33800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33801. utils.ErrorLog("解析失败:%v", err)
  33802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33803. return
  33804. }
  33805. } else {
  33806. if len(clr_type) == 0 {
  33807. clr_type = "11"
  33808. }
  33809. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33810. "insutype=" + insutype +
  33811. "&clr_type=" + clr_type +
  33812. "&setl_optins=" + clr_org +
  33813. "&stmt_begndate=" + start_time +
  33814. "&stm_enddate=" + end_time +
  33815. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33816. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33817. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33818. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33819. "&fixmedins_code=" + miConfig.Code +
  33820. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33821. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33822. "&secret_key=" + miConfig.SecretKey +
  33823. "&org_name=" + miConfig.OrgName +
  33824. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33825. fmt.Println(api)
  33826. resp, requestErr := http.Get(api)
  33827. if requestErr != nil {
  33828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33829. return
  33830. }
  33831. body, ioErr := ioutil.ReadAll(resp.Body)
  33832. fmt.Println(body)
  33833. if ioErr != nil {
  33834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33836. return
  33837. }
  33838. var respJSON map[string]interface{}
  33839. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33842. return
  33843. }
  33844. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33845. userJSONBytes, _ := json.Marshal(respJSON)
  33846. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33847. utils.ErrorLog("解析失败:%v", err)
  33848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33849. return
  33850. }
  33851. }
  33852. if res.Infcode == 0 {
  33853. if res.Output.Stmtinfo.StmtRslt == "0" {
  33854. micc := &models.MedicalInsuranceCostCompare{
  33855. StartTime: startime.Unix(),
  33856. EndTime: endtime.Unix(),
  33857. Insutype: insutype,
  33858. CheckType: 1,
  33859. Num: fixmedins_setl_cnt,
  33860. Mtime: time.Now().Unix(),
  33861. Status: 1,
  33862. UserOrgId: adminUser.CurrentOrgId,
  33863. CostTotal: medfee_sumamt,
  33864. FuncTotal: fund_pay_sumamt,
  33865. PsnPay: acct_pay,
  33866. Creator: admin_user_id,
  33867. Ctime: time.Now().Unix(),
  33868. ClrType: clr_type,
  33869. }
  33870. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33871. if err == nil {
  33872. c.ServeSuccessJSON(map[string]interface{}{
  33873. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33874. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33875. })
  33876. } else {
  33877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33878. }
  33879. } else {
  33880. c.ServeSuccessJSON(map[string]interface{}{
  33881. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33882. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33883. })
  33884. }
  33885. } else {
  33886. c.ServeSuccessJSON(map[string]interface{}{
  33887. "failed_code": -10,
  33888. "msg": res.ErrMsg,
  33889. })
  33890. }
  33891. }
  33892. }
  33893. func (c *HisApiController) Check310() {
  33894. adminUser := c.GetAdminUserInfo()
  33895. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33896. var user_name string
  33897. user_name = "高慧裕"
  33898. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33899. "insutype=" + "310" +
  33900. "&clr_type=" + "" +
  33901. "&setl_optins=" + "441202" +
  33902. "&stmt_begndate=" + "2022-03-01" +
  33903. "&stm_enddate=" + "2022-03-31" +
  33904. "&medfee_sumamt=" + "194930.12" +
  33905. "&fund_pay_sumamt=" + "188741.46" +
  33906. "&acct_pay=" + "0" +
  33907. "&fixmedins_setl_cnt=" + "452" +
  33908. "&fixmedins_code=" + miConfig.Code +
  33909. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33910. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33911. "&secret_key=" + miConfig.SecretKey +
  33912. "&org_name=" + miConfig.OrgName +
  33913. "&doctor=" + user_name
  33914. fmt.Println(api)
  33915. resp, requestErr := http.Get(api)
  33916. if requestErr != nil {
  33917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33918. return
  33919. }
  33920. body, ioErr := ioutil.ReadAll(resp.Body)
  33921. fmt.Println(body)
  33922. if ioErr != nil {
  33923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33925. return
  33926. }
  33927. var respJSON map[string]interface{}
  33928. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33931. return
  33932. }
  33933. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33934. userJSONBytes, _ := json.Marshal(respJSON)
  33935. var res ResultEight
  33936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33937. utils.ErrorLog("解析失败:%v", err)
  33938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33939. return
  33940. }
  33941. }
  33942. func (c *HisApiController) Check390() {
  33943. adminUser := c.GetAdminUserInfo()
  33944. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33945. var user_name string
  33946. user_name = "高慧裕"
  33947. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33948. "insutype=" + "390" +
  33949. "&clr_type=" + "" +
  33950. "&setl_optins=" + "441202" +
  33951. "&stmt_begndate=" + "2022-03-01" +
  33952. "&stm_enddate=" + "2022-03-31" +
  33953. "&medfee_sumamt=" + "1068448.89" +
  33954. "&fund_pay_sumamt=" + "1014677.62" +
  33955. "&acct_pay=" + "0" +
  33956. "&fixmedins_setl_cnt=" + "1950" +
  33957. "&fixmedins_code=" + miConfig.Code +
  33958. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33959. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33960. "&secret_key=" + miConfig.SecretKey +
  33961. "&org_name=" + miConfig.OrgName +
  33962. "&doctor=" + user_name
  33963. fmt.Println(api)
  33964. resp, requestErr := http.Get(api)
  33965. if requestErr != nil {
  33966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33967. return
  33968. }
  33969. body, ioErr := ioutil.ReadAll(resp.Body)
  33970. fmt.Println(body)
  33971. if ioErr != nil {
  33972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33974. return
  33975. }
  33976. var respJSON map[string]interface{}
  33977. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33980. return
  33981. }
  33982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33983. userJSONBytes, _ := json.Marshal(respJSON)
  33984. var res ResultEight
  33985. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33986. utils.ErrorLog("解析失败:%v", err)
  33987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33988. return
  33989. }
  33990. }
  33991. // 对账明细
  33992. func (c *HisApiController) GetCheckDetailAccount() {
  33993. start_time := c.GetString("start_time")
  33994. end_time := c.GetString("end_time")
  33995. admin_user_id, _ := c.GetInt64("admin_user_id")
  33996. adminUser := c.GetAdminUserInfo()
  33997. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33998. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33999. timeLayout := "2006-01-02"
  34000. loc, _ := time.LoadLocation("Local")
  34001. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34002. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34003. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34004. rand.Seed(time.Now().UnixNano())
  34005. num := rand.Intn(30000)
  34006. Mkdir(miConfig.OrgName)
  34007. file := strconv.FormatInt(int64(num), 10)
  34008. file_name := file + ".txt"
  34009. zip_name := file + ".zip"
  34010. zip_path := miConfig.OrgName + "/" + zip_name
  34011. file_path := miConfig.OrgName + "/" + file_name
  34012. decimal.DivisionPrecision = 2
  34013. var medfee_sumamt float64
  34014. var psn_cash_pay float64
  34015. var fund_pay_sumamt float64
  34016. fixmedins_setl_cnt := int64(len(orders))
  34017. for _, item := range orders {
  34018. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34019. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  34020. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34021. }
  34022. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  34023. defer f.Close()
  34024. if err != nil {
  34025. fmt.Println(err.Error())
  34026. } else {
  34027. for _, item := range orders {
  34028. var refd_setl_flag string
  34029. if item.OrderStatus == 2 {
  34030. refd_setl_flag = "0"
  34031. var str string
  34032. str = item.SetlId + " " +
  34033. item.MdtrtId + " " +
  34034. item.PsnNo + " " +
  34035. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34036. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34037. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  34038. _, err = f.Write([]byte(str))
  34039. }
  34040. if item.OrderStatus == 3 {
  34041. var str string
  34042. str = item.SetlId + " " +
  34043. item.MdtrtId + " " +
  34044. item.PsnNo + " " +
  34045. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34046. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34047. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  34048. _, err = f.Write([]byte(str))
  34049. var str2 string
  34050. str2 = item.SetlId + " " +
  34051. item.MdtrtId + " " +
  34052. item.PsnNo + " " +
  34053. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  34054. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  34055. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  34056. _, err = f.Write([]byte(str2))
  34057. }
  34058. }
  34059. }
  34060. Zip(file_path, zip_path)
  34061. fmt.Println(ReadFile(zip_path))
  34062. fmt.Println(string(ReadFile(zip_path)))
  34063. if config.IsOpen == 1 {
  34064. var user_name string
  34065. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34066. if role.ID == 0 {
  34067. user_name = "管理员"
  34068. } else {
  34069. user_name = role.UserName
  34070. }
  34071. baseParams := models.BaseParams{
  34072. SecretKey: miConfig.SecretKey,
  34073. FixmedinsCode: miConfig.Code,
  34074. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34075. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34076. OrgName: miConfig.OrgName,
  34077. Doctor: user_name,
  34078. }
  34079. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  34080. var dat map[string]interface{}
  34081. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34082. fmt.Println(dat)
  34083. } else {
  34084. fmt.Println(err)
  34085. }
  34086. userJSONBytes, _ := json.Marshal(dat)
  34087. var res ResultNine
  34088. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34089. utils.ErrorLog("解析失败:%v", err)
  34090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34091. return
  34092. }
  34093. if res.Infcode == 0 {
  34094. fileNo := res.Output.FileQuryNo
  34095. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34096. "file_qury_no=" + fileNo +
  34097. "&setl_optins=" + "定点医保中心" +
  34098. "&stmt_begndate=" + start_time +
  34099. "&stm_enddate=" + end_time +
  34100. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34101. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34102. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34103. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34104. "&fixmedins_code=" + miConfig.Code +
  34105. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34106. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34107. "&secret_key=" + miConfig.SecretKey +
  34108. "&org_name=" + miConfig.OrgName +
  34109. "&doctor=" + user_name
  34110. resp, requestErr := http.Get(api)
  34111. if requestErr != nil {
  34112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34113. return
  34114. }
  34115. body, ioErr := ioutil.ReadAll(resp.Body)
  34116. if ioErr != nil {
  34117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34119. return
  34120. }
  34121. var respJSON map[string]interface{}
  34122. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34125. return
  34126. }
  34127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34128. userJSONBytes, _ := json.Marshal(respJSON)
  34129. var res ResultTen
  34130. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34131. utils.ErrorLog("解析失败:%v", err)
  34132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34133. return
  34134. }
  34135. if res.Infcode == 0 {
  34136. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34137. micc := &models.MedicalInsuranceCostCompare{
  34138. StartTime: startime.Unix(),
  34139. EndTime: endtime.Unix(),
  34140. Insutype: "0",
  34141. CheckType: 2,
  34142. Num: fixmedins_setl_cnt,
  34143. Mtime: time.Now().Unix(),
  34144. Status: 1,
  34145. UserOrgId: adminUser.CurrentOrgId,
  34146. CostTotal: medfee_sumamt,
  34147. FuncTotal: fund_pay_sumamt,
  34148. PsnPay: psn_cash_pay,
  34149. Creator: admin_user_id,
  34150. Ctime: time.Now().Unix(),
  34151. }
  34152. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34153. c.ServeSuccessJSON(map[string]interface{}{
  34154. "msg": "明细对账成功",
  34155. })
  34156. }
  34157. } else {
  34158. }
  34159. }
  34160. }
  34161. type CustomOrderInfo struct {
  34162. Name string
  34163. Spec string
  34164. Unit string
  34165. Count float64
  34166. Price float64
  34167. Total float64
  34168. }
  34169. func (c *HisApiController) GetBatchSettleAccounts() {
  34170. admin_user_id, _ := c.GetInt64("admin_user_id")
  34171. order_ids := c.GetString("order_ids")
  34172. order_ids_arr := strings.Split(order_ids, ",")
  34173. data3 := []map[string]interface{}{}
  34174. for _, item := range order_ids_arr {
  34175. id, _ := strconv.ParseInt(item, 10, 64)
  34176. order_id := id
  34177. adminUser := c.GetAdminUserInfo()
  34178. order, _ := service.GetHisOrderByID(order_id)
  34179. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34180. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34181. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34182. orderInfos = append(orderInfos, orderInfos_two...)
  34183. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34184. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34185. var diagnosis_ids []string
  34186. if his.ID > 0 {
  34187. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34188. } else {
  34189. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34190. }
  34191. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34192. var dia_config []*models.HisXtDiagnoseConfig
  34193. var name string
  34194. for _, item := range diagnosis_ids {
  34195. id, _ := strconv.ParseInt(item, 10, 64)
  34196. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34197. dia_config = append(dia_config, &diagnosisConfig)
  34198. if len(name) == 0 {
  34199. name = diagnosisConfig.ClassName
  34200. }
  34201. //} else {
  34202. // name = name + "," + diagnosisConfig.ClassName
  34203. //}
  34204. }
  34205. var bedCostTotal float64 = 0 //床位总费
  34206. var bedCostSelfTotal float64 = 0 //床位自费
  34207. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34208. var bedSelfTotal float64 = 0 //床位部分项目自费
  34209. var bedInscpTotal float64 = 0 //床位部分项目自费
  34210. var operationCostTotal float64 = 0 //手术费
  34211. var operationCostSelfTotal float64 = 0 //手术费
  34212. var operationCostPartSelfTotal float64 = 0 //手术费
  34213. var operationSelfTotal float64 = 0 //床位部分项目自费
  34214. var operationInscpTotal float64 = 0 //床位部分项目自费
  34215. var otherCostTotal float64 = 0 //其他费用
  34216. var otherCostSelfTotal float64 = 0 //其他费用
  34217. var otherCostPartSelfTotal float64 = 0 //其他费用
  34218. var otherSelfTotal float64 = 0 //床位部分项目自费
  34219. var otherInscpTotal float64 = 0 //床位部分项目自费
  34220. var materialCostTotal float64 = 0 //材料费
  34221. var materialCostSelfTotal float64 = 0 //材料费
  34222. var materialCostPartSelfTotal float64 = 0 //材料费
  34223. var materialSelfTotal float64 = 0 //床位部分项目自费
  34224. var materialInscpTotal float64 = 0 //床位部分项目自费
  34225. var westernMedicineCostTotal float64 = 0 //西药费
  34226. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34227. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34228. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34229. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34230. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34231. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34232. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34233. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34234. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34235. var checkCostTotal float64 = 0 //检查费
  34236. var checkCostSelfTotal float64 = 0 //检查费
  34237. var checkCostPartSelfTotal float64 = 0 //检查费
  34238. var checkSelfTotal float64 = 0 //床位部分项目自费
  34239. var checkInscpTotal float64 = 0 //床位部分项目自费
  34240. var laboratoryCostTotal float64 = 0 //化验费
  34241. var laboratoryCostSelfTotal float64 = 0 //化验费
  34242. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34243. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34244. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34245. var treatCostTotal float64 = 0 //治疗费用
  34246. var treatCostSelfTotal float64 = 0 //治疗费用
  34247. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34248. var treatSelfTotal float64 = 0 //床位部分项目自费
  34249. var treatInscpTotal float64 = 0 //床位部分项目自费
  34250. decimal.DivisionPrecision = 2
  34251. for _, item := range orderInfos {
  34252. if item.MedChrgitmType == "01" { //床位费
  34253. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34254. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34255. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34256. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34257. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34258. }
  34259. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34260. if item.MedChrgitmType == "03" { //检查费
  34261. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34262. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34263. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34264. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34265. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34266. }
  34267. } else {
  34268. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34269. fmt.Println("------------")
  34270. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34271. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34272. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34273. }
  34274. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34275. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34276. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34277. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34278. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34279. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34280. }
  34281. }
  34282. if item.MedChrgitmType == "04" { //化验费
  34283. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34284. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34285. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34286. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34287. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34288. }
  34289. if item.MedChrgitmType == "05" { //治疗费
  34290. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34291. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34292. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34293. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34294. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34295. }
  34296. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34297. fmt.Println("------------")
  34298. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34299. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34300. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34301. }
  34302. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34303. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34304. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34305. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34306. }
  34307. //if item.MedChrgitmType == "06" { //手术费
  34308. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34309. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34310. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34311. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34312. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34313. //
  34314. //}
  34315. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34316. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34317. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34318. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34319. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34320. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34321. }
  34322. if item.MedChrgitmType == "09" { //西药费
  34323. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34324. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34325. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34326. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34327. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34328. }
  34329. if item.MedChrgitmType == "11" { //中成费
  34330. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34331. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34332. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34333. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34334. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34335. }
  34336. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34337. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34338. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34339. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34340. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34341. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34342. }
  34343. }
  34344. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34345. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34346. var user_name string
  34347. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34348. if role.ID == 0 {
  34349. user_name = "管理员"
  34350. } else {
  34351. user_name = role.UserName
  34352. }
  34353. baseParams := models.BaseParams{
  34354. SecretKey: miConfig.SecretKey,
  34355. FixmedinsCode: miConfig.Code,
  34356. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34357. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34358. OrgName: miConfig.OrgName,
  34359. Doctor: user_name,
  34360. RequestUrl: miConfig.Url,
  34361. AccessKey: miConfig.AccessKey,
  34362. }
  34363. businessParams := models.BusinessParams{
  34364. PsnNo: order.PsnNo,
  34365. MdtrtId: order.MdtrtId,
  34366. SetlId: order.SetlId,
  34367. }
  34368. var res ResultEleven
  34369. var resEleven10265 ResultEleven10265
  34370. if config.IsOpen == 1 {
  34371. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34372. result := service.Gdyb5203(baseParams, businessParams)
  34373. service.Gdyb5204(baseParams, businessParams)
  34374. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34375. var dat map[string]interface{}
  34376. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34377. fmt.Println(dat)
  34378. } else {
  34379. fmt.Println(err)
  34380. }
  34381. userJSONBytes, _ := json.Marshal(dat)
  34382. if miConfig.Code == "H15049901371" {
  34383. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34384. utils.ErrorLog("解析失败:%v", err)
  34385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34386. return
  34387. }
  34388. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34389. res.Output = resEleven10265.Output
  34390. res.ErrMsg = resEleven10265.ErrMsg
  34391. res.Cainfo = resEleven10265.Cainfo
  34392. res.WarnMsg = resEleven10265.WarnMsg
  34393. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34394. res.Infcode = infocode
  34395. } else {
  34396. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34397. utils.ErrorLog("解析失败:%v", err)
  34398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34399. return
  34400. }
  34401. }
  34402. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34403. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34404. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34405. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34406. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34407. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34408. var doctor_name string
  34409. if roles.ID == 0 {
  34410. doctor_name = "管理员"
  34411. } else {
  34412. doctor_name = roles.UserName
  34413. }
  34414. yiliao_leibie := ""
  34415. switch order.MedType {
  34416. case "11":
  34417. yiliao_leibie = "普通门诊"
  34418. break
  34419. case "12":
  34420. yiliao_leibie = "门诊挂号"
  34421. break
  34422. case "13":
  34423. yiliao_leibie = "急诊"
  34424. break
  34425. case "14":
  34426. yiliao_leibie = "门诊特殊病"
  34427. break
  34428. case "15":
  34429. yiliao_leibie = "门诊统筹"
  34430. break
  34431. case "16":
  34432. yiliao_leibie = "门诊慢性病"
  34433. break
  34434. case "21":
  34435. yiliao_leibie = "普通住院"
  34436. break
  34437. }
  34438. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34439. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34440. if res.Infcode == 0 {
  34441. data2 := map[string]interface{}{
  34442. "diagnosis": name,
  34443. "order_infos": orderInfos,
  34444. "number": order.MdtrtId,
  34445. "date": order.SettleAccountsDate,
  34446. "charge_admin": charge_admin,
  34447. "printor_admin": printor_admin,
  34448. "info": res.Output.Setlinfo,
  34449. "order": order,
  34450. "bedCostTotal": bedCostTotal,
  34451. "bedCostSelfTotal": bedCostSelfTotal,
  34452. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34453. "bedSelfTotal": bedSelfTotal,
  34454. "bedInscpTotal": bedInscpTotal,
  34455. "operationCostTotal": operationCostTotal,
  34456. "operationCostSelfTotal": operationCostSelfTotal,
  34457. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34458. "operationSelfTotal": operationSelfTotal,
  34459. "operationInscpTotal": operationInscpTotal,
  34460. "otherCostTotal": otherCostTotal,
  34461. "otherCostSelfTotal": otherCostSelfTotal,
  34462. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34463. "otherSelfTotal": otherSelfTotal,
  34464. "otherInscpTotal": otherInscpTotal,
  34465. "materialCostTotal": materialCostTotal,
  34466. "materialCostSelfTotal": materialCostSelfTotal,
  34467. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34468. "materialSelfTotal": materialSelfTotal,
  34469. "materialInscpTotal": materialInscpTotal,
  34470. "westernMedicineCostTotal": westernMedicineCostTotal,
  34471. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34472. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34473. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34474. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34475. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34476. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34477. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34478. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34479. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34480. "checkCostTotal": checkCostTotal,
  34481. "checkCostSelfTotal": checkCostSelfTotal,
  34482. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34483. "checkSelfTotal": checkSelfTotal,
  34484. "checkInscpTotal": checkInscpTotal,
  34485. "laboratoryCostTotal": laboratoryCostTotal,
  34486. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34487. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34488. "laboratorySelfTotal": laboratorySelfTotal,
  34489. "laboratoryInscpTotal": laboratoryInscpTotal,
  34490. "treatCostTotal": treatCostTotal,
  34491. "treatCostSelfTotal": treatCostSelfTotal,
  34492. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34493. "treatSelfTotal": treatSelfTotal,
  34494. "treatInscpTotal": treatInscpTotal,
  34495. "doctor_info": doctor_info,
  34496. "doctor_code": adminRole_two.DoctorCode,
  34497. "doctor_name": doctor_name,
  34498. "health_card_no": order.PsnNo,
  34499. "department": departments.Name,
  34500. "yiliao_leibie": yiliao_leibie,
  34501. "after_money": order.AccountPrice,
  34502. "patient": patient,
  34503. "org_name": miConfig.OrgName,
  34504. "org_code": miConfig.Code,
  34505. "order_number": order.Number,
  34506. "his_hospital": his_hospital,
  34507. "his": his,
  34508. "dia_config": dia_config,
  34509. "psn_cash_pay": order.PsnCashPay,
  34510. //"check_order_info": cus_slice,
  34511. }
  34512. data3 = append(data3, data2)
  34513. }
  34514. }
  34515. }
  34516. c.ServeSuccessJSON(map[string]interface{}{
  34517. "infos": data3,
  34518. })
  34519. }
  34520. func (c *HisApiController) GetSettleAccounts() {
  34521. //id, _ := c.GetInt64("id")
  34522. //record_time := c.GetString("record_time")
  34523. order_id, _ := c.GetInt64("order_id")
  34524. admin_user_id, _ := c.GetInt64("admin_user_id")
  34525. //timeLayout := "2006-01-02"
  34526. //loc, _ := time.LoadLocation("Local")
  34527. //
  34528. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34529. //if err != nil {
  34530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34531. // return
  34532. //}Hbyb5203
  34533. //recordDateTime := theTime.Unix()
  34534. adminUser := c.GetAdminUserInfo()
  34535. order, _ := service.GetHisOrderByID(order_id)
  34536. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34537. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34538. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34539. orderInfos = append(orderInfos, orderInfos_two...)
  34540. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34541. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34542. var diagnosis_ids []string
  34543. if his.ID > 0 {
  34544. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34545. } else {
  34546. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34547. }
  34548. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34549. var dia_config []*models.HisXtDiagnoseConfig
  34550. var name string
  34551. for _, item := range diagnosis_ids {
  34552. id, _ := strconv.ParseInt(item, 10, 64)
  34553. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34554. dia_config = append(dia_config, &diagnosisConfig)
  34555. if len(name) == 0 {
  34556. name = diagnosisConfig.ClassName
  34557. } else {
  34558. name = name + "," + diagnosisConfig.ClassName
  34559. }
  34560. }
  34561. if patient.UserOrgId == 10215 {
  34562. name = "慢性肾功能不全(血透治疗)"
  34563. }
  34564. var bedCostTotal float64 = 0 //床位总费
  34565. var bedCostSelfTotal float64 = 0 //床位自费
  34566. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34567. var bedSelfTotal float64 = 0 //床位部分项目自费
  34568. var bedInscpTotal float64 = 0 //床位部分项目自费
  34569. var operationCostTotal float64 = 0 //手术费
  34570. var operationCostSelfTotal float64 = 0 //手术费
  34571. var operationCostPartSelfTotal float64 = 0 //手术费
  34572. var operationSelfTotal float64 = 0 //床位部分项目自费
  34573. var operationInscpTotal float64 = 0 //床位部分项目自费
  34574. var otherCostTotal float64 = 0 //其他费用
  34575. var otherCostSelfTotal float64 = 0 //其他费用
  34576. var otherCostPartSelfTotal float64 = 0 //其他费用
  34577. var otherSelfTotal float64 = 0 //床位部分项目自费
  34578. var otherInscpTotal float64 = 0 //床位部分项目自费
  34579. var materialCostTotal float64 = 0 //材料费
  34580. var materialCostSelfTotal float64 = 0 //材料费
  34581. var materialCostPartSelfTotal float64 = 0 //材料费
  34582. var materialSelfTotal float64 = 0 //床位部分项目自费
  34583. var materialInscpTotal float64 = 0 //床位部分项目自费
  34584. var westernMedicineCostTotal float64 = 0 //西药费
  34585. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34586. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34587. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34588. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34589. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34590. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34591. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34592. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34593. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34594. var checkCostTotal float64 = 0 //检查费
  34595. var checkCostSelfTotal float64 = 0 //检查费
  34596. var checkCostPartSelfTotal float64 = 0 //检查费
  34597. var checkSelfTotal float64 = 0 //床位部分项目自费
  34598. var checkInscpTotal float64 = 0 //床位部分项目自费
  34599. var laboratoryCostTotal float64 = 0 //化验费
  34600. var laboratoryCostSelfTotal float64 = 0 //化验费
  34601. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34602. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34603. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34604. var treatCostTotal float64 = 0 //治疗费用
  34605. var treatCostSelfTotal float64 = 0 //治疗费用
  34606. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34607. var treatSelfTotal float64 = 0 //床位部分项目自费
  34608. var treatInscpTotal float64 = 0 //床位部分项目自费
  34609. var zcCostTotal float64 = 0 //治疗费用
  34610. var zcCostSelfTotal float64 = 0 //治疗费用
  34611. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34612. var zcSelfTotal float64 = 0 //床位部分项目自费
  34613. var zcInscpTotal float64 = 0 //床位部分项目自费
  34614. var huliCostTotal float64 = 0 //治疗费用
  34615. var huliCostSelfTotal float64 = 0 //治疗费用
  34616. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34617. var huliSelfTotal float64 = 0 //床位部分项目自费
  34618. var huliInscpTotal float64 = 0 //床位部分项目自费
  34619. decimal.DivisionPrecision = 2
  34620. for _, item := range orderInfos {
  34621. if item.MedChrgitmType == "01" { //床位费
  34622. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34623. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34624. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34625. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34626. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34627. }
  34628. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34629. if item.MedChrgitmType == "03" { //检查费
  34630. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34631. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34632. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34633. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34634. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34635. }
  34636. } else {
  34637. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34638. fmt.Println("------------")
  34639. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34640. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34641. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34642. }
  34643. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34644. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34645. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34646. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34647. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34648. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34649. }
  34650. }
  34651. if item.MedChrgitmType == "04" { //化验费
  34652. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34653. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34654. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34655. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34656. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34657. }
  34658. if item.MedChrgitmType == "05" { //治疗费
  34659. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34660. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34661. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34662. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34663. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34664. }
  34665. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34666. fmt.Println("------------")
  34667. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34668. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34669. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34670. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34671. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34672. }
  34673. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34674. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34675. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34676. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34677. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34678. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34679. }
  34680. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34681. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34682. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34683. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34684. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34685. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34686. }
  34687. if item.MedChrgitmType == "09" { //西药费
  34688. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34689. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34690. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34691. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34692. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34693. }
  34694. if item.MedChrgitmType == "11" { //中成费
  34695. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34696. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34697. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34698. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34699. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34700. }
  34701. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34702. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34703. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34704. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34705. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34706. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34707. }
  34708. if item.MedChrgitmType == "02" { //其他费
  34709. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34710. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34711. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34712. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34713. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34714. }
  34715. if item.MedChrgitmType == "07" { //其他费
  34716. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34717. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34718. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34719. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34720. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34721. }
  34722. }
  34723. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34724. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34725. var user_name string
  34726. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34727. if role.ID == 0 {
  34728. user_name = "管理员"
  34729. } else {
  34730. user_name = role.UserName
  34731. }
  34732. baseParams := models.BaseParams{
  34733. SecretKey: miConfig.SecretKey,
  34734. FixmedinsCode: miConfig.Code,
  34735. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34736. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34737. OrgName: miConfig.OrgName,
  34738. Doctor: user_name,
  34739. RequestUrl: miConfig.Url,
  34740. AccessKey: miConfig.AccessKey,
  34741. }
  34742. businessParams := models.BusinessParams{
  34743. PsnNo: order.PsnNo,
  34744. MdtrtId: order.MdtrtId,
  34745. SetlId: order.SetlId,
  34746. }
  34747. var res ResultEleven
  34748. var resah ResultElevenah
  34749. var resEleven10265 ResultEleven10265
  34750. if config.IsOpen == 1 {
  34751. if miConfig.MdtrtareaAdmvs == "421300" {
  34752. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34753. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34754. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34755. resp, requestErr := http.Get(api)
  34756. if requestErr != nil {
  34757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34758. return
  34759. }
  34760. body, ioErr := ioutil.ReadAll(resp.Body)
  34761. if ioErr != nil {
  34762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34764. return
  34765. }
  34766. var respJSON map[string]interface{}
  34767. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34770. return
  34771. }
  34772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34773. result, _ := json.Marshal(respJSON)
  34774. fmt.Println("log")
  34775. fmt.Println(string(result))
  34776. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34777. utils.ErrorLog("解析失败:%v", err)
  34778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34779. return
  34780. }
  34781. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34782. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34783. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34784. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34785. resp, requestErr := http.Get(api)
  34786. if requestErr != nil {
  34787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34788. return
  34789. }
  34790. body, ioErr := ioutil.ReadAll(resp.Body)
  34791. if ioErr != nil {
  34792. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34794. return
  34795. }
  34796. var respJSON map[string]interface{}
  34797. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34800. return
  34801. }
  34802. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34803. result, _ := json.Marshal(respJSON)
  34804. fmt.Println("log")
  34805. fmt.Println(string(result))
  34806. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34807. utils.ErrorLog("解析失败:%v", err)
  34808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34809. return
  34810. }
  34811. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34812. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34813. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34814. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34815. resp, requestErr := http.Get(api)
  34816. if requestErr != nil {
  34817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34818. return
  34819. }
  34820. body, ioErr := ioutil.ReadAll(resp.Body)
  34821. if ioErr != nil {
  34822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34824. return
  34825. }
  34826. var respJSON map[string]interface{}
  34827. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34830. return
  34831. }
  34832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34833. result, _ := json.Marshal(respJSON)
  34834. fmt.Println("log")
  34835. fmt.Println(string(result))
  34836. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34837. utils.ErrorLog("解析失败:%v", err)
  34838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34839. return
  34840. }
  34841. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34842. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34843. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34844. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34845. resp, requestErr := http.Get(api)
  34846. if requestErr != nil {
  34847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34848. return
  34849. }
  34850. body, ioErr := ioutil.ReadAll(resp.Body)
  34851. if ioErr != nil {
  34852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34854. return
  34855. }
  34856. var respJSON map[string]interface{}
  34857. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34860. return
  34861. }
  34862. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34863. result, _ := json.Marshal(respJSON)
  34864. fmt.Println("log")
  34865. fmt.Println(string(result))
  34866. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34867. utils.ErrorLog("解析失败:%v", err)
  34868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34869. return
  34870. }
  34871. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34872. var api string
  34873. if miConfig.MdtrtareaAdmvs == "320921" {
  34874. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34875. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34876. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34877. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34878. } else {
  34879. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34880. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34881. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34882. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34883. }
  34884. resp, requestErr := http.Get(api)
  34885. if requestErr != nil {
  34886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34887. return
  34888. }
  34889. body, ioErr := ioutil.ReadAll(resp.Body)
  34890. if ioErr != nil {
  34891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34893. return
  34894. }
  34895. var respJSON map[string]interface{}
  34896. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34899. return
  34900. }
  34901. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34902. result, _ := json.Marshal(respJSON)
  34903. fmt.Println("log")
  34904. fmt.Println(string(result))
  34905. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34906. utils.ErrorLog("解析失败:%v", err)
  34907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34908. return
  34909. }
  34910. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34911. res.Output = resEleven10265.Output
  34912. res.ErrMsg = resEleven10265.ErrMsg
  34913. res.Cainfo = resEleven10265.Cainfo
  34914. res.WarnMsg = resEleven10265.WarnMsg
  34915. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34916. res.Infcode = infocode
  34917. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34918. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34919. saveLog(result, requestLog, "5203", "结算单")
  34920. var dat map[string]interface{}
  34921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34922. fmt.Println(dat)
  34923. } else {
  34924. fmt.Println(err)
  34925. }
  34926. userJSONBytes, _ := json.Marshal(dat)
  34927. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34928. utils.ErrorLog("解析失败:%v", err)
  34929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34930. return
  34931. }
  34932. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34933. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34934. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34935. saveLog(result, requestLog, "5203", "结算单")
  34936. var dat map[string]interface{}
  34937. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34938. fmt.Println(dat)
  34939. } else {
  34940. fmt.Println(err)
  34941. }
  34942. userJSONBytes, _ := json.Marshal(dat)
  34943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34944. utils.ErrorLog("解析失败:%v", err)
  34945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34946. return
  34947. }
  34948. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34949. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34950. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34951. saveLog(result, requestLog, "5203", "结算单")
  34952. var dat map[string]interface{}
  34953. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34954. fmt.Println(dat)
  34955. } else {
  34956. fmt.Println(err)
  34957. }
  34958. userJSONBytes, _ := json.Marshal(dat)
  34959. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34960. utils.ErrorLog("解析失败:%v", err)
  34961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34962. return
  34963. }
  34964. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34965. var api string
  34966. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34967. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34968. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34969. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34970. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34971. resp, requestErr := http.Get(api)
  34972. if requestErr != nil {
  34973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34974. return
  34975. }
  34976. body, ioErr := ioutil.ReadAll(resp.Body)
  34977. if ioErr != nil {
  34978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34980. return
  34981. }
  34982. var respJSON map[string]interface{}
  34983. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34986. return
  34987. }
  34988. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34989. if status == "0" {
  34990. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34991. c.ServeSuccessJSON(map[string]interface{}{
  34992. "failed_code": -10,
  34993. "msg": err_msg,
  34994. })
  34995. return
  34996. }
  34997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34998. result, _ := json.Marshal(respJSON)
  34999. fmt.Println("log")
  35000. fmt.Println(string(result))
  35001. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35002. utils.ErrorLog("解析失败:%v", err)
  35003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35004. return
  35005. }
  35006. res.InfRefmsgid = resah.InfRefmsgid
  35007. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35008. // 创建对应的Time类型
  35009. t := time.UnixMilli(timestamp)
  35010. // 格式化成指定的日期字符串
  35011. str := t.Format("2006-01-02 15:04:05")
  35012. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35013. // 创建对应的Time类型
  35014. t3 := time.UnixMilli(timestamp2)
  35015. // 格式化成指定的日期字符串
  35016. str2 := t3.Format("2006-01-02 15:04:05")
  35017. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35018. // 创建对应的Time类型
  35019. t4 := time.UnixMilli(timestamp3)
  35020. // 格式化成指定的日期字符串
  35021. str3 := t4.Format("2006-01-02 15:04:05")
  35022. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35023. // 创建对应的Time类型
  35024. t5 := time.UnixMilli(timestamp4)
  35025. // 格式化成指定的日期字符串
  35026. str5 := t5.Format("2006-01-02 15:04:05")
  35027. res.Output.Setlinfo.Brdy = str2
  35028. res.Output.Setlinfo.SetlTime = str
  35029. res.Output.Setlinfo.Begndate = str3
  35030. res.Output.Setlinfo.Enddate = str5
  35031. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35032. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35033. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35034. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35035. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35036. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35037. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35038. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35039. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35040. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35041. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35042. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35043. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35044. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35045. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35046. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35047. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35048. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35049. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35050. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35051. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35052. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35053. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35054. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35055. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35056. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35057. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35058. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35059. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35060. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35061. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35062. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35063. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35064. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35065. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35066. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35067. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35068. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35069. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35070. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35071. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35072. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35073. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35074. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35075. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35076. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35077. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35078. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35079. //res.Output.Setldetail = resah.Output.Setldetail
  35080. res.ErrMsg = resah.ErrMsg
  35081. res.Cainfo = resah.Cainfo
  35082. res.WarnMsg = resah.WarnMsg
  35083. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35084. var api string
  35085. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35086. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35087. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35088. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35089. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35090. resp, requestErr := http.Get(api)
  35091. if requestErr != nil {
  35092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35093. return
  35094. }
  35095. body, ioErr := ioutil.ReadAll(resp.Body)
  35096. if ioErr != nil {
  35097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35099. return
  35100. }
  35101. var respJSON map[string]interface{}
  35102. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35105. return
  35106. }
  35107. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35108. if status == "0" {
  35109. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35110. c.ServeSuccessJSON(map[string]interface{}{
  35111. "failed_code": -10,
  35112. "msg": err_msg,
  35113. })
  35114. return
  35115. }
  35116. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35117. result, _ := json.Marshal(respJSON)
  35118. fmt.Println("log")
  35119. fmt.Println(string(result))
  35120. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35121. utils.ErrorLog("解析失败:%v", err)
  35122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35123. return
  35124. }
  35125. res.InfRefmsgid = resah.InfRefmsgid
  35126. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35127. // 创建对应的Time类型
  35128. t := time.UnixMilli(timestamp)
  35129. // 格式化成指定的日期字符串
  35130. str := t.Format("2006-01-02 15:04:05")
  35131. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35132. // 创建对应的Time类型
  35133. t3 := time.UnixMilli(timestamp2)
  35134. // 格式化成指定的日期字符串
  35135. str2 := t3.Format("2006-01-02 15:04:05")
  35136. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35137. // 创建对应的Time类型
  35138. t4 := time.UnixMilli(timestamp3)
  35139. // 格式化成指定的日期字符串
  35140. str3 := t4.Format("2006-01-02 15:04:05")
  35141. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35142. // 创建对应的Time类型
  35143. t5 := time.UnixMilli(timestamp4)
  35144. // 格式化成指定的日期字符串
  35145. str5 := t5.Format("2006-01-02 15:04:05")
  35146. res.Output.Setlinfo.Brdy = str2
  35147. res.Output.Setlinfo.SetlTime = str
  35148. res.Output.Setlinfo.Begndate = str3
  35149. res.Output.Setlinfo.Enddate = str5
  35150. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35151. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35152. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35153. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35154. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35155. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35156. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35157. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35158. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35159. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35160. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35161. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35162. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35163. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35164. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35165. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35166. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35167. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35168. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35169. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35170. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35171. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35172. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35173. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35174. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35175. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35176. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35177. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35178. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35179. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35180. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35181. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35182. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35183. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35184. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35185. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35186. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35187. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35188. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35189. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35190. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35191. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35192. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35193. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35194. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35195. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35196. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35197. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35198. //res.Output.Setldetail = resah.Output.Setldetail
  35199. res.ErrMsg = resah.ErrMsg
  35200. res.Cainfo = resah.Cainfo
  35201. res.WarnMsg = resah.WarnMsg
  35202. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35203. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35204. saveLog(result, requestLog, "5203", "结算单")
  35205. var dat map[string]interface{}
  35206. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35207. fmt.Println(dat)
  35208. } else {
  35209. fmt.Println(err)
  35210. }
  35211. userJSONBytes, _ := json.Marshal(dat)
  35212. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35213. utils.ErrorLog("解析失败:%v", err)
  35214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35215. return
  35216. }
  35217. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35218. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35219. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35220. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35221. resp, requestErr := http.Get(api)
  35222. if requestErr != nil {
  35223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35224. return
  35225. }
  35226. body, ioErr := ioutil.ReadAll(resp.Body)
  35227. if ioErr != nil {
  35228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35230. return
  35231. }
  35232. var respJSON map[string]interface{}
  35233. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35236. return
  35237. }
  35238. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35239. result, _ := json.Marshal(respJSON)
  35240. fmt.Println("log")
  35241. fmt.Println(string(result))
  35242. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35243. utils.ErrorLog("解析失败:%v", err)
  35244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35245. return
  35246. }
  35247. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35248. res.Output = resEleven10265.Output
  35249. res.ErrMsg = resEleven10265.ErrMsg
  35250. res.Cainfo = resEleven10265.Cainfo
  35251. res.WarnMsg = resEleven10265.WarnMsg
  35252. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35253. res.Infcode = infocode
  35254. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35255. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35256. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35257. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35258. resp, requestErr := http.Get(api)
  35259. if requestErr != nil {
  35260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35261. return
  35262. }
  35263. body, ioErr := ioutil.ReadAll(resp.Body)
  35264. if ioErr != nil {
  35265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35267. return
  35268. }
  35269. var respJSON map[string]interface{}
  35270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35273. return
  35274. }
  35275. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35276. result, _ := json.Marshal(respJSON)
  35277. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35278. utils.ErrorLog("解析失败:%v", err)
  35279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35280. return
  35281. }
  35282. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35283. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35284. //return
  35285. } else {
  35286. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35287. if len(his.InsuplcAdmdvs) == 0 {
  35288. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35289. } else {
  35290. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35291. }
  35292. result := service.Gdyb5203(baseParams, businessParams)
  35293. //service.Gdyb5204(baseParams, businessParams)
  35294. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35295. var dat map[string]interface{}
  35296. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35297. fmt.Println(dat)
  35298. } else {
  35299. fmt.Println(err)
  35300. }
  35301. userJSONBytes, _ := json.Marshal(dat)
  35302. if miConfig.Code == "H15049901371" {
  35303. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35304. utils.ErrorLog("解析失败:%v", err)
  35305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35306. return
  35307. }
  35308. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35309. res.Output = resEleven10265.Output
  35310. res.ErrMsg = resEleven10265.ErrMsg
  35311. res.Cainfo = resEleven10265.Cainfo
  35312. res.WarnMsg = resEleven10265.WarnMsg
  35313. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35314. res.Infcode = infocode
  35315. } else {
  35316. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35317. utils.ErrorLog("解析失败:%v", err)
  35318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35319. return
  35320. }
  35321. }
  35322. }
  35323. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35324. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35325. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35326. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35327. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35328. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35329. var doctor_name string
  35330. if roles.ID == 0 {
  35331. doctor_name = "管理员"
  35332. } else {
  35333. doctor_name = roles.UserName
  35334. }
  35335. yiliao_leibie := ""
  35336. switch order.MedType {
  35337. case "11":
  35338. yiliao_leibie = "普通门诊"
  35339. break
  35340. case "12":
  35341. yiliao_leibie = "门诊挂号"
  35342. break
  35343. case "13":
  35344. yiliao_leibie = "急诊"
  35345. break
  35346. case "14":
  35347. yiliao_leibie = "门诊特殊病"
  35348. break
  35349. case "15":
  35350. yiliao_leibie = "门诊统筹"
  35351. break
  35352. case "16":
  35353. yiliao_leibie = "门诊慢性病"
  35354. break
  35355. case "21":
  35356. yiliao_leibie = "普通住院"
  35357. break
  35358. }
  35359. //var rf []CustomFundPay
  35360. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35361. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35362. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35363. if res.Infcode == 0 {
  35364. 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 {
  35365. c.ServeSuccessJSON(map[string]interface{}{
  35366. "diagnosis": name,
  35367. "order_infos": orderInfos,
  35368. "number": order.MdtrtId,
  35369. "date": order.SettleAccountsDate,
  35370. "charge_admin": charge_admin,
  35371. "printor_admin": printor_admin,
  35372. "info": res.Output.Setlinfo,
  35373. "order": order,
  35374. "bedCostTotal": bedCostTotal,
  35375. "bedCostSelfTotal": bedCostSelfTotal,
  35376. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35377. "bedSelfTotal": bedSelfTotal,
  35378. "bedInscpTotal": bedInscpTotal,
  35379. "operationCostTotal": operationCostTotal,
  35380. "operationCostSelfTotal": operationCostSelfTotal,
  35381. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35382. "operationSelfTotal": operationSelfTotal,
  35383. "operationInscpTotal": operationInscpTotal,
  35384. "otherCostTotal": otherCostTotal,
  35385. "otherCostSelfTotal": otherCostSelfTotal,
  35386. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35387. "otherSelfTotal": otherSelfTotal,
  35388. "otherInscpTotal": otherInscpTotal,
  35389. "materialCostTotal": materialCostTotal,
  35390. "materialCostSelfTotal": materialCostSelfTotal,
  35391. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35392. "materialSelfTotal": materialSelfTotal,
  35393. "materialInscpTotal": materialInscpTotal,
  35394. "westernMedicineCostTotal": westernMedicineCostTotal,
  35395. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35396. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35397. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35398. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35399. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35400. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35401. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35402. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35403. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35404. "checkCostTotal": checkCostTotal,
  35405. "checkCostSelfTotal": checkCostSelfTotal,
  35406. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35407. "checkSelfTotal": checkSelfTotal,
  35408. "checkInscpTotal": checkInscpTotal,
  35409. "laboratoryCostTotal": laboratoryCostTotal,
  35410. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35411. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35412. "laboratorySelfTotal": laboratorySelfTotal,
  35413. "laboratoryInscpTotal": laboratoryInscpTotal,
  35414. "treatCostTotal": treatCostTotal,
  35415. "treatCostSelfTotal": treatCostSelfTotal,
  35416. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35417. "treatSelfTotal": treatSelfTotal,
  35418. "treatInscpTotal": treatInscpTotal,
  35419. "doctor_info": doctor_info,
  35420. "doctor_code": adminRole_two.DoctorCode,
  35421. "doctor_name": doctor_name,
  35422. "health_card_no": order.PsnNo,
  35423. "department": departments.Name,
  35424. "yiliao_leibie": yiliao_leibie,
  35425. "after_money": order.AccountPrice,
  35426. "patient": patient,
  35427. "org_name": miConfig.OrgName,
  35428. "org_code": miConfig.Code,
  35429. "order_number": order.Number,
  35430. "his_hospital": his_hospital,
  35431. "his": his,
  35432. "dia_config": dia_config,
  35433. "psn_cash_pay": order.PsnCashPay,
  35434. "zcCostTotal": zcCostTotal,
  35435. "zcCostSelfTotal": zcCostSelfTotal,
  35436. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35437. "zcSelfTotal": zcSelfTotal,
  35438. "zcInscpTotal": zcInscpTotal,
  35439. "huliCostTotal": huliCostTotal,
  35440. "huliCostSelfTotal": huliCostSelfTotal,
  35441. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35442. "huliSelfTotal": huliSelfTotal,
  35443. "huliInscpTotal": huliInscpTotal,
  35444. //"funds": rf,
  35445. //"check_order_info": cus_slice,
  35446. })
  35447. } else {
  35448. c.ServeSuccessJSON(map[string]interface{}{
  35449. "diagnosis": name,
  35450. "order_infos": orderInfos,
  35451. "number": order.MdtrtId,
  35452. "date": order.SettleAccountsDate,
  35453. "charge_admin": charge_admin,
  35454. "printor_admin": printor_admin,
  35455. "info": order,
  35456. "order": order,
  35457. "bedCostTotal": bedCostTotal,
  35458. "bedCostSelfTotal": bedCostSelfTotal,
  35459. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35460. "bedSelfTotal": bedSelfTotal,
  35461. "bedInscpTotal": bedInscpTotal,
  35462. "operationCostTotal": operationCostTotal,
  35463. "operationCostSelfTotal": operationCostSelfTotal,
  35464. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35465. "operationSelfTotal": operationSelfTotal,
  35466. "operationInscpTotal": operationInscpTotal,
  35467. "otherCostTotal": otherCostTotal,
  35468. "otherCostSelfTotal": otherCostSelfTotal,
  35469. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35470. "otherSelfTotal": otherSelfTotal,
  35471. "otherInscpTotal": otherInscpTotal,
  35472. "materialCostTotal": materialCostTotal,
  35473. "materialCostSelfTotal": materialCostSelfTotal,
  35474. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35475. "materialSelfTotal": materialSelfTotal,
  35476. "materialInscpTotal": materialInscpTotal,
  35477. "westernMedicineCostTotal": westernMedicineCostTotal,
  35478. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35479. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35480. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35481. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35482. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35483. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35484. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35485. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35486. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35487. "checkCostTotal": checkCostTotal,
  35488. "checkCostSelfTotal": checkCostSelfTotal,
  35489. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35490. "checkSelfTotal": checkSelfTotal,
  35491. "checkInscpTotal": checkInscpTotal,
  35492. "laboratoryCostTotal": laboratoryCostTotal,
  35493. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35494. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35495. "laboratorySelfTotal": laboratorySelfTotal,
  35496. "laboratoryInscpTotal": laboratoryInscpTotal,
  35497. "treatCostTotal": treatCostTotal,
  35498. "treatCostSelfTotal": treatCostSelfTotal,
  35499. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35500. "treatSelfTotal": treatSelfTotal,
  35501. "treatInscpTotal": treatInscpTotal,
  35502. "doctor_info": doctor_info,
  35503. "doctor_code": adminRole_two.DoctorCode,
  35504. "doctor_name": doctor_name,
  35505. "health_card_no": order.PsnNo,
  35506. "department": departments.Name,
  35507. "yiliao_leibie": yiliao_leibie,
  35508. "after_money": order.AccountPrice,
  35509. "patient": patient,
  35510. "org_name": miConfig.OrgName,
  35511. "org_code": miConfig.Code,
  35512. "order_number": order.Number,
  35513. "his_hospital": his_hospital,
  35514. "his": his,
  35515. "dia_config": dia_config,
  35516. "psn_cash_pay": order.PsnCashPay,
  35517. "zcCostTotal": zcCostTotal,
  35518. "zcCostSelfTotal": zcCostSelfTotal,
  35519. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35520. "zcSelfTotal": zcSelfTotal,
  35521. "zcInscpTotal": zcInscpTotal,
  35522. "huliCostTotal": huliCostTotal,
  35523. "huliCostSelfTotal": huliCostSelfTotal,
  35524. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35525. "huliSelfTotal": huliSelfTotal,
  35526. "huliInscpTotal": huliInscpTotal,
  35527. //"funds": rf,
  35528. //"check_order_info": cus_slice,
  35529. })
  35530. }
  35531. }
  35532. }
  35533. }
  35534. //func (c *HisApiController) CheckTreatment() {
  35535. // patient_id, _ := c.GetInt64("patient_id")
  35536. // id_card_no := c.GetString("id_card_no")
  35537. // insutype := c.GetString("insutype")
  35538. // med_type := c.GetString("med_type")
  35539. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35540. //
  35541. // adminUser := c.GetAdminUserInfo()
  35542. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35543. //
  35544. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35545. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35546. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35547. //
  35548. // if miConfig.MdtrtareaAdmvs == "421300" {
  35549. // var res ResultTwo
  35550. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35551. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35552. // "&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)
  35553. // resp, requestErr := http.Get(api)
  35554. // if requestErr != nil {
  35555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35556. // return
  35557. // }
  35558. //
  35559. // body, ioErr := ioutil.ReadAll(resp.Body)
  35560. // if ioErr != nil {
  35561. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35562. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35563. // return
  35564. // }
  35565. // var respJSON map[string]interface{}
  35566. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35567. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35569. // return
  35570. // }
  35571. //
  35572. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35573. // result, _ := json.Marshal(respJSON)
  35574. //
  35575. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35576. // utils.ErrorLog("解析失败:%v", err)
  35577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35578. // return
  35579. // }
  35580. //
  35581. // if res.Infcode == 0 {
  35582. //
  35583. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35584. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35585. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35586. // resp, requestErr := http.Get(api)
  35587. // if requestErr != nil {
  35588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35589. // return
  35590. // }
  35591. //
  35592. // body, ioErr := ioutil.ReadAll(resp.Body)
  35593. // if ioErr != nil {
  35594. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35596. // return
  35597. // }
  35598. // var respJSON map[string]interface{}
  35599. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35600. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35602. // return
  35603. // }
  35604. // var res Result2001
  35605. //
  35606. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35607. // result2, _ := json.Marshal(respJSON)
  35608. //
  35609. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35610. // utils.ErrorLog("解析失败:%v", err)
  35611. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35612. // return
  35613. // }
  35614. //
  35615. // if res.Infcode == 0 {
  35616. // c.ServeSuccessJSON(map[string]interface{}{
  35617. // "msg": res.Output.Trtinfo,
  35618. // })
  35619. // }
  35620. //
  35621. // } else {
  35622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35623. // return
  35624. // }
  35625. //
  35626. // } else {
  35627. //
  35628. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35629. // var dat map[string]interface{}
  35630. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35631. // fmt.Println(dat)
  35632. // } else {
  35633. // fmt.Println(err)
  35634. // }
  35635. // userJSONBytes, _ := json.Marshal(dat)
  35636. // var res ResultTwo
  35637. // var res10265 ResultTwo10265
  35638. // if miConfig.Code == "H15049901371" {
  35639. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35640. // utils.ErrorLog("解析失败:%v", err)
  35641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35642. // return
  35643. // }
  35644. // res.ErrMsg = res10265.ErrMsg
  35645. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35646. // res.Infcode = infocode
  35647. // res.Output = res10265.Output
  35648. // res.InfRefmsgid = res10265.InfRefmsgid
  35649. // } else {
  35650. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35651. // utils.ErrorLog("解析失败:%v", err)
  35652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35653. // return
  35654. // }
  35655. // }
  35656. //
  35657. // var user_name string
  35658. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35659. // if role.ID == 0 {
  35660. // user_name = "xxx"
  35661. // } else {
  35662. // user_name = role.UserName
  35663. // }
  35664. //
  35665. // baseParams := models.BaseParams{
  35666. // SecretKey: miConfig.SecretKey,
  35667. // FixmedinsCode: miConfig.Code,
  35668. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35669. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35670. // OrgName: miConfig.OrgName,
  35671. // Doctor: user_name,
  35672. // }
  35673. //
  35674. // if config.IsOpen == 1 {
  35675. // if miConfig.Code == "H15049901371" {
  35676. // if med_type == "14" {
  35677. // if insutype == "390" {
  35678. // med_type = "9933"
  35679. // } else if insutype == "310" {
  35680. // med_type = "990502"
  35681. // }
  35682. // } else if med_type == "11" {
  35683. // med_type = "11"
  35684. // }
  35685. // }
  35686. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35687. // var dat map[string]interface{}
  35688. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35689. // fmt.Println(dat)
  35690. // } else {
  35691. // fmt.Println(err)
  35692. // }
  35693. // var res Result2001
  35694. // var res10265 Result2001Org10265
  35695. // if miConfig.Code == "H15049901371" {
  35696. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35697. // utils.ErrorLog("解析失败:%v", err)
  35698. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35699. // return
  35700. // }
  35701. // res.ErrMsg = res10265.ErrMsg
  35702. // res.Output = res10265.Output
  35703. // res.InfRefmsgid = res10265.InfRefmsgid
  35704. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35705. // res.Infcode = infocode
  35706. // } else {
  35707. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35708. // utils.ErrorLog("解析失败:%v", err)
  35709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35710. // return
  35711. // }
  35712. // }
  35713. // if res.Infcode == 0 {
  35714. // c.ServeSuccessJSON(map[string]interface{}{
  35715. // "msg": res.Output.Trtinfo,
  35716. // })
  35717. // }
  35718. // }
  35719. // }
  35720. //}
  35721. //func (c *HisApiController) PutRecord() {
  35722. // id, _ := c.GetInt64("id")
  35723. // record_time := c.GetString("record_time")
  35724. // timeLayout := "2006-01-02"
  35725. // loc, _ := time.LoadLocation("Local")
  35726. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35727. // if err != nil {
  35728. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35729. // return
  35730. // }
  35731. // recordDateTime := theTime.Unix()
  35732. //
  35733. // adminInfo := c.GetAdminUserInfo()
  35734. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35735. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35736. //
  35737. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35738. //
  35739. // fmt.Println(miConfig.SecretKey)
  35740. //
  35741. // if patient == nil {
  35742. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35743. // return
  35744. // }
  35745. // if len(patient.IdCardNo) == 0 {
  35746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35747. // return
  35748. // }
  35749. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35750. // if config.IsOpen == 1 {
  35751. // 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
  35752. // resp, requestErr := http.Get(api)
  35753. // if requestErr != nil {
  35754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35755. // return
  35756. // }
  35757. // defer resp.Body.Close()
  35758. // body, ioErr := ioutil.ReadAll(resp.Body)
  35759. // if ioErr != nil {
  35760. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35762. // return
  35763. // }
  35764. // var respJSON map[string]interface{}
  35765. //
  35766. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35767. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35769. // return
  35770. // }
  35771. //
  35772. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35773. // userJSONBytes, _ := json.Marshal(userJSON)
  35774. // var res ResultTwo
  35775. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35776. // utils.ErrorLog("解析失败:%v", err)
  35777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35778. // return
  35779. // }
  35780. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35781. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35782. // infoStr := string(Iinfos)
  35783. // idetinfoStr := string(Idetinfos)
  35784. //
  35785. // if res.Infcode == 0 {
  35786. // his := models.VMHisPatient{
  35787. // Status: 1,
  35788. // Ctime: time.Now().Unix(),
  35789. // Mtime: time.Now().Unix(),
  35790. // PsnNo: res.Output.Baseinfo.PsnNo,
  35791. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35792. // Certno: res.Output.Baseinfo.Certno,
  35793. // PsnName: res.Output.Baseinfo.PsnName,
  35794. // Gend: res.Output.Baseinfo.Gend,
  35795. // Naty: res.Output.Baseinfo.Naty,
  35796. // Brdy: res.Output.Baseinfo.Brdy,
  35797. // Age: res.Output.Baseinfo.Age,
  35798. // Iinfo: infoStr,
  35799. // Idetinfo: idetinfoStr,
  35800. // PatientId: patient.ID,
  35801. // RecordDate: theTime.Unix(),
  35802. // UserOrgId: adminInfo.CurrentOrgId,
  35803. // AdminUserId: adminInfo.AdminUser.Id,
  35804. // IsReturn: 1,
  35805. // }
  35806. //
  35807. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35808. // //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")
  35809. // //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")
  35810. //
  35811. // //var dat map[string]interface{}
  35812. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35813. // // fmt.Println(dat)
  35814. // //} else {
  35815. // // fmt.Println(err)
  35816. // //}
  35817. //
  35818. // var dat2 map[string]interface{}
  35819. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35820. // fmt.Println(dat2)
  35821. // } else {
  35822. // fmt.Println(err)
  35823. // }
  35824. //
  35825. // } else {
  35826. // adminUser := c.GetAdminUserInfo()
  35827. // errlog := &models.HisOrderError{
  35828. // UserOrgId: adminUser.CurrentOrgId,
  35829. // Ctime: time.Now().Unix(),
  35830. // Mtime: time.Now().Unix(),
  35831. // ErrMsg: res.ErrMsg,
  35832. // Status: 1,
  35833. // PatientId: id,
  35834. // RecordTime: recordDateTime,
  35835. // Stage: 1,
  35836. // }
  35837. // service.CreateErrMsgLog(errlog)
  35838. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35839. // return
  35840. // }
  35841. // }
  35842. //
  35843. //}
  35844. //func (c *HisApiController) GetUploadDiag() {
  35845. // id, _ := c.GetInt64("id")
  35846. // record_time := c.GetString("record_time")
  35847. //
  35848. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35849. // sick_type, _ := c.GetInt64("sick_type")
  35850. // reg_type, _ := c.GetInt64("reg_type")
  35851. //
  35852. // timeLayout := "2006-01-02"
  35853. // loc, _ := time.LoadLocation("Local")
  35854. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35855. // if err != nil {
  35856. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35857. // return
  35858. // }
  35859. //
  35860. // var patientPrescription models.HisPrescriptionInfo
  35861. // recordDateTime := theTime.Unix()
  35862. // adminInfo := c.GetAdminUserInfo()
  35863. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35864. //
  35865. // if patientPrescription.ID == 0 {
  35866. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35867. // }
  35868. //
  35869. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35870. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35871. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35872. // sickConfig, _ := service.FindSickById(sick_type)
  35873. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35874. //
  35875. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35876. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35877. // "&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 +
  35878. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35879. // resp2, requestErr2 := http.Get(api2)
  35880. // if requestErr2 != nil {
  35881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35882. // return
  35883. // }
  35884. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35885. // if ioErr2 != nil {
  35886. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35888. // return
  35889. // }
  35890. // var respJSON2 map[string]interface{}
  35891. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35892. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35894. // return
  35895. // }
  35896. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35897. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35898. //
  35899. // var res2 ResultSix
  35900. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35901. // utils.ErrorLog("解析失败:%v", err)
  35902. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35903. // return
  35904. // }
  35905. // if res2.Infcode != 0 {
  35906. // adminUser := c.GetAdminUserInfo()
  35907. // errlog := &models.HisOrderError{
  35908. // UserOrgId: adminUser.CurrentOrgId,
  35909. // Ctime: time.Now().Unix(),
  35910. // Mtime: time.Now().Unix(),
  35911. // ErrMsg: res2.ErrMsg,
  35912. // Status: 1,
  35913. // PatientId: id,
  35914. // RecordTime: recordDateTime,
  35915. // Stage: 3,
  35916. // }
  35917. // service.CreateErrMsgLog(errlog)
  35918. //
  35919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35920. // return
  35921. // }
  35922. //
  35923. // c.ServeSuccessJSON(map[string]interface{}{
  35924. // "msg": "上传成功",
  35925. // })
  35926. //
  35927. //}
  35928. type QueryResult struct {
  35929. ID int64
  35930. Name string
  35931. Code string
  35932. List_type_code string
  35933. }
  35934. func (c *HisApiController) GetCheckCode() {
  35935. ids_str := c.GetString("ids")
  35936. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35937. ids_arr := strings.Split(ids_str, ",")
  35938. var queryResult []QueryResult
  35939. ids := make([]int64, 0)
  35940. for _, item := range ids_arr {
  35941. id, _ := strconv.ParseInt(item, 10, 64)
  35942. ids = append(ids, id)
  35943. }
  35944. if record_type == 1 {
  35945. drugs, _ := service.GetBatchDrugList(ids)
  35946. for _, item := range drugs {
  35947. result := QueryResult{
  35948. ID: item.ID,
  35949. Name: item.DrugName,
  35950. Code: item.MedicalInsuranceNumber,
  35951. List_type_code: "101",
  35952. }
  35953. queryResult = append(queryResult, result)
  35954. }
  35955. } else if record_type == 2 {
  35956. goods, _ := service.GetBatchGoodInformationList(ids)
  35957. fmt.Println(goods)
  35958. for _, item := range goods {
  35959. result := QueryResult{
  35960. ID: item.ID,
  35961. Name: item.GoodName,
  35962. Code: item.SocialSecurityDirectoryCode,
  35963. List_type_code: "301",
  35964. }
  35965. queryResult = append(queryResult, result)
  35966. }
  35967. } else if record_type == 3 {
  35968. projects, _ := service.GetBathchMyPorjecgList(ids)
  35969. for _, item := range projects {
  35970. result := QueryResult{
  35971. ID: item.ID,
  35972. Name: item.ProjectName,
  35973. Code: item.MedicalCode,
  35974. List_type_code: "201",
  35975. }
  35976. queryResult = append(queryResult, result)
  35977. }
  35978. }
  35979. admin_user_id, _ := c.GetInt64("admin_user_id")
  35980. adminUser := c.GetAdminUserInfo()
  35981. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35982. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35983. var user_name string
  35984. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35985. if role.ID == 0 {
  35986. user_name = "管理员"
  35987. } else {
  35988. user_name = role.UserName
  35989. }
  35990. baseParams := models.BaseParams{
  35991. SecretKey: miConfig.SecretKey,
  35992. FixmedinsCode: miConfig.Code,
  35993. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35994. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35995. OrgName: miConfig.OrgName,
  35996. Doctor: user_name,
  35997. }
  35998. var result string
  35999. if miConfig.MdtrtareaAdmvs == "430800" {
  36000. for _, item := range queryResult {
  36001. if record_type == 1 {
  36002. 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)
  36003. } else if record_type == 2 {
  36004. fmt.Println(item.Code)
  36005. 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)
  36006. } else if record_type == 3 {
  36007. 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)
  36008. }
  36009. var dat map[string]interface{}
  36010. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36011. fmt.Println(dat)
  36012. } else {
  36013. fmt.Println(err)
  36014. }
  36015. userJSONBytes, _ := json.Marshal(dat)
  36016. var res ResultSix
  36017. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36018. utils.ErrorLog("解析失败:%v", err)
  36019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36020. return
  36021. }
  36022. if res.Infcode == 0 {
  36023. if record_type == 1 {
  36024. service.UpdateBaseDrugById(item.ID)
  36025. } else if record_type == 2 {
  36026. service.UpdateGoodInformaitonByDetail(item.ID)
  36027. } else if record_type == 3 {
  36028. service.UpdateProjectById(item.ID)
  36029. }
  36030. c.ServeSuccessJSON(map[string]interface{}{
  36031. "failed_code": 0,
  36032. "msg": "目录对照成功",
  36033. })
  36034. } else {
  36035. c.ServeSuccessJSON(map[string]interface{}{
  36036. "failed_code": -10,
  36037. "msg": res.ErrMsg,
  36038. })
  36039. }
  36040. }
  36041. } else {
  36042. for _, item := range queryResult {
  36043. var result string
  36044. if record_type == 1 {
  36045. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36046. } else if record_type == 2 {
  36047. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36048. } else if record_type == 3 {
  36049. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36050. }
  36051. var dat map[string]interface{}
  36052. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36053. fmt.Println(dat)
  36054. } else {
  36055. fmt.Println(err)
  36056. }
  36057. userJSONBytes, _ := json.Marshal(dat)
  36058. var res ResultSix
  36059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36060. utils.ErrorLog("解析失败:%v", err)
  36061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36062. return
  36063. }
  36064. if res.Infcode == 0 {
  36065. if record_type == 1 {
  36066. service.UpdateBaseDrugById(item.ID)
  36067. } else if record_type == 2 {
  36068. service.UpdateGoodInformaitonByDetail(item.ID)
  36069. } else if record_type == 3 {
  36070. service.UpdateProjectById(item.ID)
  36071. }
  36072. c.ServeSuccessJSON(map[string]interface{}{
  36073. "failed_code": 0,
  36074. "msg": "目录对照成功",
  36075. })
  36076. } else {
  36077. c.ServeSuccessJSON(map[string]interface{}{
  36078. "failed_code": -10,
  36079. "msg": res.ErrMsg,
  36080. })
  36081. }
  36082. }
  36083. }
  36084. }
  36085. func (c *HisApiController) UnCheckCode() {
  36086. ids_str := c.GetString("ids")
  36087. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36088. admin_user_id, _ := c.GetInt64("admin_user_id")
  36089. ids_arr := strings.Split(ids_str, ",")
  36090. var queryResult []QueryResult
  36091. ids := make([]int64, 0)
  36092. for _, item := range ids_arr {
  36093. id, _ := strconv.ParseInt(item, 10, 64)
  36094. ids = append(ids, id)
  36095. }
  36096. if record_type == 1 {
  36097. drugs, _ := service.GetBatchDrugList(ids)
  36098. for _, item := range drugs {
  36099. result := QueryResult{
  36100. ID: item.ID,
  36101. Name: item.DrugName,
  36102. Code: item.MedicalInsuranceNumber,
  36103. List_type_code: "101",
  36104. }
  36105. queryResult = append(queryResult, result)
  36106. }
  36107. } else if record_type == 2 {
  36108. goods, _ := service.GetBatchGoodInformationList(ids)
  36109. for _, item := range goods {
  36110. result := QueryResult{
  36111. ID: item.ID,
  36112. Name: item.GoodName,
  36113. Code: item.SocialSecurityDirectoryCode,
  36114. List_type_code: "301",
  36115. }
  36116. queryResult = append(queryResult, result)
  36117. }
  36118. } else if record_type == 3 {
  36119. projects, _ := service.GetBathchMyPorjecgList(ids)
  36120. for _, item := range projects {
  36121. result := QueryResult{
  36122. ID: item.ID,
  36123. Name: item.ProjectName,
  36124. Code: item.MedicalCode,
  36125. List_type_code: "201",
  36126. }
  36127. queryResult = append(queryResult, result)
  36128. }
  36129. }
  36130. adminUser := c.GetAdminUserInfo()
  36131. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36132. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36133. var user_name string
  36134. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36135. if role.ID == 0 {
  36136. user_name = "xxx"
  36137. } else {
  36138. user_name = role.UserName
  36139. }
  36140. baseParams := &models.BaseParams{
  36141. SecretKey: miConfig.SecretKey,
  36142. FixmedinsCode: miConfig.Code,
  36143. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36144. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36145. OrgName: miConfig.OrgName,
  36146. Doctor: user_name,
  36147. }
  36148. if config.IsOpen == 1 {
  36149. if miConfig.MdtrtareaAdmvs == "430800" {
  36150. for _, item := range queryResult {
  36151. var result string
  36152. if record_type == 1 {
  36153. 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)
  36154. } else if record_type == 2 {
  36155. fmt.Println(item.Code)
  36156. 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)
  36157. } else if record_type == 3 {
  36158. 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)
  36159. }
  36160. var dat map[string]interface{}
  36161. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36162. fmt.Println(dat)
  36163. } else {
  36164. fmt.Println(err)
  36165. }
  36166. userJSONBytes, _ := json.Marshal(dat)
  36167. var res ResultSix
  36168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36169. utils.ErrorLog("解析失败:%v", err)
  36170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36171. return
  36172. }
  36173. if res.Infcode == 0 {
  36174. if record_type == 1 {
  36175. service.UpdateBaseDrugById(item.ID)
  36176. } else if record_type == 2 {
  36177. service.UpdateGoodInformaitonByDetail(item.ID)
  36178. } else if record_type == 3 {
  36179. service.UpdateProjectById(item.ID)
  36180. }
  36181. c.ServeSuccessJSON(map[string]interface{}{
  36182. "failed_code": 0,
  36183. "msg": "目录对照成功",
  36184. })
  36185. } else {
  36186. c.ServeSuccessJSON(map[string]interface{}{
  36187. "failed_code": -10,
  36188. "msg": res.ErrMsg,
  36189. })
  36190. }
  36191. }
  36192. } else {
  36193. for _, item := range queryResult {
  36194. var result string
  36195. if record_type == 1 {
  36196. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36197. } else if record_type == 2 {
  36198. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36199. } else if record_type == 3 {
  36200. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36201. }
  36202. var dat2 map[string]interface{}
  36203. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36204. fmt.Println(dat2)
  36205. } else {
  36206. fmt.Println(err)
  36207. }
  36208. userJSONBytes, _ := json.Marshal(dat2)
  36209. var res ResultSix
  36210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36211. utils.ErrorLog("解析失败:%v", err)
  36212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36213. return
  36214. }
  36215. if res.Infcode == 0 {
  36216. if record_type == 1 {
  36217. service.UpdateDrugByIdDetail(item.ID)
  36218. } else if record_type == 2 {
  36219. service.UpdateGoodInfoById(item.ID)
  36220. } else if record_type == 3 {
  36221. service.UpdateMyProjectById(item.ID)
  36222. }
  36223. c.ServeSuccessJSON(map[string]interface{}{
  36224. "failed_code": 0,
  36225. "msg": "撤销目录对照成功",
  36226. })
  36227. } else {
  36228. c.ServeSuccessJSON(map[string]interface{}{
  36229. "failed_code": -10,
  36230. "msg": res.ErrMsg,
  36231. })
  36232. }
  36233. }
  36234. }
  36235. }
  36236. }
  36237. func (c *HisApiController) GetPatientInfo() {
  36238. id_card_no := c.GetString("id_card_no")
  36239. admin_user_id, _ := c.GetInt64("admin_user_id")
  36240. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36241. if patient.ID == 0 {
  36242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36243. return
  36244. }
  36245. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36246. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36247. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36248. var res ResultTwo
  36249. var res10265 ResultTwo10265
  36250. if config.IsOpen == 1 {
  36251. if miConfig.MdtrtareaAdmvs == "150499" {
  36252. //请求内网数据
  36253. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36254. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36255. "&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
  36256. resp, requestErr := http.Get(api)
  36257. if requestErr != nil {
  36258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36259. return
  36260. }
  36261. body, ioErr := ioutil.ReadAll(resp.Body)
  36262. if ioErr != nil {
  36263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36265. return
  36266. }
  36267. var respJSON map[string]interface{}
  36268. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36271. return
  36272. }
  36273. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36274. result_byte, _ := json.Marshal(respJSON)
  36275. result := string(result_byte)
  36276. var dat map[string]interface{}
  36277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36278. fmt.Println(dat)
  36279. } else {
  36280. fmt.Println(err)
  36281. }
  36282. userJSONBytes, _ := json.Marshal(dat)
  36283. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36284. utils.ErrorLog("解析失败:%v", err)
  36285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36286. return
  36287. }
  36288. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36289. res.Infcode = Infcode
  36290. res.ErrMsg = res10265.ErrMsg
  36291. res.Output = res10265.Output
  36292. res.InfRefmsgid = res10265.InfRefmsgid
  36293. res.RespondTime = res10265.RespondTime
  36294. res.WarnInfo = res10265.WarnInfo
  36295. } else {
  36296. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36297. var dat map[string]interface{}
  36298. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36299. fmt.Println(dat)
  36300. } else {
  36301. fmt.Println(err)
  36302. }
  36303. userJSONBytes, _ := json.Marshal(dat)
  36304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36305. utils.ErrorLog("解析失败:%v", err)
  36306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36307. return
  36308. }
  36309. }
  36310. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36311. // utils.ErrorLog("解析失败:%v", err)
  36312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36313. // return
  36314. //}
  36315. for index, item := range res.Output.Iinfo {
  36316. if item.PsnInsuStas == "2" {
  36317. fmt.Println("--------")
  36318. res.Output.Iinfo[index].Insutype = "300"
  36319. res.Output.Iinfo[index].PsnInsuStas = "1"
  36320. }
  36321. }
  36322. fmt.Println(res.Output.Iinfo)
  36323. if res.Infcode != 0 {
  36324. c.ServeSuccessJSON(map[string]interface{}{
  36325. "failed_code": -10,
  36326. "msg": res.ErrMsg,
  36327. })
  36328. } else {
  36329. c.ServeSuccessJSON(map[string]interface{}{
  36330. "failed_code": 0,
  36331. "info": res,
  36332. })
  36333. }
  36334. }
  36335. }
  36336. func (c *HisApiController) PsnPutOnRecord() {
  36337. record_type, _ := c.GetInt64("type")
  36338. patient_id, _ := c.GetInt64("patient_id")
  36339. admin_user_id, _ := c.GetInt64("admin_user_id")
  36340. start_time := c.GetString("start_time")
  36341. end_time := c.GetString("end_time")
  36342. adminUser := c.GetAdminUserInfo()
  36343. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36344. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36345. var patients []*models.Patients
  36346. if record_type == 1 { //全部备案
  36347. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36348. patients = append(patients, patient...)
  36349. } else { //单个备案
  36350. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36351. patients = append(patients, patient)
  36352. }
  36353. var user_name string
  36354. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36355. if role.ID == 0 {
  36356. user_name = "xxx"
  36357. } else {
  36358. user_name = role.UserName
  36359. }
  36360. if config.IsOpen == 1 {
  36361. for _, item := range patients {
  36362. 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
  36363. resp, requestErr := http.Get(api)
  36364. if requestErr != nil {
  36365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36366. return
  36367. }
  36368. defer resp.Body.Close()
  36369. body, ioErr := ioutil.ReadAll(resp.Body)
  36370. if ioErr != nil {
  36371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36373. return
  36374. }
  36375. var respJSON map[string]interface{}
  36376. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36379. return
  36380. }
  36381. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36382. userJSONBytes, _ := json.Marshal(userJSON)
  36383. var res ResultTwo
  36384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36385. utils.ErrorLog("解析失败:%v", err)
  36386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36387. return
  36388. }
  36389. if res.Infcode == 0 {
  36390. 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)
  36391. var dat map[string]interface{}
  36392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36393. fmt.Println(dat)
  36394. } else {
  36395. fmt.Println(err)
  36396. }
  36397. userJSONBytes, _ := json.Marshal(dat)
  36398. var res2 ResultThirteen
  36399. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36400. utils.ErrorLog("解析失败:%v", err)
  36401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36402. return
  36403. }
  36404. if res2.Infcode == 0 {
  36405. psnResult := &models.GdybPsnRecord{
  36406. UserOrgId: adminUser.CurrentOrgId,
  36407. PatientId: item.ID,
  36408. PsnNo: res.Output.Baseinfo.PsnNo,
  36409. Ctime: time.Now().Unix(),
  36410. Mtime: time.Now().Unix(),
  36411. Status: 1,
  36412. IsCancel: 1,
  36413. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36414. }
  36415. service.CreatePsnRecord(psnResult)
  36416. } else {
  36417. c.ServeSuccessJSON(map[string]interface{}{
  36418. "failed_code": -10,
  36419. "msg": res2.ErrMsg,
  36420. })
  36421. return
  36422. }
  36423. }
  36424. }
  36425. }
  36426. }
  36427. func (c *HisApiController) PsnUnPutOnRecord() {
  36428. id, _ := c.GetInt64("id")
  36429. //record_type, _ := c.GetInt64("type")
  36430. admin_user_id, _ := c.GetInt64("admin_user_id")
  36431. adminUser := c.GetAdminUserInfo()
  36432. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36433. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36434. var user_name string
  36435. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36436. if role.ID == 0 {
  36437. user_name = "xxx"
  36438. } else {
  36439. user_name = role.UserName
  36440. }
  36441. psn_record, _ := service.GetPsnRecordById(id)
  36442. if psn_record.ID == 0 {
  36443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36444. return
  36445. }
  36446. if config.IsOpen == 1 {
  36447. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36448. var dat map[string]interface{}
  36449. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36450. fmt.Println(dat)
  36451. } else {
  36452. fmt.Println(err)
  36453. }
  36454. userJSONBytes, _ := json.Marshal(dat)
  36455. var res ResultFourteen
  36456. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36457. utils.ErrorLog("解析失败:%v", err)
  36458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36459. return
  36460. }
  36461. if res.Infcode == 0 {
  36462. psn_record.IsCancel = 2
  36463. service.CreatePsnRecord(&psn_record)
  36464. } else {
  36465. c.ServeSuccessJSON(map[string]interface{}{
  36466. "failed_code": -10,
  36467. "msg": res.ErrMsg,
  36468. })
  36469. return
  36470. }
  36471. }
  36472. }
  36473. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36474. patient_id, _ := c.GetInt64("patient_id")
  36475. insutype_two := c.GetString("insutype")
  36476. psn_no := c.GetString("psn_no")
  36477. doctor_id, _ := c.GetInt64("doctor_id")
  36478. sick_id, _ := c.GetInt64("sick_id")
  36479. department_id, _ := c.GetInt64("department_id")
  36480. start_time := c.GetString("start_time")
  36481. end_time := c.GetString("end_time")
  36482. check_time := c.GetString("check_time")
  36483. hospital_code := c.GetString("hospital_code")
  36484. hospital_name := c.GetString("hospital_name")
  36485. adminUser := c.GetAdminUserInfo()
  36486. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36487. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36488. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36489. sick, _ := service.FindSickById(sick_id)
  36490. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36491. if len(hospital_code) == 0 {
  36492. hospital_code = miConfig.Code
  36493. }
  36494. if len(hospital_name) == 0 {
  36495. hospital_name = miConfig.OrgName
  36496. }
  36497. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36498. var res ResultTwo
  36499. var res10265 ResultTwo10265
  36500. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36501. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36502. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36503. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36504. "&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
  36505. resp, requestErr := http.Get(api)
  36506. if requestErr != nil {
  36507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36508. return
  36509. }
  36510. body, ioErr := ioutil.ReadAll(resp.Body)
  36511. if ioErr != nil {
  36512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36514. return
  36515. }
  36516. var respJSON map[string]interface{}
  36517. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36520. return
  36521. }
  36522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36523. result, _ := json.Marshal(respJSON)
  36524. fmt.Println("log")
  36525. fmt.Println(string(result))
  36526. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36527. utils.ErrorLog("解析失败:%v", err)
  36528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36529. return
  36530. }
  36531. res.ErrMsg = res10265.ErrMsg
  36532. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36533. res.Infcode = infocode
  36534. res.Output = res10265.Output
  36535. res.InfRefmsgid = res10265.InfRefmsgid
  36536. } else {
  36537. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36538. if miConfig.Code == "H15049901371" {
  36539. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36540. utils.ErrorLog("解析失败:%v", err)
  36541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36542. return
  36543. }
  36544. res.ErrMsg = res10265.ErrMsg
  36545. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36546. res.Infcode = infocode
  36547. res.Output = res10265.Output
  36548. res.InfRefmsgid = res10265.InfRefmsgid
  36549. } else {
  36550. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36551. utils.ErrorLog("解析失败:%v", err)
  36552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36553. return
  36554. }
  36555. }
  36556. }
  36557. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36558. infoStr := string(Iinfos)
  36559. var rf []*ResultFive
  36560. json.Unmarshal([]byte(infoStr), &rf)
  36561. var insuplc_admdvs string
  36562. var insutype string
  36563. var is390 int = 0
  36564. var is310 int = 0
  36565. var insutypes []*ResultFive
  36566. for _, item := range rf {
  36567. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36568. insutypes = append(insutypes, item)
  36569. }
  36570. }
  36571. if len(insutypes) == 1 {
  36572. insutype = insutypes[0].Insutype
  36573. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36574. } else {
  36575. for _, i := range insutypes {
  36576. if i.Insutype == "390" {
  36577. is390 = 1
  36578. }
  36579. if i.Insutype == "310" {
  36580. is310 = 1
  36581. }
  36582. }
  36583. }
  36584. if is390 == 1 {
  36585. insutype = "390"
  36586. }
  36587. if is310 == 1 {
  36588. insutype = "310"
  36589. }
  36590. if len(insutypes) == 2 {
  36591. insutype = insutype_two
  36592. }
  36593. if len(insutypes) == 0 {
  36594. insutype = "310"
  36595. }
  36596. insutype = insutype_two
  36597. fmt.Println(insutype)
  36598. for _, item := range rf {
  36599. fmt.Println(item.Insutype)
  36600. fmt.Println(insutype)
  36601. if item.Insutype == insutype {
  36602. fmt.Println(item.Insutype)
  36603. fmt.Println(insutype)
  36604. insuplc_admdvs = item.InsuplcAdmdvs
  36605. }
  36606. }
  36607. fmt.Println(insuplc_admdvs)
  36608. var res2 ResultThirteen
  36609. var res10265_2 ResultThirteen10265
  36610. if config.IsOpen == 1 {
  36611. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36612. } else {
  36613. if miConfig.MdtrtareaAdmvs == "150499" {
  36614. //
  36615. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36616. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36617. // "&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
  36618. //resp, requestErr := http.Get(api)
  36619. //if requestErr != nil {
  36620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36621. // return
  36622. //}
  36623. //
  36624. //body, ioErr := ioutil.ReadAll(resp.Body)
  36625. //if ioErr != nil {
  36626. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36627. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36628. // return
  36629. //}
  36630. //var respJSON map[string]interface{}
  36631. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36632. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36634. // return
  36635. //}
  36636. //
  36637. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36638. //result, _ := json.Marshal(respJSON)
  36639. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36640. // utils.ErrorLog("解析失败:%v", err)
  36641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36642. // return
  36643. //}
  36644. //infocode = resThree.Infcode
  36645. //result, _ := json.Marshal(respJSON)
  36646. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36647. // utils.ErrorLog("解析失败:%v", err)
  36648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36649. // return
  36650. //}
  36651. //
  36652. //resThree.ErrMsg = resThree10265.ErrMsg
  36653. //
  36654. //resThree.Output = resThree10265.Output
  36655. //
  36656. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36657. //
  36658. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36659. //
  36660. } else {
  36661. 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)
  36662. var dat map[string]interface{}
  36663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36664. fmt.Println(dat)
  36665. } else {
  36666. fmt.Println(err)
  36667. }
  36668. userJSONBytes, _ := json.Marshal(dat)
  36669. if miConfig.Code == "H15049901371" {
  36670. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36671. utils.ErrorLog("解析失败:%v", err)
  36672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36673. return
  36674. }
  36675. res2.ErrMsg = res10265_2.ErrMsg
  36676. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36677. res2.Infcode = infocode
  36678. res2.Output = res10265_2.Output
  36679. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36680. } else {
  36681. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36682. utils.ErrorLog("解析失败:%v", err)
  36683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36684. return
  36685. }
  36686. }
  36687. }
  36688. }
  36689. if res2.Infcode == 0 {
  36690. psnResult := &models.GdybPsnNcdsRecord{
  36691. UserOrgId: adminUser.CurrentOrgId,
  36692. PatientId: patient.ID,
  36693. PsnNo: psn_no,
  36694. DoctorId: doctor.AdminUserId,
  36695. DepartmentId: department_id,
  36696. SickType: sick_id,
  36697. Insutype: insutype,
  36698. Ctime: time.Now().Unix(),
  36699. Mtime: time.Now().Unix(),
  36700. Status: 1,
  36701. IsCancel: 1,
  36702. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36703. }
  36704. service.CreatePsnNCDSRecord(psnResult)
  36705. c.ServeSuccessJSON(map[string]interface{}{
  36706. "failed_code": 0,
  36707. "msg": "备案成功",
  36708. "result": psnResult,
  36709. })
  36710. } else {
  36711. c.ServeSuccessJSON(map[string]interface{}{
  36712. "failed_code": -10,
  36713. "msg": res2.ErrMsg,
  36714. })
  36715. return
  36716. }
  36717. }
  36718. }
  36719. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36720. id, _ := c.GetInt64("id")
  36721. admin_user_id, _ := c.GetInt64("admin_user_id")
  36722. adminUser := c.GetAdminUserInfo()
  36723. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36724. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36725. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36726. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36727. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36728. //var user_name string
  36729. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36730. //if role.ID == 0 {
  36731. // user_name = "xxx"
  36732. //} else {
  36733. // user_name = role.UserName
  36734. //}
  36735. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36736. if psn_record.ID == 0 {
  36737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36738. return
  36739. }
  36740. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36741. var res ResultTwo
  36742. var res10265 ResultTwo10265
  36743. if miConfig.Code == "H15049901371" {
  36744. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36745. utils.ErrorLog("解析失败:%v", err)
  36746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36747. return
  36748. }
  36749. res.ErrMsg = res10265.ErrMsg
  36750. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36751. res.Infcode = infocode
  36752. res.Output = res10265.Output
  36753. res.InfRefmsgid = res10265.InfRefmsgid
  36754. } else {
  36755. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36756. utils.ErrorLog("解析失败:%v", err)
  36757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36758. return
  36759. }
  36760. }
  36761. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36762. infoStr := string(Iinfos)
  36763. var rf []*ResultFive
  36764. json.Unmarshal([]byte(infoStr), &rf)
  36765. var insuplc_admdvs string
  36766. var insutype string
  36767. var is390 int = 0
  36768. var is310 int = 0
  36769. var insutypes []*ResultFive
  36770. for _, item := range rf {
  36771. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36772. insutypes = append(insutypes, item)
  36773. }
  36774. }
  36775. if len(insutypes) == 1 {
  36776. insutype = insutypes[0].Insutype
  36777. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36778. } else {
  36779. for _, i := range insutypes {
  36780. if i.Insutype == "390" {
  36781. is390 = 1
  36782. }
  36783. if i.Insutype == "310" {
  36784. is310 = 1
  36785. }
  36786. }
  36787. }
  36788. if is390 == 1 {
  36789. insutype = "390"
  36790. }
  36791. if is310 == 1 {
  36792. insutype = "310"
  36793. }
  36794. if len(insutypes) == 0 {
  36795. insutype = "310"
  36796. }
  36797. insutype = psn_record.Insutype
  36798. for _, item := range rf {
  36799. if item.Insutype == insutype {
  36800. insuplc_admdvs = item.InsuplcAdmdvs
  36801. }
  36802. }
  36803. if config.IsOpen == 1 {
  36804. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36805. var dat map[string]interface{}
  36806. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36807. fmt.Println(dat)
  36808. } else {
  36809. fmt.Println(err)
  36810. }
  36811. userJSONBytes, _ := json.Marshal(dat)
  36812. var res ResultFourteen
  36813. var res10265 ResultFourteen10265
  36814. if miConfig.Code == "H15049901371" {
  36815. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36816. utils.ErrorLog("解析失败:%v", err)
  36817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36818. return
  36819. }
  36820. res.ErrMsg = res10265.ErrMsg
  36821. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36822. res.Infcode = infocode
  36823. res.Output = res10265.Output
  36824. res.InfRefmsgid = res10265.InfRefmsgid
  36825. } else {
  36826. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36827. utils.ErrorLog("解析失败:%v", err)
  36828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36829. return
  36830. }
  36831. }
  36832. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36833. // utils.ErrorLog("解析失败:%v", err)
  36834. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36835. // return
  36836. //}
  36837. if res.Infcode == 0 {
  36838. psn_record.IsCancel = 2
  36839. service.CreatePsnNCDSRecord(&psn_record)
  36840. c.ServeSuccessJSON(map[string]interface{}{
  36841. "failed_code": 0,
  36842. "msg": "撤销备案成功",
  36843. })
  36844. } else {
  36845. c.ServeSuccessJSON(map[string]interface{}{
  36846. "failed_code": -10,
  36847. "msg": res.ErrMsg,
  36848. })
  36849. return
  36850. }
  36851. }
  36852. }
  36853. func (c *HisApiController) TestTest() {
  36854. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36855. fmt.Println(patient.Iinfo)
  36856. }
  36857. type CustomData struct {
  36858. MsgId string
  36859. PsnNo string
  36860. Info string
  36861. }
  36862. func (c *HisApiController) ReversalData() {
  36863. var customData []*CustomData
  36864. custom := &CustomData{
  36865. MsgId: "H44022900158202103301714472004",
  36866. PsnNo: "44020000001101329945",
  36867. Info: "2207",
  36868. }
  36869. customData = append(customData, custom)
  36870. custom1 := &CustomData{
  36871. MsgId: "H4402290015820210330172057803",
  36872. PsnNo: "44020000001101161813",
  36873. Info: "2207",
  36874. }
  36875. customData = append(customData, custom1)
  36876. custom2 := &CustomData{
  36877. MsgId: "H44022900158202103301705198813",
  36878. PsnNo: "44190000133097375417",
  36879. Info: "2207",
  36880. }
  36881. customData = append(customData, custom2)
  36882. custom3 := &CustomData{
  36883. MsgId: "H44022900158202103301715524756",
  36884. PsnNo: "44020000001100187221",
  36885. Info: "2207",
  36886. }
  36887. customData = append(customData, custom3)
  36888. custom4 := &CustomData{
  36889. MsgId: "H44022900158202103301730376224",
  36890. PsnNo: "44020000001101959155",
  36891. Info: "2207",
  36892. }
  36893. customData = append(customData, custom4)
  36894. custom5 := &CustomData{
  36895. MsgId: "H44022900158202103301748008725",
  36896. PsnNo: "44020000001104246641",
  36897. Info: "2207",
  36898. }
  36899. customData = append(customData, custom5)
  36900. custom6 := &CustomData{
  36901. MsgId: "H44022900158202103301718096755",
  36902. PsnNo: "44020000001102211860",
  36903. Info: "2207",
  36904. }
  36905. customData = append(customData, custom6)
  36906. custom7 := &CustomData{
  36907. MsgId: "H44022900158202103301736551640",
  36908. PsnNo: "44020000001102687718",
  36909. Info: "2207",
  36910. }
  36911. customData = append(customData, custom7)
  36912. custom8 := &CustomData{
  36913. MsgId: "H44022900158202103301743097676",
  36914. PsnNo: "44020000001102127785",
  36915. Info: "2207",
  36916. }
  36917. customData = append(customData, custom8)
  36918. custom9 := &CustomData{
  36919. MsgId: "H44022900158202103301712304203",
  36920. PsnNo: "44020000001101518097",
  36921. Info: "2207",
  36922. }
  36923. customData = append(customData, custom9)
  36924. custom10 := &CustomData{
  36925. MsgId: "H44022900158202103301738448785",
  36926. PsnNo: "44020000001100500813",
  36927. Info: "2207",
  36928. }
  36929. customData = append(customData, custom10)
  36930. custom11 := &CustomData{
  36931. MsgId: "H44022900158202103301732455843",
  36932. PsnNo: "44020000001102690557",
  36933. Info: "2207",
  36934. }
  36935. customData = append(customData, custom11)
  36936. custom12 := &CustomData{
  36937. MsgId: "H44022900158202103301745421708",
  36938. PsnNo: "44020000001102211928",
  36939. Info: "2207",
  36940. }
  36941. customData = append(customData, custom12)
  36942. custom1212 := &CustomData{
  36943. MsgId: "H440229001582021033017351627",
  36944. PsnNo: "44020000001102481733",
  36945. Info: "2207",
  36946. }
  36947. customData = append(customData, custom1212)
  36948. custom13 := &CustomData{
  36949. MsgId: "H44022900158202103301740327951",
  36950. PsnNo: "44020000001103174866",
  36951. Info: "2207",
  36952. }
  36953. customData = append(customData, custom13)
  36954. custom14 := &CustomData{
  36955. MsgId: "H4402290015820210330174922668",
  36956. PsnNo: "44020000001102927272",
  36957. Info: "2207",
  36958. }
  36959. customData = append(customData, custom14)
  36960. custom15 := &CustomData{
  36961. MsgId: "H44022900158202103301752362273",
  36962. PsnNo: "44020000001102942890",
  36963. Info: "2207",
  36964. }
  36965. customData = append(customData, custom15)
  36966. custom16 := &CustomData{
  36967. MsgId: "H44022900158202103301751082917",
  36968. PsnNo: "44020000001101662162",
  36969. Info: "2207",
  36970. }
  36971. customData = append(customData, custom16)
  36972. custom17 := &CustomData{
  36973. MsgId: "H44022900158202103301754147728",
  36974. PsnNo: "44020000000229014511",
  36975. Info: "2207",
  36976. }
  36977. customData = append(customData, custom17)
  36978. adminUser := c.GetAdminUserInfo()
  36979. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36980. for _, item := range customData {
  36981. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36982. fmt.Println(result)
  36983. }
  36984. }
  36985. func (c *HisApiController) GetAllopatry() {
  36986. year := c.GetString("year")
  36987. month := c.GetString("month")
  36988. admin_user_id, _ := c.GetInt64("admin_user_id")
  36989. adminUser := c.GetAdminUserInfo()
  36990. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36991. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36992. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36993. var dat map[string]interface{}
  36994. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36995. fmt.Println(dat)
  36996. } else {
  36997. fmt.Println(err)
  36998. }
  36999. userJSONBytes, _ := json.Marshal(dat)
  37000. var res models.Result9001
  37001. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37002. utils.ErrorLog("解析失败:%v", err)
  37003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37004. return
  37005. }
  37006. fmt.Println(res.Output.Signinoutb)
  37007. fmt.Println(res.Output.Signinoutb.SignNo)
  37008. fmt.Println(string(userJSONBytes))
  37009. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37010. var dat3 map[string]interface{}
  37011. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  37012. fmt.Println(dat3)
  37013. } else {
  37014. fmt.Println(err)
  37015. }
  37016. userJSONBytes3, _ := json.Marshal(dat3)
  37017. var res3 models.Result3260
  37018. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  37019. utils.ErrorLog("解析失败:%v", err)
  37020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37021. return
  37022. }
  37023. var curpage int
  37024. var pagesize int = 100
  37025. var start int = 1
  37026. //var stop int
  37027. //pagecount := 10
  37028. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  37029. var res22 []models.Result3260
  37030. for curpage = 1; curpage <= pagecount; curpage++ {
  37031. if curpage == 1 {
  37032. start = 0
  37033. } else {
  37034. start = (curpage-1)*pagesize + 1
  37035. }
  37036. fmt.Println(start)
  37037. //stop = curpage * pagesize
  37038. //if stop > int(res3.Output.Totalrow) {
  37039. // stop =int(res3.Output.Totalrow)
  37040. //}
  37041. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  37042. var dat2 map[string]interface{}
  37043. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37044. fmt.Println(dat)
  37045. } else {
  37046. fmt.Println(err)
  37047. }
  37048. userJSONBytes2, _ := json.Marshal(dat2)
  37049. var res2 models.Result3260
  37050. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37051. utils.ErrorLog("解析失败:%v", err)
  37052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37053. return
  37054. }
  37055. if res2.Infcode == 0 {
  37056. res22 = append(res22, res2)
  37057. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37058. //var dat2 map[string]interface{}
  37059. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37060. // fmt.Println(dat)
  37061. //} else {
  37062. // fmt.Println(err)
  37063. //}
  37064. //c.ServeSuccessJSON(map[string]interface{}{
  37065. // "list": res2.Output.Data,
  37066. //})
  37067. //continue
  37068. }
  37069. }
  37070. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37071. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37072. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  37073. //var dat2 map[string]interface{}
  37074. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37075. // fmt.Println(dat)
  37076. //} else {
  37077. // fmt.Println(err)
  37078. //}
  37079. //userJSONBytes2, _ := json.Marshal(dat2)
  37080. //var res2 models.Result3260
  37081. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37082. // utils.ErrorLog("解析失败:%v", err)
  37083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37084. // return
  37085. //}
  37086. //if res2.Infcode == 0 {
  37087. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37088. // var dat2 map[string]interface{}
  37089. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37090. // fmt.Println(dat)
  37091. // } else {
  37092. // fmt.Println(err)
  37093. // }
  37094. // c.ServeSuccessJSON(map[string]interface{}{
  37095. // "list": res2.Output.Data,
  37096. // })
  37097. //}
  37098. }
  37099. func (c *HisApiController) ComfirmAllopatry() {
  37100. year := c.GetString("year")
  37101. month := c.GetString("month")
  37102. admin_user_id, _ := c.GetInt64("admin_user_id")
  37103. adminUser := c.GetAdminUserInfo()
  37104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37105. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37106. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37107. var dat map[string]interface{}
  37108. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37109. fmt.Println(dat)
  37110. } else {
  37111. fmt.Println(err)
  37112. }
  37113. userJSONBytes, _ := json.Marshal(dat)
  37114. var res models.Result9001
  37115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37116. utils.ErrorLog("解析失败:%v", err)
  37117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37118. return
  37119. }
  37120. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37121. var dat2 map[string]interface{}
  37122. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37123. fmt.Println(dat)
  37124. } else {
  37125. fmt.Println(err)
  37126. }
  37127. userJSONBytes2, _ := json.Marshal(dat2)
  37128. var res2 models.Result3260
  37129. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37130. utils.ErrorLog("解析失败:%v", err)
  37131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37132. return
  37133. }
  37134. //if res2.Infcode == 0 {
  37135. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37136. // var dat map[string]interface{}
  37137. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37138. // fmt.Println(dat)
  37139. // } else {
  37140. // fmt.Println(err)
  37141. // }
  37142. // userJSONBytes, _ := json.Marshal(dat)
  37143. // var res3 models.Result3261
  37144. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37145. // utils.ErrorLog("解析失败:%v", err)
  37146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37147. // return
  37148. // }
  37149. //
  37150. // if res3.Infcode == 0 {
  37151. // record := &models.HisYidiClearRecord{
  37152. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37153. // Ctime: time.Now().Unix(),
  37154. // Mtime: time.Now().Unix(),
  37155. // Status: 1,
  37156. // MsgId: msgId,
  37157. // }
  37158. // service.SaveClearRecord(record)
  37159. // c.ServeSuccessJSON(map[string]interface{}{
  37160. // "msg": "提取成功",
  37161. // })
  37162. // }
  37163. //}
  37164. }
  37165. func (c *HisApiController) RefundAllopatry() {
  37166. year := c.GetString("year")
  37167. month := c.GetString("month")
  37168. //id, _ := c.GetInt64("id")
  37169. admin_user_id, _ := c.GetInt64("admin_user_id")
  37170. adminUser := c.GetAdminUserInfo()
  37171. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37172. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37173. //record, _ := service.GetClearRecordById(id)
  37174. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37175. var dat map[string]interface{}
  37176. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37177. fmt.Println(dat)
  37178. } else {
  37179. fmt.Println(err)
  37180. }
  37181. userJSONBytes, _ := json.Marshal(dat)
  37182. var res models.Result9001
  37183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37184. utils.ErrorLog("解析失败:%v", err)
  37185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37186. return
  37187. }
  37188. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37189. var dat2 map[string]interface{}
  37190. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37191. fmt.Println(dat)
  37192. } else {
  37193. fmt.Println(err)
  37194. }
  37195. userJSONBytes2, _ := json.Marshal(dat2)
  37196. var empty ResultFourteen
  37197. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37198. utils.ErrorLog("解析失败:%v", err)
  37199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37200. return
  37201. }
  37202. if empty.Infcode == 0 {
  37203. c.ServeSuccessJSON(map[string]interface{}{
  37204. "msg": "撤销成功",
  37205. })
  37206. return
  37207. }
  37208. }
  37209. func (c *HisApiController) ReversalOtherData() {
  37210. var customData []*CustomData
  37211. custom := &CustomData{
  37212. MsgId: "H44022900158202103301714472004",
  37213. PsnNo: "44020000001101329945",
  37214. Info: "2208",
  37215. }
  37216. customData = append(customData, custom)
  37217. custom1 := &CustomData{
  37218. MsgId: "H4402290015820210330172057803",
  37219. PsnNo: "44020000001101161813",
  37220. Info: "2208",
  37221. }
  37222. customData = append(customData, custom1)
  37223. custom2 := &CustomData{
  37224. MsgId: "H44022900158202103301705198813",
  37225. PsnNo: "44190000133097375417",
  37226. Info: "2208",
  37227. }
  37228. customData = append(customData, custom2)
  37229. custom3 := &CustomData{
  37230. MsgId: "H44022900158202103301715524756",
  37231. PsnNo: "44020000001100187221",
  37232. Info: "2208",
  37233. }
  37234. customData = append(customData, custom3)
  37235. custom4 := &CustomData{
  37236. MsgId: "H44022900158202103301730376224",
  37237. PsnNo: "44020000001101959155",
  37238. Info: "2208",
  37239. }
  37240. customData = append(customData, custom4)
  37241. custom5 := &CustomData{
  37242. MsgId: "H44022900158202103301748008725",
  37243. PsnNo: "44020000001104246641",
  37244. Info: "2208",
  37245. }
  37246. customData = append(customData, custom5)
  37247. custom6 := &CustomData{
  37248. MsgId: "H44022900158202103301718096755",
  37249. PsnNo: "44020000001102211860",
  37250. Info: "2208",
  37251. }
  37252. customData = append(customData, custom6)
  37253. custom7 := &CustomData{
  37254. MsgId: "H44022900158202103301736551640",
  37255. PsnNo: "44020000001102687718",
  37256. Info: "2208",
  37257. }
  37258. customData = append(customData, custom7)
  37259. custom8 := &CustomData{
  37260. MsgId: "H44022900158202103301743097676",
  37261. PsnNo: "44020000001102127785",
  37262. Info: "2208",
  37263. }
  37264. customData = append(customData, custom8)
  37265. custom9 := &CustomData{
  37266. MsgId: "H44022900158202103301712304203",
  37267. PsnNo: "44020000001101518097",
  37268. Info: "2208",
  37269. }
  37270. customData = append(customData, custom9)
  37271. custom10 := &CustomData{
  37272. MsgId: "H44022900158202103301738448785",
  37273. PsnNo: "44020000001100500813",
  37274. Info: "2208",
  37275. }
  37276. customData = append(customData, custom10)
  37277. custom11 := &CustomData{
  37278. MsgId: "H44022900158202103301732455843",
  37279. PsnNo: "44020000001102690557",
  37280. Info: "2208",
  37281. }
  37282. customData = append(customData, custom11)
  37283. custom12 := &CustomData{
  37284. MsgId: "H44022900158202103301745421708",
  37285. PsnNo: "44020000001102211928",
  37286. Info: "2208",
  37287. }
  37288. customData = append(customData, custom12)
  37289. custom1212 := &CustomData{
  37290. MsgId: "H440229001582021033017351627",
  37291. PsnNo: "44020000001102481733",
  37292. Info: "2208",
  37293. }
  37294. customData = append(customData, custom1212)
  37295. custom13 := &CustomData{
  37296. MsgId: "H44022900158202103301740327951",
  37297. PsnNo: "44020000001103174866",
  37298. Info: "2208",
  37299. }
  37300. customData = append(customData, custom13)
  37301. custom14 := &CustomData{
  37302. MsgId: "H4402290015820210330174922668",
  37303. PsnNo: "44020000001102927272",
  37304. Info: "2208",
  37305. }
  37306. customData = append(customData, custom14)
  37307. custom15 := &CustomData{
  37308. MsgId: "H44022900158202103301752362273",
  37309. PsnNo: "44020000001102942890",
  37310. Info: "2208",
  37311. }
  37312. customData = append(customData, custom15)
  37313. custom16 := &CustomData{
  37314. MsgId: "H44022900158202103301751082917",
  37315. PsnNo: "44020000001101662162",
  37316. Info: "2208",
  37317. }
  37318. customData = append(customData, custom16)
  37319. custom17 := &CustomData{
  37320. MsgId: "H44022900158202103301754147728",
  37321. PsnNo: "44020000000229014511",
  37322. Info: "2208",
  37323. }
  37324. customData = append(customData, custom17)
  37325. adminUser := c.GetAdminUserInfo()
  37326. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37327. for _, item := range customData {
  37328. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37329. fmt.Println(result)
  37330. }
  37331. }
  37332. func PathExists(path string) (bool, error) {
  37333. _, err := os.Stat(path)
  37334. if err == nil {
  37335. return true, nil
  37336. }
  37337. if os.IsNotExist(err) {
  37338. return false, nil
  37339. }
  37340. return false, err
  37341. }
  37342. // 创建文件夹
  37343. func Mkdir(dir string) {
  37344. // 创建文件夹
  37345. exist, err := PathExists(dir)
  37346. if err != nil {
  37347. fmt.Println(err.Error())
  37348. } else {
  37349. if exist {
  37350. fmt.Println(dir + "文件夹已存在!")
  37351. } else {
  37352. // 文件夹名称,权限
  37353. err := os.Mkdir(dir, os.ModePerm)
  37354. if err != nil {
  37355. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37356. } else {
  37357. fmt.Println(dir + "文件夹创建成功!")
  37358. }
  37359. }
  37360. }
  37361. }
  37362. // 压缩文件
  37363. func Zip(srcFile string, destZip string) error {
  37364. zipfile, err := os.Create(destZip)
  37365. if err != nil {
  37366. return err
  37367. }
  37368. defer zipfile.Close()
  37369. archive := zip.NewWriter(zipfile)
  37370. defer archive.Close()
  37371. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37372. if err != nil {
  37373. return err
  37374. }
  37375. header, err := zip.FileInfoHeader(info)
  37376. if err != nil {
  37377. return err
  37378. }
  37379. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37380. // header.Name = path
  37381. if info.IsDir() {
  37382. header.Name += "/"
  37383. } else {
  37384. header.Method = zip.Deflate
  37385. }
  37386. writer, err := archive.CreateHeader(header)
  37387. if err != nil {
  37388. return err
  37389. }
  37390. if !info.IsDir() {
  37391. file, err := os.Open(path)
  37392. if err != nil {
  37393. return err
  37394. }
  37395. defer file.Close()
  37396. _, err = io.Copy(writer, file)
  37397. }
  37398. return err
  37399. })
  37400. return err
  37401. }
  37402. func ReadFile(filePath string) []byte {
  37403. f, err := os.Open(filePath)
  37404. if err != nil {
  37405. fmt.Println("read file fail", err)
  37406. return nil
  37407. }
  37408. defer f.Close()
  37409. fd, err := ioutil.ReadAll(f)
  37410. if err != nil {
  37411. fmt.Println("read to fd fail", err)
  37412. return nil
  37413. }
  37414. return fd
  37415. }
  37416. func saveLogq(result string, request string, infno string, desc string) {
  37417. dir := "日志"
  37418. utils.Mkdir(dir)
  37419. month := time.Unix(1557042972, 0).Format("1")
  37420. year := time.Now().Format("2006")
  37421. month = time.Now().Format("01")
  37422. day := time.Now().Format("02")
  37423. hour := time.Now().Format("15")
  37424. min := time.Now().Format("04")
  37425. sec := time.Now().Format("05")
  37426. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37427. file := year + month + day + "_log"
  37428. file_name := file + ".txt"
  37429. file_path := "日志" + "/" + file_name
  37430. exist, _ := utils.PathExists(file_path)
  37431. if exist { //存在
  37432. fmt.Println("存在")
  37433. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37434. if err != nil {
  37435. fmt.Println("read fail")
  37436. }
  37437. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37438. n, _ := f.Seek(0, 2)
  37439. _, err = f.WriteAt([]byte(content), n)
  37440. } else { //不存在
  37441. fmt.Println("文件不存在,创建文件")
  37442. f, err := os.Create("日志" + "/" + file_name)
  37443. defer f.Close()
  37444. if err != nil {
  37445. } else {
  37446. _, err = f.Write([]byte("记录日志"))
  37447. }
  37448. }
  37449. }
  37450. func saveLog(result string, request string, infno string, desc string) {
  37451. org_id, _ := beego.AppConfig.Int64("org_id")
  37452. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37453. dir := miConfig.OrgName + "日志"
  37454. utils.Mkdir(dir)
  37455. month := time.Unix(1557042972, 0).Format("1")
  37456. year := time.Now().Format("2006")
  37457. month = time.Now().Format("01")
  37458. day := time.Now().Format("02")
  37459. hour := time.Now().Format("15")
  37460. min := time.Now().Format("04")
  37461. sec := time.Now().Format("05")
  37462. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37463. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37464. file_name := file + ".txt"
  37465. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37466. exist, _ := utils.PathExists(file_path)
  37467. if exist { //存在
  37468. fmt.Println("存在")
  37469. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37470. if err != nil {
  37471. fmt.Println("read fail")
  37472. }
  37473. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37474. n, _ := f.Seek(0, 2)
  37475. _, err = f.WriteAt([]byte(content), n)
  37476. } else { //不存在
  37477. fmt.Println("文件不存在,创建文件")
  37478. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37479. defer f.Close()
  37480. if err != nil {
  37481. } else {
  37482. _, err = f.Write([]byte("记录日志"))
  37483. }
  37484. }
  37485. }
  37486. type Charset string
  37487. const (
  37488. UTF8 = Charset("UTF-8")
  37489. GB18030 = Charset("GB18030")
  37490. )
  37491. func ConvertToString(src string, srcCode string, tagCode string) string {
  37492. srcCoder := mahonia.NewDecoder(srcCode)
  37493. srcResult := srcCoder.ConvertString(src)
  37494. tagCoder := mahonia.NewDecoder(tagCode)
  37495. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37496. result := string(cdata)
  37497. return result
  37498. }
  37499. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37500. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37501. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37502. var token string
  37503. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37504. var api string
  37505. if miConfig.MdtrtareaAdmvs == "320921" {
  37506. 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 +
  37507. "&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
  37508. fmt.Println(api)
  37509. } else {
  37510. 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 +
  37511. "&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
  37512. }
  37513. resp, requestErr := http.Get(api)
  37514. if requestErr != nil {
  37515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37516. return ""
  37517. }
  37518. body, ioErr := ioutil.ReadAll(resp.Body)
  37519. if ioErr != nil {
  37520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37522. return ""
  37523. }
  37524. var respJSON map[string]interface{}
  37525. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37528. return ""
  37529. }
  37530. var status string
  37531. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37532. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37533. var res ResultTwo //1101结果
  37534. var res10265 ResultTwo10265 //1101结果
  37535. if status == "0" { //读卡成功
  37536. var card_info string //卡信息
  37537. var busi_card_info string
  37538. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37539. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37540. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37541. fmt.Println(card_info)
  37542. fmt.Println(busi_card_info)
  37543. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37544. result, _ := json.Marshal(respJSON)
  37545. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37546. utils.ErrorLog("解析失败:%v", err)
  37547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37548. return ""
  37549. }
  37550. res.ErrMsg = res10265.ErrMsg
  37551. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37552. res.Infcode = infocode
  37553. res.Output = res10265.Output
  37554. res.InfRefmsgid = res10265.InfRefmsgid
  37555. if res.Infcode == 0 {
  37556. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37557. if err == gorm.ErrRecordNotFound {
  37558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37559. return ""
  37560. } else if err != nil {
  37561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37562. return ""
  37563. } else {
  37564. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37565. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37566. infoStr := string(Iinfos)
  37567. idetinfoStr := string(Idetinfos)
  37568. psn := &models.HisPsn{
  37569. PsnNo: res.Output.Baseinfo.PsnNo,
  37570. PatientId: patient.ID,
  37571. Certno: res.Output.Baseinfo.Certno,
  37572. Gend: res.Output.Baseinfo.Gend,
  37573. Naty: res.Output.Baseinfo.Naty,
  37574. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37575. PsnName: res.Output.Baseinfo.PsnName,
  37576. Idetinfo: idetinfoStr,
  37577. Insuinfo: infoStr,
  37578. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37579. CardInfo: card_info,
  37580. VerifyNumber: token,
  37581. }
  37582. service.CreateHisPsn(psn)
  37583. return token
  37584. }
  37585. }
  37586. } else {
  37587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37588. return ""
  37589. }
  37590. } else { //读卡失败
  37591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37592. return ""
  37593. }
  37594. return token
  37595. }
  37596. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37597. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37598. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37599. var token string
  37600. var api string
  37601. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37602. "&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
  37603. fmt.Println(api)
  37604. resp, requestErr := http.Get(api)
  37605. if requestErr != nil {
  37606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37607. return ""
  37608. }
  37609. body, ioErr := ioutil.ReadAll(resp.Body)
  37610. if ioErr != nil {
  37611. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37613. return ""
  37614. }
  37615. var respJSON map[string]interface{}
  37616. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37619. return ""
  37620. }
  37621. var status string
  37622. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37623. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37624. var res ResultTwo //1101结果
  37625. if status == "1" { //读卡成功
  37626. var card_info string //卡信息
  37627. var busi_card_info string
  37628. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37629. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37630. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37631. fmt.Println(card_info)
  37632. fmt.Println(busi_card_info)
  37633. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37634. result, _ := json.Marshal(respJSON)
  37635. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37636. utils.ErrorLog("解析失败:%v", err)
  37637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37638. return ""
  37639. }
  37640. if res.Infcode == 0 {
  37641. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37642. if err == gorm.ErrRecordNotFound {
  37643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37644. return ""
  37645. } else if err != nil {
  37646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37647. return ""
  37648. } else {
  37649. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37650. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37651. infoStr := string(Iinfos)
  37652. idetinfoStr := string(Idetinfos)
  37653. psn := &models.HisPsn{
  37654. PsnNo: res.Output.Baseinfo.PsnNo,
  37655. PatientId: patient.ID,
  37656. Certno: res.Output.Baseinfo.Certno,
  37657. Gend: res.Output.Baseinfo.Gend,
  37658. Naty: res.Output.Baseinfo.Naty,
  37659. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37660. PsnName: res.Output.Baseinfo.PsnName,
  37661. Idetinfo: idetinfoStr,
  37662. Insuinfo: infoStr,
  37663. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37664. CardInfo: card_info,
  37665. VerifyNumber: token,
  37666. }
  37667. service.CreateHisPsn(psn)
  37668. return token
  37669. }
  37670. }
  37671. } else {
  37672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37673. return ""
  37674. }
  37675. return token
  37676. }
  37677. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37678. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37679. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37680. var token string
  37681. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37682. var api string
  37683. if miConfig.MdtrtareaAdmvs == "320921" {
  37684. 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 +
  37685. "&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
  37686. fmt.Println(api)
  37687. } else {
  37688. 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 +
  37689. "&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
  37690. }
  37691. resp, requestErr := http.Get(api)
  37692. if requestErr != nil {
  37693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37694. return ""
  37695. }
  37696. body, ioErr := ioutil.ReadAll(resp.Body)
  37697. if ioErr != nil {
  37698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37700. return ""
  37701. }
  37702. var respJSON map[string]interface{}
  37703. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37706. return ""
  37707. }
  37708. var status string
  37709. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37710. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37711. var res ResultTwo //1101结果
  37712. var res10265 ResultTwo10265 //1101结果
  37713. if status == "0" { //读卡成功
  37714. var card_info string //卡信息
  37715. var busi_card_info string
  37716. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37717. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37718. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37719. fmt.Println(card_info)
  37720. fmt.Println(busi_card_info)
  37721. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37722. result, _ := json.Marshal(respJSON)
  37723. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37724. utils.ErrorLog("解析失败:%v", err)
  37725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37726. return ""
  37727. }
  37728. res.ErrMsg = res10265.ErrMsg
  37729. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37730. res.Infcode = infocode
  37731. res.Output = res10265.Output
  37732. res.InfRefmsgid = res10265.InfRefmsgid
  37733. if res.Infcode == 0 {
  37734. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37735. if err == gorm.ErrRecordNotFound {
  37736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37737. return ""
  37738. } else if err != nil {
  37739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37740. return ""
  37741. } else {
  37742. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37743. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37744. infoStr := string(Iinfos)
  37745. idetinfoStr := string(Idetinfos)
  37746. psn := &models.HisPsn{
  37747. PsnNo: res.Output.Baseinfo.PsnNo,
  37748. PatientId: patient.ID,
  37749. Certno: res.Output.Baseinfo.Certno,
  37750. Gend: res.Output.Baseinfo.Gend,
  37751. Naty: res.Output.Baseinfo.Naty,
  37752. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37753. PsnName: res.Output.Baseinfo.PsnName,
  37754. Idetinfo: idetinfoStr,
  37755. Insuinfo: infoStr,
  37756. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37757. CardInfo: card_info,
  37758. VerifyNumber: token,
  37759. }
  37760. service.CreateHisPsn(psn)
  37761. return token
  37762. }
  37763. }
  37764. } else {
  37765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37766. return ""
  37767. }
  37768. } else { //读卡失败
  37769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37770. return ""
  37771. }
  37772. return token
  37773. }
  37774. func DeleteExtraSpaceTwo(s string) string {
  37775. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37776. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37777. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37778. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37779. s2 := make([]byte, len(s1)) //定义字符数组切片
  37780. copy(s2, s1) //将字符串复制到切片
  37781. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37782. for len(spc_index) > 0 { //找到适配项
  37783. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37784. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37785. }
  37786. return string(s2)
  37787. }
  37788. func Remove0000(s string) string {
  37789. str := make([]rune, 0, len(s))
  37790. for _, v := range []rune(s) {
  37791. if v == 0 {
  37792. continue
  37793. }
  37794. str = append(str, v)
  37795. }
  37796. return string(str)
  37797. }
  37798. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37799. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37800. readCard := DllDef.MustFindProc("EcQuery")
  37801. pCardInfo := make([]byte, 8192)
  37802. pBusiCardInfo := make([]byte, 8192)
  37803. data := make(map[string]interface{})
  37804. //pData := make(map[string]interface{})
  37805. inputData := make(map[string]interface{})
  37806. inputData["orgId"] = code
  37807. inputData["businessType"] = "01101"
  37808. inputData["operatorId"] = operator_id
  37809. inputData["operatorName"] = operator_name
  37810. inputData["officeId"] = "001"
  37811. inputData["officeName"] = "血透室"
  37812. //
  37813. data["data"] = inputData
  37814. data["transType"] = "ec.query"
  37815. data["orgId"] = code
  37816. bytesData, _ := json.Marshal(data)
  37817. pCardInfo = bytesData
  37818. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37819. fmt.Println(ret2)
  37820. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37821. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37822. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37823. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37824. if ret2 != 0 {
  37825. return "", ""
  37826. }
  37827. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37828. }
  37829. func DeleteExtraSpace(s string) string {
  37830. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37831. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37832. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37833. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37834. s2 := make([]byte, len(s1)) //定义字符数组切片
  37835. copy(s2, s1) //将字符串复制到切片
  37836. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37837. for len(spc_index) > 0 { //找到适配项
  37838. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37839. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37840. }
  37841. return string(s2)
  37842. }
  37843. // 对账
  37844. func (c *HisApiController) Post3202() {
  37845. start_time := c.GetString("start_time")
  37846. end_time := c.GetString("end_time")
  37847. //insutype := c.GetString("insutype")
  37848. clr_type := c.GetString("clr_type")
  37849. clr_org := c.GetString("clr_optins")
  37850. admin_user_id, _ := c.GetInt64("admin_user_id")
  37851. adminUser := c.GetAdminUserInfo()
  37852. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37853. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37854. if len(clr_org) == 0 {
  37855. clr_org = miConfig.MdtrtareaAdmvs
  37856. }
  37857. timeLayout := "2006-01-02"
  37858. loc, _ := time.LoadLocation("Local")
  37859. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37860. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37861. var orders []*models.HisOrder
  37862. if clr_org == "421300" {
  37863. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37864. } else if clr_org == "420902" {
  37865. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37866. } else {
  37867. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37868. }
  37869. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37870. //fixmedins_setl_cnt := int64(len(orders))
  37871. var medfee_sumamt float64
  37872. var acct_pay float64
  37873. var fund_pay_sumamt float64
  37874. for _, item := range orders {
  37875. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37876. acct_pay = acct_pay + item.AcctPay
  37877. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37878. }
  37879. //var medfee_sumamt_two float64
  37880. //var acct_pay_two float64
  37881. //var fund_pay_sumamt_two float64
  37882. //for _, item := range orders_two {
  37883. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37884. // acct_pay_two = acct_pay_two + item.AcctPay
  37885. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37886. //}
  37887. //var user_name string
  37888. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37889. //if role.ID == 0 {
  37890. // user_name = "xxx"
  37891. //} else {
  37892. // user_name = role.UserName
  37893. //}
  37894. var res ResultSix
  37895. if config.IsOpen == 1 {
  37896. var bps []*models.BusinessParamsTwo
  37897. var bp models.BusinessParamsTwo
  37898. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37899. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37900. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37901. bp.MedfeeSumamt = medfee_sumamt_str
  37902. bp.AcctPay = acct_pay_str
  37903. bp.FundPaySumamt = fund_pay_sumamt_str
  37904. bp.Insutype = ""
  37905. bp.StmtBegndate = start_time
  37906. bp.ClrType = clr_type
  37907. bp.SetlOptins = clr_org
  37908. bp.StmtEnddate = end_time
  37909. bps = append(bps, &bp)
  37910. data := make(map[string]interface{})
  37911. data["bps"] = bps
  37912. data["org_name"] = miConfig.OrgName
  37913. data["doctor"] = role.UserName
  37914. data["fixmedins_code"] = miConfig.Code
  37915. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37916. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37917. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37918. if miConfig.MdtrtareaAdmvs == "421300" {
  37919. client := &http.Client{}
  37920. bytesData, _ := json.Marshal(data)
  37921. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37922. resp, _ := client.Do(req)
  37923. defer resp.Body.Close()
  37924. body, ioErr := ioutil.ReadAll(resp.Body)
  37925. if ioErr != nil {
  37926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37928. return
  37929. }
  37930. var respJSON map[string]interface{}
  37931. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37934. return
  37935. }
  37936. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37937. userJSONBytes, _ := json.Marshal(respJSON)
  37938. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37939. utils.ErrorLog("解析失败:%v", err)
  37940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37941. return
  37942. }
  37943. }
  37944. if miConfig.MdtrtareaAdmvs == "420200" {
  37945. client := &http.Client{}
  37946. bytesData, _ := json.Marshal(data)
  37947. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37948. resp, _ := client.Do(req)
  37949. defer resp.Body.Close()
  37950. body, ioErr := ioutil.ReadAll(resp.Body)
  37951. if ioErr != nil {
  37952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37954. return
  37955. }
  37956. var respJSON map[string]interface{}
  37957. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37960. return
  37961. }
  37962. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37963. userJSONBytes, _ := json.Marshal(respJSON)
  37964. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37965. utils.ErrorLog("解析失败:%v", err)
  37966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37967. return
  37968. }
  37969. }
  37970. if miConfig.MdtrtareaAdmvs == "421182" {
  37971. client := &http.Client{}
  37972. bytesData, _ := json.Marshal(data)
  37973. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37974. resp, _ := client.Do(req)
  37975. defer resp.Body.Close()
  37976. body, ioErr := ioutil.ReadAll(resp.Body)
  37977. if ioErr != nil {
  37978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37980. return
  37981. }
  37982. var respJSON map[string]interface{}
  37983. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37986. return
  37987. }
  37988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37989. userJSONBytes, _ := json.Marshal(respJSON)
  37990. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37991. utils.ErrorLog("解析失败:%v", err)
  37992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37993. return
  37994. }
  37995. }
  37996. if miConfig.MdtrtareaAdmvs == "420902" {
  37997. client := &http.Client{}
  37998. bytesData, _ := json.Marshal(data)
  37999. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38000. resp, _ := client.Do(req)
  38001. defer resp.Body.Close()
  38002. body, ioErr := ioutil.ReadAll(resp.Body)
  38003. if ioErr != nil {
  38004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38006. return
  38007. }
  38008. var respJSON map[string]interface{}
  38009. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38012. return
  38013. }
  38014. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38015. userJSONBytes, _ := json.Marshal(respJSON)
  38016. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38017. utils.ErrorLog("解析失败:%v", err)
  38018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38019. return
  38020. }
  38021. }
  38022. if res.Infcode == 0 {
  38023. c.ServeSuccessJSON(map[string]interface{}{
  38024. "msg": "发起成功",
  38025. })
  38026. } else {
  38027. c.ServeSuccessJSON(map[string]interface{}{
  38028. "failed_code": -10,
  38029. "msg": res.ErrMsg,
  38030. })
  38031. }
  38032. }
  38033. }
  38034. func (c *HisApiController) Post3204a() {
  38035. start_time := c.GetString("start_time")
  38036. end_time := c.GetString("end_time")
  38037. //insutype := c.GetString("insutype")
  38038. clr_type := c.GetString("clr_type")
  38039. clr_org := c.GetString("clr_optins")
  38040. admin_user_id, _ := c.GetInt64("admin_user_id")
  38041. adminUser := c.GetAdminUserInfo()
  38042. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38043. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38044. if len(clr_org) == 0 {
  38045. clr_org = miConfig.MdtrtareaAdmvs
  38046. }
  38047. timeLayout := "2006-01-02"
  38048. loc, _ := time.LoadLocation("Local")
  38049. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38050. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38051. var orders []*models.HisOrder
  38052. if clr_org == "421300" {
  38053. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38054. } else if clr_org == "420902" {
  38055. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38056. } else {
  38057. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38058. }
  38059. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38060. //fixmedins_setl_cnt := int64(len(orders))
  38061. var medfee_sumamt float64
  38062. var acct_pay float64
  38063. var fund_pay_sumamt float64
  38064. for _, item := range orders {
  38065. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38066. acct_pay = acct_pay + item.AcctPay
  38067. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38068. }
  38069. //var medfee_sumamt_two float64
  38070. //var acct_pay_two float64
  38071. //var fund_pay_sumamt_two float64
  38072. //for _, item := range orders_two {
  38073. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38074. // acct_pay_two = acct_pay_two + item.AcctPay
  38075. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38076. //}
  38077. //var user_name string
  38078. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38079. //if role.ID == 0 {
  38080. // user_name = "xxx"
  38081. //} else {
  38082. // user_name = role.UserName
  38083. //}
  38084. var res ResultSix
  38085. if config.IsOpen == 1 {
  38086. var bps []*models.BusinessParamsTwo
  38087. var bp models.BusinessParamsTwo
  38088. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38089. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38090. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38091. bp.MedfeeSumamt = medfee_sumamt_str
  38092. bp.AcctPay = acct_pay_str
  38093. bp.FundPaySumamt = fund_pay_sumamt_str
  38094. bp.Insutype = ""
  38095. bp.StmtBegndate = start_time
  38096. bp.ClrType = clr_type
  38097. bp.SetlOptins = clr_org
  38098. bp.StmtEnddate = end_time
  38099. bps = append(bps, &bp)
  38100. data := make(map[string]interface{})
  38101. data["bps"] = bps
  38102. data["org_name"] = miConfig.OrgName
  38103. data["doctor"] = role.UserName
  38104. data["fixmedins_code"] = miConfig.Code
  38105. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38106. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38107. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38108. if miConfig.MdtrtareaAdmvs == "421300" {
  38109. client := &http.Client{}
  38110. bytesData, _ := json.Marshal(data)
  38111. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38112. resp, _ := client.Do(req)
  38113. defer resp.Body.Close()
  38114. body, ioErr := ioutil.ReadAll(resp.Body)
  38115. if ioErr != nil {
  38116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38118. return
  38119. }
  38120. var respJSON map[string]interface{}
  38121. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38124. return
  38125. }
  38126. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38127. userJSONBytes, _ := json.Marshal(respJSON)
  38128. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38129. utils.ErrorLog("解析失败:%v", err)
  38130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38131. return
  38132. }
  38133. }
  38134. if miConfig.MdtrtareaAdmvs == "420200" {
  38135. client := &http.Client{}
  38136. bytesData, _ := json.Marshal(data)
  38137. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38138. resp, _ := client.Do(req)
  38139. defer resp.Body.Close()
  38140. body, ioErr := ioutil.ReadAll(resp.Body)
  38141. if ioErr != nil {
  38142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38144. return
  38145. }
  38146. var respJSON map[string]interface{}
  38147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38150. return
  38151. }
  38152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38153. userJSONBytes, _ := json.Marshal(respJSON)
  38154. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38155. utils.ErrorLog("解析失败:%v", err)
  38156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38157. return
  38158. }
  38159. }
  38160. if miConfig.MdtrtareaAdmvs == "421182" {
  38161. client := &http.Client{}
  38162. bytesData, _ := json.Marshal(data)
  38163. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38164. resp, _ := client.Do(req)
  38165. defer resp.Body.Close()
  38166. body, ioErr := ioutil.ReadAll(resp.Body)
  38167. if ioErr != nil {
  38168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38170. return
  38171. }
  38172. var respJSON map[string]interface{}
  38173. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38176. return
  38177. }
  38178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38179. userJSONBytes, _ := json.Marshal(respJSON)
  38180. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38181. utils.ErrorLog("解析失败:%v", err)
  38182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38183. return
  38184. }
  38185. }
  38186. if miConfig.MdtrtareaAdmvs == "420902" {
  38187. client := &http.Client{}
  38188. bytesData, _ := json.Marshal(data)
  38189. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38190. resp, _ := client.Do(req)
  38191. defer resp.Body.Close()
  38192. body, ioErr := ioutil.ReadAll(resp.Body)
  38193. if ioErr != nil {
  38194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38196. return
  38197. }
  38198. var respJSON map[string]interface{}
  38199. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38202. return
  38203. }
  38204. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38205. userJSONBytes, _ := json.Marshal(respJSON)
  38206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38207. utils.ErrorLog("解析失败:%v", err)
  38208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38209. return
  38210. }
  38211. }
  38212. if res.Infcode == 0 {
  38213. c.ServeSuccessJSON(map[string]interface{}{
  38214. "msg": "撤销成功",
  38215. })
  38216. } else {
  38217. c.ServeSuccessJSON(map[string]interface{}{
  38218. "failed_code": -10,
  38219. "msg": res.ErrMsg,
  38220. })
  38221. }
  38222. }
  38223. }
  38224. func (c *HisApiController) Post3204() {
  38225. admin_user_id, _ := c.GetInt64("admin_user_id")
  38226. id := c.GetString("id")
  38227. adminUser := c.GetAdminUserInfo()
  38228. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38229. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38230. //clr_org := miConfig.MdtrtareaAdmvs
  38231. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38232. var res ResultSix
  38233. if config.IsOpen == 1 {
  38234. data := make(map[string]interface{})
  38235. data["id"] = id
  38236. data["org_name"] = miConfig.OrgName
  38237. data["doctor"] = role.UserName
  38238. data["fixmedins_code"] = miConfig.Code
  38239. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38240. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38241. client := &http.Client{}
  38242. bytesData, _ := json.Marshal(data)
  38243. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38244. resp, _ := client.Do(req)
  38245. defer resp.Body.Close()
  38246. body, ioErr := ioutil.ReadAll(resp.Body)
  38247. if ioErr != nil {
  38248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38250. return
  38251. }
  38252. var respJSON map[string]interface{}
  38253. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38256. return
  38257. }
  38258. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38259. userJSONBytes, _ := json.Marshal(respJSON)
  38260. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38261. utils.ErrorLog("解析失败:%v", err)
  38262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38263. return
  38264. }
  38265. if res.Infcode == 0 {
  38266. c.ServeSuccessJSON(map[string]interface{}{
  38267. "msg": "发起成功",
  38268. })
  38269. } else {
  38270. c.ServeSuccessJSON(map[string]interface{}{
  38271. "failed_code": -10,
  38272. "msg": res.ErrMsg,
  38273. })
  38274. }
  38275. }
  38276. }
  38277. func (c *HisApiController) Post8404() {
  38278. admin_user_id, _ := c.GetInt64("admin_user_id")
  38279. month := c.GetString("month")
  38280. adminUser := c.GetAdminUserInfo()
  38281. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38282. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38283. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38284. var res ResultSix
  38285. if config.IsOpen == 1 {
  38286. data := make(map[string]interface{})
  38287. data["month"] = month
  38288. data["org_name"] = miConfig.OrgName
  38289. data["doctor"] = role.UserName
  38290. data["fixmedins_code"] = miConfig.Code
  38291. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38292. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38293. client := &http.Client{}
  38294. bytesData, _ := json.Marshal(data)
  38295. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38296. resp, _ := client.Do(req)
  38297. defer resp.Body.Close()
  38298. body, ioErr := ioutil.ReadAll(resp.Body)
  38299. if ioErr != nil {
  38300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38302. return
  38303. }
  38304. var respJSON map[string]interface{}
  38305. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38308. return
  38309. }
  38310. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38311. userJSONBytes, _ := json.Marshal(respJSON)
  38312. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38313. utils.ErrorLog("解析失败:%v", err)
  38314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38315. return
  38316. }
  38317. if res.Infcode == 0 {
  38318. c.ServeSuccessJSON(map[string]interface{}{
  38319. "msg": "查询成功",
  38320. })
  38321. } else {
  38322. c.ServeSuccessJSON(map[string]interface{}{
  38323. "failed_code": -10,
  38324. "msg": res.ErrMsg,
  38325. })
  38326. }
  38327. }
  38328. }
  38329. func (c *HisApiController) Post3202b() {
  38330. start_time := c.GetString("start_time")
  38331. end_time := c.GetString("end_time")
  38332. //insutype := c.GetString("insutype")
  38333. clr_type := c.GetString("clr_type")
  38334. clr_org := c.GetString("clr_optins")
  38335. admin_user_id, _ := c.GetInt64("admin_user_id")
  38336. adminUser := c.GetAdminUserInfo()
  38337. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38338. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38339. if len(clr_org) == 0 {
  38340. clr_org = miConfig.MdtrtareaAdmvs
  38341. }
  38342. timeLayout := "2006-01-02"
  38343. loc, _ := time.LoadLocation("Local")
  38344. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38345. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38346. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38347. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38348. //fixmedins_setl_cnt := int64(len(orders))
  38349. var medfee_sumamt float64
  38350. var acct_pay float64
  38351. var fund_pay_sumamt float64
  38352. for _, item := range orders {
  38353. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38354. acct_pay = acct_pay + item.AcctPay
  38355. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38356. }
  38357. //var medfee_sumamt_two float64
  38358. //var acct_pay_two float64
  38359. //var fund_pay_sumamt_two float64
  38360. //for _, item := range orders_two {
  38361. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38362. // acct_pay_two = acct_pay_two + item.AcctPay
  38363. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38364. //}
  38365. //var user_name string
  38366. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38367. //if role.ID == 0 {
  38368. // user_name = "xxx"
  38369. //} else {
  38370. // user_name = role.UserName
  38371. //}
  38372. var res ResultSix
  38373. if config.IsOpen == 1 {
  38374. var bps []*models.BusinessParamsTwo
  38375. var bp models.BusinessParamsTwo
  38376. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38377. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38378. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38379. bp.MedfeeSumamt = medfee_sumamt_str
  38380. bp.AcctPay = acct_pay_str
  38381. bp.FundPaySumamt = fund_pay_sumamt_str
  38382. bp.Insutype = "390"
  38383. bp.StmtBegndate = start_time
  38384. bp.ClrType = clr_type
  38385. bp.SetlOptins = clr_org
  38386. bp.StmtEnddate = end_time
  38387. bps = append(bps, &bp)
  38388. data := make(map[string]interface{})
  38389. data["bps"] = bps
  38390. data["org_name"] = miConfig.OrgName
  38391. data["doctor"] = role.UserName
  38392. data["fixmedins_code"] = miConfig.Code
  38393. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38394. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38395. if miConfig.MdtrtareaAdmvs == "421300" {
  38396. client := &http.Client{}
  38397. bytesData, _ := json.Marshal(data)
  38398. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38399. resp, _ := client.Do(req)
  38400. defer resp.Body.Close()
  38401. body, ioErr := ioutil.ReadAll(resp.Body)
  38402. if ioErr != nil {
  38403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38405. return
  38406. }
  38407. var respJSON map[string]interface{}
  38408. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38411. return
  38412. }
  38413. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38414. userJSONBytes, _ := json.Marshal(respJSON)
  38415. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38416. utils.ErrorLog("解析失败:%v", err)
  38417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38418. return
  38419. }
  38420. }
  38421. if miConfig.MdtrtareaAdmvs == "420200" {
  38422. client := &http.Client{}
  38423. bytesData, _ := json.Marshal(data)
  38424. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38425. resp, _ := client.Do(req)
  38426. defer resp.Body.Close()
  38427. body, ioErr := ioutil.ReadAll(resp.Body)
  38428. if ioErr != nil {
  38429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38431. return
  38432. }
  38433. var respJSON map[string]interface{}
  38434. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38437. return
  38438. }
  38439. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38440. userJSONBytes, _ := json.Marshal(respJSON)
  38441. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38442. utils.ErrorLog("解析失败:%v", err)
  38443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38444. return
  38445. }
  38446. }
  38447. if miConfig.MdtrtareaAdmvs == "421182" {
  38448. client := &http.Client{}
  38449. bytesData, _ := json.Marshal(data)
  38450. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38451. resp, _ := client.Do(req)
  38452. defer resp.Body.Close()
  38453. body, ioErr := ioutil.ReadAll(resp.Body)
  38454. if ioErr != nil {
  38455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38457. return
  38458. }
  38459. var respJSON map[string]interface{}
  38460. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38463. return
  38464. }
  38465. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38466. userJSONBytes, _ := json.Marshal(respJSON)
  38467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38468. utils.ErrorLog("解析失败:%v", err)
  38469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38470. return
  38471. }
  38472. }
  38473. if res.Infcode == 0 {
  38474. c.ServeSuccessJSON(map[string]interface{}{
  38475. "msg": "发起成功",
  38476. })
  38477. } else {
  38478. c.ServeSuccessJSON(map[string]interface{}{
  38479. "failed_code": -10,
  38480. "msg": res.ErrMsg,
  38481. })
  38482. }
  38483. }
  38484. }
  38485. func (c *HisApiController) Post1608() {
  38486. start_time := c.GetString("start_time")
  38487. end_time := c.GetString("end_time")
  38488. admin_user_id, _ := c.GetInt64("admin_user_id")
  38489. adminUser := c.GetAdminUserInfo()
  38490. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38491. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38492. timeLayout := "2006-01-02"
  38493. loc, _ := time.LoadLocation("Local")
  38494. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38495. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38496. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38497. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38498. fixmedins_setl_cnt := int64(len(orders))
  38499. var medfee_sumamt float64
  38500. var func_smamt float64
  38501. for _, item := range orders {
  38502. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38503. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38504. }
  38505. times := strings.Split(start_time, "-")
  38506. time_tows := strings.Split(end_time, "-")
  38507. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38508. var res ResultSix
  38509. if config.IsOpen == 1 {
  38510. //var bps []*models.BusinessParamsTwo
  38511. //var bp models.BusinessParamsTwo
  38512. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38513. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38514. data := make(map[string]interface{})
  38515. data["org_name"] = miConfig.OrgName
  38516. data["doctor"] = role.UserName
  38517. data["func_smamt"] = func_smamt_str
  38518. data["fixmedins_code"] = miConfig.Code
  38519. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38520. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38521. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38522. data["medfee_sumamt"] = medfee_sumamt_str
  38523. data["start_time"] = times[0] + times[1] + times[2]
  38524. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38525. if miConfig.MdtrtareaAdmvs == "421300" {
  38526. client := &http.Client{}
  38527. bytesData, _ := json.Marshal(data)
  38528. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38529. resp, _ := client.Do(req)
  38530. defer resp.Body.Close()
  38531. body, ioErr := ioutil.ReadAll(resp.Body)
  38532. if ioErr != nil {
  38533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38535. return
  38536. }
  38537. var respJSON map[string]interface{}
  38538. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38541. return
  38542. }
  38543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38544. userJSONBytes, _ := json.Marshal(respJSON)
  38545. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38546. utils.ErrorLog("解析失败:%v", err)
  38547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38548. return
  38549. }
  38550. }
  38551. if miConfig.MdtrtareaAdmvs == "420200" {
  38552. client := &http.Client{}
  38553. bytesData, _ := json.Marshal(data)
  38554. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38555. resp, _ := client.Do(req)
  38556. defer resp.Body.Close()
  38557. body, ioErr := ioutil.ReadAll(resp.Body)
  38558. if ioErr != nil {
  38559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38561. return
  38562. }
  38563. var respJSON map[string]interface{}
  38564. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38567. return
  38568. }
  38569. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38570. userJSONBytes, _ := json.Marshal(respJSON)
  38571. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38572. utils.ErrorLog("解析失败:%v", err)
  38573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38574. return
  38575. }
  38576. }
  38577. if miConfig.MdtrtareaAdmvs == "421182" {
  38578. client := &http.Client{}
  38579. bytesData, _ := json.Marshal(data)
  38580. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38581. resp, _ := client.Do(req)
  38582. defer resp.Body.Close()
  38583. body, ioErr := ioutil.ReadAll(resp.Body)
  38584. if ioErr != nil {
  38585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38587. return
  38588. }
  38589. var respJSON map[string]interface{}
  38590. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38593. return
  38594. }
  38595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38596. userJSONBytes, _ := json.Marshal(respJSON)
  38597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38598. utils.ErrorLog("解析失败:%v", err)
  38599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38600. return
  38601. }
  38602. }
  38603. if res.Infcode == 0 {
  38604. c.ServeSuccessJSON(map[string]interface{}{
  38605. "msg": "发起成功",
  38606. })
  38607. } else {
  38608. c.ServeSuccessJSON(map[string]interface{}{
  38609. "failed_code": -10,
  38610. "msg": res.ErrMsg,
  38611. })
  38612. }
  38613. }
  38614. }
  38615. // 5.11.1.1【5262】结算信息按时间段查询
  38616. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38617. admin_user_id, _ := c.GetInt64("admin_user_id")
  38618. adminUser := c.GetAdminUserInfo()
  38619. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38620. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38621. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38622. var res Result5262
  38623. if config.IsOpen == 1 {
  38624. if miConfig.MdtrtareaAdmvs == "421300" {
  38625. data := make(map[string]interface{})
  38626. data["bps"] = bp
  38627. data["org_name"] = miConfig.OrgName
  38628. data["doctor"] = role.UserName
  38629. data["fixmedins_code"] = miConfig.Code
  38630. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38631. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38632. data["page"] = strconv.FormatInt(page, 10)
  38633. data["limit"] = strconv.FormatInt(limit, 10)
  38634. fmt.Println(data)
  38635. client := &http.Client{}
  38636. bytesData, _ := json.Marshal(data)
  38637. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38638. resp, _ := client.Do(req)
  38639. defer resp.Body.Close()
  38640. body, ioErr := ioutil.ReadAll(resp.Body)
  38641. if ioErr != nil {
  38642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38644. return
  38645. }
  38646. var respJSON map[string]interface{}
  38647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38650. return
  38651. }
  38652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38653. userJSONBytes, _ := json.Marshal(respJSON)
  38654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38655. utils.ErrorLog("解析失败:%v", err)
  38656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38657. return
  38658. }
  38659. }
  38660. if miConfig.MdtrtareaAdmvs == "420200" {
  38661. data := make(map[string]interface{})
  38662. data["bps"] = bp
  38663. data["org_name"] = miConfig.OrgName
  38664. data["doctor"] = role.UserName
  38665. data["fixmedins_code"] = miConfig.Code
  38666. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38667. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38668. data["page"] = strconv.FormatInt(page, 10)
  38669. data["limit"] = strconv.FormatInt(limit, 10)
  38670. fmt.Println(data)
  38671. client := &http.Client{}
  38672. bytesData, _ := json.Marshal(data)
  38673. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38674. resp, _ := client.Do(req)
  38675. defer resp.Body.Close()
  38676. body, ioErr := ioutil.ReadAll(resp.Body)
  38677. if ioErr != nil {
  38678. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38680. return
  38681. }
  38682. var respJSON map[string]interface{}
  38683. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38686. return
  38687. }
  38688. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38689. userJSONBytes, _ := json.Marshal(respJSON)
  38690. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38691. utils.ErrorLog("解析失败:%v", err)
  38692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38693. return
  38694. }
  38695. }
  38696. if miConfig.MdtrtareaAdmvs == "421182" {
  38697. data := make(map[string]interface{})
  38698. data["bps"] = bp
  38699. data["org_name"] = miConfig.OrgName
  38700. data["doctor"] = role.UserName
  38701. data["fixmedins_code"] = miConfig.Code
  38702. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38703. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38704. data["page"] = strconv.FormatInt(page, 10)
  38705. data["limit"] = strconv.FormatInt(limit, 10)
  38706. fmt.Println(data)
  38707. client := &http.Client{}
  38708. bytesData, _ := json.Marshal(data)
  38709. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38710. resp, _ := client.Do(req)
  38711. defer resp.Body.Close()
  38712. body, ioErr := ioutil.ReadAll(resp.Body)
  38713. if ioErr != nil {
  38714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38716. return
  38717. }
  38718. var respJSON map[string]interface{}
  38719. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38722. return
  38723. }
  38724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38725. userJSONBytes, _ := json.Marshal(respJSON)
  38726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38727. utils.ErrorLog("解析失败:%v", err)
  38728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38729. return
  38730. }
  38731. }
  38732. if miConfig.MdtrtareaAdmvs == "420902" {
  38733. data := make(map[string]interface{})
  38734. data["bps"] = bp
  38735. data["org_name"] = miConfig.OrgName
  38736. data["doctor"] = role.UserName
  38737. data["fixmedins_code"] = miConfig.Code
  38738. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38739. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38740. data["page"] = strconv.FormatInt(page, 10)
  38741. data["limit"] = strconv.FormatInt(limit, 10)
  38742. fmt.Println(data)
  38743. client := &http.Client{}
  38744. bytesData, _ := json.Marshal(data)
  38745. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38746. resp, _ := client.Do(req)
  38747. defer resp.Body.Close()
  38748. body, ioErr := ioutil.ReadAll(resp.Body)
  38749. if ioErr != nil {
  38750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38752. return
  38753. }
  38754. var respJSON map[string]interface{}
  38755. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38758. return
  38759. }
  38760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38761. userJSONBytes, _ := json.Marshal(respJSON)
  38762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38763. utils.ErrorLog("解析失败:%v", err)
  38764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38765. return
  38766. }
  38767. }
  38768. if res.Infcode == 0 {
  38769. c.ServeSuccessJSON(map[string]interface{}{
  38770. "order": res.Output.Result,
  38771. "total": res.Output.PageInfo.RecordCounts,
  38772. })
  38773. } else {
  38774. c.ServeSuccessJSON(map[string]interface{}{
  38775. "failed_code": -10,
  38776. "msg": res.ErrMsg,
  38777. })
  38778. }
  38779. }
  38780. }
  38781. // 5.11.1.2【5267】异地结算信息时间段查询
  38782. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38783. admin_user_id, _ := c.GetInt64("admin_user_id")
  38784. adminUser := c.GetAdminUserInfo()
  38785. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38786. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38787. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38788. var res Result5267
  38789. if config.IsOpen == 1 {
  38790. if miConfig.MdtrtareaAdmvs == "421300" {
  38791. data := make(map[string]interface{})
  38792. data["bps"] = bp
  38793. data["org_name"] = miConfig.OrgName
  38794. data["doctor"] = role.UserName
  38795. data["fixmedins_code"] = miConfig.Code
  38796. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38797. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38798. data["page"] = page
  38799. data["limit"] = limit
  38800. fmt.Println(data)
  38801. client := &http.Client{}
  38802. bytesData, _ := json.Marshal(data)
  38803. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38804. resp, _ := client.Do(req)
  38805. defer resp.Body.Close()
  38806. body, ioErr := ioutil.ReadAll(resp.Body)
  38807. if ioErr != nil {
  38808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38810. return
  38811. }
  38812. var respJSON map[string]interface{}
  38813. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38816. return
  38817. }
  38818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38819. userJSONBytes, _ := json.Marshal(respJSON)
  38820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38821. utils.ErrorLog("解析失败:%v", err)
  38822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38823. return
  38824. }
  38825. }
  38826. if miConfig.MdtrtareaAdmvs == "420200" {
  38827. data := make(map[string]interface{})
  38828. data["bps"] = bp
  38829. data["org_name"] = miConfig.OrgName
  38830. data["doctor"] = role.UserName
  38831. data["fixmedins_code"] = miConfig.Code
  38832. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38833. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38834. data["page"] = page
  38835. data["limit"] = limit
  38836. fmt.Println(data)
  38837. client := &http.Client{}
  38838. bytesData, _ := json.Marshal(data)
  38839. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38840. resp, _ := client.Do(req)
  38841. defer resp.Body.Close()
  38842. body, ioErr := ioutil.ReadAll(resp.Body)
  38843. if ioErr != nil {
  38844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38846. return
  38847. }
  38848. var respJSON map[string]interface{}
  38849. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38852. return
  38853. }
  38854. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38855. userJSONBytes, _ := json.Marshal(respJSON)
  38856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38857. utils.ErrorLog("解析失败:%v", err)
  38858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38859. return
  38860. }
  38861. }
  38862. if miConfig.MdtrtareaAdmvs == "421182" {
  38863. data := make(map[string]interface{})
  38864. data["bps"] = bp
  38865. data["org_name"] = miConfig.OrgName
  38866. data["doctor"] = role.UserName
  38867. data["fixmedins_code"] = miConfig.Code
  38868. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38869. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38870. data["page"] = page
  38871. data["limit"] = limit
  38872. fmt.Println(data)
  38873. client := &http.Client{}
  38874. bytesData, _ := json.Marshal(data)
  38875. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38876. resp, _ := client.Do(req)
  38877. defer resp.Body.Close()
  38878. body, ioErr := ioutil.ReadAll(resp.Body)
  38879. if ioErr != nil {
  38880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38882. return
  38883. }
  38884. var respJSON map[string]interface{}
  38885. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38888. return
  38889. }
  38890. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38891. userJSONBytes, _ := json.Marshal(respJSON)
  38892. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38893. utils.ErrorLog("解析失败:%v", err)
  38894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38895. return
  38896. }
  38897. }
  38898. if res.Infcode == 0 {
  38899. c.ServeSuccessJSON(map[string]interface{}{
  38900. "order": res.Output.Result,
  38901. "total": res.Output.PageInfo.RecordCounts,
  38902. })
  38903. } else {
  38904. c.ServeSuccessJSON(map[string]interface{}{
  38905. "failed_code": -10,
  38906. "msg": res.ErrMsg,
  38907. })
  38908. }
  38909. }
  38910. }
  38911. func (c *HisApiController) Post3501() {
  38912. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38913. data := make(map[string]interface{})
  38914. var struct3501s []models.Struct3501
  38915. var struct3501 models.Struct3501
  38916. struct3501.OrgName = miConfig.OrgName
  38917. struct3501.AccessKey = miConfig.AccessKey
  38918. struct3501.RequestUrl = miConfig.Url
  38919. struct3501.SecretKey = miConfig.SecretKey
  38920. struct3501.ManuDate = "2022-08-17"
  38921. struct3501.FixmedinsBchno = ""
  38922. struct3501.ManuLotnum = ""
  38923. struct3501.RxFlag = "0"
  38924. struct3501.ExpyEnd = "2022-08-17"
  38925. struct3501.Invdate = "2022-08-17"
  38926. struct3501.InvCnt = "20.25"
  38927. struct3501.Memo = ""
  38928. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38929. struct3501.FixmedinsHilistId = miConfig.Code
  38930. struct3501.FixmedinsHilistName = miConfig.OrgName
  38931. struct3501s = append(struct3501s, struct3501)
  38932. data["struct_3501s"] = struct3501s
  38933. client := &http.Client{}
  38934. bytesData, _ := json.Marshal(data)
  38935. var req *http.Request
  38936. if miConfig.MdtrtareaAdmvs == "320921" {
  38937. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38938. } else {
  38939. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38940. }
  38941. resp, _ := client.Do(req)
  38942. defer resp.Body.Close()
  38943. body, ioErr := ioutil.ReadAll(resp.Body)
  38944. if ioErr != nil {
  38945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38947. return
  38948. }
  38949. var respJSON map[string]interface{}
  38950. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38953. return
  38954. }
  38955. var res ResultSix
  38956. var resSix10265 ResultSix10265 //1101结果
  38957. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38958. result, _ := json.Marshal(respJSON)
  38959. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38960. utils.ErrorLog("解析失败:%v", err)
  38961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38962. return
  38963. }
  38964. res.InfRefmsgid = resSix10265.InfRefmsgid
  38965. res.Output = resSix10265.Output
  38966. res.ErrMsg = resSix10265.ErrMsg
  38967. res.Cainfo = resSix10265.Cainfo
  38968. res.WarnMsg = resSix10265.WarnMsg
  38969. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38970. res.Infcode = infocode
  38971. if infocode == 0 {
  38972. c.ServeSuccessJSON(map[string]interface{}{
  38973. "msg": "上传成功",
  38974. })
  38975. return
  38976. } else {
  38977. c.ServeSuccessJSON(map[string]interface{}{
  38978. "failed_code": -10,
  38979. "msg": res.ErrMsg,
  38980. })
  38981. return
  38982. }
  38983. }
  38984. func (c *HisApiController) Post3502() {
  38985. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38986. data := make(map[string]interface{})
  38987. var struct3502s []models.Struct3502
  38988. var struct3502 models.Struct3502
  38989. struct3502.OrgName = miConfig.OrgName
  38990. struct3502.AccessKey = miConfig.AccessKey
  38991. struct3502.RequestUrl = miConfig.Url
  38992. struct3502.SecretKey = miConfig.SecretKey
  38993. struct3502.ManuDate = "2022-08-15"
  38994. struct3502.FixmedinsBchno = ""
  38995. struct3502.ManuLotnum = ""
  38996. struct3502.RxFlag = "0"
  38997. struct3502.ExpyEnd = "2022-08-15"
  38998. struct3502.Invdate = "2022-08-15"
  38999. struct3502.InvCnt = "20.25"
  39000. struct3502.Memo = ""
  39001. struct3502.MedListCodg = "XB01ABD056B002020200517"
  39002. struct3502.FixmedinsHilistId = miConfig.Code
  39003. struct3502.FixmedinsHilistName = miConfig.OrgName
  39004. struct3502s = append(struct3502s, struct3502)
  39005. data["struct_3502s"] = struct3502s
  39006. client := &http.Client{}
  39007. bytesData, _ := json.Marshal(data)
  39008. var req *http.Request
  39009. if miConfig.MdtrtareaAdmvs == "320921" {
  39010. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39011. } else {
  39012. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39013. }
  39014. resp, _ := client.Do(req)
  39015. defer resp.Body.Close()
  39016. body, ioErr := ioutil.ReadAll(resp.Body)
  39017. if ioErr != nil {
  39018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39020. return
  39021. }
  39022. var respJSON map[string]interface{}
  39023. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39026. return
  39027. }
  39028. var res ResultSix
  39029. var resSix10265 ResultSix10265 //1101结果
  39030. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39031. result, _ := json.Marshal(respJSON)
  39032. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39033. utils.ErrorLog("解析失败:%v", err)
  39034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39035. return
  39036. }
  39037. res.InfRefmsgid = resSix10265.InfRefmsgid
  39038. res.Output = resSix10265.Output
  39039. res.ErrMsg = resSix10265.ErrMsg
  39040. res.Cainfo = resSix10265.Cainfo
  39041. res.WarnMsg = resSix10265.WarnMsg
  39042. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39043. res.Infcode = infocode
  39044. if infocode == 0 {
  39045. c.ServeSuccessJSON(map[string]interface{}{
  39046. "msg": "上传成功",
  39047. })
  39048. return
  39049. } else {
  39050. c.ServeSuccessJSON(map[string]interface{}{
  39051. "failed_code": -10,
  39052. "msg": res.ErrMsg,
  39053. })
  39054. return
  39055. }
  39056. }
  39057. func (c *HisApiController) Post3503() {
  39058. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39059. data := make(map[string]interface{})
  39060. var struct3501s []models.Struct3501
  39061. var struct3501 models.Struct3501
  39062. struct3501.OrgName = miConfig.OrgName
  39063. struct3501.AccessKey = miConfig.AccessKey
  39064. struct3501.RequestUrl = miConfig.Url
  39065. struct3501.SecretKey = miConfig.SecretKey
  39066. struct3501.ManuDate = "2022-08-15"
  39067. struct3501.FixmedinsBchno = ""
  39068. struct3501.ManuLotnum = ""
  39069. struct3501.RxFlag = "0"
  39070. struct3501.ExpyEnd = "2022-08-15"
  39071. struct3501.Invdate = "2022-08-15"
  39072. struct3501.InvCnt = "20.25"
  39073. struct3501.Memo = ""
  39074. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39075. struct3501.FixmedinsHilistId = miConfig.Code
  39076. struct3501.FixmedinsHilistName = miConfig.OrgName
  39077. struct3501s = append(struct3501s, struct3501)
  39078. data["struct_3501s"] = struct3501s
  39079. client := &http.Client{}
  39080. bytesData, _ := json.Marshal(data)
  39081. var req *http.Request
  39082. if miConfig.MdtrtareaAdmvs == "320921" {
  39083. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39084. } else {
  39085. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39086. }
  39087. resp, _ := client.Do(req)
  39088. defer resp.Body.Close()
  39089. body, ioErr := ioutil.ReadAll(resp.Body)
  39090. if ioErr != nil {
  39091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39093. return
  39094. }
  39095. var respJSON map[string]interface{}
  39096. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39099. return
  39100. }
  39101. var res ResultSix
  39102. var resSix10265 ResultSix10265 //1101结果
  39103. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39104. result, _ := json.Marshal(respJSON)
  39105. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39106. utils.ErrorLog("解析失败:%v", err)
  39107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39108. return
  39109. }
  39110. res.InfRefmsgid = resSix10265.InfRefmsgid
  39111. res.Output = resSix10265.Output
  39112. res.ErrMsg = resSix10265.ErrMsg
  39113. res.Cainfo = resSix10265.Cainfo
  39114. res.WarnMsg = resSix10265.WarnMsg
  39115. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39116. res.Infcode = infocode
  39117. if infocode == 0 {
  39118. c.ServeSuccessJSON(map[string]interface{}{
  39119. "msg": "上传成功",
  39120. })
  39121. return
  39122. } else {
  39123. c.ServeSuccessJSON(map[string]interface{}{
  39124. "failed_code": -10,
  39125. "msg": res.ErrMsg,
  39126. })
  39127. return
  39128. }
  39129. }
  39130. func (c *HisApiController) Post3504() {
  39131. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39132. data := make(map[string]interface{})
  39133. var struct3501s []models.Struct3501
  39134. var struct3501 models.Struct3501
  39135. struct3501.OrgName = miConfig.OrgName
  39136. struct3501.AccessKey = miConfig.AccessKey
  39137. struct3501.RequestUrl = miConfig.Url
  39138. struct3501.SecretKey = miConfig.SecretKey
  39139. struct3501.ManuDate = "2022-08-15"
  39140. struct3501.FixmedinsBchno = ""
  39141. struct3501.ManuLotnum = ""
  39142. struct3501.RxFlag = "0"
  39143. struct3501.ExpyEnd = "2022-08-15"
  39144. struct3501.Invdate = "2022-08-15"
  39145. struct3501.InvCnt = "20.25"
  39146. struct3501.Memo = ""
  39147. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39148. struct3501.FixmedinsHilistId = miConfig.Code
  39149. struct3501.FixmedinsHilistName = miConfig.OrgName
  39150. struct3501s = append(struct3501s, struct3501)
  39151. data["struct_3501s"] = struct3501s
  39152. client := &http.Client{}
  39153. bytesData, _ := json.Marshal(data)
  39154. var req *http.Request
  39155. if miConfig.MdtrtareaAdmvs == "320921" {
  39156. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39157. } else {
  39158. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39159. }
  39160. resp, _ := client.Do(req)
  39161. defer resp.Body.Close()
  39162. body, ioErr := ioutil.ReadAll(resp.Body)
  39163. if ioErr != nil {
  39164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39166. return
  39167. }
  39168. var respJSON map[string]interface{}
  39169. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39172. return
  39173. }
  39174. var res ResultSix
  39175. var resSix10265 ResultSix10265 //1101结果
  39176. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39177. result, _ := json.Marshal(respJSON)
  39178. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39179. utils.ErrorLog("解析失败:%v", err)
  39180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39181. return
  39182. }
  39183. res.InfRefmsgid = resSix10265.InfRefmsgid
  39184. res.Output = resSix10265.Output
  39185. res.ErrMsg = resSix10265.ErrMsg
  39186. res.Cainfo = resSix10265.Cainfo
  39187. res.WarnMsg = resSix10265.WarnMsg
  39188. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39189. res.Infcode = infocode
  39190. if infocode == 0 {
  39191. c.ServeSuccessJSON(map[string]interface{}{
  39192. "msg": "上传成功",
  39193. })
  39194. return
  39195. } else {
  39196. c.ServeSuccessJSON(map[string]interface{}{
  39197. "failed_code": -10,
  39198. "msg": res.ErrMsg,
  39199. })
  39200. return
  39201. }
  39202. }
  39203. func (c *HisApiController) Post3505() {
  39204. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39205. data := make(map[string]interface{})
  39206. var struct3501s []models.Struct3501
  39207. var struct3501 models.Struct3501
  39208. struct3501.OrgName = miConfig.OrgName
  39209. struct3501.AccessKey = miConfig.AccessKey
  39210. struct3501.RequestUrl = miConfig.Url
  39211. struct3501.SecretKey = miConfig.SecretKey
  39212. struct3501.ManuDate = "2022-08-15"
  39213. struct3501.FixmedinsBchno = ""
  39214. struct3501.ManuLotnum = ""
  39215. struct3501.RxFlag = "0"
  39216. struct3501.ExpyEnd = "2022-08-15"
  39217. struct3501.Invdate = "2022-08-15"
  39218. struct3501.InvCnt = "20.25"
  39219. struct3501.Memo = ""
  39220. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39221. struct3501.FixmedinsHilistId = miConfig.Code
  39222. struct3501.FixmedinsHilistName = miConfig.OrgName
  39223. struct3501s = append(struct3501s, struct3501)
  39224. data["struct_3501s"] = struct3501s
  39225. client := &http.Client{}
  39226. bytesData, _ := json.Marshal(data)
  39227. var req *http.Request
  39228. if miConfig.MdtrtareaAdmvs == "320921" {
  39229. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39230. } else {
  39231. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39232. }
  39233. resp, _ := client.Do(req)
  39234. defer resp.Body.Close()
  39235. body, ioErr := ioutil.ReadAll(resp.Body)
  39236. if ioErr != nil {
  39237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39239. return
  39240. }
  39241. var respJSON map[string]interface{}
  39242. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39245. return
  39246. }
  39247. var res ResultSix
  39248. var resSix10265 ResultSix10265 //1101结果
  39249. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39250. result, _ := json.Marshal(respJSON)
  39251. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39252. utils.ErrorLog("解析失败:%v", err)
  39253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39254. return
  39255. }
  39256. res.InfRefmsgid = resSix10265.InfRefmsgid
  39257. res.Output = resSix10265.Output
  39258. res.ErrMsg = resSix10265.ErrMsg
  39259. res.Cainfo = resSix10265.Cainfo
  39260. res.WarnMsg = resSix10265.WarnMsg
  39261. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39262. res.Infcode = infocode
  39263. if infocode == 0 {
  39264. c.ServeSuccessJSON(map[string]interface{}{
  39265. "msg": "上传成功",
  39266. })
  39267. return
  39268. } else {
  39269. c.ServeSuccessJSON(map[string]interface{}{
  39270. "failed_code": -10,
  39271. "msg": res.ErrMsg,
  39272. })
  39273. return
  39274. }
  39275. }
  39276. func (c *HisApiController) Post3506() {
  39277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39278. data := make(map[string]interface{})
  39279. var struct3501s []models.Struct3501
  39280. var struct3501 models.Struct3501
  39281. struct3501.OrgName = miConfig.OrgName
  39282. struct3501.AccessKey = miConfig.AccessKey
  39283. struct3501.RequestUrl = miConfig.Url
  39284. struct3501.SecretKey = miConfig.SecretKey
  39285. struct3501.ManuDate = "2022-08-15"
  39286. struct3501.FixmedinsBchno = ""
  39287. struct3501.ManuLotnum = ""
  39288. struct3501.RxFlag = "0"
  39289. struct3501.ExpyEnd = "2022-08-15"
  39290. struct3501.Invdate = "2022-08-15"
  39291. struct3501.InvCnt = "20.25"
  39292. struct3501.Memo = ""
  39293. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39294. struct3501.FixmedinsHilistId = miConfig.Code
  39295. struct3501.FixmedinsHilistName = miConfig.OrgName
  39296. struct3501s = append(struct3501s, struct3501)
  39297. data["struct_3501s"] = struct3501s
  39298. client := &http.Client{}
  39299. bytesData, _ := json.Marshal(data)
  39300. var req *http.Request
  39301. if miConfig.MdtrtareaAdmvs == "320921" {
  39302. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39303. } else {
  39304. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39305. }
  39306. resp, _ := client.Do(req)
  39307. defer resp.Body.Close()
  39308. body, ioErr := ioutil.ReadAll(resp.Body)
  39309. if ioErr != nil {
  39310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39312. return
  39313. }
  39314. var respJSON map[string]interface{}
  39315. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39318. return
  39319. }
  39320. var res ResultSix
  39321. var resSix10265 ResultSix10265 //1101结果
  39322. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39323. result, _ := json.Marshal(respJSON)
  39324. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39325. utils.ErrorLog("解析失败:%v", err)
  39326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39327. return
  39328. }
  39329. res.InfRefmsgid = resSix10265.InfRefmsgid
  39330. res.Output = resSix10265.Output
  39331. res.ErrMsg = resSix10265.ErrMsg
  39332. res.Cainfo = resSix10265.Cainfo
  39333. res.WarnMsg = resSix10265.WarnMsg
  39334. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39335. res.Infcode = infocode
  39336. if infocode == 0 {
  39337. c.ServeSuccessJSON(map[string]interface{}{
  39338. "msg": "上传成功",
  39339. })
  39340. return
  39341. } else {
  39342. c.ServeSuccessJSON(map[string]interface{}{
  39343. "failed_code": -10,
  39344. "msg": res.ErrMsg,
  39345. })
  39346. return
  39347. }
  39348. }
  39349. func (c *HisApiController) Post3507() {
  39350. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39351. data := make(map[string]interface{})
  39352. var struct3501s []models.Struct3501
  39353. var struct3501 models.Struct3501
  39354. struct3501.OrgName = miConfig.OrgName
  39355. struct3501.AccessKey = miConfig.AccessKey
  39356. struct3501.RequestUrl = miConfig.Url
  39357. struct3501.SecretKey = miConfig.SecretKey
  39358. struct3501.ManuDate = "2022-08-15"
  39359. struct3501.FixmedinsBchno = ""
  39360. struct3501.ManuLotnum = ""
  39361. struct3501.RxFlag = "0"
  39362. struct3501.ExpyEnd = "2022-08-15"
  39363. struct3501.Invdate = "2022-08-15"
  39364. struct3501.InvCnt = "20.25"
  39365. struct3501.Memo = ""
  39366. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39367. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39368. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39369. struct3501s = append(struct3501s, struct3501)
  39370. data["struct_3501s"] = struct3501s
  39371. client := &http.Client{}
  39372. bytesData, _ := json.Marshal(data)
  39373. var req *http.Request
  39374. if miConfig.MdtrtareaAdmvs == "320921" {
  39375. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39376. } else {
  39377. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39378. }
  39379. resp, _ := client.Do(req)
  39380. defer resp.Body.Close()
  39381. body, ioErr := ioutil.ReadAll(resp.Body)
  39382. if ioErr != nil {
  39383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39385. return
  39386. }
  39387. var respJSON map[string]interface{}
  39388. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39391. return
  39392. }
  39393. var res ResultSix
  39394. var resSix10265 ResultSix10265 //1101结果
  39395. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39396. result, _ := json.Marshal(respJSON)
  39397. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39398. utils.ErrorLog("解析失败:%v", err)
  39399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39400. return
  39401. }
  39402. res.InfRefmsgid = resSix10265.InfRefmsgid
  39403. res.Output = resSix10265.Output
  39404. res.ErrMsg = resSix10265.ErrMsg
  39405. res.Cainfo = resSix10265.Cainfo
  39406. res.WarnMsg = resSix10265.WarnMsg
  39407. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39408. res.Infcode = infocode
  39409. if infocode == 0 {
  39410. c.ServeSuccessJSON(map[string]interface{}{
  39411. "msg": "上传成功",
  39412. })
  39413. return
  39414. } else {
  39415. c.ServeSuccessJSON(map[string]interface{}{
  39416. "failed_code": -10,
  39417. "msg": res.ErrMsg,
  39418. })
  39419. return
  39420. }
  39421. }
  39422. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39423. // WebSocket服务器地址
  39424. serverURL := "ws://127.0.0.1:8899"
  39425. // 解析WebSocket服务器地址
  39426. u, err := url.Parse(serverURL)
  39427. if err != nil {
  39428. }
  39429. // 建立WebSocket连接
  39430. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39431. if err != nil {
  39432. }
  39433. defer conn.Close()
  39434. input2 := make(map[string]interface{})
  39435. input := make(map[string]interface{})
  39436. inputData := make(map[string]interface{})
  39437. inputData["orgId"] = code
  39438. inputData["businessType"] = "01101"
  39439. inputData["operatorId"] = operator_id
  39440. inputData["operatorName"] = operator_name
  39441. inputData["officeId"] = "001"
  39442. inputData["officeName"] = "血透室"
  39443. inputData["deviceType"] = ""
  39444. input["data"] = inputData
  39445. input["orgId"] = code
  39446. input["transType"] = "ec.query"
  39447. //if md == ""
  39448. if md[:4] == "4403" {
  39449. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39450. } else if md[:4] == "4401" {
  39451. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39452. } else {
  39453. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39454. }
  39455. input2["indata"] = input
  39456. fmt.Println(input2)
  39457. bytesData, _ := json.Marshal(input2)
  39458. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39459. if err != nil {
  39460. fmt.Println(err)
  39461. }
  39462. // 接收消息
  39463. _, receivedMessage, err := conn.ReadMessage()
  39464. if err != nil {
  39465. fmt.Println(err)
  39466. }
  39467. return "", string(receivedMessage)
  39468. }
  39469. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39470. // WebSocket服务器地址
  39471. serverURL := "ws://127.0.0.1:8899"
  39472. // 解析WebSocket服务器地址
  39473. u, err := url.Parse(serverURL)
  39474. if err != nil {
  39475. }
  39476. // 建立WebSocket连接
  39477. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39478. if err != nil {
  39479. }
  39480. defer conn.Close()
  39481. input2 := make(map[string]interface{})
  39482. input := make(map[string]interface{})
  39483. inputData := make(map[string]interface{})
  39484. inputData["orgId"] = code
  39485. inputData["businessType"] = "01101"
  39486. inputData["operatorId"] = operator_id
  39487. inputData["operatorName"] = operator_name
  39488. inputData["officeId"] = "001"
  39489. inputData["officeName"] = "血透室"
  39490. inputData["deviceType"] = ""
  39491. input["data"] = inputData
  39492. input["orgId"] = code
  39493. input["transType"] = "ec.query"
  39494. //if md == ""
  39495. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39496. input2["indata"] = input
  39497. fmt.Println(input2)
  39498. bytesData, _ := json.Marshal(input2)
  39499. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39500. if err != nil {
  39501. fmt.Println(err)
  39502. }
  39503. // 接收消息
  39504. _, receivedMessage, err := conn.ReadMessage()
  39505. if err != nil {
  39506. fmt.Println(err)
  39507. }
  39508. return "", string(receivedMessage)
  39509. }
  39510. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39511. // WebSocket服务器地址
  39512. serverURL := "ws://127.0.0.1:8899"
  39513. // 解析WebSocket服务器地址
  39514. u, err := url.Parse(serverURL)
  39515. if err != nil {
  39516. }
  39517. // 建立WebSocket连接
  39518. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39519. if err != nil {
  39520. }
  39521. defer conn.Close()
  39522. input2 := make(map[string]interface{})
  39523. input := make(map[string]interface{})
  39524. inputData := make(map[string]interface{})
  39525. inputData["orgId"] = code
  39526. inputData["businessType"] = "01301"
  39527. inputData["operatorId"] = operator_id
  39528. inputData["operatorName"] = operator_name
  39529. inputData["officeId"] = "001"
  39530. inputData["officeName"] = "血透室"
  39531. inputData["deviceType"] = ""
  39532. input["data"] = inputData
  39533. input["orgId"] = code
  39534. input["transType"] = "ec.query"
  39535. //if md == ""
  39536. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39537. input2["indata"] = input
  39538. fmt.Println(input2)
  39539. bytesData, _ := json.Marshal(input2)
  39540. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39541. if err != nil {
  39542. fmt.Println(err)
  39543. }
  39544. // 接收消息
  39545. _, receivedMessage, err := conn.ReadMessage()
  39546. if err != nil {
  39547. fmt.Println(err)
  39548. }
  39549. return "", string(receivedMessage)
  39550. }
  39551. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39552. // WebSocket服务器地址
  39553. serverURL := "ws://127.0.0.1:8899"
  39554. // 解析WebSocket服务器地址
  39555. u, err := url.Parse(serverURL)
  39556. if err != nil {
  39557. }
  39558. // 建立WebSocket连接
  39559. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39560. if err != nil {
  39561. }
  39562. defer conn.Close()
  39563. input2 := make(map[string]interface{})
  39564. input := make(map[string]interface{})
  39565. inputData := make(map[string]interface{})
  39566. inputData["orgId"] = code
  39567. inputData["businessType"] = "01103"
  39568. inputData["operatorId"] = operator_id
  39569. inputData["operatorName"] = operator_name
  39570. inputData["officeId"] = "001"
  39571. inputData["officeName"] = "血透室"
  39572. inputData["deviceType"] = ""
  39573. input["data"] = inputData
  39574. input["orgId"] = code
  39575. input["transType"] = "ec.query"
  39576. //if md ==
  39577. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39578. input2["indata"] = input
  39579. fmt.Println(input2)
  39580. bytesData, _ := json.Marshal(input2)
  39581. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39582. if err != nil {
  39583. fmt.Println(err)
  39584. }
  39585. // 接收消息
  39586. _, receivedMessage, err := conn.ReadMessage()
  39587. if err != nil {
  39588. fmt.Println(err)
  39589. }
  39590. return "", string(receivedMessage)
  39591. }
  39592. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39593. // WebSocket服务器地址
  39594. serverURL := "ws://127.0.0.1:8899"
  39595. // 解析WebSocket服务器地址
  39596. u, err := url.Parse(serverURL)
  39597. if err != nil {
  39598. }
  39599. // 建立WebSocket连接
  39600. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39601. if err != nil {
  39602. }
  39603. defer conn.Close()
  39604. input2 := make(map[string]interface{})
  39605. input := make(map[string]interface{})
  39606. inputData := make(map[string]interface{})
  39607. inputData["orgId"] = code
  39608. inputData["businessType"] = "01101"
  39609. inputData["operatorId"] = operator_id
  39610. inputData["operatorName"] = operator_name
  39611. inputData["officeId"] = "001"
  39612. inputData["officeName"] = "血透室"
  39613. inputData["deviceType"] = ""
  39614. input["data"] = inputData
  39615. input["orgId"] = code
  39616. input["transType"] = "ec.query"
  39617. //if md == ""
  39618. if md[:4] == "4403" {
  39619. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39620. } else if md[:4] == "4401" {
  39621. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39622. } else {
  39623. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39624. }
  39625. input2["indata"] = input
  39626. fmt.Println(input2)
  39627. bytesData, _ := json.Marshal(input2)
  39628. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39629. if err != nil {
  39630. fmt.Println(err)
  39631. }
  39632. // 接收消息
  39633. _, receivedMessage, err := conn.ReadMessage()
  39634. if err != nil {
  39635. fmt.Println(err)
  39636. }
  39637. return "", string(receivedMessage)
  39638. }
  39639. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39640. // WebSocket服务器地址
  39641. serverURL := "ws://127.0.0.1:8899"
  39642. // 解析WebSocket服务器地址
  39643. u, err := url.Parse(serverURL)
  39644. if err != nil {
  39645. }
  39646. // 建立WebSocket连接
  39647. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39648. if err != nil {
  39649. }
  39650. defer conn.Close()
  39651. input2 := make(map[string]interface{})
  39652. input := make(map[string]interface{})
  39653. inputData := make(map[string]interface{})
  39654. inputData["orgId"] = code
  39655. inputData["businessType"] = "01301"
  39656. inputData["operatorId"] = operator_id
  39657. inputData["operatorName"] = operator_name
  39658. inputData["officeId"] = "001"
  39659. inputData["officeName"] = "血透室"
  39660. inputData["deviceType"] = ""
  39661. input["data"] = inputData
  39662. input["orgId"] = code
  39663. input["transType"] = "ec.query"
  39664. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39665. input2["indata"] = input
  39666. bytesData, _ := json.Marshal(input2)
  39667. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39668. if err != nil {
  39669. fmt.Println(err)
  39670. }
  39671. // 接收消息
  39672. _, receivedMessage, err := conn.ReadMessage()
  39673. if err != nil {
  39674. fmt.Println(err)
  39675. }
  39676. return "", string(receivedMessage)
  39677. }
  39678. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39679. newArr = make([]string, 0)
  39680. for i := 0; i < len(arr); i++ {
  39681. repeat := false
  39682. for j := i + 1; j < len(arr); j++ {
  39683. if arr[i] == arr[j] {
  39684. repeat = true
  39685. break
  39686. }
  39687. }
  39688. if !repeat {
  39689. newArr = append(newArr, arr[i])
  39690. }
  39691. }
  39692. return
  39693. }
  39694. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39695. if len(idNumber) != 18 {
  39696. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39697. }
  39698. // 提取出生日期
  39699. year, err := strconv.Atoi(idNumber[6:10])
  39700. if err != nil {
  39701. return "", 0, err
  39702. }
  39703. month, err := strconv.Atoi(idNumber[10:12])
  39704. if err != nil {
  39705. return "", 0, err
  39706. }
  39707. day, err := strconv.Atoi(idNumber[12:14])
  39708. if err != nil {
  39709. return "", 0, err
  39710. }
  39711. // 格式化生日字符串
  39712. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39713. birthdateFormatted := birthdate.Format("2006-01-02")
  39714. // 计算年龄
  39715. today := time.Now()
  39716. age := today.Year() - birthdate.Year()
  39717. if today.YearDay() < birthdate.YearDay() {
  39718. age--
  39719. }
  39720. return birthdateFormatted, age, nil
  39721. }
  39722. // 从身份证号码中提取出生年月日
  39723. func getBirthDateFromIDCard(idCard string) (string, error) {
  39724. // 身份证号码长度应为18位
  39725. if len(idCard) != 18 {
  39726. return "", fmt.Errorf("身份证号码长度应为18位")
  39727. }
  39728. // 提取出生日期部分 (YYYYMMDD)
  39729. birthDateStr := idCard[6:14]
  39730. // 解析出生日期
  39731. birthDate, err := time.Parse("20060102", birthDateStr)
  39732. if err != nil {
  39733. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39734. }
  39735. // 格式化出生日期为 YYYY-MM-DD
  39736. formattedDate := birthDate.Format("2006-01-02")
  39737. return formattedDate, nil
  39738. }