his_api_controller.go 1.6MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042
  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/3103", &HisApiController{}, "get:Get3103")
  134. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  135. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  136. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  137. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  138. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  139. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  140. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  141. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  142. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  143. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  144. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  145. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  146. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  147. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  148. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  149. //库盘和变更
  150. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  151. //删除库盘和变更
  152. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  153. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  154. //药品变更
  155. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  156. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  157. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  158. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  159. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  160. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  161. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  162. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  163. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  164. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  165. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  166. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  167. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  168. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  169. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  170. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  171. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  172. }
  173. func (c *HisApiController) Get3201() {
  174. adminUser := c.GetAdminUserInfo()
  175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  176. 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)
  177. var response Response
  178. if err := json.Unmarshal([]byte(result), &response); err != nil {
  179. fmt.Println("Error decoding JSON:", err)
  180. return
  181. }
  182. }
  183. func (c *HisApiController) TestNet() {
  184. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  185. //return
  186. c.ServeSuccessJSON(map[string]interface{}{
  187. "msg": "成功",
  188. })
  189. }
  190. func (c *HisApiController) Get3508() {
  191. admin_user_id, _ := c.GetInt64("admin_user_id")
  192. drug_id, _ := c.GetInt64("id")
  193. start_time := c.GetString("start_time")
  194. end_time := c.GetString("end_time")
  195. adminUser := c.GetAdminUserInfo()
  196. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  197. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  198. drug, _ := service.GetDrugByID(drug_id)
  199. var struct3508 models.Struct3508
  200. struct3508.OrgName = miConfig.OrgName
  201. struct3508.FixmedinsCode = miConfig.Code
  202. struct3508.AccessKey = miConfig.AccessKey
  203. struct3508.Opter = curRoles.UserName
  204. struct3508.RequestUrl = miConfig.Url
  205. struct3508.Url = miConfig.Url
  206. struct3508.AppId = miConfig.Cainfo
  207. struct3508.AppSecret = miConfig.AppSecret
  208. struct3508.Enckey = miConfig.EncKey
  209. struct3508.SignKey = miConfig.SignKey
  210. struct3508.SecretKey = miConfig.SecretKey
  211. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  212. struct3508.Begndate = start_time
  213. struct3508.Enddate = end_time
  214. result1, result2, _ := service.FJyb3508(struct3508)
  215. saveLog(result1, result2, "3508", "3508")
  216. var res models.Result3508
  217. var respJSON2 map[string]interface{}
  218. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. userJSONBytes2, _ := json.Marshal(respJSON2)
  224. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  225. utils.ErrorLog("解析失败:%v", err)
  226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  227. return
  228. }
  229. if res.Infcode == -1 {
  230. c.ServeSuccessJSON(map[string]interface{}{
  231. "failed_code": -10,
  232. "msg": res.ErrMsg,
  233. })
  234. } else {
  235. c.ServeSuccessJSON(map[string]interface{}{
  236. "info": res.Output,
  237. })
  238. }
  239. }
  240. func (c *HisApiController) Get3509() {
  241. admin_user_id, _ := c.GetInt64("admin_user_id")
  242. drug_id, _ := c.GetInt64("id")
  243. start_time := c.GetString("start_time")
  244. end_time := c.GetString("end_time")
  245. adminUser := c.GetAdminUserInfo()
  246. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  248. drug, _ := service.GetDrugByID(drug_id)
  249. var struct3508 models.Struct3509
  250. struct3508.OrgName = miConfig.OrgName
  251. struct3508.FixmedinsCode = miConfig.Code
  252. struct3508.AccessKey = miConfig.AccessKey
  253. struct3508.Opter = curRoles.UserName
  254. struct3508.RequestUrl = miConfig.Url
  255. struct3508.Url = miConfig.Url
  256. struct3508.AppId = miConfig.Cainfo
  257. struct3508.AppSecret = miConfig.AppSecret
  258. struct3508.Enckey = miConfig.EncKey
  259. struct3508.SignKey = miConfig.SignKey
  260. struct3508.SecretKey = miConfig.SecretKey
  261. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  262. struct3508.Begndate = start_time
  263. struct3508.Enddate = end_time
  264. result1, result2, _ := service.FJyb3509(struct3508)
  265. saveLog(result1, result2, "3509", "3509")
  266. var res models.Result3509
  267. var respJSON2 map[string]interface{}
  268. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  271. return
  272. }
  273. userJSONBytes2, _ := json.Marshal(respJSON2)
  274. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  275. utils.ErrorLog("解析失败:%v", err)
  276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  277. return
  278. }
  279. if res.Infcode == -1 {
  280. c.ServeSuccessJSON(map[string]interface{}{
  281. "failed_code": -10,
  282. "msg": res.ErrMsg,
  283. })
  284. } else {
  285. c.ServeSuccessJSON(map[string]interface{}{
  286. "info": res.Output,
  287. })
  288. }
  289. }
  290. func (c *HisApiController) Get3510() {
  291. admin_user_id, _ := c.GetInt64("admin_user_id")
  292. drug_id, _ := c.GetInt64("id")
  293. start_time := c.GetString("start_time")
  294. end_time := c.GetString("end_time")
  295. adminUser := c.GetAdminUserInfo()
  296. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  297. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  298. drug, _ := service.GetDrugByID(drug_id)
  299. var struct3508 models.Struct3510
  300. struct3508.FixmedinsCode = miConfig.Code
  301. struct3508.OrgName = miConfig.OrgName
  302. struct3508.AccessKey = miConfig.AccessKey
  303. struct3508.Opter = curRoles.UserName
  304. struct3508.RequestUrl = miConfig.Url
  305. struct3508.Url = miConfig.Url
  306. struct3508.AppId = miConfig.Cainfo
  307. struct3508.AppSecret = miConfig.AppSecret
  308. struct3508.Enckey = miConfig.EncKey
  309. struct3508.SignKey = miConfig.SignKey
  310. struct3508.SecretKey = miConfig.SecretKey
  311. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  312. struct3508.Begndate = start_time
  313. struct3508.Enddate = end_time
  314. result1, result2, _ := service.FJyb3510(struct3508)
  315. saveLog(result1, result2, "3510", "3510")
  316. var res models.Result3510
  317. var respJSON2 map[string]interface{}
  318. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  321. return
  322. }
  323. userJSONBytes2, _ := json.Marshal(respJSON2)
  324. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  325. utils.ErrorLog("解析失败:%v", err)
  326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  327. return
  328. }
  329. if res.Infcode == -1 {
  330. c.ServeSuccessJSON(map[string]interface{}{
  331. "failed_code": -10,
  332. "msg": res.ErrMsg,
  333. })
  334. } else {
  335. c.ServeSuccessJSON(map[string]interface{}{
  336. "info": res.Output,
  337. })
  338. }
  339. }
  340. func (c *HisApiController) Get3511() {
  341. admin_user_id, _ := c.GetInt64("admin_user_id")
  342. drug_id, _ := c.GetInt64("id")
  343. start_time := c.GetString("start_time")
  344. end_time := c.GetString("end_time")
  345. adminUser := c.GetAdminUserInfo()
  346. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  348. drug, _ := service.GetDrugByID(drug_id)
  349. var struct3508 models.Struct3511
  350. struct3508.FixmedinsCode = miConfig.Code
  351. struct3508.OrgName = miConfig.OrgName
  352. struct3508.AccessKey = miConfig.AccessKey
  353. struct3508.Opter = curRoles.UserName
  354. struct3508.RequestUrl = miConfig.Url
  355. struct3508.Url = miConfig.Url
  356. struct3508.AppId = miConfig.Cainfo
  357. struct3508.AppSecret = miConfig.AppSecret
  358. struct3508.Enckey = miConfig.EncKey
  359. struct3508.SignKey = miConfig.SignKey
  360. struct3508.SecretKey = miConfig.SecretKey
  361. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  362. struct3508.Begndate = start_time
  363. struct3508.Enddate = end_time
  364. result1, result2, _ := service.FJyb3511(struct3508)
  365. saveLog(result1, result2, "3511", "3511")
  366. var res models.Result3511
  367. var respJSON2 map[string]interface{}
  368. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  371. return
  372. }
  373. userJSONBytes2, _ := json.Marshal(respJSON2)
  374. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  375. utils.ErrorLog("解析失败:%v", err)
  376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  377. return
  378. }
  379. if res.Infcode == -1 {
  380. c.ServeSuccessJSON(map[string]interface{}{
  381. "failed_code": -10,
  382. "msg": res.ErrMsg,
  383. })
  384. } else {
  385. c.ServeSuccessJSON(map[string]interface{}{
  386. "info": res.Output,
  387. })
  388. }
  389. }
  390. func (c *HisApiController) Get3512() {
  391. admin_user_id, _ := c.GetInt64("admin_user_id")
  392. drug_id, _ := c.GetInt64("id")
  393. start_time := c.GetString("start_time")
  394. end_time := c.GetString("end_time")
  395. adminUser := c.GetAdminUserInfo()
  396. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  397. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  398. drug, _ := service.GetDrugByID(drug_id)
  399. var struct3508 models.Struct3512
  400. struct3508.FixmedinsCode = miConfig.Code
  401. struct3508.OrgName = miConfig.OrgName
  402. struct3508.AccessKey = miConfig.AccessKey
  403. struct3508.Opter = curRoles.UserName
  404. struct3508.RequestUrl = miConfig.Url
  405. struct3508.Url = miConfig.Url
  406. struct3508.AppId = miConfig.Cainfo
  407. struct3508.AppSecret = miConfig.AppSecret
  408. struct3508.Enckey = miConfig.EncKey
  409. struct3508.SignKey = miConfig.SignKey
  410. struct3508.SecretKey = miConfig.SecretKey
  411. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  412. struct3508.Begndate = start_time
  413. struct3508.Enddate = end_time
  414. result1, result2, _ := service.FJyb3512(struct3508)
  415. saveLog(result1, result2, "3512", "3512")
  416. var res models.Result3512
  417. var respJSON2 map[string]interface{}
  418. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  421. return
  422. }
  423. userJSONBytes2, _ := json.Marshal(respJSON2)
  424. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == -1 {
  430. c.ServeSuccessJSON(map[string]interface{}{
  431. "failed_code": -10,
  432. "msg": res.ErrMsg,
  433. })
  434. } else {
  435. c.ServeSuccessJSON(map[string]interface{}{
  436. "info": res.Output,
  437. })
  438. }
  439. }
  440. func (c *HisApiController) Get3513() {
  441. admin_user_id, _ := c.GetInt64("admin_user_id")
  442. drug_id, _ := c.GetInt64("id")
  443. start_time := c.GetString("start_time")
  444. end_time := c.GetString("end_time")
  445. adminUser := c.GetAdminUserInfo()
  446. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  447. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  448. drug, _ := service.GetDrugByID(drug_id)
  449. var struct3508 models.Struct3513
  450. struct3508.FixmedinsCode = miConfig.Code
  451. struct3508.OrgName = miConfig.OrgName
  452. struct3508.AccessKey = miConfig.AccessKey
  453. struct3508.Opter = curRoles.UserName
  454. struct3508.RequestUrl = miConfig.Url
  455. struct3508.Url = miConfig.Url
  456. struct3508.AppId = miConfig.Cainfo
  457. struct3508.AppSecret = miConfig.AppSecret
  458. struct3508.Enckey = miConfig.EncKey
  459. struct3508.SignKey = miConfig.SignKey
  460. struct3508.SecretKey = miConfig.SecretKey
  461. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  462. struct3508.Begndate = start_time
  463. struct3508.Enddate = end_time
  464. result1, result2, _ := service.FJyb3513(struct3508)
  465. saveLog(result1, result2, "3513", "3513")
  466. var res models.Result3513
  467. var respJSON2 map[string]interface{}
  468. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  471. return
  472. }
  473. userJSONBytes2, _ := json.Marshal(respJSON2)
  474. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  475. utils.ErrorLog("解析失败:%v", err)
  476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  477. return
  478. }
  479. if res.Infcode == -1 {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "failed_code": -10,
  482. "msg": res.ErrMsg,
  483. })
  484. } else {
  485. c.ServeSuccessJSON(map[string]interface{}{
  486. "info": res.Output,
  487. })
  488. }
  489. }
  490. func (c *HisApiController) Get35081() {
  491. admin_user_id, _ := c.GetInt64("admin_user_id")
  492. drug_id, _ := c.GetInt64("id")
  493. //start_time := c.GetString("start_time")
  494. //end_time := c.GetString("end_time")
  495. page, _ := c.GetInt("page")
  496. adminUser := c.GetAdminUserInfo()
  497. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  498. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  499. drug, _ := service.GetDrugByID(drug_id)
  500. var struct3508 models.Struct35081
  501. struct3508.FixmedinsCode = miConfig.Code
  502. struct3508.OrgName = miConfig.OrgName
  503. struct3508.AccessKey = miConfig.AccessKey
  504. struct3508.Opter = curRoles.UserName
  505. struct3508.RequestUrl = miConfig.Url
  506. struct3508.Url = miConfig.Url
  507. struct3508.AppId = miConfig.Cainfo
  508. struct3508.AppSecret = miConfig.AppSecret
  509. struct3508.Enckey = miConfig.EncKey
  510. struct3508.SignKey = miConfig.SignKey
  511. struct3508.SecretKey = miConfig.SecretKey
  512. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  513. struct3508.PageNum = page
  514. struct3508.PageSize = 10
  515. result1, result2, _ := service.FJyb35081(struct3508)
  516. saveLog(result1, result2, "35081", "35081")
  517. var res models.Result35081
  518. var respJSON2 map[string]interface{}
  519. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  522. return
  523. }
  524. userJSONBytes2, _ := json.Marshal(respJSON2)
  525. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  526. utils.ErrorLog("解析失败:%v", err)
  527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  528. return
  529. }
  530. if res.Infcode == -1 {
  531. c.ServeSuccessJSON(map[string]interface{}{
  532. "failed_code": -10,
  533. "msg": res.ErrMsg,
  534. })
  535. } else {
  536. c.ServeSuccessJSON(map[string]interface{}{
  537. "info": res.Output,
  538. })
  539. }
  540. }
  541. func (c *HisApiController) Get35082() {
  542. admin_user_id, _ := c.GetInt64("admin_user_id")
  543. drug_id, _ := c.GetInt64("id")
  544. //start_time := c.GetString("start_time")
  545. //end_time := c.GetString("end_time")
  546. page, _ := c.GetInt("page")
  547. adminUser := c.GetAdminUserInfo()
  548. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  550. drug, _ := service.GetDrugByID(drug_id)
  551. var struct3508 models.Struct35082
  552. struct3508.FixmedinsCode = miConfig.Code
  553. struct3508.OrgName = miConfig.OrgName
  554. struct3508.AccessKey = miConfig.AccessKey
  555. struct3508.Opter = curRoles.UserName
  556. struct3508.RequestUrl = miConfig.Url
  557. struct3508.Url = miConfig.Url
  558. struct3508.AppId = miConfig.Cainfo
  559. struct3508.AppSecret = miConfig.AppSecret
  560. struct3508.Enckey = miConfig.EncKey
  561. struct3508.SignKey = miConfig.SignKey
  562. struct3508.SecretKey = miConfig.SecretKey
  563. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  564. struct3508.PageNum = page
  565. struct3508.PageSize = 10
  566. result1, result2, _ := service.FJyb35082(struct3508)
  567. saveLog(result1, result2, "35082", "35082")
  568. var res models.Result35082
  569. var respJSON2 map[string]interface{}
  570. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  573. return
  574. }
  575. userJSONBytes2, _ := json.Marshal(respJSON2)
  576. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  577. utils.ErrorLog("解析失败:%v", err)
  578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  579. return
  580. }
  581. if res.Infcode == -1 {
  582. c.ServeSuccessJSON(map[string]interface{}{
  583. "failed_code": -10,
  584. "msg": res.ErrMsg,
  585. })
  586. } else {
  587. c.ServeSuccessJSON(map[string]interface{}{
  588. "info": res.Output,
  589. })
  590. }
  591. }
  592. func (c *HisApiController) FJ3501AND3502() {
  593. ids := c.GetString("ids")
  594. admin_user_id, _ := c.GetInt64("admin_user_id")
  595. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  596. id_arr := strings.Split(ids, ",")
  597. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  598. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  599. //库盘
  600. var errs []string
  601. for _, drug := range drugs {
  602. if drug.IsPc == 0 {
  603. var res2 ResultSix
  604. var res3 ResultSix
  605. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  606. var struct3501 models.Struct3501
  607. struct3501.Code = miConfig.Code
  608. struct3501.OrgName = miConfig.OrgName
  609. struct3501.AccessKey = miConfig.AccessKey
  610. struct3501.Opter = roles.UserName
  611. struct3501.RequestUrl = miConfig.Url
  612. struct3501.Url = miConfig.Url
  613. struct3501.AppId = miConfig.Cainfo
  614. struct3501.AppSecret = miConfig.AppSecret
  615. struct3501.Enckey = miConfig.EncKey
  616. struct3501.SignKey = miConfig.SignKey
  617. struct3501.SecretKey = miConfig.SecretKey
  618. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  619. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  620. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  621. struct3501.RxFlag = "1"
  622. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  623. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  624. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  625. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  626. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  627. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  628. struct3501.FixmedinsBchno = number
  629. struct3501.DrugTracCodg = drug.DrugCode
  630. memo := make(map[string]interface{})
  631. memo["pric"] = drug.Price
  632. bytesData, _ := json.Marshal(memo)
  633. struct3501.Memo = string(bytesData)
  634. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  635. result1, result2, _ := service.FJyb3501(struct3501)
  636. saveLog(result1, result2, "3501", "3501")
  637. //saveLog(result, requestLog, "2201", "挂号")
  638. var respJSON2 map[string]interface{}
  639. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  642. return
  643. }
  644. userJSONBytes2, _ := json.Marshal(respJSON2)
  645. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  646. utils.ErrorLog("解析失败:%v", err)
  647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  648. return
  649. }
  650. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  651. data := make(map[string]interface{})
  652. data["struct_3501s"] = struct3501
  653. client := &http.Client{}
  654. bytesData, _ := json.Marshal(data)
  655. var req *http.Request
  656. if miConfig.MdtrtareaAdmvs == "320921" {
  657. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  658. } else {
  659. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  660. }
  661. resp, _ := client.Do(req)
  662. defer resp.Body.Close()
  663. body, ioErr := ioutil.ReadAll(resp.Body)
  664. if ioErr != nil {
  665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  666. }
  667. var respJSON map[string]interface{}
  668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. var resSix10265 ResultSix10265 //1101结果
  674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  675. result, _ := json.Marshal(respJSON)
  676. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  677. utils.ErrorLog("解析失败:%v", err)
  678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  679. return
  680. }
  681. res2.InfRefmsgid = resSix10265.InfRefmsgid
  682. res2.Output = resSix10265.Output
  683. res2.ErrMsg = resSix10265.ErrMsg
  684. res2.Cainfo = resSix10265.Cainfo
  685. res2.WarnMsg = resSix10265.WarnMsg
  686. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  687. res2.Infcode = infocode
  688. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  689. data := make(map[string]interface{})
  690. data["struct_3501s"] = struct3501
  691. client := &http.Client{}
  692. bytesData, _ := json.Marshal(data)
  693. var req *http.Request
  694. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  695. resp, _ := client.Do(req)
  696. defer resp.Body.Close()
  697. body, ioErr := ioutil.ReadAll(resp.Body)
  698. if ioErr != nil {
  699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  700. }
  701. var respJSON map[string]interface{}
  702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  705. return
  706. }
  707. var resSix10265 ResultSix10265 //1101结果
  708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  709. result, _ := json.Marshal(respJSON)
  710. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  711. utils.ErrorLog("解析失败:%v", err)
  712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  713. return
  714. }
  715. res2.InfRefmsgid = resSix10265.InfRefmsgid
  716. res2.Output = resSix10265.Output
  717. res2.ErrMsg = resSix10265.ErrMsg
  718. res2.Cainfo = resSix10265.Cainfo
  719. res2.WarnMsg = resSix10265.WarnMsg
  720. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  721. res2.Infcode = infocode
  722. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  723. data := make(map[string]interface{})
  724. data["struct_3501s"] = struct3501
  725. client := &http.Client{}
  726. bytesData, _ := json.Marshal(data)
  727. var req *http.Request
  728. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  729. resp, _ := client.Do(req)
  730. defer resp.Body.Close()
  731. body, ioErr := ioutil.ReadAll(resp.Body)
  732. if ioErr != nil {
  733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  734. }
  735. var respJSON map[string]interface{}
  736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  739. return
  740. }
  741. var resSix10265 ResultSix10265 //1101结果
  742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  743. result, _ := json.Marshal(respJSON)
  744. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  745. utils.ErrorLog("解析失败:%v", err)
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. res2.InfRefmsgid = resSix10265.InfRefmsgid
  750. res2.Output = resSix10265.Output
  751. res2.ErrMsg = resSix10265.ErrMsg
  752. res2.Cainfo = resSix10265.Cainfo
  753. res2.WarnMsg = resSix10265.WarnMsg
  754. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  755. res2.Infcode = infocode
  756. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  757. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  758. saveLog(result1, result2, "3501", "3501")
  759. //saveLog(result, requestLog, "2201", "挂号")
  760. var respJSON2 map[string]interface{}
  761. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. return
  765. }
  766. userJSONBytes2, _ := json.Marshal(respJSON2)
  767. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  768. utils.ErrorLog("解析失败:%v", err)
  769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  770. return
  771. }
  772. }
  773. if res2.Infcode != -1 {
  774. drug.IsPc = 1
  775. drug.Bchno = number
  776. drug.PcDate = time.Now().Unix()
  777. err := service.SaveW(drug)
  778. if err == nil {
  779. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  780. var struct3502 models.Struct3502
  781. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  782. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  783. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  784. struct3502.FixmedinsCode = miConfig.Code
  785. struct3502.Code = miConfig.Code
  786. struct3502.RxFlag = "0"
  787. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  788. struct3502.OrgName = miConfig.OrgName
  789. struct3502.Opter = roles.UserName
  790. struct3502.AccessKey = miConfig.AccessKey
  791. struct3502.RequestUrl = miConfig.Url
  792. struct3502.SecretKey = miConfig.SecretKey
  793. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  794. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  795. struct3502.Url = miConfig.Url
  796. struct3502.AppId = miConfig.Cainfo
  797. struct3502.AppSecret = miConfig.AppSecret
  798. struct3502.Enckey = miConfig.EncKey
  799. struct3502.SignKey = miConfig.SignKey
  800. struct3502.SecretKey = miConfig.SecretKey
  801. struct3502.DrugTracCodg = drug.DrugCode
  802. struct3502.Memo = ""
  803. struct3502.InvChgType = "108"
  804. struct3502.FixmedinsBchno = bg_number
  805. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  806. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  807. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  808. result11, result22, _ := service.FJyb3502(struct3502)
  809. saveLog(result11, result22, "3502", "3502")
  810. var respJSON3 map[string]interface{}
  811. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  814. return
  815. }
  816. userJSONBytes3, _ := json.Marshal(respJSON3)
  817. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  818. utils.ErrorLog("解析失败:%v", err)
  819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  820. return
  821. }
  822. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  823. data := make(map[string]interface{})
  824. data["struct_3502s"] = struct3502
  825. client := &http.Client{}
  826. bytesData, _ := json.Marshal(data)
  827. var req *http.Request
  828. if miConfig.MdtrtareaAdmvs == "320921" {
  829. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  830. } else {
  831. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  832. }
  833. resp, _ := client.Do(req)
  834. defer resp.Body.Close()
  835. body, ioErr := ioutil.ReadAll(resp.Body)
  836. if ioErr != nil {
  837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  838. }
  839. var respJSON map[string]interface{}
  840. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  843. return
  844. }
  845. var resSix10265 ResultSix10265 //1101结果
  846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  847. result, _ := json.Marshal(respJSON)
  848. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  849. utils.ErrorLog("解析失败:%v", err)
  850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  851. return
  852. }
  853. res3.InfRefmsgid = resSix10265.InfRefmsgid
  854. res3.Output = resSix10265.Output
  855. res3.ErrMsg = resSix10265.ErrMsg
  856. res3.Cainfo = resSix10265.Cainfo
  857. res3.WarnMsg = resSix10265.WarnMsg
  858. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  859. res3.Infcode = infocode
  860. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  861. data := make(map[string]interface{})
  862. data["struct_3502s"] = struct3502
  863. client := &http.Client{}
  864. bytesData, _ := json.Marshal(data)
  865. var req *http.Request
  866. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  867. resp, _ := client.Do(req)
  868. defer resp.Body.Close()
  869. body, ioErr := ioutil.ReadAll(resp.Body)
  870. if ioErr != nil {
  871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  872. }
  873. var respJSON map[string]interface{}
  874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  877. return
  878. }
  879. var resSix10265 ResultSix10265 //1101结果
  880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  881. result, _ := json.Marshal(respJSON)
  882. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  883. utils.ErrorLog("解析失败:%v", err)
  884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  885. return
  886. }
  887. res3.InfRefmsgid = resSix10265.InfRefmsgid
  888. res3.Output = resSix10265.Output
  889. res3.ErrMsg = resSix10265.ErrMsg
  890. res3.Cainfo = resSix10265.Cainfo
  891. res3.WarnMsg = resSix10265.WarnMsg
  892. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  893. res3.Infcode = infocode
  894. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  895. data := make(map[string]interface{})
  896. data["struct_3501s"] = struct3501
  897. client := &http.Client{}
  898. bytesData, _ := json.Marshal(data)
  899. var req *http.Request
  900. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  901. resp, _ := client.Do(req)
  902. defer resp.Body.Close()
  903. body, ioErr := ioutil.ReadAll(resp.Body)
  904. if ioErr != nil {
  905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  906. }
  907. var respJSON map[string]interface{}
  908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. return
  912. }
  913. var resSix10265 ResultSix10265 //1101结果
  914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  915. result, _ := json.Marshal(respJSON)
  916. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  917. utils.ErrorLog("解析失败:%v", err)
  918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  919. return
  920. }
  921. res2.InfRefmsgid = resSix10265.InfRefmsgid
  922. res2.Output = resSix10265.Output
  923. res2.ErrMsg = resSix10265.ErrMsg
  924. res2.Cainfo = resSix10265.Cainfo
  925. res2.WarnMsg = resSix10265.WarnMsg
  926. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  927. res2.Infcode = infocode
  928. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  929. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  930. saveLog(result11, result22, "3502", "3502")
  931. var respJSON3 map[string]interface{}
  932. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  935. return
  936. }
  937. userJSONBytes3, _ := json.Marshal(respJSON3)
  938. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  939. utils.ErrorLog("解析失败:%v", err)
  940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  941. return
  942. }
  943. }
  944. if res3.Infcode == -1 {
  945. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  946. c.ServeSuccessJSON(map[string]interface{}{
  947. "failed_code": -10,
  948. "msg": res3.ErrMsg,
  949. })
  950. } else {
  951. drug.IsBg = 1
  952. drug.BgBchno = bg_number
  953. service.SaveW(drug)
  954. }
  955. }
  956. } else {
  957. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  958. }
  959. }
  960. //变更
  961. }
  962. if len(errs) == 0 {
  963. c.ServeSuccessJSON(map[string]interface{}{
  964. "msg": "盘存变更成功",
  965. })
  966. } else {
  967. c.ServeSuccessJSON(map[string]interface{}{
  968. "failed_code": -10,
  969. "msg": errs,
  970. })
  971. }
  972. }
  973. func (c *HisApiController) DeletePCandBG() {
  974. ids := c.GetString("ids")
  975. id_arr := strings.Split(ids, ",")
  976. admin_user_id, _ := c.GetInt64("admin_user_id")
  977. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  978. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  979. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  980. var err []string
  981. for _, item := range drugs {
  982. if item.IsPc == 1 && item.IsBg == 1 {
  983. var res FJ3507Result
  984. var res2 FJ3507Result
  985. var struct3507 models.Struct3507
  986. struct3507.FixmedinsBchno = item.Bchno
  987. struct3507.InvDataType = "1"
  988. struct3507.Opter = roles.UserName
  989. struct3507.OrgName = miConfig.OrgName
  990. struct3507.AccessKey = miConfig.AccessKey
  991. struct3507.RequestUrl = miConfig.Url
  992. struct3507.FixmedinsCode = miConfig.Code
  993. struct3507.Code = miConfig.Code
  994. struct3507.SecretKey = miConfig.SecretKey
  995. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  996. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  997. struct3507.Url = miConfig.Url
  998. struct3507.AppId = miConfig.Cainfo
  999. struct3507.AppSecret = miConfig.AppSecret
  1000. struct3507.Enckey = miConfig.EncKey
  1001. struct3507.SignKey = miConfig.SignKey
  1002. struct3507.SecretKey = miConfig.SecretKey
  1003. if miConfig.MdtrtareaAdmvs == "350500" {
  1004. result, result1, _ := service.FJyb3507(struct3507)
  1005. saveLog(result, result1, "3507", "3507")
  1006. var respJSON2 map[string]interface{}
  1007. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1010. return
  1011. }
  1012. userJSONBytes2, _ := json.Marshal(respJSON2)
  1013. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1014. utils.ErrorLog("解析失败:%v", err)
  1015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1016. return
  1017. }
  1018. } else {
  1019. data := make(map[string]interface{})
  1020. data["struct_3507s"] = struct3507
  1021. client := &http.Client{}
  1022. bytesData, _ := json.Marshal(data)
  1023. var req *http.Request
  1024. if miConfig.MdtrtareaAdmvs == "320921" {
  1025. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1026. } else {
  1027. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1028. }
  1029. resp, _ := client.Do(req)
  1030. defer resp.Body.Close()
  1031. body, ioErr := ioutil.ReadAll(resp.Body)
  1032. if ioErr != nil {
  1033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1034. }
  1035. var respJSON map[string]interface{}
  1036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. var resSix10265 ResultSix10265 //1101结果
  1042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1043. result, _ := json.Marshal(respJSON)
  1044. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1045. utils.ErrorLog("解析失败:%v", err)
  1046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1047. return
  1048. }
  1049. res.InfRefmsgid = resSix10265.InfRefmsgid
  1050. //res.Output = resSix10265.Output
  1051. res.ErrMsg = resSix10265.ErrMsg
  1052. res.Cainfo = resSix10265.Cainfo
  1053. res.WarnMsg = resSix10265.WarnMsg
  1054. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1055. res.Infcode = infocode
  1056. }
  1057. if res.Infcode == 0 {
  1058. item.IsPc = 0
  1059. err2 := service.SaveW(item)
  1060. if err2 == nil {
  1061. var struct3507_2 models.Struct3507
  1062. struct3507_2.OrgName = miConfig.OrgName
  1063. struct3507_2.AccessKey = miConfig.AccessKey
  1064. struct3507_2.RequestUrl = miConfig.Url
  1065. struct3507_2.Opter = roles.UserName
  1066. struct3507_2.FixmedinsCode = miConfig.Code
  1067. struct3507_2.Code = miConfig.Code
  1068. struct3507_2.SecretKey = miConfig.SecretKey
  1069. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1070. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1071. struct3507_2.Url = miConfig.Url
  1072. struct3507_2.AppId = miConfig.Cainfo
  1073. struct3507_2.AppSecret = miConfig.AppSecret
  1074. struct3507_2.Enckey = miConfig.EncKey
  1075. struct3507_2.SignKey = miConfig.SignKey
  1076. struct3507_2.SecretKey = miConfig.SecretKey
  1077. struct3507_2.FixmedinsBchno = item.BgBchno
  1078. struct3507_2.InvDataType = "2"
  1079. if miConfig.MdtrtareaAdmvs == "350500" {
  1080. result11, result22, _ := service.FJyb3507(struct3507_2)
  1081. saveLog(result11, result22, "3507", "3507")
  1082. var respJSON3 map[string]interface{}
  1083. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1086. return
  1087. }
  1088. userJSONBytes3, _ := json.Marshal(respJSON3)
  1089. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1090. utils.ErrorLog("解析失败:%v", err)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. } else {
  1095. data := make(map[string]interface{})
  1096. data["struct_3507s"] = struct3507_2
  1097. client := &http.Client{}
  1098. bytesData, _ := json.Marshal(data)
  1099. var req *http.Request
  1100. if miConfig.MdtrtareaAdmvs == "320921" {
  1101. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1102. } else {
  1103. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1104. }
  1105. resp, _ := client.Do(req)
  1106. defer resp.Body.Close()
  1107. body, ioErr := ioutil.ReadAll(resp.Body)
  1108. if ioErr != nil {
  1109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1110. }
  1111. var respJSON map[string]interface{}
  1112. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1115. return
  1116. }
  1117. var resSix10265 ResultSix10265 //1101结果
  1118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1119. result, _ := json.Marshal(respJSON)
  1120. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1121. utils.ErrorLog("解析失败:%v", err)
  1122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1123. return
  1124. }
  1125. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1126. //res2.Output = resSix10265.Output
  1127. res2.ErrMsg = resSix10265.ErrMsg
  1128. res2.Cainfo = resSix10265.Cainfo
  1129. res2.WarnMsg = resSix10265.WarnMsg
  1130. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1131. res2.Infcode = infocode
  1132. }
  1133. if res2.Infcode != -1 {
  1134. item.IsBg = 0
  1135. item.Bchno = ""
  1136. item.BgBchno = ""
  1137. item.PcDate = 0
  1138. service.SaveW(item)
  1139. } else {
  1140. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1141. }
  1142. }
  1143. } else {
  1144. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1145. }
  1146. }
  1147. if item.IsPc == 1 && item.IsBg == 0 {
  1148. var res FJ3507Result
  1149. var struct3507 models.Struct3507
  1150. struct3507.FixmedinsBchno = item.Bchno
  1151. struct3507.InvDataType = "1"
  1152. struct3507.Opter = roles.UserName
  1153. struct3507.FixmedinsCode = miConfig.Code
  1154. struct3507.Code = miConfig.Code
  1155. struct3507.OrgName = miConfig.OrgName
  1156. struct3507.AccessKey = miConfig.AccessKey
  1157. struct3507.RequestUrl = miConfig.Url
  1158. struct3507.SecretKey = miConfig.SecretKey
  1159. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1160. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1161. struct3507.Url = miConfig.Url
  1162. struct3507.AppId = miConfig.Cainfo
  1163. struct3507.AppSecret = miConfig.AppSecret
  1164. struct3507.Enckey = miConfig.EncKey
  1165. struct3507.SignKey = miConfig.SignKey
  1166. struct3507.SecretKey = miConfig.SecretKey
  1167. //result, result1, _ := service.FJyb3507(struct3507)
  1168. //saveLog(result, result1, "3507", "3507")
  1169. if miConfig.MdtrtareaAdmvs == "350500" {
  1170. result, result1, _ := service.FJyb3507(struct3507)
  1171. saveLog(result, result1, "3507", "3507")
  1172. var respJSON2 map[string]interface{}
  1173. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1176. return
  1177. }
  1178. userJSONBytes2, _ := json.Marshal(respJSON2)
  1179. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1180. utils.ErrorLog("解析失败:%v", err)
  1181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. return
  1183. }
  1184. } else {
  1185. data := make(map[string]interface{})
  1186. data["struct_3507s"] = struct3507
  1187. client := &http.Client{}
  1188. bytesData, _ := json.Marshal(data)
  1189. var req *http.Request
  1190. if miConfig.MdtrtareaAdmvs == "320921" {
  1191. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1192. } else {
  1193. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1194. }
  1195. resp, _ := client.Do(req)
  1196. defer resp.Body.Close()
  1197. body, ioErr := ioutil.ReadAll(resp.Body)
  1198. if ioErr != nil {
  1199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1200. }
  1201. var respJSON map[string]interface{}
  1202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1205. return
  1206. }
  1207. var resSix10265 ResultSix10265 //1101结果
  1208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1209. result, _ := json.Marshal(respJSON)
  1210. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1211. utils.ErrorLog("解析失败:%v", err)
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1213. return
  1214. }
  1215. res.InfRefmsgid = resSix10265.InfRefmsgid
  1216. //res.Output = resSix10265.Output
  1217. res.ErrMsg = resSix10265.ErrMsg
  1218. res.Cainfo = resSix10265.Cainfo
  1219. res.WarnMsg = resSix10265.WarnMsg
  1220. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1221. res.Infcode = infocode
  1222. }
  1223. if res.Infcode == 0 {
  1224. item.IsPc = 0
  1225. item.Bchno = ""
  1226. item.BgBchno = ""
  1227. item.PcDate = 0
  1228. service.SaveW(item)
  1229. } else {
  1230. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1231. }
  1232. }
  1233. if item.IsPc == 0 && item.IsBg == 1 {
  1234. var res FJ3507Result
  1235. var struct3507 models.Struct3507
  1236. struct3507.FixmedinsBchno = item.BgBchno
  1237. struct3507.InvDataType = "2"
  1238. struct3507.Opter = roles.UserName
  1239. struct3507.FixmedinsCode = miConfig.Code
  1240. struct3507.OrgName = miConfig.OrgName
  1241. struct3507.AccessKey = miConfig.AccessKey
  1242. struct3507.RequestUrl = miConfig.Url
  1243. struct3507.SecretKey = miConfig.SecretKey
  1244. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1245. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1246. struct3507.Url = miConfig.Url
  1247. struct3507.AppId = miConfig.Cainfo
  1248. struct3507.AppSecret = miConfig.AppSecret
  1249. struct3507.Enckey = miConfig.EncKey
  1250. struct3507.SignKey = miConfig.SignKey
  1251. struct3507.SecretKey = miConfig.SecretKey
  1252. //result, result1, _ := service.FJyb3507(struct3507)
  1253. //saveLog(result, result1, "3507", "3507")
  1254. if miConfig.MdtrtareaAdmvs == "350500" {
  1255. result, result1, _ := service.FJyb3507(struct3507)
  1256. saveLog(result, result1, "3507", "3507")
  1257. var respJSON2 map[string]interface{}
  1258. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1261. return
  1262. }
  1263. userJSONBytes2, _ := json.Marshal(respJSON2)
  1264. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1265. utils.ErrorLog("解析失败:%v", err)
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1267. return
  1268. }
  1269. } else {
  1270. data := make(map[string]interface{})
  1271. data["struct_3507s"] = struct3507
  1272. client := &http.Client{}
  1273. bytesData, _ := json.Marshal(data)
  1274. var req *http.Request
  1275. if miConfig.MdtrtareaAdmvs == "320921" {
  1276. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1277. } else {
  1278. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1279. }
  1280. resp, _ := client.Do(req)
  1281. defer resp.Body.Close()
  1282. body, ioErr := ioutil.ReadAll(resp.Body)
  1283. if ioErr != nil {
  1284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1285. }
  1286. var respJSON map[string]interface{}
  1287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1290. return
  1291. }
  1292. var resSix10265 ResultSix10265 //1101结果
  1293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1294. result, _ := json.Marshal(respJSON)
  1295. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1296. utils.ErrorLog("解析失败:%v", err)
  1297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1298. return
  1299. }
  1300. res.InfRefmsgid = resSix10265.InfRefmsgid
  1301. //res.Output = resSix10265.Output
  1302. res.ErrMsg = resSix10265.ErrMsg
  1303. res.Cainfo = resSix10265.Cainfo
  1304. res.WarnMsg = resSix10265.WarnMsg
  1305. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1306. res.Infcode = infocode
  1307. }
  1308. if res.Infcode == 0 {
  1309. item.IsBg = 0
  1310. item.Bchno = ""
  1311. item.BgBchno = ""
  1312. item.PcDate = 0
  1313. service.SaveW(item)
  1314. } else {
  1315. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1316. }
  1317. }
  1318. }
  1319. if len(err) == 0 {
  1320. c.ServeSuccessJSON(map[string]interface{}{
  1321. "msg": "删除盘存变更成功",
  1322. })
  1323. } else {
  1324. c.ServeSuccessJSON(map[string]interface{}{
  1325. "failed_code": -10,
  1326. "msg": err,
  1327. })
  1328. }
  1329. }
  1330. func (c *HisApiController) DeleteXSandBG() {
  1331. ids := c.GetString("ids")
  1332. id_arr := strings.Split(ids, ",")
  1333. admin_user_id, _ := c.GetInt64("admin_user_id")
  1334. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1335. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1337. var err []string
  1338. for _, item := range flows {
  1339. if item.IsSale == 1 && item.IsChange == 1 {
  1340. var res FJ3507Result
  1341. var res2 FJ3507Result
  1342. var struct3507 models.Struct3507
  1343. struct3507.FixmedinsBchno = item.Bchno
  1344. struct3507.InvDataType = "4"
  1345. struct3507.Opter = roles.UserName
  1346. struct3507.OrgName = miConfig.OrgName
  1347. struct3507.AccessKey = miConfig.AccessKey
  1348. struct3507.RequestUrl = miConfig.Url
  1349. struct3507.FixmedinsCode = miConfig.Code
  1350. struct3507.SecretKey = miConfig.SecretKey
  1351. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1352. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1353. struct3507.Url = miConfig.Url
  1354. struct3507.AppId = miConfig.Cainfo
  1355. struct3507.AppSecret = miConfig.AppSecret
  1356. struct3507.Enckey = miConfig.EncKey
  1357. struct3507.SignKey = miConfig.SignKey
  1358. struct3507.SecretKey = miConfig.SecretKey
  1359. //result, result1, _ := service.FJyb3507(struct3507)
  1360. //saveLog(result, result1, "3507", "3507")
  1361. if miConfig.MdtrtareaAdmvs == "350500" {
  1362. result, result1, _ := service.FJyb3507(struct3507)
  1363. saveLog(result, result1, "3507", "3507")
  1364. var respJSON2 map[string]interface{}
  1365. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1368. return
  1369. }
  1370. userJSONBytes2, _ := json.Marshal(respJSON2)
  1371. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1372. utils.ErrorLog("解析失败:%v", err)
  1373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1374. return
  1375. }
  1376. } else {
  1377. data := make(map[string]interface{})
  1378. data["struct_3507s"] = struct3507
  1379. client := &http.Client{}
  1380. bytesData, _ := json.Marshal(data)
  1381. var req *http.Request
  1382. if miConfig.MdtrtareaAdmvs == "320921" {
  1383. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1384. } else {
  1385. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1386. }
  1387. resp, _ := client.Do(req)
  1388. defer resp.Body.Close()
  1389. body, ioErr := ioutil.ReadAll(resp.Body)
  1390. if ioErr != nil {
  1391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1392. }
  1393. var respJSON map[string]interface{}
  1394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1397. return
  1398. }
  1399. var resSix10265 ResultSix10265 //1101结果
  1400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1401. result, _ := json.Marshal(respJSON)
  1402. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1403. utils.ErrorLog("解析失败:%v", err)
  1404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1405. return
  1406. }
  1407. res.InfRefmsgid = resSix10265.InfRefmsgid
  1408. //res.Output = resSix10265.Output
  1409. res.ErrMsg = resSix10265.ErrMsg
  1410. res.Cainfo = resSix10265.Cainfo
  1411. res.WarnMsg = resSix10265.WarnMsg
  1412. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1413. res.Infcode = infocode
  1414. }
  1415. if res.Infcode == 0 {
  1416. item.IsSale = 0
  1417. item.SaleDate = ""
  1418. item.Bchno = ""
  1419. err2 := service.SaveDF(item)
  1420. if err2 == nil {
  1421. var struct3507_2 models.Struct3507
  1422. struct3507_2.OrgName = miConfig.OrgName
  1423. struct3507_2.AccessKey = miConfig.AccessKey
  1424. struct3507_2.RequestUrl = miConfig.Url
  1425. struct3507_2.Opter = roles.UserName
  1426. struct3507_2.FixmedinsCode = miConfig.Code
  1427. struct3507_2.Code = miConfig.Code
  1428. struct3507_2.SecretKey = miConfig.SecretKey
  1429. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1430. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1431. struct3507_2.Url = miConfig.Url
  1432. struct3507_2.AppId = miConfig.Cainfo
  1433. struct3507_2.AppSecret = miConfig.AppSecret
  1434. struct3507_2.Enckey = miConfig.EncKey
  1435. struct3507_2.SignKey = miConfig.SignKey
  1436. struct3507_2.SecretKey = miConfig.SecretKey
  1437. struct3507_2.FixmedinsBchno = item.BgBchno
  1438. struct3507_2.InvDataType = "2"
  1439. if miConfig.MdtrtareaAdmvs == "350500" {
  1440. result11, result22, _ := service.FJyb3507(struct3507_2)
  1441. saveLog(result11, result22, "3507", "3507")
  1442. var respJSON3 map[string]interface{}
  1443. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1446. return
  1447. }
  1448. userJSONBytes3, _ := json.Marshal(respJSON3)
  1449. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1450. utils.ErrorLog("解析失败:%v", err)
  1451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1452. return
  1453. }
  1454. } else {
  1455. data := make(map[string]interface{})
  1456. data["struct_3507s"] = struct3507_2
  1457. client := &http.Client{}
  1458. bytesData, _ := json.Marshal(data)
  1459. var req *http.Request
  1460. if miConfig.MdtrtareaAdmvs == "320921" {
  1461. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1462. } else {
  1463. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1464. }
  1465. resp, _ := client.Do(req)
  1466. defer resp.Body.Close()
  1467. body, ioErr := ioutil.ReadAll(resp.Body)
  1468. if ioErr != nil {
  1469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1470. }
  1471. var respJSON map[string]interface{}
  1472. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1475. return
  1476. }
  1477. var resSix10265 ResultSix10265 //1101结果
  1478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1479. result, _ := json.Marshal(respJSON)
  1480. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1481. utils.ErrorLog("解析失败:%v", err)
  1482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1483. return
  1484. }
  1485. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1486. //res.Output = resSix10265.Output
  1487. res2.ErrMsg = resSix10265.ErrMsg
  1488. res2.Cainfo = resSix10265.Cainfo
  1489. res2.WarnMsg = resSix10265.WarnMsg
  1490. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1491. res2.Infcode = infocode
  1492. }
  1493. if res2.Infcode == 0 {
  1494. item.IsChange = 0
  1495. item.BgBchno = ""
  1496. service.SaveDF2(item)
  1497. } else {
  1498. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1499. }
  1500. }
  1501. } else {
  1502. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1503. }
  1504. }
  1505. if item.IsSale == 2 && item.IsChange == 1 {
  1506. var res FJ3507Result
  1507. var res2 FJ3507Result
  1508. var struct3507 models.Struct3507
  1509. struct3507.FixmedinsBchno = item.Bchno
  1510. struct3507.InvDataType = "4"
  1511. struct3507.Opter = roles.UserName
  1512. struct3507.OrgName = miConfig.OrgName
  1513. struct3507.AccessKey = miConfig.AccessKey
  1514. struct3507.RequestUrl = miConfig.Url
  1515. struct3507.FixmedinsCode = miConfig.Code
  1516. struct3507.Code = miConfig.Code
  1517. struct3507.SecretKey = miConfig.SecretKey
  1518. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1519. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1520. struct3507.Url = miConfig.Url
  1521. struct3507.AppId = miConfig.Cainfo
  1522. struct3507.AppSecret = miConfig.AppSecret
  1523. struct3507.Enckey = miConfig.EncKey
  1524. struct3507.SignKey = miConfig.SignKey
  1525. struct3507.SecretKey = miConfig.SecretKey
  1526. //result, result1, _ := service.FJyb3507(struct3507)
  1527. //saveLog(result, result1, "3507", "3507")
  1528. //
  1529. //var respJSON2 map[string]interface{}
  1530. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1531. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. // return
  1534. //}
  1535. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1536. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1537. // utils.ErrorLog("解析失败:%v", err)
  1538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. // return
  1540. //}
  1541. if miConfig.MdtrtareaAdmvs == "350500" {
  1542. result, result1, _ := service.FJyb3507(struct3507)
  1543. saveLog(result, result1, "3507", "3507")
  1544. var respJSON2 map[string]interface{}
  1545. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1548. return
  1549. }
  1550. userJSONBytes2, _ := json.Marshal(respJSON2)
  1551. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1552. utils.ErrorLog("解析失败:%v", err)
  1553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1554. return
  1555. }
  1556. } else {
  1557. data := make(map[string]interface{})
  1558. data["struct_3507s"] = struct3507
  1559. client := &http.Client{}
  1560. bytesData, _ := json.Marshal(data)
  1561. var req *http.Request
  1562. if miConfig.MdtrtareaAdmvs == "320921" {
  1563. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1564. } else {
  1565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1566. }
  1567. resp, _ := client.Do(req)
  1568. defer resp.Body.Close()
  1569. body, ioErr := ioutil.ReadAll(resp.Body)
  1570. if ioErr != nil {
  1571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1572. }
  1573. var respJSON map[string]interface{}
  1574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1577. return
  1578. }
  1579. var resSix10265 ResultSix10265 //1101结果
  1580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1581. result, _ := json.Marshal(respJSON)
  1582. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1583. utils.ErrorLog("解析失败:%v", err)
  1584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1585. return
  1586. }
  1587. res.InfRefmsgid = resSix10265.InfRefmsgid
  1588. //res.Output = resSix10265.Output
  1589. res.ErrMsg = resSix10265.ErrMsg
  1590. res.Cainfo = resSix10265.Cainfo
  1591. res.WarnMsg = resSix10265.WarnMsg
  1592. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1593. res.Infcode = infocode
  1594. }
  1595. if res.Infcode == 0 {
  1596. item.IsSale = 0
  1597. item.SaleDate = ""
  1598. item.Bchno = ""
  1599. err2 := service.SaveDF(item)
  1600. if err2 == nil {
  1601. var struct3507_2 models.Struct3507
  1602. struct3507_2.OrgName = miConfig.OrgName
  1603. struct3507_2.AccessKey = miConfig.AccessKey
  1604. struct3507_2.RequestUrl = miConfig.Url
  1605. struct3507_2.Opter = roles.UserName
  1606. struct3507_2.FixmedinsCode = miConfig.Code
  1607. struct3507_2.Code = miConfig.Code
  1608. struct3507_2.SecretKey = miConfig.SecretKey
  1609. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1610. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1611. struct3507_2.Url = miConfig.Url
  1612. struct3507_2.AppId = miConfig.Cainfo
  1613. struct3507_2.AppSecret = miConfig.AppSecret
  1614. struct3507_2.Enckey = miConfig.EncKey
  1615. struct3507_2.SignKey = miConfig.SignKey
  1616. struct3507_2.SecretKey = miConfig.SecretKey
  1617. struct3507_2.FixmedinsBchno = item.BgBchno
  1618. struct3507_2.InvDataType = "2"
  1619. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1620. //saveLog(result11, result22, "3507", "3507")
  1621. //var respJSON3 map[string]interface{}
  1622. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1623. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1625. // return
  1626. //}
  1627. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1628. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1629. // utils.ErrorLog("解析失败:%v", err)
  1630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1631. // return
  1632. //}
  1633. if miConfig.MdtrtareaAdmvs == "350500" {
  1634. result11, result22, _ := service.FJyb3507(struct3507_2)
  1635. saveLog(result11, result22, "3507", "3507")
  1636. var respJSON3 map[string]interface{}
  1637. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. userJSONBytes3, _ := json.Marshal(respJSON3)
  1643. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1644. utils.ErrorLog("解析失败:%v", err)
  1645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1646. return
  1647. }
  1648. } else {
  1649. data := make(map[string]interface{})
  1650. data["struct_3507s"] = struct3507_2
  1651. client := &http.Client{}
  1652. bytesData, _ := json.Marshal(data)
  1653. var req *http.Request
  1654. if miConfig.MdtrtareaAdmvs == "320921" {
  1655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1656. } else {
  1657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1658. }
  1659. resp, _ := client.Do(req)
  1660. defer resp.Body.Close()
  1661. body, ioErr := ioutil.ReadAll(resp.Body)
  1662. if ioErr != nil {
  1663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1664. }
  1665. var respJSON map[string]interface{}
  1666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1669. return
  1670. }
  1671. var resSix10265 ResultSix10265 //1101结果
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. result, _ := json.Marshal(respJSON)
  1674. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1675. utils.ErrorLog("解析失败:%v", err)
  1676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1677. return
  1678. }
  1679. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1680. //res.Output = resSix10265.Output
  1681. res2.ErrMsg = resSix10265.ErrMsg
  1682. res2.Cainfo = resSix10265.Cainfo
  1683. res2.WarnMsg = resSix10265.WarnMsg
  1684. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1685. res2.Infcode = infocode
  1686. }
  1687. if res2.Infcode == 0 {
  1688. item.IsChange = 0
  1689. item.BgBchno = ""
  1690. service.SaveDF2(item)
  1691. } else {
  1692. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1693. }
  1694. }
  1695. } else {
  1696. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1697. }
  1698. }
  1699. if item.IsSale == 1 && item.IsChange == 0 {
  1700. var res FJ3507Result
  1701. var struct3507 models.Struct3507
  1702. struct3507.FixmedinsBchno = item.Bchno
  1703. struct3507.InvDataType = "4"
  1704. struct3507.Opter = roles.UserName
  1705. struct3507.FixmedinsCode = miConfig.Code
  1706. struct3507.Code = miConfig.Code
  1707. struct3507.OrgName = miConfig.OrgName
  1708. struct3507.AccessKey = miConfig.AccessKey
  1709. struct3507.RequestUrl = miConfig.Url
  1710. struct3507.SecretKey = miConfig.SecretKey
  1711. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1712. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1713. struct3507.Url = miConfig.Url
  1714. struct3507.AppId = miConfig.Cainfo
  1715. struct3507.AppSecret = miConfig.AppSecret
  1716. struct3507.Enckey = miConfig.EncKey
  1717. struct3507.SignKey = miConfig.SignKey
  1718. struct3507.SecretKey = miConfig.SecretKey
  1719. //result, result1, _ := service.FJyb3507(struct3507)
  1720. //saveLog(result, result1, "3507", "3507")
  1721. //
  1722. //var respJSON3 map[string]interface{}
  1723. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1724. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1726. // return
  1727. //}
  1728. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1729. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1730. // utils.ErrorLog("解析失败:%v", err)
  1731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1732. // return
  1733. //}
  1734. if miConfig.MdtrtareaAdmvs == "350500" {
  1735. result, result1, _ := service.FJyb3507(struct3507)
  1736. saveLog(result, result1, "3507", "3507")
  1737. var respJSON2 map[string]interface{}
  1738. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1741. return
  1742. }
  1743. userJSONBytes2, _ := json.Marshal(respJSON2)
  1744. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1745. utils.ErrorLog("解析失败:%v", err)
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1747. return
  1748. }
  1749. } else {
  1750. data := make(map[string]interface{})
  1751. data["struct_3507s"] = struct3507
  1752. client := &http.Client{}
  1753. bytesData, _ := json.Marshal(data)
  1754. var req *http.Request
  1755. if miConfig.MdtrtareaAdmvs == "320921" {
  1756. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1757. } else {
  1758. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1759. }
  1760. resp, _ := client.Do(req)
  1761. defer resp.Body.Close()
  1762. body, ioErr := ioutil.ReadAll(resp.Body)
  1763. if ioErr != nil {
  1764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1765. }
  1766. var respJSON map[string]interface{}
  1767. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1770. return
  1771. }
  1772. var resSix10265 ResultSix10265 //1101结果
  1773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1774. result, _ := json.Marshal(respJSON)
  1775. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1776. utils.ErrorLog("解析失败:%v", err)
  1777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1778. return
  1779. }
  1780. res.InfRefmsgid = resSix10265.InfRefmsgid
  1781. //res.Output = resSix10265.Output
  1782. res.ErrMsg = resSix10265.ErrMsg
  1783. res.Cainfo = resSix10265.Cainfo
  1784. res.WarnMsg = resSix10265.WarnMsg
  1785. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1786. res.Infcode = infocode
  1787. }
  1788. if res.Infcode == 0 {
  1789. item.IsSale = 0
  1790. item.SaleDate = ""
  1791. service.SaveDF(item)
  1792. } else {
  1793. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1794. }
  1795. }
  1796. if item.IsSale == 2 && item.IsChange == 0 {
  1797. var res FJ3507Result
  1798. var struct3507 models.Struct3507
  1799. struct3507.FixmedinsBchno = item.Bchno
  1800. struct3507.InvDataType = "4"
  1801. struct3507.Opter = roles.UserName
  1802. struct3507.FixmedinsCode = miConfig.Code
  1803. struct3507.Code = miConfig.Code
  1804. struct3507.OrgName = miConfig.OrgName
  1805. struct3507.AccessKey = miConfig.AccessKey
  1806. struct3507.RequestUrl = miConfig.Url
  1807. struct3507.SecretKey = miConfig.SecretKey
  1808. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1809. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1810. struct3507.Url = miConfig.Url
  1811. struct3507.AppId = miConfig.Cainfo
  1812. struct3507.AppSecret = miConfig.AppSecret
  1813. struct3507.Enckey = miConfig.EncKey
  1814. struct3507.SignKey = miConfig.SignKey
  1815. struct3507.SecretKey = miConfig.SecretKey
  1816. //result, result1, _ := service.FJyb3507(struct3507)
  1817. //saveLog(result, result1, "3507", "3507")
  1818. //
  1819. //var respJSON3 map[string]interface{}
  1820. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1821. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1822. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. // return
  1824. //}
  1825. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1826. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1827. // utils.ErrorLog("解析失败:%v", err)
  1828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1829. // return
  1830. //}
  1831. if miConfig.MdtrtareaAdmvs == "350500" {
  1832. result, result1, _ := service.FJyb3507(struct3507)
  1833. saveLog(result, result1, "3507", "3507")
  1834. var respJSON2 map[string]interface{}
  1835. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1838. return
  1839. }
  1840. userJSONBytes2, _ := json.Marshal(respJSON2)
  1841. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1842. utils.ErrorLog("解析失败:%v", err)
  1843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1844. return
  1845. }
  1846. } else {
  1847. data := make(map[string]interface{})
  1848. data["struct_3507s"] = struct3507
  1849. client := &http.Client{}
  1850. bytesData, _ := json.Marshal(data)
  1851. var req *http.Request
  1852. if miConfig.MdtrtareaAdmvs == "320921" {
  1853. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1854. } else {
  1855. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1856. }
  1857. resp, _ := client.Do(req)
  1858. defer resp.Body.Close()
  1859. body, ioErr := ioutil.ReadAll(resp.Body)
  1860. if ioErr != nil {
  1861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1862. }
  1863. var respJSON map[string]interface{}
  1864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1867. return
  1868. }
  1869. var resSix10265 ResultSix10265 //1101结果
  1870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1871. result, _ := json.Marshal(respJSON)
  1872. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1873. utils.ErrorLog("解析失败:%v", err)
  1874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1875. return
  1876. }
  1877. res.InfRefmsgid = resSix10265.InfRefmsgid
  1878. //res.Output = resSix10265.Output
  1879. res.ErrMsg = resSix10265.ErrMsg
  1880. res.Cainfo = resSix10265.Cainfo
  1881. res.WarnMsg = resSix10265.WarnMsg
  1882. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1883. res.Infcode = infocode
  1884. }
  1885. if res.Infcode == 0 {
  1886. item.IsSale = 0
  1887. item.SaleDate = ""
  1888. item.Bchno = ""
  1889. service.SaveDF(item)
  1890. } else {
  1891. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1892. }
  1893. }
  1894. if item.IsSale == 0 && item.IsChange == 1 {
  1895. var res FJ3507Result
  1896. var struct3507 models.Struct3507
  1897. struct3507.FixmedinsBchno = item.BgBchno
  1898. struct3507.InvDataType = "2"
  1899. struct3507.Opter = roles.UserName
  1900. struct3507.FixmedinsCode = miConfig.Code
  1901. struct3507.Code = miConfig.Code
  1902. struct3507.OrgName = miConfig.OrgName
  1903. struct3507.AccessKey = miConfig.AccessKey
  1904. struct3507.RequestUrl = miConfig.Url
  1905. struct3507.SecretKey = miConfig.SecretKey
  1906. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1907. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1908. struct3507.Url = miConfig.Url
  1909. struct3507.AppId = miConfig.Cainfo
  1910. struct3507.AppSecret = miConfig.AppSecret
  1911. struct3507.Enckey = miConfig.EncKey
  1912. struct3507.SignKey = miConfig.SignKey
  1913. struct3507.SecretKey = miConfig.SecretKey
  1914. //result, result1, _ := service.FJyb3507(struct3507)
  1915. //saveLog(result, result1, "3507", "3507")
  1916. //
  1917. //var respJSON3 map[string]interface{}
  1918. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1919. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. // return
  1922. //}
  1923. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1924. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1925. // utils.ErrorLog("解析失败:%v", err)
  1926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1927. // return
  1928. //}
  1929. if miConfig.MdtrtareaAdmvs == "350500" {
  1930. result, result1, _ := service.FJyb3507(struct3507)
  1931. saveLog(result, result1, "3507", "3507")
  1932. var respJSON2 map[string]interface{}
  1933. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1936. return
  1937. }
  1938. userJSONBytes2, _ := json.Marshal(respJSON2)
  1939. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1940. utils.ErrorLog("解析失败:%v", err)
  1941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1942. return
  1943. }
  1944. } else {
  1945. data := make(map[string]interface{})
  1946. data["struct_3507s"] = struct3507
  1947. client := &http.Client{}
  1948. bytesData, _ := json.Marshal(data)
  1949. var req *http.Request
  1950. if miConfig.MdtrtareaAdmvs == "320921" {
  1951. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1952. } else {
  1953. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1954. }
  1955. resp, _ := client.Do(req)
  1956. defer resp.Body.Close()
  1957. body, ioErr := ioutil.ReadAll(resp.Body)
  1958. if ioErr != nil {
  1959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1960. }
  1961. var respJSON map[string]interface{}
  1962. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1965. return
  1966. }
  1967. var resSix10265 ResultSix10265 //1101结果
  1968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1969. result, _ := json.Marshal(respJSON)
  1970. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1971. utils.ErrorLog("解析失败:%v", err)
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1973. return
  1974. }
  1975. res.InfRefmsgid = resSix10265.InfRefmsgid
  1976. //res.Output = resSix10265.Output
  1977. res.ErrMsg = resSix10265.ErrMsg
  1978. res.Cainfo = resSix10265.Cainfo
  1979. res.WarnMsg = resSix10265.WarnMsg
  1980. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1981. res.Infcode = infocode
  1982. }
  1983. if res.Infcode == 0 {
  1984. item.IsChange = 0
  1985. item.BgBchno = ""
  1986. service.SaveDF2(item)
  1987. } else {
  1988. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1989. }
  1990. }
  1991. }
  1992. if len(err) == 0 {
  1993. c.ServeSuccessJSON(map[string]interface{}{
  1994. "msg": "删除销售变更成功",
  1995. })
  1996. } else {
  1997. c.ServeSuccessJSON(map[string]interface{}{
  1998. "failed_code": -10,
  1999. "msg": err,
  2000. })
  2001. }
  2002. }
  2003. //func (c *HisApiController) BatchFJ3501AND3502() {
  2004. // //ids := c.GetString("ids")
  2005. // start_time := c.GetString("start_time")
  2006. // end_time := c.GetString("end_time")
  2007. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2008. //
  2009. //
  2010. // timeLayout := "2006-01-02"
  2011. // loc, _ := time.LoadLocation("Local")
  2012. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2013. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2014. //
  2015. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2016. // //id_arr := strings.Split(ids, ",")
  2017. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2018. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2019. // //库盘
  2020. // var errs []string
  2021. // for _, drug := range drugs {
  2022. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2023. // var res2 ResultSix
  2024. // var res3 ResultSix
  2025. //
  2026. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2027. // var struct3501 models.Struct3501
  2028. // struct3501.Code = miConfig.Code
  2029. // struct3501.OrgName = miConfig.OrgName
  2030. // struct3501.AccessKey = miConfig.AccessKey
  2031. // struct3501.Opter = roles.UserName
  2032. // struct3501.RequestUrl = miConfig.Url
  2033. // struct3501.Url = miConfig.Url
  2034. // struct3501.AppId = miConfig.Cainfo
  2035. // struct3501.AppSecret = miConfig.AppSecret
  2036. // struct3501.Enckey = miConfig.EncKey
  2037. // struct3501.SignKey = miConfig.SignKey
  2038. // struct3501.SecretKey = miConfig.SecretKey
  2039. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2040. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2041. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2042. // struct3501.RxFlag = "1"
  2043. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2044. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2045. //
  2046. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2047. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2048. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2049. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2050. // struct3501.FixmedinsBchno = number
  2051. // struct3501.DrugTracCodg = drug.DrugCode
  2052. // memo := make(map[string]interface{})
  2053. // memo["pric"] = drug.Price
  2054. // bytesData, _ := json.Marshal(memo)
  2055. // struct3501.Memo = string(bytesData)
  2056. //
  2057. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2058. //
  2059. // result1, result2, _ := service.FJyb3501(struct3501)
  2060. // saveLog(result1, result2, "3501", "3501")
  2061. // //saveLog(result, requestLog, "2201", "挂号")
  2062. //
  2063. // var respJSON2 map[string]interface{}
  2064. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2065. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2067. // return
  2068. // }
  2069. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2070. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2071. // utils.ErrorLog("解析失败:%v", err)
  2072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. // return
  2074. // }
  2075. //
  2076. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2077. // data := make(map[string]interface{})
  2078. // data["struct_3501s"] = struct3501
  2079. // client := &http.Client{}
  2080. // bytesData, _ := json.Marshal(data)
  2081. // var req *http.Request
  2082. // if miConfig.MdtrtareaAdmvs == "320921" {
  2083. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2084. // } else {
  2085. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2086. // }
  2087. //
  2088. // resp, _ := client.Do(req)
  2089. // defer resp.Body.Close()
  2090. // body, ioErr := ioutil.ReadAll(resp.Body)
  2091. // if ioErr != nil {
  2092. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2093. // }
  2094. // var respJSON map[string]interface{}
  2095. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2096. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2098. // return
  2099. // }
  2100. // var resSix10265 ResultSix10265 //1101结果
  2101. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2102. // result, _ := json.Marshal(respJSON)
  2103. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2104. // utils.ErrorLog("解析失败:%v", err)
  2105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2106. // return
  2107. // }
  2108. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2109. // res2.Output = resSix10265.Output
  2110. // res2.ErrMsg = resSix10265.ErrMsg
  2111. // res2.Cainfo = resSix10265.Cainfo
  2112. // res2.WarnMsg = resSix10265.WarnMsg
  2113. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2114. // res2.Infcode = infocode
  2115. //
  2116. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2117. // data := make(map[string]interface{})
  2118. // data["struct_3501s"] = struct3501
  2119. // client := &http.Client{}
  2120. // bytesData, _ := json.Marshal(data)
  2121. // var req *http.Request
  2122. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2123. // resp, _ := client.Do(req)
  2124. // defer resp.Body.Close()
  2125. // body, ioErr := ioutil.ReadAll(resp.Body)
  2126. // if ioErr != nil {
  2127. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2128. // }
  2129. // var respJSON map[string]interface{}
  2130. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2131. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2133. // return
  2134. // }
  2135. // var resSix10265 ResultSix10265 //1101结果
  2136. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2137. // result, _ := json.Marshal(respJSON)
  2138. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2139. // utils.ErrorLog("解析失败:%v", err)
  2140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2141. // return
  2142. // }
  2143. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2144. // res2.Output = resSix10265.Output
  2145. // res2.ErrMsg = resSix10265.ErrMsg
  2146. // res2.Cainfo = resSix10265.Cainfo
  2147. // res2.WarnMsg = resSix10265.WarnMsg
  2148. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2149. // res2.Infcode = infocode
  2150. //
  2151. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2152. // data := make(map[string]interface{})
  2153. // data["struct_3501s"] = struct3501
  2154. // client := &http.Client{}
  2155. // bytesData, _ := json.Marshal(data)
  2156. // var req *http.Request
  2157. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2158. // resp, _ := client.Do(req)
  2159. // defer resp.Body.Close()
  2160. // body, ioErr := ioutil.ReadAll(resp.Body)
  2161. // if ioErr != nil {
  2162. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2163. // }
  2164. // var respJSON map[string]interface{}
  2165. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2166. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2168. // return
  2169. // }
  2170. // var resSix10265 ResultSix10265 //1101结果
  2171. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2172. // result, _ := json.Marshal(respJSON)
  2173. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2174. // utils.ErrorLog("解析失败:%v", err)
  2175. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2176. // return
  2177. // }
  2178. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2179. // res2.Output = resSix10265.Output
  2180. // res2.ErrMsg = resSix10265.ErrMsg
  2181. // res2.Cainfo = resSix10265.Cainfo
  2182. // res2.WarnMsg = resSix10265.WarnMsg
  2183. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2184. // res2.Infcode = infocode
  2185. //
  2186. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2187. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2188. // saveLog(result1, result2, "3501", "3501")
  2189. // //saveLog(result, requestLog, "2201", "挂号")
  2190. //
  2191. // var respJSON2 map[string]interface{}
  2192. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2195. // return
  2196. // }
  2197. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2198. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2199. // utils.ErrorLog("解析失败:%v", err)
  2200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2201. // return
  2202. // }
  2203. //
  2204. // }
  2205. //
  2206. // if res2.Infcode != -1 {
  2207. // drug.IsPc = 1
  2208. // drug.Bchno = number
  2209. // drug.PcDate = time.Now().Unix()
  2210. // err := service.SaveW(drug)
  2211. // if err == nil {
  2212. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2213. // var struct3502 models.Struct3502
  2214. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2215. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2216. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2217. // struct3502.FixmedinsCode = miConfig.Code
  2218. // struct3502.Code = miConfig.Code
  2219. //
  2220. // struct3502.RxFlag = "0"
  2221. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2222. // struct3502.OrgName = miConfig.OrgName
  2223. // struct3502.Opter = roles.UserName
  2224. // struct3502.AccessKey = miConfig.AccessKey
  2225. // struct3502.RequestUrl = miConfig.Url
  2226. // struct3502.SecretKey = miConfig.SecretKey
  2227. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2228. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2229. // struct3502.Url = miConfig.Url
  2230. // struct3502.AppId = miConfig.Cainfo
  2231. // struct3502.AppSecret = miConfig.AppSecret
  2232. // struct3502.Enckey = miConfig.EncKey
  2233. // struct3502.SignKey = miConfig.SignKey
  2234. // struct3502.SecretKey = miConfig.SecretKey
  2235. // struct3502.DrugTracCodg = drug.DrugCode
  2236. //
  2237. // struct3502.Memo = ""
  2238. // struct3502.InvChgType = "108"
  2239. // struct3502.FixmedinsBchno = bg_number
  2240. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2241. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2242. //
  2243. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2244. // result11, result22, _ := service.FJyb3502(struct3502)
  2245. // saveLog(result11, result22, "3502", "3502")
  2246. //
  2247. // var respJSON3 map[string]interface{}
  2248. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2249. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2251. // return
  2252. // }
  2253. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2254. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2255. // utils.ErrorLog("解析失败:%v", err)
  2256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2257. // return
  2258. // }
  2259. //
  2260. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2261. // data := make(map[string]interface{})
  2262. // data["struct_3502s"] = struct3502
  2263. // client := &http.Client{}
  2264. // bytesData, _ := json.Marshal(data)
  2265. // var req *http.Request
  2266. // if miConfig.MdtrtareaAdmvs == "320921" {
  2267. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2268. // } else {
  2269. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2270. // }
  2271. //
  2272. // resp, _ := client.Do(req)
  2273. // defer resp.Body.Close()
  2274. // body, ioErr := ioutil.ReadAll(resp.Body)
  2275. // if ioErr != nil {
  2276. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2277. // }
  2278. // var respJSON map[string]interface{}
  2279. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2280. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2282. // return
  2283. // }
  2284. // var resSix10265 ResultSix10265 //1101结果
  2285. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2286. // result, _ := json.Marshal(respJSON)
  2287. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2288. // utils.ErrorLog("解析失败:%v", err)
  2289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2290. // return
  2291. // }
  2292. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2293. // res3.Output = resSix10265.Output
  2294. // res3.ErrMsg = resSix10265.ErrMsg
  2295. // res3.Cainfo = resSix10265.Cainfo
  2296. // res3.WarnMsg = resSix10265.WarnMsg
  2297. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2298. // res3.Infcode = infocode
  2299. //
  2300. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2301. //
  2302. // data := make(map[string]interface{})
  2303. // data["struct_3502s"] = struct3502
  2304. // client := &http.Client{}
  2305. // bytesData, _ := json.Marshal(data)
  2306. // var req *http.Request
  2307. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2308. // resp, _ := client.Do(req)
  2309. // defer resp.Body.Close()
  2310. // body, ioErr := ioutil.ReadAll(resp.Body)
  2311. // if ioErr != nil {
  2312. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2313. // }
  2314. // var respJSON map[string]interface{}
  2315. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2316. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2318. // return
  2319. // }
  2320. // var resSix10265 ResultSix10265 //1101结果
  2321. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2322. // result, _ := json.Marshal(respJSON)
  2323. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2324. // utils.ErrorLog("解析失败:%v", err)
  2325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2326. // return
  2327. // }
  2328. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2329. // res3.Output = resSix10265.Output
  2330. // res3.ErrMsg = resSix10265.ErrMsg
  2331. // res3.Cainfo = resSix10265.Cainfo
  2332. // res3.WarnMsg = resSix10265.WarnMsg
  2333. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2334. // res3.Infcode = infocode
  2335. //
  2336. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2337. //
  2338. // data := make(map[string]interface{})
  2339. // data["struct_3501s"] = struct3501
  2340. // client := &http.Client{}
  2341. // bytesData, _ := json.Marshal(data)
  2342. // var req *http.Request
  2343. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2344. // resp, _ := client.Do(req)
  2345. // defer resp.Body.Close()
  2346. // body, ioErr := ioutil.ReadAll(resp.Body)
  2347. // if ioErr != nil {
  2348. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2349. // }
  2350. // var respJSON map[string]interface{}
  2351. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2352. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2354. // return
  2355. // }
  2356. // var resSix10265 ResultSix10265 //1101结果
  2357. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2358. // result, _ := json.Marshal(respJSON)
  2359. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2360. // utils.ErrorLog("解析失败:%v", err)
  2361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2362. // return
  2363. // }
  2364. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2365. // res2.Output = resSix10265.Output
  2366. // res2.ErrMsg = resSix10265.ErrMsg
  2367. // res2.Cainfo = resSix10265.Cainfo
  2368. // res2.WarnMsg = resSix10265.WarnMsg
  2369. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2370. // res2.Infcode = infocode
  2371. //
  2372. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2373. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2374. // saveLog(result11, result22, "3502", "3502")
  2375. //
  2376. // var respJSON3 map[string]interface{}
  2377. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. // return
  2381. // }
  2382. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2383. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2384. // utils.ErrorLog("解析失败:%v", err)
  2385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2386. // return
  2387. // }
  2388. // }
  2389. // if res3.Infcode == -1 {
  2390. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2391. // c.ServeSuccessJSON(map[string]interface{}{
  2392. // "failed_code": -10,
  2393. // "msg": res3.ErrMsg,
  2394. // })
  2395. // } else {
  2396. // drug.IsBg = 1
  2397. // drug.BgBchno = bg_number
  2398. // service.SaveW(drug)
  2399. // }
  2400. // }
  2401. // } else {
  2402. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2403. // }
  2404. // }
  2405. // //变更
  2406. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2407. // var res3 ResultSix
  2408. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2409. //
  2410. // var struct3502 models.Struct3502
  2411. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2412. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2413. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2414. // struct3502.FixmedinsCode = miConfig.Code
  2415. // struct3502.Code = miConfig.Code
  2416. //
  2417. // struct3502.Opter = roles.UserName
  2418. // struct3502.RxFlag = "0"
  2419. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2420. // struct3502.OrgName = miConfig.OrgName
  2421. // struct3502.AccessKey = miConfig.AccessKey
  2422. // struct3502.RequestUrl = miConfig.Url
  2423. // struct3502.SecretKey = miConfig.SecretKey
  2424. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2425. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2426. // struct3502.InvChgType = "108"
  2427. // struct3502.DrugTracCodg = drug.DrugCode
  2428. //
  2429. // struct3502.Url = miConfig.Url
  2430. // struct3502.AppId = miConfig.Cainfo
  2431. // struct3502.AppSecret = miConfig.AppSecret
  2432. // struct3502.Enckey = miConfig.EncKey
  2433. // struct3502.SignKey = miConfig.SignKey
  2434. // struct3502.SecretKey = miConfig.SecretKey
  2435. //
  2436. // struct3502.FixmedinsBchno = bg_number
  2437. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2438. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2439. //
  2440. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2441. // result1, result2, _ := service.FJyb3502(struct3502)
  2442. // saveLog(result1, result2, "3502", "3502")
  2443. // var respJSON3 map[string]interface{}
  2444. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2445. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2447. // return
  2448. // }
  2449. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2450. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2451. // utils.ErrorLog("解析失败:%v", err)
  2452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2453. // return
  2454. // }
  2455. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2456. // data := make(map[string]interface{})
  2457. // data["struct_3502s"] = struct3502
  2458. // client := &http.Client{}
  2459. // bytesData, _ := json.Marshal(data)
  2460. // var req *http.Request
  2461. // if miConfig.MdtrtareaAdmvs == "320921" {
  2462. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2463. // } else {
  2464. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2465. // }
  2466. // resp, _ := client.Do(req)
  2467. // defer resp.Body.Close()
  2468. // body, ioErr := ioutil.ReadAll(resp.Body)
  2469. // if ioErr != nil {
  2470. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2471. // }
  2472. // var respJSON map[string]interface{}
  2473. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2474. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2476. // return
  2477. // }
  2478. // var resSix10265 ResultSix10265 //1101结果
  2479. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2480. // result, _ := json.Marshal(respJSON)
  2481. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2482. // utils.ErrorLog("解析失败:%v", err)
  2483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2484. // return
  2485. // }
  2486. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2487. // res3.Output = resSix10265.Output
  2488. // res3.ErrMsg = resSix10265.ErrMsg
  2489. // res3.Cainfo = resSix10265.Cainfo
  2490. // res3.WarnMsg = resSix10265.WarnMsg
  2491. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2492. // res3.Infcode = infocode
  2493. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2494. //
  2495. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2496. //
  2497. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2498. //
  2499. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2500. //
  2501. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2502. // saveLog(result1, result2, "3501", "3501")
  2503. // //saveLog(result, requestLog, "2201", "挂号")
  2504. //
  2505. // var respJSON2 map[string]interface{}
  2506. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2507. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2509. // return
  2510. // }
  2511. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2512. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2513. // utils.ErrorLog("解析失败:%v", err)
  2514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2515. // return
  2516. // }
  2517. //
  2518. // }
  2519. // if res3.Infcode == -1 {
  2520. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2521. // } else {
  2522. // drug.IsBg = 1
  2523. // drug.BgBchno = bg_number
  2524. // service.SaveW(drug)
  2525. // }
  2526. // }
  2527. // }
  2528. //
  2529. // if len(errs) == 0 {
  2530. // c.ServeSuccessJSON(map[string]interface{}{
  2531. // "msg": "盘存变更成功",
  2532. // })
  2533. // } else {
  2534. // c.ServeSuccessJSON(map[string]interface{}{
  2535. // "failed_code": -10,
  2536. // "msg": errs,
  2537. // })
  2538. // }
  2539. //}
  2540. func (c *HisApiController) DeleteXSandBGTwo() {
  2541. patient_id, _ := c.GetInt64("patient_id")
  2542. admin_user_id, _ := c.GetInt64("admin_user_id")
  2543. times := c.GetString("time", "")
  2544. timeLayout := "2006-01-02"
  2545. loc, _ := time.LoadLocation("Local")
  2546. var stime, etime int64
  2547. if times == "" {
  2548. stime, etime = GetNowTime()
  2549. } else {
  2550. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2551. stime = stmp.Unix()
  2552. etime = stime + 86399
  2553. }
  2554. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2555. var flows []*models.DrugFlow
  2556. for _, item := range advicelist {
  2557. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2558. flows = append(flows, flow...)
  2559. }
  2560. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2561. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2562. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2563. var err []string
  2564. for _, item := range flows {
  2565. if item.IsSale == 1 {
  2566. var res FJ3507Result
  2567. var struct3507 models.Struct3507
  2568. struct3507.FixmedinsBchno = item.Bchno
  2569. struct3507.InvDataType = "4"
  2570. struct3507.Opter = roles.UserName
  2571. struct3507.OrgName = miConfig.OrgName
  2572. struct3507.AccessKey = miConfig.AccessKey
  2573. struct3507.RequestUrl = miConfig.Url
  2574. struct3507.FixmedinsCode = miConfig.Code
  2575. struct3507.SecretKey = miConfig.SecretKey
  2576. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2577. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2578. struct3507.Url = miConfig.Url
  2579. struct3507.AppId = miConfig.Cainfo
  2580. struct3507.AppSecret = miConfig.AppSecret
  2581. struct3507.Enckey = miConfig.EncKey
  2582. struct3507.SignKey = miConfig.SignKey
  2583. struct3507.SecretKey = miConfig.SecretKey
  2584. if miConfig.MdtrtareaAdmvs == "350500" {
  2585. result, result1, _ := service.FJyb3507(struct3507)
  2586. saveLog(result, result1, "3507", "3507")
  2587. var respJSON2 map[string]interface{}
  2588. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2591. return
  2592. }
  2593. userJSONBytes2, _ := json.Marshal(respJSON2)
  2594. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2595. utils.ErrorLog("解析失败:%v", err)
  2596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2597. return
  2598. }
  2599. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2600. data := make(map[string]interface{})
  2601. data["struct_3507s"] = struct3507
  2602. client := &http.Client{}
  2603. bytesData, _ := json.Marshal(data)
  2604. var req *http.Request
  2605. if miConfig.MdtrtareaAdmvs == "320921" {
  2606. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2607. } else {
  2608. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2609. }
  2610. resp, _ := client.Do(req)
  2611. defer resp.Body.Close()
  2612. body, ioErr := ioutil.ReadAll(resp.Body)
  2613. if ioErr != nil {
  2614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2615. }
  2616. var respJSON map[string]interface{}
  2617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2620. return
  2621. }
  2622. var resSix10265 ResultSix10265 //1101结果
  2623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2624. result, _ := json.Marshal(respJSON)
  2625. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2626. utils.ErrorLog("解析失败:%v", err)
  2627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. return
  2629. }
  2630. res.InfRefmsgid = resSix10265.InfRefmsgid
  2631. //res.Output = resSix10265.Output
  2632. res.ErrMsg = resSix10265.ErrMsg
  2633. res.Cainfo = resSix10265.Cainfo
  2634. res.WarnMsg = resSix10265.WarnMsg
  2635. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2636. res.Infcode = infocode
  2637. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2638. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2639. saveLog(result2, result1, "3507", "3507")
  2640. var respJSON2 map[string]interface{}
  2641. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2644. return
  2645. }
  2646. userJSONBytes2, _ := json.Marshal(respJSON2)
  2647. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2648. utils.ErrorLog("解析失败:%v", err)
  2649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2650. return
  2651. }
  2652. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2653. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2654. saveLog(result2, result1, "3507", "3507")
  2655. var respJSON2 map[string]interface{}
  2656. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2659. return
  2660. }
  2661. userJSONBytes2, _ := json.Marshal(respJSON2)
  2662. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2663. utils.ErrorLog("解析失败:%v", err)
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. return
  2666. }
  2667. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2668. result1, result2 := service.Jxyb3507(struct3507)
  2669. saveLog(result2, result1, "3507", "3507")
  2670. var respJSON2 map[string]interface{}
  2671. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2674. return
  2675. }
  2676. userJSONBytes2, _ := json.Marshal(respJSON2)
  2677. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2678. utils.ErrorLog("解析失败:%v", err)
  2679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2680. return
  2681. }
  2682. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2683. result1, result2 := service.AHyb3507(struct3507)
  2684. saveLog(result2, result1, "3507", "3507")
  2685. var respJSON2 map[string]interface{}
  2686. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2689. return
  2690. }
  2691. userJSONBytes2, _ := json.Marshal(respJSON2)
  2692. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2693. utils.ErrorLog("解析失败:%v", err)
  2694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2695. return
  2696. }
  2697. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2698. data := make(map[string]interface{})
  2699. data["struct_3507s"] = struct3507
  2700. client := &http.Client{}
  2701. bytesData, _ := json.Marshal(data)
  2702. var req *http.Request
  2703. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2704. resp, _ := client.Do(req)
  2705. defer resp.Body.Close()
  2706. body, ioErr := ioutil.ReadAll(resp.Body)
  2707. if ioErr != nil {
  2708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2709. }
  2710. var respJSON map[string]interface{}
  2711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2713. }
  2714. var resSix10265 ResultSix10265 //1101结果
  2715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2716. result, _ := json.Marshal(respJSON)
  2717. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2718. utils.ErrorLog("解析失败:%v", err)
  2719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2720. return
  2721. }
  2722. res.InfRefmsgid = resSix10265.InfRefmsgid
  2723. res.ErrMsg = resSix10265.ErrMsg
  2724. res.Cainfo = resSix10265.Cainfo
  2725. res.WarnMsg = resSix10265.WarnMsg
  2726. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2727. res.Infcode = infocode
  2728. }
  2729. if res.Infcode == 0 {
  2730. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2731. item.IsSale = 0
  2732. item.SaleDate = ""
  2733. item.Bchno = ""
  2734. service.SaveDF(item)
  2735. } else {
  2736. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2737. }
  2738. }
  2739. }
  2740. c.ServeSuccessJSON(map[string]interface{}{
  2741. "msg": "删除销售数据成功",
  2742. })
  2743. }
  2744. // 删除
  2745. func (c *HisApiController) DeleteXSandBGThree() {
  2746. id, _ := c.GetInt64("id")
  2747. admin_user_id, _ := c.GetInt64("admin_user_id")
  2748. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2749. var flows []*models.DrugFlow
  2750. for _, item := range advicelist {
  2751. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2752. flows = append(flows, flow...)
  2753. }
  2754. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2755. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2756. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2757. var err []string
  2758. for _, item := range flows {
  2759. if item.IsSale == 1 {
  2760. var res FJ3507Result
  2761. var struct3507 models.Struct3507
  2762. struct3507.FixmedinsBchno = item.Bchno
  2763. struct3507.InvDataType = "4"
  2764. struct3507.Opter = roles.UserName
  2765. struct3507.OrgName = miConfig.OrgName
  2766. struct3507.AccessKey = miConfig.AccessKey
  2767. struct3507.RequestUrl = miConfig.Url
  2768. struct3507.FixmedinsCode = miConfig.Code
  2769. struct3507.SecretKey = miConfig.SecretKey
  2770. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2771. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2772. struct3507.Url = miConfig.Url
  2773. struct3507.AppId = miConfig.Cainfo
  2774. struct3507.AppSecret = miConfig.AppSecret
  2775. struct3507.Enckey = miConfig.EncKey
  2776. struct3507.SignKey = miConfig.SignKey
  2777. struct3507.SecretKey = miConfig.SecretKey
  2778. if miConfig.MdtrtareaAdmvs == "350500" {
  2779. result, result1, _ := service.FJyb3507(struct3507)
  2780. saveLog(result, result1, "3507", "3507")
  2781. var respJSON2 map[string]interface{}
  2782. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2785. return
  2786. }
  2787. userJSONBytes2, _ := json.Marshal(respJSON2)
  2788. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2789. utils.ErrorLog("解析失败:%v", err)
  2790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2791. return
  2792. }
  2793. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2794. data := make(map[string]interface{})
  2795. data["struct_3507s"] = struct3507
  2796. client := &http.Client{}
  2797. bytesData, _ := json.Marshal(data)
  2798. var req *http.Request
  2799. if miConfig.MdtrtareaAdmvs == "320921" {
  2800. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2801. } else {
  2802. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2803. }
  2804. resp, _ := client.Do(req)
  2805. defer resp.Body.Close()
  2806. body, ioErr := ioutil.ReadAll(resp.Body)
  2807. if ioErr != nil {
  2808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2809. }
  2810. var respJSON map[string]interface{}
  2811. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2814. return
  2815. }
  2816. var resSix10265 ResultSix10265 //1101结果
  2817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2818. result, _ := json.Marshal(respJSON)
  2819. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2820. utils.ErrorLog("解析失败:%v", err)
  2821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2822. return
  2823. }
  2824. res.InfRefmsgid = resSix10265.InfRefmsgid
  2825. //res.Output = resSix10265.Output
  2826. res.ErrMsg = resSix10265.ErrMsg
  2827. res.Cainfo = resSix10265.Cainfo
  2828. res.WarnMsg = resSix10265.WarnMsg
  2829. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2830. res.Infcode = infocode
  2831. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2832. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2833. saveLog(result2, result1, "3507", "3507")
  2834. var respJSON2 map[string]interface{}
  2835. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2838. return
  2839. }
  2840. userJSONBytes2, _ := json.Marshal(respJSON2)
  2841. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2842. utils.ErrorLog("解析失败:%v", err)
  2843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2844. return
  2845. }
  2846. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2847. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2848. saveLog(result2, result1, "3507", "3507")
  2849. var respJSON2 map[string]interface{}
  2850. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2853. return
  2854. }
  2855. userJSONBytes2, _ := json.Marshal(respJSON2)
  2856. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2857. utils.ErrorLog("解析失败:%v", err)
  2858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2859. return
  2860. }
  2861. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2862. result1, result2 := service.Jxyb3507(struct3507)
  2863. saveLog(result2, result1, "3507", "3507")
  2864. var respJSON2 map[string]interface{}
  2865. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2868. return
  2869. }
  2870. userJSONBytes2, _ := json.Marshal(respJSON2)
  2871. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2872. utils.ErrorLog("解析失败:%v", err)
  2873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. return
  2875. }
  2876. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2877. result1, result2 := service.AHyb3507(struct3507)
  2878. saveLog(result2, result1, "3507", "3507")
  2879. var respJSON2 map[string]interface{}
  2880. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2883. return
  2884. }
  2885. userJSONBytes2, _ := json.Marshal(respJSON2)
  2886. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2887. utils.ErrorLog("解析失败:%v", err)
  2888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2889. return
  2890. }
  2891. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2892. data := make(map[string]interface{})
  2893. data["struct_3507s"] = struct3507
  2894. client := &http.Client{}
  2895. bytesData, _ := json.Marshal(data)
  2896. var req *http.Request
  2897. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2898. resp, _ := client.Do(req)
  2899. defer resp.Body.Close()
  2900. body, ioErr := ioutil.ReadAll(resp.Body)
  2901. if ioErr != nil {
  2902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2903. }
  2904. var respJSON map[string]interface{}
  2905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2907. }
  2908. var resSix10265 ResultSix10265 //1101结果
  2909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2910. result, _ := json.Marshal(respJSON)
  2911. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2912. utils.ErrorLog("解析失败:%v", err)
  2913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2914. return
  2915. }
  2916. res.InfRefmsgid = resSix10265.InfRefmsgid
  2917. res.ErrMsg = resSix10265.ErrMsg
  2918. res.Cainfo = resSix10265.Cainfo
  2919. res.WarnMsg = resSix10265.WarnMsg
  2920. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2921. res.Infcode = infocode
  2922. }
  2923. if res.Infcode == 0 {
  2924. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2925. item.IsSale = 0
  2926. item.SaleDate = ""
  2927. item.Bchno = ""
  2928. service.SaveDF(item)
  2929. } else {
  2930. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2931. }
  2932. }
  2933. }
  2934. c.ServeSuccessJSON(map[string]interface{}{
  2935. "msg": "删除销售数据成功",
  2936. })
  2937. }
  2938. // 获取当天起止时间戳
  2939. func GetNowTime() (int64, int64) {
  2940. t := time.Now()
  2941. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2942. timesamp := addTime.Unix()
  2943. return timesamp, timesamp + 86399
  2944. }
  2945. func (c *HisApiController) ChangeDrugfour() {
  2946. patient_id, _ := c.GetInt64("patient_id")
  2947. admin_user_id, _ := c.GetInt64("admin_user_id")
  2948. times := c.GetString("time", "")
  2949. timeLayout := "2006-01-02"
  2950. loc, _ := time.LoadLocation("Local")
  2951. var stime, etime int64
  2952. if times == "" {
  2953. stime, etime = GetNowTime()
  2954. } else {
  2955. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2956. stime = stmp.Unix()
  2957. etime = stime + 86399
  2958. }
  2959. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2960. var flows []*models.DrugFlow
  2961. for _, item := range advicelist {
  2962. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2963. flows = append(flows, flow...)
  2964. }
  2965. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2966. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2967. var err []string
  2968. for _, item := range flows {
  2969. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2970. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2971. if prescription.OrderStatus == 2 {
  2972. if item.IsSale == 0 {
  2973. var res FJ3507Result
  2974. var res3507for10188 FJ3507ResultFor10188
  2975. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2976. //进行商品销售接口
  2977. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2978. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2979. var respJSON3 map[string]interface{}
  2980. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2983. return
  2984. }
  2985. userJSONBytes3, _ := json.Marshal(respJSON3)
  2986. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2987. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2988. utils.ErrorLog("解析失败:%v", err)
  2989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2990. return
  2991. }
  2992. //if res3507for10188.Infcode
  2993. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2994. //res.Output = resSix10265.Output
  2995. res.ErrMsg = res3507for10188.ErrMsg
  2996. res.Cainfo = res3507for10188.Cainfo
  2997. res.WarnMsg = res3507for10188.WarnMsg
  2998. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2999. res.Infcode = infocode
  3000. } else {
  3001. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3002. utils.ErrorLog("解析失败:%v", err)
  3003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3004. return
  3005. }
  3006. }
  3007. if res.Infcode == 0 {
  3008. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3009. item.IsSale = 1
  3010. item.Bchno = number
  3011. item.SaleDate = time.Now().Format("2006-01-02")
  3012. service.SaveDF(item)
  3013. } else {
  3014. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3015. }
  3016. }
  3017. } else { //还没结,提示用户去结算,并药品追溯上传
  3018. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3019. }
  3020. }
  3021. }
  3022. str := strings.Join(err, " ")
  3023. saveLog(str, str, "3505", "3505自动上传日志")
  3024. c.ServeSuccessJSON(map[string]interface{}{
  3025. "status": "1",
  3026. "msg": err,
  3027. })
  3028. }
  3029. func (c *HisApiController) ChangeDrugFive() {
  3030. id, _ := c.GetInt64("id")
  3031. admin_user_id, _ := c.GetInt64("admin_user_id")
  3032. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3033. var flows []*models.DrugFlow
  3034. for _, item := range advicelist {
  3035. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3036. flows = append(flows, flow...)
  3037. }
  3038. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3039. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3040. var err []string
  3041. for _, item := range flows {
  3042. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3043. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3044. if prescription.OrderStatus == 2 {
  3045. if item.IsSale == 0 {
  3046. var res FJ3507Result
  3047. var res3507for10188 FJ3507ResultFor10188
  3048. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3049. //进行商品销售接口
  3050. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3051. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3052. var respJSON3 map[string]interface{}
  3053. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3056. return
  3057. }
  3058. userJSONBytes3, _ := json.Marshal(respJSON3)
  3059. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3060. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3061. utils.ErrorLog("解析失败:%v", err)
  3062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3063. return
  3064. }
  3065. //if res3507for10188.Infcode
  3066. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3067. //res.Output = resSix10265.Output
  3068. res.ErrMsg = res3507for10188.ErrMsg
  3069. res.Cainfo = res3507for10188.Cainfo
  3070. res.WarnMsg = res3507for10188.WarnMsg
  3071. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3072. res.Infcode = infocode
  3073. } else {
  3074. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3075. utils.ErrorLog("解析失败:%v", err)
  3076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3077. return
  3078. }
  3079. }
  3080. if res.Infcode == 0 {
  3081. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3082. item.IsSale = 1
  3083. item.Bchno = number
  3084. item.SaleDate = time.Now().Format("2006-01-02")
  3085. service.SaveDF(item)
  3086. } else {
  3087. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3088. }
  3089. }
  3090. } else { //还没结,提示用户去结算,并药品追溯上传
  3091. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3092. }
  3093. }
  3094. }
  3095. str := strings.Join(err, " ")
  3096. saveLog(str, str, "3505", "3505自动上传日志")
  3097. c.ServeSuccessJSON(map[string]interface{}{
  3098. "status": "1",
  3099. "msg": err,
  3100. })
  3101. }
  3102. //func (c *HisApiController) ChangeDrugfour() {
  3103. // patient_id, _ := c.GetInt64("patient_id")
  3104. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3105. // //id_arr := strings.Split(ids, ",")
  3106. // times := c.GetString("time", "")
  3107. // timeLayout := "2006-01-02"
  3108. // loc, _ := time.LoadLocation("Local")
  3109. // var stime, etime int64
  3110. // if times == "" {
  3111. // stime, etime = GetNowTime()
  3112. // } else {
  3113. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3114. // stime = stmp.Unix()
  3115. // etime = stime + 86399
  3116. // }
  3117. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3118. // var flows []*models.DrugFlow
  3119. // for _, item := range advicelist {
  3120. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3121. // flows = append(flows, flow...)
  3122. // }
  3123. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3124. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3125. // var err []string
  3126. //
  3127. // for _, item := range flows {
  3128. // var res3 ResultSix
  3129. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3130. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3131. // if prescription.OrderStatus == 2 {
  3132. // //已经结算
  3133. // //判断是否已经销售
  3134. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3135. // //是否已经变更 1是 0否
  3136. // if item.IsChange == 0 { //没变更,进行变更操作
  3137. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3138. //
  3139. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3140. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3141. // var respJSON3 map[string]interface{}
  3142. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3143. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3145. // return
  3146. // }
  3147. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3148. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3149. // utils.ErrorLog("解析失败:%v", err)
  3150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3151. // return
  3152. // }
  3153. // if res3.Infcode == 0 {
  3154. // item.IsChange = 1
  3155. // item.BgBchno = bg_number
  3156. // service.SaveDF2(item)
  3157. // } else {
  3158. //
  3159. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3160. // }
  3161. // }
  3162. // } else { //没销售,
  3163. // var res FJ3507Result
  3164. // var res3507for10188 FJ3507ResultFor10188
  3165. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3166. //
  3167. // //进行商品销售接口
  3168. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3169. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3170. // var respJSON3 map[string]interface{}
  3171. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3172. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3174. // return
  3175. // }
  3176. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3177. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3178. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3179. // utils.ErrorLog("解析失败:%v", err)
  3180. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3181. // return
  3182. // }
  3183. // //if res3507for10188.Infcode
  3184. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3185. // //res.Output = resSix10265.Output
  3186. // res.ErrMsg = res3507for10188.ErrMsg
  3187. // res.Cainfo = res3507for10188.Cainfo
  3188. // res.WarnMsg = res3507for10188.WarnMsg
  3189. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3190. // res.Infcode = infocode
  3191. // } else {
  3192. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3193. // utils.ErrorLog("解析失败:%v", err)
  3194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3195. // return
  3196. // }
  3197. //
  3198. // }
  3199. // if res.Infcode == 0 {
  3200. // item.IsSale = 1
  3201. // item.Bchno = number
  3202. // item.SaleDate = time.Now().Format("2006-01-02")
  3203. //
  3204. // err5 := service.SaveDF(item)
  3205. // if err5 == nil {
  3206. // if item.IsChange == 0 { //没变更,进行变更操作
  3207. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3208. //
  3209. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3210. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3211. //
  3212. // var respJSON3 map[string]interface{}
  3213. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3214. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3216. // return
  3217. // }
  3218. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3219. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3220. // utils.ErrorLog("解析失败:%v", err)
  3221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3222. // return
  3223. // }
  3224. // //if res3507for10188.Infcode
  3225. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3226. // //res.Output = resSix10265.Output
  3227. // res3.ErrMsg = res3507for10188.ErrMsg
  3228. // res3.Cainfo = res3507for10188.Cainfo
  3229. // res3.WarnMsg = res3507for10188.WarnMsg
  3230. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3231. // res3.Infcode = infocode
  3232. // } else {
  3233. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3234. // utils.ErrorLog("解析失败:%v", err)
  3235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3236. // return
  3237. // }
  3238. // }
  3239. // if res3.Infcode == 0 {
  3240. // item.IsChange = 1
  3241. // item.BgBchno = bg_number
  3242. // service.SaveDF2(item)
  3243. // } else {
  3244. //
  3245. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3246. // }
  3247. // }
  3248. // }
  3249. // } else {
  3250. //
  3251. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3252. // }
  3253. // }
  3254. //
  3255. // } else { //还没结,提示用户去结算,并药品追溯上传
  3256. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3257. // }
  3258. // }
  3259. // }
  3260. // if len(err) == 0 {
  3261. // c.ServeSuccessJSON(map[string]interface{}{
  3262. // "msg": "销售变更成功",
  3263. // })
  3264. // } else {
  3265. // c.ServeSuccessJSON(map[string]interface{}{
  3266. // "failed_code": -10,
  3267. // "msg": err,
  3268. // })
  3269. // }
  3270. //}
  3271. func (c *HisApiController) ChangeDrug() {
  3272. ids := c.GetString("ids")
  3273. id_arr := strings.Split(ids, ",")
  3274. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3275. admin_user_id, _ := c.GetInt64("admin_user_id")
  3276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3278. var err []string
  3279. for _, item := range flows {
  3280. var res3 ResultSix
  3281. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3282. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3283. if prescription.OrderStatus == 2 {
  3284. //已经结算
  3285. //判断是否已经销售
  3286. if item.IsSale == 1 { //是否已经销售,1是 0否
  3287. //是否已经变更 1是 0否
  3288. if item.IsChange == 0 { //没变更,进行变更操作
  3289. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3290. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3291. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3292. var respJSON3 map[string]interface{}
  3293. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3296. return
  3297. }
  3298. userJSONBytes3, _ := json.Marshal(respJSON3)
  3299. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3300. utils.ErrorLog("解析失败:%v", err)
  3301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3302. return
  3303. }
  3304. if res3.Infcode == 0 {
  3305. item.IsChange = 1
  3306. item.BgBchno = bg_number
  3307. service.SaveDF2(item)
  3308. } else {
  3309. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3310. }
  3311. }
  3312. } else { //没销售,
  3313. var res FJ3507Result
  3314. var res3507for10188 FJ3507ResultFor10188
  3315. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3316. //进行商品销售接口
  3317. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3318. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3319. var respJSON3 map[string]interface{}
  3320. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3323. return
  3324. }
  3325. userJSONBytes3, _ := json.Marshal(respJSON3)
  3326. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3327. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3328. utils.ErrorLog("解析失败:%v", err)
  3329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3330. return
  3331. }
  3332. //if res3507for10188.Infcode
  3333. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3334. //res.Output = resSix10265.Output
  3335. res.ErrMsg = res3507for10188.ErrMsg
  3336. res.Cainfo = res3507for10188.Cainfo
  3337. res.WarnMsg = res3507for10188.WarnMsg
  3338. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3339. res.Infcode = infocode
  3340. } else {
  3341. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3342. utils.ErrorLog("解析失败:%v", err)
  3343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3344. return
  3345. }
  3346. }
  3347. if res.Infcode == 0 {
  3348. item.IsSale = 1
  3349. item.Bchno = number
  3350. item.SaleDate = time.Now().Format("2006-01-02")
  3351. err5 := service.SaveDF(item)
  3352. if err5 == nil {
  3353. if item.IsChange == 0 { //没变更,进行变更操作
  3354. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3355. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3356. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3357. var respJSON3 map[string]interface{}
  3358. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3361. return
  3362. }
  3363. userJSONBytes3, _ := json.Marshal(respJSON3)
  3364. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3365. utils.ErrorLog("解析失败:%v", err)
  3366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3367. return
  3368. }
  3369. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3370. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3371. utils.ErrorLog("解析失败:%v", err)
  3372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3373. return
  3374. }
  3375. //if res3507for10188.Infcode
  3376. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3377. //res.Output = resSix10265.Output
  3378. res3.ErrMsg = res3507for10188.ErrMsg
  3379. res3.Cainfo = res3507for10188.Cainfo
  3380. res3.WarnMsg = res3507for10188.WarnMsg
  3381. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3382. res3.Infcode = infocode
  3383. } else {
  3384. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3385. utils.ErrorLog("解析失败:%v", err)
  3386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3387. return
  3388. }
  3389. }
  3390. if res3.Infcode == 0 {
  3391. item.IsChange = 1
  3392. item.BgBchno = bg_number
  3393. service.SaveDF2(item)
  3394. } else {
  3395. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3396. }
  3397. }
  3398. }
  3399. } else {
  3400. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3401. }
  3402. }
  3403. } else { //还没结算
  3404. var res3507for10188 FJ3507ResultFor10188
  3405. if item.IsChange == 0 { //没变更,进行变更操作
  3406. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3407. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3408. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3409. var respJSON3 map[string]interface{}
  3410. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3413. return
  3414. }
  3415. userJSONBytes3, _ := json.Marshal(respJSON3)
  3416. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3417. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3418. utils.ErrorLog("解析失败:%v", err)
  3419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3420. return
  3421. }
  3422. //if res3507for10188.Infcode
  3423. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3424. //res.Output = resSix10265.Output
  3425. res3.ErrMsg = res3507for10188.ErrMsg
  3426. res3.Cainfo = res3507for10188.Cainfo
  3427. res3.WarnMsg = res3507for10188.WarnMsg
  3428. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3429. res3.Infcode = infocode
  3430. } else {
  3431. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3432. utils.ErrorLog("解析失败:%v", err)
  3433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3434. return
  3435. }
  3436. }
  3437. if res3.Infcode == 0 {
  3438. item.IsChange = 1
  3439. item.BgBchno = bg_number
  3440. service.SaveDF2(item)
  3441. } else {
  3442. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3443. }
  3444. }
  3445. }
  3446. } else if item.ConsumableType == 7 {
  3447. var res3507for10188 FJ3507ResultFor10188
  3448. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3449. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3450. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3451. //判断是否已经销售
  3452. if item.IsSale == 2 { //是否已经销售,1是 0否
  3453. //是否已经变更 1是 0否
  3454. if item.IsChange == 0 { //没变更,进行变更操作
  3455. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3456. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3457. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3458. var respJSON3 map[string]interface{}
  3459. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3462. return
  3463. }
  3464. userJSONBytes3, _ := json.Marshal(respJSON3)
  3465. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3466. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3467. utils.ErrorLog("解析失败:%v", err)
  3468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3469. return
  3470. }
  3471. //if res3507for10188.Infcode
  3472. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3473. //res.Output = resSix10265.Output
  3474. res3.ErrMsg = res3507for10188.ErrMsg
  3475. res3.Cainfo = res3507for10188.Cainfo
  3476. res3.WarnMsg = res3507for10188.WarnMsg
  3477. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3478. res3.Infcode = infocode
  3479. } else {
  3480. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3481. utils.ErrorLog("解析失败:%v", err)
  3482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3483. return
  3484. }
  3485. }
  3486. if res3.Infcode == 0 {
  3487. item.IsChange = 1
  3488. item.BgBchno = bg_number
  3489. service.SaveDF2(item)
  3490. } else {
  3491. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3492. }
  3493. }
  3494. } else { //没销售,
  3495. //进行商品销售退货接口
  3496. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3497. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3498. saveLog(result111, result222, "3506", "销售退货")
  3499. var res7 FJ3507Result
  3500. //进行商品销售接口
  3501. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3502. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3503. var respJSON3 map[string]interface{}
  3504. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3507. return
  3508. }
  3509. userJSONBytes3, _ := json.Marshal(respJSON3)
  3510. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3511. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3512. utils.ErrorLog("解析失败:%v", err)
  3513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3514. return
  3515. }
  3516. //if res3507for10188.Infcode
  3517. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3518. //res.Output = resSix10265.Output
  3519. res7.ErrMsg = res3507for10188.ErrMsg
  3520. res7.Cainfo = res3507for10188.Cainfo
  3521. res7.WarnMsg = res3507for10188.WarnMsg
  3522. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3523. res7.Infcode = infocode
  3524. } else {
  3525. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3526. utils.ErrorLog("解析失败:%v", err)
  3527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3528. return
  3529. }
  3530. }
  3531. if res7.Infcode == 0 {
  3532. item.IsSale = 2
  3533. item.SaleDate = item.SaleDate
  3534. item.Bchno = number
  3535. service.SaveDF(item)
  3536. if item.IsChange == 0 { //没变更,进行变更操作
  3537. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3538. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3539. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3540. var respJSON3 map[string]interface{}
  3541. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3544. return
  3545. }
  3546. userJSONBytes3, _ := json.Marshal(respJSON3)
  3547. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3548. // utils.ErrorLog("解析失败:%v", err)
  3549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3550. // return
  3551. //}
  3552. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3553. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3554. utils.ErrorLog("解析失败:%v", err)
  3555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3556. return
  3557. }
  3558. //if res3507for10188.Infcode
  3559. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3560. //res.Output = resSix10265.Output
  3561. res3.ErrMsg = res3507for10188.ErrMsg
  3562. res3.Cainfo = res3507for10188.Cainfo
  3563. res3.WarnMsg = res3507for10188.WarnMsg
  3564. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3565. res3.Infcode = infocode
  3566. } else {
  3567. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3568. utils.ErrorLog("解析失败:%v", err)
  3569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3570. return
  3571. }
  3572. }
  3573. if res3.Infcode == 0 {
  3574. item.IsChange = 1
  3575. item.BgBchno = bg_number
  3576. service.SaveDF2(item)
  3577. } else {
  3578. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3579. }
  3580. }
  3581. } else {
  3582. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3583. }
  3584. }
  3585. } else { //还没结算
  3586. if item.IsChange == 0 { //没变更,进行变更操作
  3587. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3588. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3589. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3590. var respJSON3 map[string]interface{}
  3591. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3594. return
  3595. }
  3596. userJSONBytes3, _ := json.Marshal(respJSON3)
  3597. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3598. // utils.ErrorLog("解析失败:%v", err)
  3599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3600. // return
  3601. //}
  3602. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3603. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3604. utils.ErrorLog("解析失败:%v", err)
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. return
  3607. }
  3608. //if res3507for10188.Infcode
  3609. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3610. //res.Output = resSix10265.Output
  3611. res3.ErrMsg = res3507for10188.ErrMsg
  3612. res3.Cainfo = res3507for10188.Cainfo
  3613. res3.WarnMsg = res3507for10188.WarnMsg
  3614. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3615. res3.Infcode = infocode
  3616. } else {
  3617. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3618. utils.ErrorLog("解析失败:%v", err)
  3619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3620. return
  3621. }
  3622. }
  3623. if res3.Infcode == 0 {
  3624. item.IsChange = 1
  3625. item.BgBchno = bg_number
  3626. service.SaveDF2(item)
  3627. } else {
  3628. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3629. }
  3630. }
  3631. }
  3632. }
  3633. }
  3634. if len(err) == 0 {
  3635. c.ServeSuccessJSON(map[string]interface{}{
  3636. "msg": "销售变更成功",
  3637. })
  3638. } else {
  3639. c.ServeSuccessJSON(map[string]interface{}{
  3640. "failed_code": -10,
  3641. "msg": err,
  3642. })
  3643. }
  3644. }
  3645. func (c *HisApiController) ChangeDrugtwo() {
  3646. //ids := c.GetString("ids")
  3647. //id_arr := strings.Split(ids, ",")
  3648. flows, _ := service.GetNewDrugFlowInfothree123()
  3649. admin_user_id, _ := c.GetInt64("admin_user_id")
  3650. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3651. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3652. var err []string
  3653. for _, item := range flows {
  3654. var res3 ResultSix
  3655. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3656. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3657. if prescription.OrderStatus == 2 {
  3658. //已经结算
  3659. //判断是否已经销售
  3660. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3661. // //是否已经变更 1是 0否
  3662. // if item.IsChange == 0 { //没变更,进行变更操作
  3663. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3664. //
  3665. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3666. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3667. // var respJSON3 map[string]interface{}
  3668. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3669. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3671. // return
  3672. // }
  3673. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3674. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3675. // utils.ErrorLog("解析失败:%v", err)
  3676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3677. // return
  3678. // }
  3679. // if res3.Infcode == 0 {
  3680. // item.IsChange = 1
  3681. // item.BgBchno = bg_number
  3682. // service.SaveDF2(item)
  3683. // } else {
  3684. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3685. // }
  3686. // }
  3687. //}
  3688. //else
  3689. { //没销售,
  3690. var res FJ3507Result
  3691. var res3507for10188 FJ3507ResultFor10188
  3692. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3693. //进行商品销售接口
  3694. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3695. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3696. var respJSON3 map[string]interface{}
  3697. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3700. return
  3701. }
  3702. userJSONBytes3, _ := json.Marshal(respJSON3)
  3703. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3704. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3705. utils.ErrorLog("解析失败:%v", err)
  3706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3707. return
  3708. }
  3709. //if res3507for10188.Infcode
  3710. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3711. //res.Output = resSix10265.Output
  3712. res.ErrMsg = res3507for10188.ErrMsg
  3713. res.Cainfo = res3507for10188.Cainfo
  3714. res.WarnMsg = res3507for10188.WarnMsg
  3715. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3716. res.Infcode = infocode
  3717. } else {
  3718. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3719. utils.ErrorLog("解析失败:%v", err)
  3720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3721. return
  3722. }
  3723. }
  3724. if res.Infcode == 0 {
  3725. item.IsSale = 1
  3726. item.Bchno = number
  3727. item.SaleDate = time.Now().Format("2006-01-02")
  3728. service.SaveDF(item)
  3729. //if err5 == nil {
  3730. // if item.IsChange == 0 { //没变更,进行变更操作
  3731. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3732. //
  3733. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3734. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3735. //
  3736. // var respJSON3 map[string]interface{}
  3737. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3738. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3740. // return
  3741. // }
  3742. //
  3743. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3744. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3745. // utils.ErrorLog("解析失败:%v", err)
  3746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3747. // return
  3748. // }
  3749. // //if res3507for10188.Infcode
  3750. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3751. // //res.Output = resSix10265.Output
  3752. // res3.ErrMsg = res3507for10188.ErrMsg
  3753. // res3.Cainfo = res3507for10188.Cainfo
  3754. // res3.WarnMsg = res3507for10188.WarnMsg
  3755. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3756. // res3.Infcode = infocode
  3757. // } else {
  3758. //
  3759. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3760. // utils.ErrorLog("解析失败:%v", err)
  3761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3762. // return
  3763. // }
  3764. //
  3765. // }
  3766. //
  3767. // if res3.Infcode == 0 {
  3768. // item.IsChange = 1
  3769. // item.BgBchno = bg_number
  3770. // service.SaveDF2(item)
  3771. // } else {
  3772. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3773. // }
  3774. // }
  3775. //}
  3776. } else {
  3777. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3778. }
  3779. }
  3780. } else { //还没结算
  3781. var res3507for10188 FJ3507ResultFor10188
  3782. if item.IsChange == 0 { //没变更,进行变更操作
  3783. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3784. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3785. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3786. var respJSON3 map[string]interface{}
  3787. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3790. return
  3791. }
  3792. userJSONBytes3, _ := json.Marshal(respJSON3)
  3793. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3794. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3795. utils.ErrorLog("解析失败:%v", err)
  3796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3797. return
  3798. }
  3799. //if res3507for10188.Infcode
  3800. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3801. //res.Output = resSix10265.Output
  3802. res3.ErrMsg = res3507for10188.ErrMsg
  3803. res3.Cainfo = res3507for10188.Cainfo
  3804. res3.WarnMsg = res3507for10188.WarnMsg
  3805. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3806. res3.Infcode = infocode
  3807. } else {
  3808. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3809. utils.ErrorLog("解析失败:%v", err)
  3810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3811. return
  3812. }
  3813. }
  3814. if res3.Infcode == 0 {
  3815. item.IsChange = 1
  3816. item.BgBchno = bg_number
  3817. service.SaveDF2(item)
  3818. } else {
  3819. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3820. }
  3821. }
  3822. }
  3823. }
  3824. //if item.ConsumableType == 7 {
  3825. // var res3507for10188 FJ3507ResultFor10188
  3826. //
  3827. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3828. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3829. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3830. // //判断是否已经销售
  3831. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3832. // //是否已经变更 1是 0否
  3833. // if item.IsChange == 0 { //没变更,进行变更操作
  3834. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3835. //
  3836. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3837. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3838. //
  3839. // var respJSON3 map[string]interface{}
  3840. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3841. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3843. // return
  3844. // }
  3845. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3846. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3847. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3848. // utils.ErrorLog("解析失败:%v", err)
  3849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3850. // return
  3851. // }
  3852. // //if res3507for10188.Infcode
  3853. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3854. // //res.Output = resSix10265.Output
  3855. // res3.ErrMsg = res3507for10188.ErrMsg
  3856. // res3.Cainfo = res3507for10188.Cainfo
  3857. // res3.WarnMsg = res3507for10188.WarnMsg
  3858. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3859. // res3.Infcode = infocode
  3860. // } else {
  3861. //
  3862. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3863. // utils.ErrorLog("解析失败:%v", err)
  3864. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3865. // return
  3866. // }
  3867. //
  3868. // }
  3869. // if res3.Infcode == 0 {
  3870. // item.IsChange = 1
  3871. // item.BgBchno = bg_number
  3872. // service.SaveDF2(item)
  3873. // } else {
  3874. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3875. // }
  3876. // }
  3877. // } else { //没销售,
  3878. // //进行商品销售退货接口
  3879. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3880. //
  3881. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3882. // saveLog(result111, result222, "3506", "销售退货")
  3883. // var res7 FJ3507Result
  3884. //
  3885. // //进行商品销售接口
  3886. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3887. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3888. // var respJSON3 map[string]interface{}
  3889. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3890. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3891. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3892. // return
  3893. // }
  3894. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3895. //
  3896. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3897. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3898. // utils.ErrorLog("解析失败:%v", err)
  3899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3900. // return
  3901. // }
  3902. // //if res3507for10188.Infcode
  3903. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3904. // //res.Output = resSix10265.Output
  3905. // res7.ErrMsg = res3507for10188.ErrMsg
  3906. // res7.Cainfo = res3507for10188.Cainfo
  3907. // res7.WarnMsg = res3507for10188.WarnMsg
  3908. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3909. // res7.Infcode = infocode
  3910. // } else {
  3911. //
  3912. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3913. // utils.ErrorLog("解析失败:%v", err)
  3914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3915. // return
  3916. // }
  3917. //
  3918. // }
  3919. // if res7.Infcode == 0 {
  3920. // item.IsSale = 2
  3921. // item.SaleDate = item.SaleDate
  3922. // item.Bchno = number
  3923. // service.SaveDF(item)
  3924. // if item.IsChange == 0 { //没变更,进行变更操作
  3925. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3926. //
  3927. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3928. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3929. //
  3930. // var respJSON3 map[string]interface{}
  3931. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3932. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3934. // return
  3935. // }
  3936. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3937. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3938. // // utils.ErrorLog("解析失败:%v", err)
  3939. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3940. // // return
  3941. // //}
  3942. //
  3943. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3944. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3945. // utils.ErrorLog("解析失败:%v", err)
  3946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3947. // return
  3948. // }
  3949. // //if res3507for10188.Infcode
  3950. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3951. // //res.Output = resSix10265.Output
  3952. // res3.ErrMsg = res3507for10188.ErrMsg
  3953. // res3.Cainfo = res3507for10188.Cainfo
  3954. // res3.WarnMsg = res3507for10188.WarnMsg
  3955. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3956. // res3.Infcode = infocode
  3957. // } else {
  3958. //
  3959. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3960. // utils.ErrorLog("解析失败:%v", err)
  3961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3962. // return
  3963. // }
  3964. //
  3965. // }
  3966. // if res3.Infcode == 0 {
  3967. // item.IsChange = 1
  3968. // item.BgBchno = bg_number
  3969. // service.SaveDF2(item)
  3970. // } else {
  3971. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3972. // }
  3973. // }
  3974. // } else {
  3975. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3976. // }
  3977. // }
  3978. // } else { //还没结算
  3979. // if item.IsChange == 0 { //没变更,进行变更操作
  3980. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3981. //
  3982. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3983. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3984. //
  3985. // var respJSON3 map[string]interface{}
  3986. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3987. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3989. // return
  3990. // }
  3991. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3992. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3993. // // utils.ErrorLog("解析失败:%v", err)
  3994. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. // // return
  3996. // //}
  3997. //
  3998. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3999. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4000. // utils.ErrorLog("解析失败:%v", err)
  4001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4002. // return
  4003. // }
  4004. // //if res3507for10188.Infcode
  4005. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4006. // //res.Output = resSix10265.Output
  4007. // res3.ErrMsg = res3507for10188.ErrMsg
  4008. // res3.Cainfo = res3507for10188.Cainfo
  4009. // res3.WarnMsg = res3507for10188.WarnMsg
  4010. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4011. // res3.Infcode = infocode
  4012. // } else {
  4013. //
  4014. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4015. // utils.ErrorLog("解析失败:%v", err)
  4016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4017. // return
  4018. // }
  4019. //
  4020. // }
  4021. // if res3.Infcode == 0 {
  4022. // item.IsChange = 1
  4023. // item.BgBchno = bg_number
  4024. // service.SaveDF2(item)
  4025. // } else {
  4026. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4027. // }
  4028. // }
  4029. // }
  4030. //}
  4031. }
  4032. if len(err) == 0 {
  4033. c.ServeSuccessJSON(map[string]interface{}{
  4034. "msg": "销售变更成功",
  4035. })
  4036. } else {
  4037. c.ServeSuccessJSON(map[string]interface{}{
  4038. "failed_code": -10,
  4039. "msg": err,
  4040. })
  4041. }
  4042. }
  4043. func (c *HisApiController) ChangeDrugthree() {
  4044. //ids := c.GetString("ids")
  4045. //id_arr := strings.Split(ids, ",")
  4046. flows, _ := service.GetNewDrugFlowInfothree()
  4047. admin_user_id, _ := c.GetInt64("admin_user_id")
  4048. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4049. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4050. var err []string
  4051. for _, item := range flows {
  4052. var res3 ResultSix
  4053. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4054. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4055. if prescription.OrderStatus == 2 {
  4056. //已经结算
  4057. //判断是否已经销售
  4058. if item.IsSale == 1 { //是否已经销售,1是 0否
  4059. //是否已经变更 1是 0否
  4060. if item.IsChange == 0 { //没变更,进行变更操作
  4061. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4062. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4063. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4064. var respJSON3 map[string]interface{}
  4065. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4068. return
  4069. }
  4070. userJSONBytes3, _ := json.Marshal(respJSON3)
  4071. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4072. utils.ErrorLog("解析失败:%v", err)
  4073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4074. return
  4075. }
  4076. if res3.Infcode == 0 {
  4077. item.IsChange = 1
  4078. item.BgBchno = bg_number
  4079. service.SaveDF2(item)
  4080. } else {
  4081. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4082. }
  4083. }
  4084. } else { //没销售,
  4085. var res FJ3507Result
  4086. var res3507for10188 FJ3507ResultFor10188
  4087. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4088. //进行商品销售接口
  4089. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4090. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4091. var respJSON3 map[string]interface{}
  4092. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4095. return
  4096. }
  4097. userJSONBytes3, _ := json.Marshal(respJSON3)
  4098. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4099. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4100. utils.ErrorLog("解析失败:%v", err)
  4101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4102. return
  4103. }
  4104. //if res3507for10188.Infcode
  4105. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4106. //res.Output = resSix10265.Output
  4107. res.ErrMsg = res3507for10188.ErrMsg
  4108. res.Cainfo = res3507for10188.Cainfo
  4109. res.WarnMsg = res3507for10188.WarnMsg
  4110. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4111. res.Infcode = infocode
  4112. } else {
  4113. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4114. utils.ErrorLog("解析失败:%v", err)
  4115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4116. return
  4117. }
  4118. }
  4119. if res.Infcode == 0 {
  4120. item.IsSale = 1
  4121. item.Bchno = number
  4122. item.SaleDate = time.Now().Format("2006-01-02")
  4123. err5 := service.SaveDF(item)
  4124. if err5 == nil {
  4125. if item.IsChange == 0 { //没变更,进行变更操作
  4126. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4127. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4128. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4129. var respJSON3 map[string]interface{}
  4130. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4133. return
  4134. }
  4135. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4136. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4137. utils.ErrorLog("解析失败:%v", err)
  4138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4139. return
  4140. }
  4141. //if res3507for10188.Infcode
  4142. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4143. //res.Output = resSix10265.Output
  4144. res3.ErrMsg = res3507for10188.ErrMsg
  4145. res3.Cainfo = res3507for10188.Cainfo
  4146. res3.WarnMsg = res3507for10188.WarnMsg
  4147. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4148. res3.Infcode = infocode
  4149. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4150. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4151. utils.ErrorLog("解析失败:%v", err)
  4152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4153. return
  4154. }
  4155. //if res3507for10188.Infcode
  4156. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4157. //res.Output = resSix10265.Output
  4158. res3.ErrMsg = res3507for10188.ErrMsg
  4159. res3.Cainfo = res3507for10188.Cainfo
  4160. res3.WarnMsg = res3507for10188.WarnMsg
  4161. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4162. res3.Infcode = infocode
  4163. } else {
  4164. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4165. utils.ErrorLog("解析失败:%v", err)
  4166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4167. return
  4168. }
  4169. }
  4170. if res3.Infcode == 0 {
  4171. item.IsChange = 1
  4172. item.BgBchno = bg_number
  4173. service.SaveDF2(item)
  4174. } else {
  4175. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4176. }
  4177. }
  4178. }
  4179. } else {
  4180. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4181. }
  4182. }
  4183. } else { //还没结算
  4184. var res3507for10188 FJ3507ResultFor10188
  4185. if item.IsChange == 0 { //没变更,进行变更操作
  4186. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4187. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4188. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4189. var respJSON3 map[string]interface{}
  4190. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4193. return
  4194. }
  4195. userJSONBytes3, _ := json.Marshal(respJSON3)
  4196. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4197. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4198. utils.ErrorLog("解析失败:%v", err)
  4199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4200. return
  4201. }
  4202. //if res3507for10188.Infcode
  4203. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4204. //res.Output = resSix10265.Output
  4205. res3.ErrMsg = res3507for10188.ErrMsg
  4206. res3.Cainfo = res3507for10188.Cainfo
  4207. res3.WarnMsg = res3507for10188.WarnMsg
  4208. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4209. res3.Infcode = infocode
  4210. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4211. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4212. utils.ErrorLog("解析失败:%v", err)
  4213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4214. return
  4215. }
  4216. //if res3507for10188.Infcode
  4217. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4218. //res.Output = resSix10265.Output
  4219. res3.ErrMsg = res3507for10188.ErrMsg
  4220. res3.Cainfo = res3507for10188.Cainfo
  4221. res3.WarnMsg = res3507for10188.WarnMsg
  4222. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4223. res3.Infcode = infocode
  4224. } else {
  4225. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4226. utils.ErrorLog("解析失败:%v", err)
  4227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4228. return
  4229. }
  4230. }
  4231. if res3.Infcode == 0 {
  4232. item.IsChange = 1
  4233. item.BgBchno = bg_number
  4234. service.SaveDF2(item)
  4235. } else {
  4236. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4237. }
  4238. }
  4239. }
  4240. } else if item.ConsumableType == 7 {
  4241. var res3507for10188 FJ3507ResultFor10188
  4242. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4243. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4244. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4245. //判断是否已经销售
  4246. if item.IsSale == 2 { //是否已经销售,1是 0否
  4247. //是否已经变更 1是 0否
  4248. if item.IsChange == 0 { //没变更,进行变更操作
  4249. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4250. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4251. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4252. var respJSON3 map[string]interface{}
  4253. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4256. return
  4257. }
  4258. userJSONBytes3, _ := json.Marshal(respJSON3)
  4259. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4260. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4261. utils.ErrorLog("解析失败:%v", err)
  4262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4263. return
  4264. }
  4265. //if res3507for10188.Infcode
  4266. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4267. //res.Output = resSix10265.Output
  4268. res3.ErrMsg = res3507for10188.ErrMsg
  4269. res3.Cainfo = res3507for10188.Cainfo
  4270. res3.WarnMsg = res3507for10188.WarnMsg
  4271. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4272. res3.Infcode = infocode
  4273. } else {
  4274. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4275. utils.ErrorLog("解析失败:%v", err)
  4276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4277. return
  4278. }
  4279. }
  4280. if res3.Infcode == 0 {
  4281. item.IsChange = 1
  4282. item.BgBchno = bg_number
  4283. service.SaveDF2(item)
  4284. } else {
  4285. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4286. }
  4287. }
  4288. } else { //没销售,
  4289. //进行商品销售退货接口
  4290. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4291. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4292. saveLog(result111, result222, "3506", "销售退货")
  4293. var res7 FJ3507Result
  4294. //进行商品销售接口
  4295. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4296. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4297. var respJSON3 map[string]interface{}
  4298. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4301. return
  4302. }
  4303. userJSONBytes3, _ := json.Marshal(respJSON3)
  4304. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4305. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4306. utils.ErrorLog("解析失败:%v", err)
  4307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4308. return
  4309. }
  4310. //if res3507for10188.Infcode
  4311. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4312. //res.Output = resSix10265.Output
  4313. res7.ErrMsg = res3507for10188.ErrMsg
  4314. res7.Cainfo = res3507for10188.Cainfo
  4315. res7.WarnMsg = res3507for10188.WarnMsg
  4316. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4317. res7.Infcode = infocode
  4318. } else {
  4319. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4320. utils.ErrorLog("解析失败:%v", err)
  4321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4322. return
  4323. }
  4324. }
  4325. if res7.Infcode == 0 {
  4326. item.IsSale = 2
  4327. item.SaleDate = item.SaleDate
  4328. item.Bchno = number
  4329. service.SaveDF(item)
  4330. if item.IsChange == 0 { //没变更,进行变更操作
  4331. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4332. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4333. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4334. var respJSON3 map[string]interface{}
  4335. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4338. return
  4339. }
  4340. userJSONBytes3, _ := json.Marshal(respJSON3)
  4341. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4342. // utils.ErrorLog("解析失败:%v", err)
  4343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4344. // return
  4345. //}
  4346. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4347. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4348. utils.ErrorLog("解析失败:%v", err)
  4349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4350. return
  4351. }
  4352. //if res3507for10188.Infcode
  4353. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4354. //res.Output = resSix10265.Output
  4355. res3.ErrMsg = res3507for10188.ErrMsg
  4356. res3.Cainfo = res3507for10188.Cainfo
  4357. res3.WarnMsg = res3507for10188.WarnMsg
  4358. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4359. res3.Infcode = infocode
  4360. } else {
  4361. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4362. utils.ErrorLog("解析失败:%v", err)
  4363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4364. return
  4365. }
  4366. }
  4367. if res3.Infcode == 0 {
  4368. item.IsChange = 1
  4369. item.BgBchno = bg_number
  4370. service.SaveDF2(item)
  4371. } else {
  4372. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4373. }
  4374. }
  4375. } else {
  4376. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4377. }
  4378. }
  4379. } else { //还没结算
  4380. if item.IsChange == 0 { //没变更,进行变更操作
  4381. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4382. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4383. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4384. var respJSON3 map[string]interface{}
  4385. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4388. return
  4389. }
  4390. userJSONBytes3, _ := json.Marshal(respJSON3)
  4391. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4392. // utils.ErrorLog("解析失败:%v", err)
  4393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. // return
  4395. //}
  4396. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4397. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4398. utils.ErrorLog("解析失败:%v", err)
  4399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4400. return
  4401. }
  4402. //if res3507for10188.Infcode
  4403. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4404. //res.Output = resSix10265.Output
  4405. res3.ErrMsg = res3507for10188.ErrMsg
  4406. res3.Cainfo = res3507for10188.Cainfo
  4407. res3.WarnMsg = res3507for10188.WarnMsg
  4408. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4409. res3.Infcode = infocode
  4410. } else {
  4411. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4412. utils.ErrorLog("解析失败:%v", err)
  4413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4414. return
  4415. }
  4416. }
  4417. if res3.Infcode == 0 {
  4418. item.IsChange = 1
  4419. item.BgBchno = bg_number
  4420. service.SaveDF2(item)
  4421. } else {
  4422. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4423. }
  4424. }
  4425. }
  4426. }
  4427. }
  4428. if len(err) == 0 {
  4429. c.ServeSuccessJSON(map[string]interface{}{
  4430. "msg": "销售变更成功",
  4431. })
  4432. } else {
  4433. c.ServeSuccessJSON(map[string]interface{}{
  4434. "failed_code": -10,
  4435. "msg": err,
  4436. })
  4437. }
  4438. }
  4439. func (c *HisApiController) ChangeDrugTen() {
  4440. start_time_str := c.GetString("start_time")
  4441. end_time_str := c.GetString("end_time")
  4442. //ids := c.GetString("ids")
  4443. //id_arr := strings.Split(ids, ",")
  4444. timeLayout := "2006-01-02"
  4445. loc, _ := time.LoadLocation("Local")
  4446. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4447. recordStartTime := theStartTime.Unix()
  4448. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4449. recordEndTime := theEndTime.Unix()
  4450. //timestamp := int64(1729612800)
  4451. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4452. admin_user_id, _ := c.GetInt64("admin_user_id")
  4453. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4454. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4455. var err []string
  4456. for _, item := range flows {
  4457. var res3 ResultSix
  4458. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4459. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4460. continue
  4461. }
  4462. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4463. continue
  4464. }
  4465. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4466. if prescription.OrderStatus == 2 {
  4467. //已经结算
  4468. //判断 是否已经销售
  4469. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4470. ////是否已经变更 1是 0否
  4471. //if item.IsChange == 0 { //没变更,进行变更操作
  4472. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4473. //
  4474. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4475. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4476. // var respJSON3 map[string]interface{}
  4477. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4478. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4480. // return
  4481. // }
  4482. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4483. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4484. // utils.ErrorLog("解析失败:%v", err)
  4485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4486. // return
  4487. // }
  4488. // if res3.Infcode == 0 {
  4489. // item.IsChange = 1
  4490. // item.BgBchno = bg_number
  4491. // service.SaveDF2(item)
  4492. // } else {
  4493. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4494. // }
  4495. //}
  4496. //} else
  4497. if item.IsSale == 0 { //没销售,
  4498. var res FJ3507Result
  4499. var res3507for10188 FJ3507ResultFor10188
  4500. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4501. //进行商品销售接口
  4502. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4503. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4504. var respJSON3 map[string]interface{}
  4505. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4508. return
  4509. }
  4510. userJSONBytes3, _ := json.Marshal(respJSON3)
  4511. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4512. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4513. utils.ErrorLog("解析失败:%v", err)
  4514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4515. return
  4516. }
  4517. //if res3507for10188.Infcode
  4518. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4519. //res.Output = resSix10265.Output
  4520. res.ErrMsg = res3507for10188.ErrMsg
  4521. res.Cainfo = res3507for10188.Cainfo
  4522. res.WarnMsg = res3507for10188.WarnMsg
  4523. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4524. res.Infcode = infocode
  4525. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4526. } else {
  4527. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4528. utils.ErrorLog("解析失败:%v", err)
  4529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4530. return
  4531. }
  4532. }
  4533. if res.Infcode == 0 {
  4534. item.IsSale = 1
  4535. item.Bchno = number
  4536. item.SaleDate = time.Now().Format("2006-01-02")
  4537. err5 := service.SaveDF(item)
  4538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4539. //if err5 == nil {
  4540. //
  4541. // if item.IsChange == 1 { //没变更,进行变更操作
  4542. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4543. //
  4544. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4545. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4546. //
  4547. // var respJSON3 map[string]interface{}
  4548. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4549. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4551. // return
  4552. // }
  4553. //
  4554. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4555. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4556. // utils.ErrorLog("解析失败:%v", err)
  4557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4558. // return
  4559. // }
  4560. // //if res3507for10188.Infcode
  4561. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4562. // //res.Output = resSix10265.Output
  4563. // res3.ErrMsg = res3507for10188.ErrMsg
  4564. // res3.Cainfo = res3507for10188.Cainfo
  4565. // res3.WarnMsg = res3507for10188.WarnMsg
  4566. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4567. // res3.Infcode = infocode
  4568. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4569. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4570. // utils.ErrorLog("解析失败:%v", err)
  4571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4572. // return
  4573. // }
  4574. // //if res3507for10188.Infcode
  4575. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4576. // //res.Output = resSix10265.Output
  4577. // res3.ErrMsg = res3507for10188.ErrMsg
  4578. // res3.Cainfo = res3507for10188.Cainfo
  4579. // res3.WarnMsg = res3507for10188.WarnMsg
  4580. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4581. // res3.Infcode = infocode
  4582. //
  4583. // } else {
  4584. //
  4585. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4586. // utils.ErrorLog("解析失败:%v", err)
  4587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4588. // return
  4589. // }
  4590. //
  4591. // }
  4592. //
  4593. // if res3.Infcode == 0 {
  4594. // item.IsChange = 1
  4595. // item.BgBchno = bg_number
  4596. // service.SaveDF2(item)
  4597. // return
  4598. // } else {
  4599. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4600. // }
  4601. // }
  4602. //}
  4603. } else {
  4604. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4605. }
  4606. }
  4607. }
  4608. } else if item.ConsumableType == 7 {
  4609. var res3507for10188 FJ3507ResultFor10188
  4610. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4611. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4612. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4613. //判断是否已经销售
  4614. if item.IsSale == 2 { //是否已经销售,1是 0否
  4615. //是否已经变更 1是 0否
  4616. if item.IsChange == 0 { //没变更,进行变更操作
  4617. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4618. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4619. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4620. var respJSON3 map[string]interface{}
  4621. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4624. return
  4625. }
  4626. userJSONBytes3, _ := json.Marshal(respJSON3)
  4627. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4628. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4629. utils.ErrorLog("解析失败:%v", err)
  4630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4631. return
  4632. }
  4633. //if res3507for10188.Infcode
  4634. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4635. //res.Output = resSix10265.Output
  4636. res3.ErrMsg = res3507for10188.ErrMsg
  4637. res3.Cainfo = res3507for10188.Cainfo
  4638. res3.WarnMsg = res3507for10188.WarnMsg
  4639. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4640. res3.Infcode = infocode
  4641. } else {
  4642. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4643. utils.ErrorLog("解析失败:%v", err)
  4644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4645. return
  4646. }
  4647. }
  4648. if res3.Infcode == 0 {
  4649. item.IsChange = 1
  4650. item.BgBchno = bg_number
  4651. service.SaveDF2(item)
  4652. } else {
  4653. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4654. }
  4655. }
  4656. } else { //没销售,
  4657. //进行商品销售退货接口
  4658. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4659. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4660. saveLog(result111, result222, "3506", "销售退货")
  4661. var res7 FJ3507Result
  4662. //进行商品销售接口
  4663. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4664. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4665. var respJSON3 map[string]interface{}
  4666. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4669. return
  4670. }
  4671. userJSONBytes3, _ := json.Marshal(respJSON3)
  4672. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4673. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4674. utils.ErrorLog("解析失败:%v", err)
  4675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4676. return
  4677. }
  4678. //if res3507for10188.Infcode
  4679. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4680. //res.Output = resSix10265.Output
  4681. res7.ErrMsg = res3507for10188.ErrMsg
  4682. res7.Cainfo = res3507for10188.Cainfo
  4683. res7.WarnMsg = res3507for10188.WarnMsg
  4684. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4685. res7.Infcode = infocode
  4686. } else {
  4687. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4688. utils.ErrorLog("解析失败:%v", err)
  4689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4690. return
  4691. }
  4692. }
  4693. if res7.Infcode == 0 {
  4694. item.IsSale = 2
  4695. item.SaleDate = item.SaleDate
  4696. item.Bchno = number
  4697. service.SaveDF(item)
  4698. if item.IsChange == 0 { //没变更,进行变更操作
  4699. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4700. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4701. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4702. var respJSON3 map[string]interface{}
  4703. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4706. return
  4707. }
  4708. userJSONBytes3, _ := json.Marshal(respJSON3)
  4709. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4710. // utils.ErrorLog("解析失败:%v", err)
  4711. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4712. // return
  4713. //}
  4714. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4715. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4716. utils.ErrorLog("解析失败:%v", err)
  4717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4718. return
  4719. }
  4720. //if res3507for10188.Infcode
  4721. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4722. //res.Output = resSix10265.Output
  4723. res3.ErrMsg = res3507for10188.ErrMsg
  4724. res3.Cainfo = res3507for10188.Cainfo
  4725. res3.WarnMsg = res3507for10188.WarnMsg
  4726. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4727. res3.Infcode = infocode
  4728. } else {
  4729. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4730. utils.ErrorLog("解析失败:%v", err)
  4731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4732. return
  4733. }
  4734. }
  4735. if res3.Infcode == 0 {
  4736. item.IsChange = 1
  4737. item.BgBchno = bg_number
  4738. service.SaveDF2(item)
  4739. } else {
  4740. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4741. }
  4742. }
  4743. } else {
  4744. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4745. }
  4746. }
  4747. } else { //还没结算
  4748. if item.IsChange == 0 { //没变更,进行变更操作
  4749. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4750. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4751. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4752. var respJSON3 map[string]interface{}
  4753. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4756. return
  4757. }
  4758. userJSONBytes3, _ := json.Marshal(respJSON3)
  4759. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4760. // utils.ErrorLog("解析失败:%v", err)
  4761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4762. // return
  4763. //}
  4764. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4765. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4766. utils.ErrorLog("解析失败:%v", err)
  4767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4768. return
  4769. }
  4770. //if res3507for10188.Infcode
  4771. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4772. //res.Output = resSix10265.Output
  4773. res3.ErrMsg = res3507for10188.ErrMsg
  4774. res3.Cainfo = res3507for10188.Cainfo
  4775. res3.WarnMsg = res3507for10188.WarnMsg
  4776. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4777. res3.Infcode = infocode
  4778. } else {
  4779. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4780. utils.ErrorLog("解析失败:%v", err)
  4781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4782. return
  4783. }
  4784. }
  4785. if res3.Infcode == 0 {
  4786. item.IsChange = 1
  4787. item.BgBchno = bg_number
  4788. service.SaveDF2(item)
  4789. } else {
  4790. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4791. }
  4792. }
  4793. }
  4794. }
  4795. }
  4796. if len(err) == 0 {
  4797. c.ServeSuccessJSON(map[string]interface{}{
  4798. "msg": "销售变更成功",
  4799. })
  4800. } else {
  4801. c.ServeSuccessJSON(map[string]interface{}{
  4802. "failed_code": -10,
  4803. "msg": err,
  4804. })
  4805. }
  4806. }
  4807. func ChangeDrugTenone() {
  4808. //ids := c.GetString("ids")
  4809. //id_arr := strings.Split(ids, ",")
  4810. now := time.Now()
  4811. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4812. //timestamp := int64(1729612800)
  4813. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4814. admin_user_id := int64(2463)
  4815. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4816. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4817. var err []string
  4818. for _, item := range flows {
  4819. var res3 ResultSix
  4820. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4821. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4822. continue
  4823. }
  4824. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4825. continue
  4826. }
  4827. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4828. if prescription.OrderStatus == 2 {
  4829. //已经结算
  4830. //判断是否已经销售
  4831. if item.IsSale == 1 { //是否已经销售,1是 0否
  4832. //是否已经变更 1是 0否
  4833. if item.IsChange == 0 { //没变更,进行变更操作
  4834. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4835. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4836. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4837. var respJSON3 map[string]interface{}
  4838. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4840. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4841. return
  4842. }
  4843. userJSONBytes3, _ := json.Marshal(respJSON3)
  4844. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4845. utils.ErrorLog("解析失败:%v", err)
  4846. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4847. return
  4848. }
  4849. if res3.Infcode == 0 {
  4850. item.IsChange = 1
  4851. item.BgBchno = bg_number
  4852. service.SaveDF2(item)
  4853. } else {
  4854. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4855. }
  4856. }
  4857. } else { //没销售,
  4858. var res FJ3507Result
  4859. var res3507for10188 FJ3507ResultFor10188
  4860. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4861. //进行商品销售接口
  4862. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4863. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4864. var respJSON3 map[string]interface{}
  4865. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4867. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4868. return
  4869. }
  4870. userJSONBytes3, _ := json.Marshal(respJSON3)
  4871. {
  4872. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4873. utils.ErrorLog("解析失败:%v", err)
  4874. return
  4875. }
  4876. //if res3507for10188.Infcode
  4877. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4878. //res.Output = resSix10265.Output
  4879. res.ErrMsg = res3507for10188.ErrMsg
  4880. res.Cainfo = res3507for10188.Cainfo
  4881. res.WarnMsg = res3507for10188.WarnMsg
  4882. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4883. res.Infcode = infocode
  4884. }
  4885. if res.Infcode == 0 {
  4886. item.IsSale = 1
  4887. item.Bchno = number
  4888. item.SaleDate = time.Now().Format("2006-01-02")
  4889. err5 := service.SaveDF(item)
  4890. if err5 == nil {
  4891. if item.IsChange == 1 { //没变更,进行变更操作
  4892. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4893. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4894. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4895. var respJSON3 map[string]interface{}
  4896. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4898. return
  4899. }
  4900. {
  4901. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4902. utils.ErrorLog("解析失败:%v", err)
  4903. return
  4904. }
  4905. //if res3507for10188.Infcode
  4906. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4907. //res.Output = resSix10265.Output
  4908. res3.ErrMsg = res3507for10188.ErrMsg
  4909. res3.Cainfo = res3507for10188.Cainfo
  4910. res3.WarnMsg = res3507for10188.WarnMsg
  4911. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4912. res3.Infcode = infocode
  4913. }
  4914. if res3.Infcode == 0 {
  4915. item.IsChange = 1
  4916. item.BgBchno = bg_number
  4917. service.SaveDF2(item)
  4918. } else {
  4919. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4920. }
  4921. }
  4922. }
  4923. } else {
  4924. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4925. }
  4926. }
  4927. }
  4928. }
  4929. }
  4930. }
  4931. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4932. var struct3502 models.Struct3502
  4933. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4934. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4935. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4936. struct3502.FixmedinsCode = miConfig.Code
  4937. struct3502.Code = miConfig.Code
  4938. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4939. struct3502.Opter = role.UserName
  4940. struct3502.RxFlag = "1"
  4941. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4942. struct3502.OrgName = miConfig.OrgName
  4943. struct3502.AccessKey = miConfig.AccessKey
  4944. struct3502.RequestUrl = miConfig.Url
  4945. struct3502.SecretKey = miConfig.SecretKey
  4946. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4947. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4948. struct3502.Url = miConfig.Url
  4949. struct3502.AppId = miConfig.Cainfo
  4950. struct3502.AppSecret = miConfig.AppSecret
  4951. struct3502.Enckey = miConfig.EncKey
  4952. struct3502.SignKey = miConfig.SignKey
  4953. struct3502.SecretKey = miConfig.SecretKey
  4954. struct3502.InvChgType = chgType
  4955. struct3502.FixmedinsBchno = number
  4956. struct3502.Cnt = strconv.FormatInt(count, 10)
  4957. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4958. //result1, result2, _ := service.FJyb3502(struct3502)
  4959. if miConfig.MdtrtareaAdmvs == "350500" {
  4960. result1, result2, _ := service.FJyb3502(struct3502)
  4961. //saveLog(result1, result2, "3502", "3502")
  4962. return result1, result2
  4963. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4964. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4965. return result1, result2
  4966. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4967. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4968. return result1, result2
  4969. } else {
  4970. data := make(map[string]interface{})
  4971. data["struct_3502s"] = struct3502
  4972. client := &http.Client{}
  4973. bytesData, _ := json.Marshal(data)
  4974. var req *http.Request
  4975. if miConfig.MdtrtareaAdmvs == "320921" {
  4976. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4977. } else {
  4978. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4979. }
  4980. resp, _ := client.Do(req)
  4981. defer resp.Body.Close()
  4982. body, ioErr := ioutil.ReadAll(resp.Body)
  4983. if ioErr != nil {
  4984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4985. }
  4986. var respJSON map[string]interface{}
  4987. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4989. }
  4990. //var resSix10265 ResultSix10265 //1101结果
  4991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4992. result, _ := json.Marshal(respJSON)
  4993. return string(result), ""
  4994. }
  4995. }
  4996. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4997. var struct3505 models.Struct3505
  4998. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4999. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5000. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5001. struct3505.FixmedinsBchno = number
  5002. struct3505.Opter = role.UserName
  5003. struct3505.Bchno = "---"
  5004. struct3505.FixmedinsCode = miConfig.Code
  5005. struct3505.Code = miConfig.Code
  5006. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5007. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5008. struct3505.PrscDrName = roles.UserName
  5009. if org_id == 10191 {
  5010. struct3505.PharName = "刘水山"
  5011. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5012. }
  5013. if org_id == 10188 {
  5014. struct3505.PharName = "李汉清"
  5015. struct3505.PharPracCertNo = "30220200932022010034"
  5016. }
  5017. if org_id == 10217 {
  5018. struct3505.PharName = "张敏"
  5019. struct3505.PharPracCertNo = "30220230432090100108"
  5020. }
  5021. if org_id == 10318 {
  5022. struct3505.PharName = "邹刘阳"
  5023. struct3505.PharPracCertNo = "210441200001378"
  5024. }
  5025. if org_id == 10402 {
  5026. struct3505.PharName = "刘韶健"
  5027. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5028. }
  5029. if org_id == 9919 {
  5030. struct3505.PharName = "周君权"
  5031. struct3505.PharPracCertNo = "089644396094401375"
  5032. }
  5033. if org_id == 10644 {
  5034. struct3505.PharName = "陈金娣"
  5035. struct3505.PharPracCertNo = "20181441500320100066"
  5036. }
  5037. if org_id == 10567 {
  5038. struct3505.PharName = "范小兰"
  5039. struct3505.PharPracCertNo = "0200102079485"
  5040. }
  5041. if org_id == 10721 {
  5042. struct3505.PharName = "孙莉侠"
  5043. struct3505.PharPracCertNo = "060399"
  5044. }
  5045. if org_id == 10726 {
  5046. struct3505.PharName = "彭建福"
  5047. struct3505.PharPracCertNo = "D445281006261"
  5048. }
  5049. if org_id == 10265 {
  5050. struct3505.PharName = "李彩星"
  5051. struct3505.PharPracCertNo = "20171110600110100019"
  5052. }
  5053. if org_id == 10028 {
  5054. struct3505.PharName = "曾细平"
  5055. struct3505.PharPracCertNo = "D440307022134"
  5056. }
  5057. if org_id == 10138 {
  5058. struct3505.PharName = "彭斯遥"
  5059. struct3505.PharPracCertNo = "30220200943042010052"
  5060. }
  5061. if org_id == 10278 {
  5062. struct3505.PharName = "彭斯遥"
  5063. struct3505.PharPracCertNo = "30220200943042010052"
  5064. }
  5065. if org_id == 10610 {
  5066. struct3505.PharName = "彭斯遥"
  5067. struct3505.PharPracCertNo = "30220200943042010052"
  5068. }
  5069. if org_id == 10537 {
  5070. struct3505.PharName = "彭斯遥"
  5071. struct3505.PharPracCertNo = "30220200943042010052"
  5072. }
  5073. if org_id == 9504 {
  5074. struct3505.PharName = "资美红"
  5075. struct3505.PharPracCertNo = "D440904006635"
  5076. }
  5077. if org_id == 10480 {
  5078. struct3505.PharName = "陈思"
  5079. struct3505.PharPracCertNo = "30220240434110010470"
  5080. }
  5081. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5082. struct3505.SetlId = order.SetlId
  5083. struct3505.MdtrtSn = order.MdtrtId
  5084. struct3505.ManuLotnum = drug.BatchNumber
  5085. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5086. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5087. struct3505.RxFlag = "1"
  5088. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5089. struct3505.TrdnFlag = "0"
  5090. } else {
  5091. struct3505.TrdnFlag = "1"
  5092. }
  5093. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5094. struct3505.TrdnFlag = "1"
  5095. }
  5096. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5097. struct3505.TrdnFlag = "0"
  5098. }
  5099. struct3505.RtalDocno = order.Number
  5100. struct3505.PsnCertType = "01"
  5101. struct3505.CertNo = order.Certno
  5102. struct3505.PsnNo = order.PsnNo
  5103. struct3505.PsnName = order.PsnName
  5104. struct3505.Url = miConfig.Url
  5105. struct3505.AppId = miConfig.Cainfo
  5106. struct3505.AppSecret = miConfig.AppSecret
  5107. struct3505.Enckey = miConfig.EncKey
  5108. struct3505.SignKey = miConfig.SignKey
  5109. struct3505.SecretKey = miConfig.SecretKey
  5110. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5111. struct3505.SelRetnCnt = strValue
  5112. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5113. struct3505.SelRetnOpterName = role.UserName
  5114. if order.IsMedicineInsurance == 1 {
  5115. struct3505.MdtrtSetlType = "1"
  5116. } else {
  5117. struct3505.MdtrtSetlType = "2"
  5118. }
  5119. struct3505.OrgName = miConfig.OrgName
  5120. struct3505.AccessKey = miConfig.AccessKey
  5121. struct3505.RequestUrl = miConfig.Url
  5122. struct3505.SecretKey = miConfig.SecretKey
  5123. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5124. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5125. struct3505.Cainfo = miConfig.Cainfo
  5126. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5127. if miConfig.MdtrtareaAdmvs == "350500" {
  5128. result1, result2, _ := service.FJyb3505(struct3505)
  5129. return result1, result2
  5130. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5131. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5132. return result1, result2
  5133. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5134. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5135. return result1, result2
  5136. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5137. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5138. return result1, result2
  5139. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5140. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5141. return result1, result2
  5142. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5143. data := make(map[string]interface{})
  5144. data["struct_3505s"] = struct3505
  5145. client := &http.Client{}
  5146. bytesData, _ := json.Marshal(data)
  5147. var req *http.Request
  5148. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5149. resp, _ := client.Do(req)
  5150. defer resp.Body.Close()
  5151. body, ioErr := ioutil.ReadAll(resp.Body)
  5152. if ioErr != nil {
  5153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5154. }
  5155. var respJSON map[string]interface{}
  5156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5158. }
  5159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5160. result, _ := json.Marshal(respJSON)
  5161. return string(result), ""
  5162. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5163. data := make(map[string]interface{})
  5164. data["struct_3505s"] = struct3505
  5165. client := &http.Client{}
  5166. bytesData, _ := json.Marshal(data)
  5167. var req *http.Request
  5168. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5169. resp, _ := client.Do(req)
  5170. defer resp.Body.Close()
  5171. body, ioErr := ioutil.ReadAll(resp.Body)
  5172. if ioErr != nil {
  5173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5174. }
  5175. var respJSON map[string]interface{}
  5176. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5178. }
  5179. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5180. if status == "0" {
  5181. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5182. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5183. }
  5184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5185. result, _ := json.Marshal(respJSON)
  5186. return string(result), ""
  5187. } else {
  5188. data := make(map[string]interface{})
  5189. data["struct_3505s"] = struct3505
  5190. client := &http.Client{}
  5191. bytesData, _ := json.Marshal(data)
  5192. var req *http.Request
  5193. if miConfig.MdtrtareaAdmvs == "320921" {
  5194. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5195. } else {
  5196. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5197. }
  5198. resp, _ := client.Do(req)
  5199. defer resp.Body.Close()
  5200. body, ioErr := ioutil.ReadAll(resp.Body)
  5201. if ioErr != nil {
  5202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5203. }
  5204. var respJSON map[string]interface{}
  5205. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5207. }
  5208. //var resSix10265 ResultSix10265 //1101结果
  5209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5210. result, _ := json.Marshal(respJSON)
  5211. return string(result), ""
  5212. }
  5213. }
  5214. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5215. var struct3505 models.Struct3505
  5216. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5217. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5218. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5219. struct3505.FixmedinsBchno = number
  5220. struct3505.Opter = role.UserName
  5221. struct3505.FixmedinsCode = miConfig.Code
  5222. struct3505.Code = miConfig.Code
  5223. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5224. struct3505.PrscDrName = roles.UserName
  5225. if org_id == 10191 {
  5226. struct3505.PharName = "刘水山"
  5227. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5228. }
  5229. if org_id == 10188 {
  5230. struct3505.PharName = "李汉清"
  5231. struct3505.PharPracCertNo = "30220200932022010034"
  5232. }
  5233. if org_id == 10217 {
  5234. struct3505.PharName = "张敏"
  5235. struct3505.PharPracCertNo = "30220230432090100108"
  5236. }
  5237. if org_id == 10318 {
  5238. struct3505.PharName = "邹刘阳"
  5239. struct3505.PharPracCertNo = "210441200001378"
  5240. }
  5241. if org_id == 10402 {
  5242. struct3505.PharName = "刘韶健"
  5243. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5244. }
  5245. if org_id == 9919 {
  5246. struct3505.PharName = "周君权"
  5247. struct3505.PharPracCertNo = "089644396094401375"
  5248. }
  5249. if org_id == 10644 {
  5250. struct3505.PharName = "陈金娣"
  5251. struct3505.PharPracCertNo = "20181441500320100066"
  5252. }
  5253. if org_id == 10567 {
  5254. struct3505.PharName = "范小兰"
  5255. struct3505.PharPracCertNo = "0200102079485"
  5256. }
  5257. if org_id == 10721 {
  5258. struct3505.PharName = "孙莉侠"
  5259. struct3505.PharPracCertNo = "060399"
  5260. }
  5261. if org_id == 10726 {
  5262. struct3505.PharName = "彭建福"
  5263. struct3505.PharPracCertNo = "D445281006261"
  5264. }
  5265. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5266. struct3505.SetlId = order.SetlId
  5267. struct3505.MdtrtSn = order.MdtrtId
  5268. struct3505.ManuLotnum = drug.Number
  5269. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5270. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5271. struct3505.RxFlag = "1"
  5272. struct3505.TrdnFlag = "0"
  5273. struct3505.RtalDocno = order.Number
  5274. struct3505.PsnCertType = "01"
  5275. struct3505.CertNo = order.Certno
  5276. struct3505.PsnNo = order.PsnNo
  5277. struct3505.PsnName = order.PsnName
  5278. struct3505.Url = miConfig.Url
  5279. struct3505.AppId = miConfig.Cainfo
  5280. struct3505.AppSecret = miConfig.AppSecret
  5281. struct3505.Enckey = miConfig.EncKey
  5282. struct3505.SignKey = miConfig.SignKey
  5283. struct3505.SecretKey = miConfig.SecretKey
  5284. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5285. struct3505.SelRetnCnt = strValue
  5286. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5287. struct3505.SelRetnOpterName = role.UserName
  5288. if order.IsMedicineInsurance == 1 {
  5289. struct3505.MdtrtSetlType = "1"
  5290. } else {
  5291. struct3505.MdtrtSetlType = "2"
  5292. }
  5293. struct3505.OrgName = miConfig.OrgName
  5294. struct3505.AccessKey = miConfig.AccessKey
  5295. struct3505.RequestUrl = miConfig.Url
  5296. struct3505.SecretKey = miConfig.SecretKey
  5297. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5298. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5299. struct3505.Cainfo = miConfig.Cainfo
  5300. struct3505.DrugTracCodg = drug.DrugCode
  5301. if miConfig.MdtrtareaAdmvs == "350500" {
  5302. result1, result2, _ := service.FJyb3505(struct3505)
  5303. return result1, result2
  5304. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5305. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5306. return result1, result2
  5307. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5308. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5309. return result1, result2
  5310. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5311. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5312. return result1, result2
  5313. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5314. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5315. return result1, result2
  5316. } else {
  5317. data := make(map[string]interface{})
  5318. data["struct_3505s"] = struct3505
  5319. client := &http.Client{}
  5320. bytesData, _ := json.Marshal(data)
  5321. var req *http.Request
  5322. if miConfig.MdtrtareaAdmvs == "320921" {
  5323. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5324. } else {
  5325. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5326. }
  5327. resp, _ := client.Do(req)
  5328. defer resp.Body.Close()
  5329. body, ioErr := ioutil.ReadAll(resp.Body)
  5330. if ioErr != nil {
  5331. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5332. }
  5333. var respJSON map[string]interface{}
  5334. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5336. }
  5337. //var resSix10265 ResultSix10265 //1101结果
  5338. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5339. result, _ := json.Marshal(respJSON)
  5340. return string(result), ""
  5341. }
  5342. }
  5343. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5344. var struct3506 models.Struct3506
  5345. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5346. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5347. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5348. struct3506.FixmedinsCode = miConfig.Code
  5349. struct3506.Code = miConfig.Code
  5350. struct3506.FixmedinsBchno = number
  5351. struct3506.Opter = role.UserName
  5352. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5353. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5354. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5355. struct3506.MdtrtSn = order.MdtrtId
  5356. struct3506.ExpyEnd = ""
  5357. struct3506.RxFlag = "0"
  5358. struct3506.TrdnFlag = "1"
  5359. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5360. struct3506.SelRetnCnt = strValue
  5361. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5362. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5363. struct3506.SelRetnOpterName = role.UserName
  5364. struct3506.OrgName = miConfig.OrgName
  5365. struct3506.AccessKey = miConfig.AccessKey
  5366. struct3506.RequestUrl = miConfig.Url
  5367. struct3506.SecretKey = miConfig.SecretKey
  5368. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5369. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5370. struct3506.Url = miConfig.Url
  5371. struct3506.AppId = miConfig.Cainfo
  5372. struct3506.AppSecret = miConfig.AppSecret
  5373. struct3506.Enckey = miConfig.EncKey
  5374. struct3506.SignKey = miConfig.SignKey
  5375. struct3506.SecretKey = miConfig.SecretKey
  5376. struct3506.DrugTracCodg = drug.DrugCode
  5377. if miConfig.MdtrtareaAdmvs == "350500" {
  5378. result1, result2, _ := service.FJyb3506(struct3506)
  5379. return result1, result2
  5380. } else {
  5381. data := make(map[string]interface{})
  5382. data["struct_3506s"] = struct3506
  5383. client := &http.Client{}
  5384. bytesData, _ := json.Marshal(data)
  5385. var req *http.Request
  5386. if miConfig.MdtrtareaAdmvs == "320921" {
  5387. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5388. } else {
  5389. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5390. }
  5391. resp, _ := client.Do(req)
  5392. defer resp.Body.Close()
  5393. body, ioErr := ioutil.ReadAll(resp.Body)
  5394. if ioErr != nil {
  5395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5396. }
  5397. var respJSON map[string]interface{}
  5398. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5400. }
  5401. //var resSix10265 ResultSix10265 //1101结果
  5402. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5403. result, _ := json.Marshal(respJSON)
  5404. return string(result), ""
  5405. }
  5406. }
  5407. func (c *HisApiController) Get1318() {
  5408. adminUser := c.GetAdminUserInfo()
  5409. admin_user_id, _ := c.GetInt64("admin_user_id")
  5410. code := c.GetString("code")
  5411. code = ""
  5412. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5413. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5414. api := ""
  5415. if miConfig.MdtrtareaAdmvs == "320921" {
  5416. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5417. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5418. } else {
  5419. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5420. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5421. }
  5422. resp, requestErr := http.Get(api)
  5423. if requestErr != nil {
  5424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5425. return
  5426. }
  5427. body, ioErr := ioutil.ReadAll(resp.Body)
  5428. if ioErr != nil {
  5429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5431. return
  5432. }
  5433. var respJSON map[string]interface{}
  5434. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5437. return
  5438. }
  5439. //var res Result2406
  5440. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5441. result, _ := json.Marshal(respJSON)
  5442. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5443. utils.ErrorLog("解析失败:%v", err)
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5445. return
  5446. }
  5447. if res.Infcode == "0" {
  5448. c.ServeSuccessJSON(map[string]interface{}{
  5449. "result": "",
  5450. })
  5451. } else {
  5452. c.ServeSuccessJSON(map[string]interface{}{
  5453. "failed_code": -10,
  5454. "msg": res.ErrMsg,
  5455. })
  5456. */return
  5457. //}
  5458. }
  5459. func (c *HisApiController) Get2503() {
  5460. adminUser := c.GetAdminUserInfo()
  5461. admin_user_id, _ := c.GetInt64("admin_user_id")
  5462. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5463. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5464. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5465. }
  5466. func (c *HisApiController) Get2406() {
  5467. id, _ := c.GetInt64("id")
  5468. record_time := c.GetString("record_time")
  5469. his_patient_id, _ := c.GetInt64("his_patient_id")
  5470. admin_user_id, _ := c.GetInt64("admin_user_id")
  5471. diagnosis_id := c.GetString("diagnosis")
  5472. timeLayout := "2006-01-02"
  5473. loc, _ := time.LoadLocation("Local")
  5474. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5475. if err != nil {
  5476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5477. return
  5478. }
  5479. recordDateTime := theTime.Unix()
  5480. adminUser := c.GetAdminUserInfo()
  5481. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5482. var config []*models.HisXtDiagnoseConfig
  5483. for _, item := range diagnosis_ids {
  5484. id, _ := strconv.ParseInt(item, 10, 64)
  5485. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5486. config = append(config, &diagnosisConfig)
  5487. }
  5488. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5489. fmt.Println(his_patient_id)
  5490. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5491. //timestamp := time.Now().Unix()
  5492. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5493. var patientPrescription models.HisPrescriptionInfo
  5494. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5495. if patientPrescription.ID == 0 {
  5496. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5497. }
  5498. var res2 Result2406
  5499. if miConfig.MdtrtareaAdmvs == "341203" {
  5500. data := make(map[string]interface{})
  5501. client := &http.Client{}
  5502. data["psn_no"] = his.PsnNo
  5503. data["mdtrt_id"] = his.Number
  5504. data["operator"] = roles.UserName
  5505. data["cert_no"] = his.IdCardNo
  5506. data["org_name"] = miConfig.OrgName
  5507. data["psn_name"] = his.Name
  5508. data["ipt_otp_no"] = his.IptOtpNo
  5509. data["ipt_psn_sp_flag_type"] = "0901"
  5510. data["ipt_psn_sp_flag"] = "1"
  5511. data["fixmedins_code"] = miConfig.Code
  5512. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5513. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5514. data["url"] = miConfig.Url
  5515. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5516. bytesData, _ := json.Marshal(data)
  5517. var req *http.Request
  5518. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5519. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5520. resp, _ := client.Do(req)
  5521. defer resp.Body.Close()
  5522. body, ioErr := ioutil.ReadAll(resp.Body)
  5523. if ioErr != nil {
  5524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5526. return
  5527. }
  5528. var respJSON map[string]interface{}
  5529. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5532. return
  5533. }
  5534. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5535. if status == "0" {
  5536. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5537. c.ServeSuccessJSON(map[string]interface{}{
  5538. "failed_code": -10,
  5539. "msg": err_msg,
  5540. })
  5541. return
  5542. }
  5543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5544. userJSONBytes, _ := json.Marshal(respJSON)
  5545. fmt.Println("log")
  5546. fmt.Println(string(userJSONBytes))
  5547. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5548. utils.ErrorLog("解析失败:%v", err)
  5549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5550. return
  5551. }
  5552. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5553. data := make(map[string]interface{})
  5554. client := &http.Client{}
  5555. data["psn_no"] = his.PsnNo
  5556. data["mdtrt_id"] = his.Number
  5557. data["operator"] = roles.UserName
  5558. data["cert_no"] = his.IdCardNo
  5559. data["org_name"] = miConfig.OrgName
  5560. data["psn_name"] = his.Name
  5561. data["ipt_otp_no"] = his.IptOtpNo
  5562. data["ipt_psn_sp_flag_type"] = "0901"
  5563. data["ipt_psn_sp_flag"] = "1"
  5564. data["fixmedins_code"] = miConfig.Code
  5565. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5566. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5567. data["url"] = miConfig.Url
  5568. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5569. bytesData, _ := json.Marshal(data)
  5570. var req *http.Request
  5571. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5572. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5573. resp, _ := client.Do(req)
  5574. defer resp.Body.Close()
  5575. body, ioErr := ioutil.ReadAll(resp.Body)
  5576. if ioErr != nil {
  5577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5579. return
  5580. }
  5581. var respJSON map[string]interface{}
  5582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5585. return
  5586. }
  5587. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5588. if status == "0" {
  5589. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5590. c.ServeSuccessJSON(map[string]interface{}{
  5591. "failed_code": -10,
  5592. "msg": err_msg,
  5593. })
  5594. return
  5595. }
  5596. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5597. userJSONBytes, _ := json.Marshal(respJSON)
  5598. fmt.Println("log")
  5599. fmt.Println(string(userJSONBytes))
  5600. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5601. utils.ErrorLog("解析失败:%v", err)
  5602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5603. return
  5604. }
  5605. }
  5606. if res2.Infcode != 0 {
  5607. adminUser := c.GetAdminUserInfo()
  5608. errlog := &models.HisOrderError{
  5609. UserOrgId: adminUser.CurrentOrgId,
  5610. Ctime: time.Now().Unix(),
  5611. Mtime: time.Now().Unix(),
  5612. ErrMsg: res2.ErrMsg,
  5613. Status: 1,
  5614. PatientId: id,
  5615. RecordTime: recordDateTime,
  5616. Stage: 3,
  5617. }
  5618. service.CreateErrMsgLog(errlog)
  5619. c.ServeSuccessJSON(map[string]interface{}{
  5620. "failed_code": -10,
  5621. "msg": res2.ErrMsg,
  5622. })
  5623. return
  5624. } else {
  5625. c.ServeSuccessJSON(map[string]interface{}{
  5626. "msg": "上传成功",
  5627. })
  5628. return
  5629. }
  5630. }
  5631. func (c *HisApiController) Get4105() {
  5632. }
  5633. func (c *HisApiController) Post5302() {
  5634. patient_id, _ := c.GetInt64("id")
  5635. admin_user_id, _ := c.GetInt64("admin_user_id")
  5636. p, _ := service.GetHisPatientById(patient_id)
  5637. adminUser := c.GetAdminUserInfo()
  5638. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5639. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5640. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5641. }
  5642. func (c *HisApiController) Get4104() {
  5643. }
  5644. type Output struct {
  5645. CertNo string `json:"certno"`
  5646. PsnName string `json:"psn_name"`
  5647. CardNo string `json:"card_no"`
  5648. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5649. CardSN string `json:"card_sn"`
  5650. PsnCertType string `json:"psn_cert_type"`
  5651. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5652. MdtrtCertType string `json:"mdtrt_cert_type"`
  5653. QRCode string `json:"qrCode"`
  5654. EcToken string `json:"ecToken"`
  5655. }
  5656. type AHResponse struct {
  5657. Body AHBody `json:"body"`
  5658. Code int `json:"code"`
  5659. CSBCode int `json:"csbCode"`
  5660. Message string `json:"message"`
  5661. RequestID string `json:"requestId"`
  5662. State struct{} `json:"state"`
  5663. }
  5664. type AHBody struct {
  5665. ErrMsg string `json:"err_msg"`
  5666. InfRefMsgID string `json:"inf_refmsgid"`
  5667. InfCode int `json:"infcode"`
  5668. Output struct {
  5669. Result []struct {
  5670. BasMednFlag string `json:"bas_medn_flag"`
  5671. ChldMedcFlag string `json:"chld_medc_flag"`
  5672. ChrgitmLv string `json:"chrgitm_lv"`
  5673. Cnt float64 `json:"cnt"`
  5674. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5675. DrtReimFlag string `json:"drt_reim_flag"`
  5676. FeedetlSn string `json:"feedetl_sn"`
  5677. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5678. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5679. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5680. ListSpItemFlag string `json:"list_sp_item_flag"`
  5681. LmtUsedFlag string `json:"lmt_used_flag"`
  5682. MedChrgitmType string `json:"med_chrgitm_type"`
  5683. Memo string `json:"memo"`
  5684. OverlmtAmt float64 `json:"overlmt_amt"`
  5685. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5686. Pric float64 `json:"pric"`
  5687. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5688. SelfpayProp float64 `json:"selfpay_prop"`
  5689. } `json:"result"`
  5690. } `json:"output"`
  5691. }
  5692. type Response struct {
  5693. Output Output `json:"output"`
  5694. Infcode int `json:"infcode"`
  5695. InfRefMsgID string `json:"inf_refmsgid"`
  5696. RefMsgTime string `json:"refmsg_time"`
  5697. RespondTime string `json:"respond_time"`
  5698. ErrMsg string `json:"err_msg"`
  5699. WarnMsg string `json:"warn_msg"`
  5700. SignType string `json:"signtype"`
  5701. CAInfo string `json:"cainfo"`
  5702. }
  5703. func (c *HisApiController) Getquerydata() {
  5704. query_type, _ := c.GetInt64("type")
  5705. refd_setl_flag := c.GetString("refd_setl_flag")
  5706. med_type := c.GetString("med_type")
  5707. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5708. cert_no := c.GetString("cert_no")
  5709. psn_no := c.GetString("psn_no")
  5710. start_time := c.GetString("start_time")
  5711. end_time := c.GetString("end_time")
  5712. page, _ := c.GetInt64("page")
  5713. limit, _ := c.GetInt64("limit")
  5714. var bp models.BusinessParams5262
  5715. bp.RefdSetlFlag = refd_setl_flag
  5716. bp.MedType = med_type
  5717. bp.Certno = cert_no
  5718. bp.Psnno = psn_no
  5719. bp.QBegntime = start_time
  5720. bp.QEndtime = end_time
  5721. if query_type == 1 { //本地
  5722. Post5262(c, bp, page, limit)
  5723. } else { //异地
  5724. Post5267(c, bp, page, limit)
  5725. }
  5726. }
  5727. func (c *HisApiController) Drugscheck() {
  5728. admin_user_id, _ := c.GetInt64("admin_user_id")
  5729. adminUser := c.GetAdminUserInfo()
  5730. var queryResult []QueryResult
  5731. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5732. for _, item := range drugs {
  5733. result := QueryResult{
  5734. ID: item.ID,
  5735. Name: item.DrugName,
  5736. Code: item.MedicalInsuranceNumber,
  5737. List_type_code: "101",
  5738. }
  5739. queryResult = append(queryResult, result)
  5740. }
  5741. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5742. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5743. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5744. for _, item := range queryResult {
  5745. 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)
  5746. }
  5747. }
  5748. func (c *HisApiController) Goodcheck() {
  5749. admin_user_id, _ := c.GetInt64("admin_user_id")
  5750. adminUser := c.GetAdminUserInfo()
  5751. var queryResult []QueryResult
  5752. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5753. for _, item := range goods {
  5754. result := QueryResult{
  5755. ID: item.ID,
  5756. Name: item.GoodName,
  5757. Code: item.SocialSecurityDirectoryCode,
  5758. List_type_code: "301",
  5759. }
  5760. queryResult = append(queryResult, result)
  5761. }
  5762. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5763. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5764. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5765. for _, item := range queryResult {
  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. //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)
  5768. }
  5769. }
  5770. func (c *HisApiController) Projectcheck() {
  5771. admin_user_id, _ := c.GetInt64("admin_user_id")
  5772. adminUser := c.GetAdminUserInfo()
  5773. var queryResult []QueryResult
  5774. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5775. for _, item := range projects {
  5776. result := QueryResult{
  5777. ID: item.ID,
  5778. Name: item.ProjectName,
  5779. Code: item.MedicalCode,
  5780. List_type_code: "201",
  5781. }
  5782. queryResult = append(queryResult, result)
  5783. }
  5784. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5785. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5786. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5787. for _, item := range queryResult {
  5788. 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)
  5789. }
  5790. }
  5791. //func (c *HisApiController)CancleDia(){
  5792. //
  5793. // id, _ := c.GetInt64("id")
  5794. // record_time := c.GetString("record_time")
  5795. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5796. //
  5797. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5798. //
  5799. // diagnosis_id := c.GetString("diagnosis")
  5800. // sick_type, _ := c.GetInt64("sick_type")
  5801. // reg_type, _ := c.GetInt64("p_type")
  5802. // begin_time := c.GetString("begin_time")
  5803. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5804. //
  5805. //
  5806. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5807. //
  5808. // fmt.Println(acct_used_flag)
  5809. //
  5810. //
  5811. // timeLayout := "2006-01-02"
  5812. // loc, _ := time.LoadLocation("Local")
  5813. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5814. // if err != nil {
  5815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5816. // return
  5817. // }
  5818. // recordDateTime := theTime.Unix()
  5819. // adminUser := c.GetAdminUserInfo()
  5820. //
  5821. //
  5822. //
  5823. //
  5824. //
  5825. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5826. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5827. // var patientPrescription models.HisPrescriptionInfo
  5828. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5829. // if patientPrescription.ID == 0 {
  5830. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5831. // }
  5832. // //if patientPrescription.Do
  5833. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5834. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5835. //
  5836. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5837. //
  5838. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5839. //
  5840. // var config []*models.HisXtDiagnoseConfig
  5841. // for _, item := range diagnosis_ids {
  5842. // id, _ := strconv.ParseInt(item, 10, 64)
  5843. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5844. // config = append(config, &diagnosisConfig)
  5845. // }
  5846. //
  5847. // sickConfig, _ := service.FindSickById(sick_type)
  5848. //
  5849. //
  5850. // data := make(map[string]interface{})
  5851. // client := &http.Client{}
  5852. // data["psn_no"] = his.PsnNo
  5853. // data["mdtrt_id"] = his.Number
  5854. // data["doctor"] = roles.UserName
  5855. // data["department"] = department.Name
  5856. // data["org_name"] = miConfig.OrgName
  5857. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5858. // data["doctor_id"] = doctor_info.DoctorNumber
  5859. // data["new_doctor_name"] = doctor_info.UserName
  5860. // data["fixmedins_code"] = miConfig.Code
  5861. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5862. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5863. // data["secret_key"] = miConfig.SecretKey
  5864. // data["sick_code"] = sickConfig.CountryCode
  5865. // data["sick_name"] = sickConfig.ClassName
  5866. // data["url"] = miConfig.Url
  5867. // data["ak"] = miConfig.AccessKey
  5868. // data["begin_time"] = begin_time
  5869. // data["cainfo"] = miConfig.Cainfo
  5870. // data["is_vaild"] = "0"
  5871. //
  5872. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5873. // data["config"] = config
  5874. // bytesData, _ := json.Marshal(data)
  5875. //
  5876. // var req *http.Request
  5877. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5878. // resp, _ := client.Do(req)
  5879. // defer resp.Body.Close()
  5880. // body, ioErr := ioutil.ReadAll(resp.Body)
  5881. // if ioErr != nil {
  5882. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5884. // return
  5885. // }
  5886. // var respJSON map[string]interface{}
  5887. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5888. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5890. // return
  5891. // }
  5892. //
  5893. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5894. // userJSONBytes, _ := json.Marshal(respJSON)
  5895. // fmt.Println("log")
  5896. // fmt.Println(string(userJSONBytes))
  5897. //
  5898. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5899. // utils.ErrorLog("解析失败:%v", err)
  5900. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5901. // return
  5902. // }
  5903. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5904. // res2.Output = ressix10265.Output
  5905. // res2.ErrMsg = ressix10265.ErrMsg
  5906. // res2.Cainfo = ressix10265.Cainfo
  5907. // res2.WarnMsg = ressix10265.WarnMsg
  5908. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5909. // res2.Infcode = infocode
  5910. //
  5911. //}
  5912. func (c *HisApiController) Get4102() {
  5913. order_id, _ := c.GetInt64("order_id")
  5914. admin_user_id, _ := c.GetInt64("admin_user_id")
  5915. stas_type := c.GetString("stas_type")
  5916. order, _ := service.GetHisOrderByIDTwo(order_id)
  5917. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5918. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5919. var pp models.PublicParams
  5920. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5921. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5922. pp.FixmedinsName = miConfig.OrgName
  5923. pp.FixmedinsCode = miConfig.Code
  5924. pp.RequestUrl = miConfig.Url
  5925. pp.Cainfo = miConfig.Cainfo
  5926. pp.SecretKey = miConfig.SecretKey
  5927. pp.AccessKey = miConfig.AccessKey
  5928. pp.OpterName = curRoles.UserName
  5929. if miConfig.MdtrtareaAdmvs == "350500" {
  5930. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5931. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5932. saveLog(result, request, "4102", "清单确认")
  5933. var dat map[string]interface{}
  5934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5935. fmt.Println(dat)
  5936. } else {
  5937. fmt.Println(err)
  5938. }
  5939. var empty ResultFourteen
  5940. userJSONBytes, _ := json.Marshal(dat)
  5941. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5942. utils.ErrorLog("解析失败:%v", err)
  5943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5944. return
  5945. }
  5946. if empty.Infcode == 0 {
  5947. c.ServeSuccessJSON(map[string]interface{}{
  5948. "msg": "确认成功",
  5949. })
  5950. return
  5951. }
  5952. } else {
  5953. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5954. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5955. result3, request3 := service.Jxyb4105(pp)
  5956. saveLog(result, request, "4102", "清单确认")
  5957. saveLog(result2, request2, "4103", "清单确认")
  5958. saveLog(result3, request3, "4105", "清单统计")
  5959. var dat map[string]interface{}
  5960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5961. fmt.Println(dat)
  5962. } else {
  5963. fmt.Println(err)
  5964. }
  5965. var empty ResultFourteen
  5966. userJSONBytes, _ := json.Marshal(dat)
  5967. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5968. utils.ErrorLog("解析失败:%v", err)
  5969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5970. return
  5971. }
  5972. if empty.Infcode == 0 {
  5973. c.ServeSuccessJSON(map[string]interface{}{
  5974. "msg": "确认成功",
  5975. })
  5976. return
  5977. }
  5978. }
  5979. }
  5980. // 对账权限查询
  5981. func (c *HisApiController) Get3260() {
  5982. admin_user_id, _ := c.GetInt64("admin_user_id")
  5983. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5984. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5985. var api string
  5986. var res models.JSResult3260
  5987. if miConfig.MdtrtareaAdmvs == "320921" {
  5988. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5989. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5990. } else {
  5991. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5992. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5993. }
  5994. resp, requestErr := http.Get(api)
  5995. if requestErr != nil {
  5996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5997. return
  5998. }
  5999. body, ioErr := ioutil.ReadAll(resp.Body)
  6000. if ioErr != nil {
  6001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6003. return
  6004. }
  6005. var respJSON map[string]interface{}
  6006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6009. return
  6010. }
  6011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6012. result, _ := json.Marshal(respJSON)
  6013. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6014. utils.ErrorLog("解析失败:%v", err)
  6015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6016. return
  6017. }
  6018. if res.Infcode == "0" {
  6019. c.ServeSuccessJSON(map[string]interface{}{
  6020. "result": res.Output.Data,
  6021. })
  6022. } else {
  6023. c.ServeSuccessJSON(map[string]interface{}{
  6024. "failed_code": -10,
  6025. "msg": res.ErrMsg,
  6026. })
  6027. return
  6028. }
  6029. }
  6030. func (c *HisApiController) Get3261() {
  6031. admin_user_id, _ := c.GetInt64("admin_user_id")
  6032. //month := c.GetString("month")
  6033. startTime := c.GetString("start_time")
  6034. //endTime, _ := c.GetString("end_time")
  6035. times := strings.Split(startTime, "-")
  6036. stmt_mon := times[0] + times[1]
  6037. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6038. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6039. var api string
  6040. var res models.JSResult3261
  6041. //var res10265 Result5301For10265
  6042. if miConfig.MdtrtareaAdmvs == "320921" {
  6043. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6044. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6045. } else {
  6046. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6047. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6048. }
  6049. resp, requestErr := http.Get(api)
  6050. if requestErr != nil {
  6051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6052. return
  6053. }
  6054. body, ioErr := ioutil.ReadAll(resp.Body)
  6055. if ioErr != nil {
  6056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6058. return
  6059. }
  6060. var respJSON map[string]interface{}
  6061. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6064. return
  6065. }
  6066. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6067. result, _ := json.Marshal(respJSON)
  6068. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6069. utils.ErrorLog("解析失败:%v", err)
  6070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6071. return
  6072. }
  6073. if res.Infcode == "0" {
  6074. c.ServeSuccessJSON(map[string]interface{}{
  6075. "result": res.Output,
  6076. })
  6077. } else {
  6078. c.ServeSuccessJSON(map[string]interface{}{
  6079. "failed_code": -10,
  6080. "msg": res.ErrMsg,
  6081. })
  6082. return
  6083. }
  6084. }
  6085. type TempFun struct {
  6086. FundKey string
  6087. FundCode string
  6088. }
  6089. func (c *HisApiController) Get3262() {
  6090. admin_user_id, _ := c.GetInt64("admin_user_id")
  6091. startTime := c.GetString("start_time")
  6092. endTime := c.GetString("end_time")
  6093. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6094. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6095. //timeLayout := "2006-01-02"
  6096. //loc, _ := time.LoadLocation("Local")
  6097. //var theStartTIme int64
  6098. //if len(startTime) > 0 {
  6099. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6100. // if err != nil {
  6101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6102. // return
  6103. // }
  6104. // theStartTIme = theTime.Unix()
  6105. //}
  6106. //var theEndtTIme int64
  6107. //if len(endTime) > 0 {
  6108. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6109. // if err != nil {
  6110. // utils.ErrorLog(err.Error())
  6111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6112. // return
  6113. // }
  6114. // theEndtTIme = theTime.Unix()
  6115. //}
  6116. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6117. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6118. for _, team := range datas {
  6119. fmt.Println(team.PsnTime)
  6120. for _, team_two := range datas_two {
  6121. fmt.Println(team_two.PsnTime)
  6122. if team.FundKey == team_two.FundKey {
  6123. fmt.Println(team_two.PsnTime)
  6124. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6125. fmt.Println(team.PsnTime)
  6126. }
  6127. }
  6128. }
  6129. fmt.Println("1111")
  6130. fmt.Println(datas)
  6131. fmt.Println("1111")
  6132. var twos []models.FixMonRecDetailFileInTwo
  6133. for _, team := range datas {
  6134. var two models.FixMonRecDetailFileInTwo
  6135. two.MedType = team.MedType
  6136. two.Insutype = team.Insutype
  6137. two.PsnType = team.PsnType
  6138. two.MedType = team.MedType
  6139. two.FixBlngAdmdvs = "999999"
  6140. two.InsuAdmdvs = "555555"
  6141. two.PsnTime = team.PsnTime
  6142. two.PsnCnt = team.PsnCnt
  6143. two.FundKey = team.FundKey
  6144. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6145. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6146. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6147. two.MedfeeSumAmt = ms
  6148. two.InscpAmt = ia
  6149. two.FundPaySumAmt = fps
  6150. twos = append(twos, two)
  6151. }
  6152. //startTime := c.GetString("start_time")
  6153. //endTime, _ := c.GetString("end_time")
  6154. times := strings.Split(startTime, "-")
  6155. stmt_mon := times[0] + times[1]
  6156. var funs []models.FundDetail
  6157. for _, item := range datas {
  6158. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6159. funs = append(funs, fun...)
  6160. }
  6161. var funInfos []models.Fund
  6162. //for _, item := range funs {
  6163. // var rf []models.FundInfo
  6164. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6165. // for _, subitem := range rf {
  6166. // var fund models.Fund
  6167. // fund.FundCode = subitem.FundPayType
  6168. // fund.FundName = subitem.FundPayTypeName
  6169. // fund.FundAmt = subitem.FundPayAmt
  6170. // fund.FundKey = item.FundKey
  6171. // fund.InsuAdmdvs = "555555"
  6172. // fund.FixBlngAdmdvs = "999999"
  6173. // funInfos = append(funInfos, fund)
  6174. // }
  6175. //}
  6176. var tempFuns []TempFun
  6177. for _, funInfo := range funInfos {
  6178. var tempFun TempFun
  6179. tempFun.FundKey = funInfo.FundKey
  6180. tempFun.FundCode = funInfo.FundCode
  6181. tempFuns = append(tempFuns, tempFun)
  6182. }
  6183. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6184. fmt.Println(tempFuns)
  6185. var funInfosTwo []models.Fund
  6186. decimal.DivisionPrecision = 2
  6187. for _, item := range tempFuns {
  6188. var fund models.Fund
  6189. for _, subItem := range funInfos {
  6190. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6191. fund.FundKey = subItem.FundKey
  6192. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6193. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6194. fund.FundName = subItem.FundName
  6195. fund.FundCode = subItem.FundCode
  6196. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6197. }
  6198. }
  6199. funInfosTwo = append(funInfosTwo, fund)
  6200. }
  6201. fmt.Println("funInfosTwo")
  6202. fmt.Println(funInfosTwo)
  6203. var upld_btch string
  6204. var empty models.JSResultEmpty
  6205. data := make(map[string]interface{})
  6206. data["org_name"] = miConfig.OrgName
  6207. data["doctor"] = curRoles.UserName
  6208. data["doctor_name"] = curRoles.UserName
  6209. data["fixmedins_code"] = miConfig.Code
  6210. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6211. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6212. data["secret_key"] = miConfig.SecretKey
  6213. data["url"] = miConfig.Url
  6214. data["ak"] = miConfig.AccessKey
  6215. data["cainfo"] = miConfig.Cainfo
  6216. data["datas"] = twos
  6217. data["fund"] = funInfosTwo
  6218. fmt.Println(twos)
  6219. month := time.Unix(1557042972, 0).Format("1")
  6220. year := time.Now().Format("2006")
  6221. month = time.Now().Format("01")
  6222. day := time.Now().Format("02")
  6223. hour := time.Now().Format("15")
  6224. min := time.Now().Format("04")
  6225. sec := time.Now().Format("05")
  6226. fix_fill_date := year + month + day + hour + min + sec
  6227. data["fix_fill_dept"] = miConfig.OrgName
  6228. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6229. data["fix_fill_psn"] = curRoles.UserName
  6230. data["fix_fill_date"] = fix_fill_date
  6231. data["stmt_loc"] = "2"
  6232. data["setl_mon"] = stmt_mon
  6233. upld_btch = "0"
  6234. data["upld_btch"] = upld_btch
  6235. //fmt.Println(data)
  6236. client := &http.Client{}
  6237. bytesData, _ := json.Marshal(data)
  6238. var req *http.Request
  6239. if miConfig.MdtrtareaAdmvs == "320921" {
  6240. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6241. } else {
  6242. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6243. }
  6244. resp, _ := client.Do(req)
  6245. defer resp.Body.Close()
  6246. body, ioErr := ioutil.ReadAll(resp.Body)
  6247. if ioErr != nil {
  6248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6250. }
  6251. var respJSON map[string]interface{}
  6252. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6255. }
  6256. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6257. //fmt.Println(respJSON)
  6258. result, _ := json.Marshal(respJSON)
  6259. //fmt.Println(result)
  6260. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6261. utils.ErrorLog("解析失败:%v", err)
  6262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6263. }
  6264. if empty.Infcode != "0" {
  6265. c.ServeSuccessJSON(map[string]interface{}{
  6266. "failed_code": -10,
  6267. "msg": empty.ErrMsg,
  6268. })
  6269. return
  6270. } else {
  6271. c.ServeSuccessJSON(map[string]interface{}{
  6272. "msg": "上传成功",
  6273. })
  6274. return
  6275. }
  6276. }
  6277. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6278. newArr = make([]TempFun, 0)
  6279. for i := 0; i < len(arr); i++ {
  6280. repeat := false
  6281. for j := i + 1; j < len(arr); j++ {
  6282. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6283. repeat = true
  6284. break
  6285. }
  6286. }
  6287. if !repeat {
  6288. newArr = append(newArr, arr[i])
  6289. }
  6290. }
  6291. return
  6292. }
  6293. func (c *HisApiController) Get3263() {
  6294. admin_user_id, _ := c.GetInt64("admin_user_id")
  6295. startTime := c.GetString("start_time")
  6296. //endTime, _ := c.GetString("end_time")
  6297. times := strings.Split(startTime, "-")
  6298. setl_mon := times[0] + times[1]
  6299. upld_btch := "0"
  6300. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6301. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6302. var result3263 models.JSResult3263
  6303. data := make(map[string]interface{})
  6304. data["org_name"] = miConfig.OrgName
  6305. data["doctor"] = curRoles.UserName
  6306. data["doctor_name"] = curRoles.UserName
  6307. data["fixmedins_code"] = miConfig.Code
  6308. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6309. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6310. data["secret_key"] = miConfig.SecretKey
  6311. data["url"] = miConfig.Url
  6312. data["ak"] = miConfig.AccessKey
  6313. data["cainfo"] = miConfig.Cainfo
  6314. data["setl_mon"] = setl_mon
  6315. data["stmt_loc"] = "2"
  6316. data["upld_btch"] = upld_btch
  6317. client := &http.Client{}
  6318. bytesData, _ := json.Marshal(data)
  6319. var req *http.Request
  6320. if miConfig.MdtrtareaAdmvs == "320921" {
  6321. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6322. } else {
  6323. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6324. }
  6325. resp, _ := client.Do(req)
  6326. defer resp.Body.Close()
  6327. body, ioErr := ioutil.ReadAll(resp.Body)
  6328. if ioErr != nil {
  6329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6331. }
  6332. var respJSON map[string]interface{}
  6333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6336. }
  6337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6338. fmt.Println(respJSON)
  6339. result, _ := json.Marshal(respJSON)
  6340. fmt.Println(result)
  6341. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6342. utils.ErrorLog("解析失败:%v", err)
  6343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6344. }
  6345. if result3263.Infcode != "0" {
  6346. c.ServeSuccessJSON(map[string]interface{}{
  6347. "failed_code": -10,
  6348. "msg": result3263.ErrMsg,
  6349. })
  6350. return
  6351. } else {
  6352. c.ServeSuccessJSON(map[string]interface{}{
  6353. "list": result3263.Output,
  6354. })
  6355. return
  6356. }
  6357. }
  6358. func (c *HisApiController) Get3264() {
  6359. admin_user_id, _ := c.GetInt64("admin_user_id")
  6360. startTime := c.GetString("start_time")
  6361. //endTime, _ := c.GetString("end_time")
  6362. times := strings.Split(startTime, "-")
  6363. setl_mon := times[0] + times[1]
  6364. upld_btch := "0"
  6365. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6366. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6367. //solidify_id := []
  6368. var result3263 models.JSResult3263
  6369. data := make(map[string]interface{})
  6370. data["org_name"] = miConfig.OrgName
  6371. data["doctor"] = curRoles.UserName
  6372. data["doctor_name"] = curRoles.UserName
  6373. data["fixmedins_code"] = miConfig.Code
  6374. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6375. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6376. data["secret_key"] = miConfig.SecretKey
  6377. data["url"] = miConfig.Url
  6378. data["ak"] = miConfig.AccessKey
  6379. data["cainfo"] = miConfig.Cainfo
  6380. data["setl_mon"] = setl_mon
  6381. data["stmt_loc"] = "2"
  6382. data["upld_btch"] = upld_btch
  6383. client := &http.Client{}
  6384. bytesData, _ := json.Marshal(data)
  6385. var req3263 *http.Request
  6386. if miConfig.MdtrtareaAdmvs == "320921" {
  6387. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6388. } else {
  6389. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6390. }
  6391. resp, _ := client.Do(req3263)
  6392. defer resp.Body.Close()
  6393. body, ioErr := ioutil.ReadAll(resp.Body)
  6394. if ioErr != nil {
  6395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6397. }
  6398. var respJSON3263 map[string]interface{}
  6399. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6402. }
  6403. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6404. fmt.Println(respJSON3263)
  6405. result, _ := json.Marshal(respJSON3263)
  6406. fmt.Println(result)
  6407. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6408. utils.ErrorLog("解析失败:%v", err)
  6409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6410. }
  6411. var ids []string
  6412. for _, item := range result3263.Output {
  6413. ids = append(ids, item.SolidifyID)
  6414. }
  6415. var empty models.JSResultEmpty
  6416. data2 := make(map[string]interface{})
  6417. data2["org_name"] = miConfig.OrgName
  6418. data2["doctor"] = curRoles.UserName
  6419. data2["doctor_name"] = curRoles.UserName
  6420. data2["fixmedins_code"] = miConfig.Code
  6421. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6422. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6423. data2["secret_key"] = miConfig.SecretKey
  6424. data2["url"] = miConfig.Url
  6425. data2["ak"] = miConfig.AccessKey
  6426. data2["cainfo"] = miConfig.Cainfo
  6427. data2["setl_mon"] = setl_mon
  6428. data2["stmt_loc"] = "2"
  6429. data2["upld_btch"] = upld_btch
  6430. data2["solidify_id"] = ids
  6431. client2 := &http.Client{}
  6432. bytesData2, _ := json.Marshal(data2)
  6433. var req *http.Request
  6434. if miConfig.MdtrtareaAdmvs == "320921" {
  6435. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6436. } else {
  6437. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6438. }
  6439. resp2, _ := client2.Do(req)
  6440. defer resp.Body.Close()
  6441. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6442. if ioErr2 != nil {
  6443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6445. }
  6446. var respJSON map[string]interface{}
  6447. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6450. }
  6451. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6452. fmt.Println(respJSON)
  6453. result2, _ := json.Marshal(respJSON)
  6454. fmt.Println(result2)
  6455. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6456. utils.ErrorLog("解析失败:%v", err)
  6457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6458. }
  6459. if empty.Infcode != "0" {
  6460. c.ServeSuccessJSON(map[string]interface{}{
  6461. "failed_code": -10,
  6462. "msg": empty.ErrMsg,
  6463. })
  6464. return
  6465. } else {
  6466. c.ServeSuccessJSON(map[string]interface{}{
  6467. "msg": "",
  6468. })
  6469. return
  6470. }
  6471. }
  6472. func (c *HisApiController) Get3265() {
  6473. admin_user_id, _ := c.GetInt64("admin_user_id")
  6474. startTime := c.GetString("start_time")
  6475. //endTime, _ := c.GetString("end_time")
  6476. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6477. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6478. times := strings.Split(startTime, "-")
  6479. setl_mon := times[0] + times[1]
  6480. var upld_btch string
  6481. upld_btch = "0"
  6482. //var empty models.JSResultEmpty
  6483. var result3265 models.JSResult3264
  6484. var result3263 models.JSResult3263
  6485. data2 := make(map[string]interface{})
  6486. data2["org_name"] = miConfig.OrgName
  6487. data2["doctor"] = curRoles.UserName
  6488. data2["doctor_name"] = curRoles.UserName
  6489. data2["fixmedins_code"] = miConfig.Code
  6490. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6491. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6492. data2["secret_key"] = miConfig.SecretKey
  6493. data2["url"] = miConfig.Url
  6494. data2["ak"] = miConfig.AccessKey
  6495. data2["cainfo"] = miConfig.Cainfo
  6496. data2["setl_mon"] = setl_mon
  6497. data2["stmt_loc"] = "2"
  6498. data2["upld_btch"] = upld_btch
  6499. client2 := &http.Client{}
  6500. bytesData2, _ := json.Marshal(data2)
  6501. var req3263 *http.Request
  6502. if miConfig.MdtrtareaAdmvs == "320921" {
  6503. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6504. } else {
  6505. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6506. }
  6507. resp2, _ := client2.Do(req3263)
  6508. defer resp2.Body.Close()
  6509. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6510. if ioErr2 != nil {
  6511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6513. }
  6514. var respJSON3263 map[string]interface{}
  6515. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6518. }
  6519. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6520. fmt.Println(respJSON3263)
  6521. result2, _ := json.Marshal(respJSON3263)
  6522. fmt.Println(result2)
  6523. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6524. utils.ErrorLog("解析失败:%v", err)
  6525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6526. }
  6527. var ids []string
  6528. for _, item := range result3263.Output {
  6529. ids = append(ids, item.SolidifyID)
  6530. }
  6531. data := make(map[string]interface{})
  6532. data["org_name"] = miConfig.OrgName
  6533. data["doctor"] = curRoles.UserName
  6534. data["doctor_name"] = curRoles.UserName
  6535. data["fixmedins_code"] = miConfig.Code
  6536. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6537. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6538. data["secret_key"] = miConfig.SecretKey
  6539. data["url"] = miConfig.Url
  6540. data["ak"] = miConfig.AccessKey
  6541. data["cainfo"] = miConfig.Cainfo
  6542. data["setl_mon"] = setl_mon
  6543. data["solidify_id"] = ids
  6544. month := time.Unix(1557042972, 0).Format("1")
  6545. year := time.Now().Format("2006")
  6546. month = time.Now().Format("01")
  6547. day := time.Now().Format("02")
  6548. hour := time.Now().Format("15")
  6549. min := time.Now().Format("04")
  6550. sec := time.Now().Format("05")
  6551. fix_fill_date := year + month + day + hour + min + sec
  6552. data["fix_fill_dept"] = miConfig.OrgName
  6553. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6554. data["fix_fill_psn"] = curRoles.UserName
  6555. data["fix_fill_date"] = fix_fill_date
  6556. data["stmt_loc"] = "2"
  6557. data["upld_btch"] = upld_btch
  6558. client := &http.Client{}
  6559. bytesData, _ := json.Marshal(data)
  6560. var req *http.Request
  6561. if miConfig.MdtrtareaAdmvs == "320921" {
  6562. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6563. } else {
  6564. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6565. }
  6566. resp, _ := client.Do(req)
  6567. defer resp.Body.Close()
  6568. body, ioErr := ioutil.ReadAll(resp.Body)
  6569. if ioErr != nil {
  6570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6572. }
  6573. var respJSON map[string]interface{}
  6574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6577. }
  6578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6579. fmt.Println(respJSON)
  6580. result, _ := json.Marshal(respJSON)
  6581. fmt.Println(result)
  6582. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6583. utils.ErrorLog("解析失败:%v", err)
  6584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6585. }
  6586. if result3265.Infcode != "0" {
  6587. c.ServeSuccessJSON(map[string]interface{}{
  6588. "failed_code": -10,
  6589. "msg": result3265.ErrMsg,
  6590. })
  6591. return
  6592. } else {
  6593. c.ServeSuccessJSON(map[string]interface{}{
  6594. "info": result3265.Output,
  6595. })
  6596. return
  6597. }
  6598. }
  6599. func (c *HisApiController) Get3266() {
  6600. admin_user_id, _ := c.GetInt64("admin_user_id")
  6601. startTime := c.GetString("start_time")
  6602. //endTime, _ := c.GetString("end_time")
  6603. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6604. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6605. times := strings.Split(startTime, "-")
  6606. stmt_mon := times[0] + times[1]
  6607. var upld_btch string
  6608. //var empty models.JSResultEmpty
  6609. var result3265 models.JSResult3264
  6610. data := make(map[string]interface{})
  6611. data["org_name"] = miConfig.OrgName
  6612. data["doctor"] = curRoles.UserName
  6613. data["doctor_name"] = curRoles.UserName
  6614. data["fixmedins_code"] = miConfig.Code
  6615. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6616. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6617. data["secret_key"] = miConfig.SecretKey
  6618. data["url"] = miConfig.Url
  6619. data["ak"] = miConfig.AccessKey
  6620. data["cainfo"] = miConfig.Cainfo
  6621. data["setl_mon"] = stmt_mon
  6622. month := time.Unix(1557042972, 0).Format("1")
  6623. year := time.Now().Format("2006")
  6624. month = time.Now().Format("01")
  6625. day := time.Now().Format("02")
  6626. hour := time.Now().Format("15")
  6627. min := time.Now().Format("04")
  6628. sec := time.Now().Format("05")
  6629. fix_fill_date := year + month + day + hour + min + sec
  6630. data["fix_fill_dept"] = miConfig.OrgName
  6631. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6632. data["fix_fill_psn"] = curRoles.UserName
  6633. data["fix_fill_date"] = fix_fill_date
  6634. data["stmt_loc"] = "2"
  6635. upld_btch = "0"
  6636. data["upld_btch"] = upld_btch
  6637. client := &http.Client{}
  6638. bytesData, _ := json.Marshal(data)
  6639. var req *http.Request
  6640. if miConfig.MdtrtareaAdmvs == "320921" {
  6641. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6642. } else {
  6643. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6644. }
  6645. resp, _ := client.Do(req)
  6646. defer resp.Body.Close()
  6647. body, ioErr := ioutil.ReadAll(resp.Body)
  6648. if ioErr != nil {
  6649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6651. }
  6652. var respJSON map[string]interface{}
  6653. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6656. }
  6657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6658. fmt.Println(respJSON)
  6659. result, _ := json.Marshal(respJSON)
  6660. fmt.Println(result)
  6661. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6662. utils.ErrorLog("解析失败:%v", err)
  6663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6664. }
  6665. if result3265.Infcode != "0" {
  6666. c.ServeSuccessJSON(map[string]interface{}{
  6667. "failed_code": -10,
  6668. "msg": result3265.ErrMsg,
  6669. })
  6670. return
  6671. } else {
  6672. c.ServeSuccessJSON(map[string]interface{}{
  6673. "info": result3265.Output,
  6674. })
  6675. return
  6676. }
  6677. }
  6678. func (c *HisApiController) Get3267() {
  6679. admin_user_id, _ := c.GetInt64("admin_user_id")
  6680. startTime := c.GetString("start_time")
  6681. //endTime, _ := c.GetString("end_time")
  6682. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6683. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6684. times := strings.Split(startTime, "-")
  6685. setl_mon := times[0] + times[1]
  6686. var upld_btch string
  6687. //var empty models.JSResultEmpty
  6688. var result3265 models.JSResult3264
  6689. upld_btch = "0"
  6690. data := make(map[string]interface{})
  6691. data["org_name"] = miConfig.OrgName
  6692. data["doctor"] = curRoles.UserName
  6693. data["doctor_name"] = curRoles.UserName
  6694. data["fixmedins_code"] = miConfig.Code
  6695. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6696. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6697. data["secret_key"] = miConfig.SecretKey
  6698. data["url"] = miConfig.Url
  6699. data["ak"] = miConfig.AccessKey
  6700. data["cainfo"] = miConfig.Cainfo
  6701. data["setl_mon"] = setl_mon
  6702. data["stmt_loc"] = "2"
  6703. data["upld_btch"] = upld_btch
  6704. client := &http.Client{}
  6705. bytesData, _ := json.Marshal(data)
  6706. var req *http.Request
  6707. if miConfig.MdtrtareaAdmvs == "320921" {
  6708. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6709. } else {
  6710. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6711. }
  6712. resp, _ := client.Do(req)
  6713. defer resp.Body.Close()
  6714. body, ioErr := ioutil.ReadAll(resp.Body)
  6715. if ioErr != nil {
  6716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6718. }
  6719. var respJSON map[string]interface{}
  6720. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6723. }
  6724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6725. fmt.Println(respJSON)
  6726. result, _ := json.Marshal(respJSON)
  6727. fmt.Println(result)
  6728. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6729. utils.ErrorLog("解析失败:%v", err)
  6730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6731. }
  6732. if result3265.Infcode != "0" {
  6733. c.ServeSuccessJSON(map[string]interface{}{
  6734. "failed_code": -10,
  6735. "msg": result3265.ErrMsg,
  6736. })
  6737. return
  6738. } else {
  6739. c.ServeSuccessJSON(map[string]interface{}{
  6740. "info": result3265.Output.Data,
  6741. })
  6742. return
  6743. }
  6744. }
  6745. func (c *HisApiController) Get3268() {
  6746. admin_user_id, _ := c.GetInt64("admin_user_id")
  6747. startTime := c.GetString("start_time")
  6748. endTime := c.GetString("end_time")
  6749. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6750. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6751. times := strings.Split(startTime, "-")
  6752. setl_mon := times[0] + times[1]
  6753. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6754. var twos []models.FixMonRecDetailFileInTwo
  6755. var funs []models.FundDetail
  6756. for _, item := range datas {
  6757. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6758. funs = append(funs, fun...)
  6759. }
  6760. var funInfos []models.Fund
  6761. //for _, item := range funs {
  6762. // var rf []models.FundInfo
  6763. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6764. // for _, subitem := range rf {
  6765. // var fund models.Fund
  6766. // fund.FundCode = subitem.FundPayType
  6767. // fund.FundName = subitem.FundPayTypeName
  6768. // fund.FundAmt = subitem.FundPayAmt
  6769. // fund.FundKey = item.FundKey
  6770. // fund.InsuAdmdvs = "555555"
  6771. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6772. // funInfos = append(funInfos, fund)
  6773. // }
  6774. //}
  6775. for _, team := range datas {
  6776. var two models.FixMonRecDetailFileInTwo
  6777. two.SetlDate = time.Now().Format("2006-01-02")
  6778. two.MedType = team.MedType
  6779. two.Insutype = team.Insutype
  6780. two.PsnType = team.PsnType
  6781. two.MedType = team.MedType
  6782. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6783. two.InsuAdmdvs = team.InsuAdmdvs
  6784. two.PsnTime = team.PsnTime
  6785. two.PsnCnt = team.PsnCnt
  6786. two.FundKey = team.FundKey
  6787. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6788. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6789. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6790. two.MedfeeSumAmt = ms
  6791. two.InscpAmt = ia
  6792. two.FundPaySumAmt = fps
  6793. twos = append(twos, two)
  6794. }
  6795. var upld_btch string
  6796. upld_btch = "0"
  6797. var empty models.JSResultEmpty
  6798. data := make(map[string]interface{})
  6799. data["org_name"] = miConfig.OrgName
  6800. data["doctor"] = curRoles.UserName
  6801. data["doctor_name"] = curRoles.UserName
  6802. data["fixmedins_code"] = miConfig.Code
  6803. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6804. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6805. data["secret_key"] = miConfig.SecretKey
  6806. data["url"] = miConfig.Url
  6807. data["ak"] = miConfig.AccessKey
  6808. data["cainfo"] = miConfig.Cainfo
  6809. data["datas"] = twos
  6810. data["fund"] = funInfos
  6811. data["setl_mon"] = setl_mon
  6812. month := time.Unix(1557042972, 0).Format("1")
  6813. year := time.Now().Format("2006")
  6814. month = time.Now().Format("01")
  6815. day := time.Now().Format("02")
  6816. hour := time.Now().Format("15")
  6817. min := time.Now().Format("04")
  6818. sec := time.Now().Format("05")
  6819. fix_fill_date := year + month + day + hour + min + sec
  6820. data["fix_fill_dept"] = miConfig.OrgName
  6821. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6822. data["fix_fill_psn"] = curRoles.UserName
  6823. data["fix_fill_date"] = fix_fill_date
  6824. data["stmt_loc"] = "2"
  6825. data["upld_btch"] = upld_btch
  6826. client := &http.Client{}
  6827. bytesData, _ := json.Marshal(data)
  6828. var req *http.Request
  6829. if miConfig.MdtrtareaAdmvs == "320921" {
  6830. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6831. } else {
  6832. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6833. }
  6834. resp, _ := client.Do(req)
  6835. defer resp.Body.Close()
  6836. body, ioErr := ioutil.ReadAll(resp.Body)
  6837. if ioErr != nil {
  6838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6840. }
  6841. var respJSON map[string]interface{}
  6842. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6845. }
  6846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6847. fmt.Println(respJSON)
  6848. result, _ := json.Marshal(respJSON)
  6849. fmt.Println(result)
  6850. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6851. utils.ErrorLog("解析失败:%v", err)
  6852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6853. }
  6854. if empty.Infcode != "0" {
  6855. c.ServeSuccessJSON(map[string]interface{}{
  6856. "failed_code": -10,
  6857. "msg": empty.ErrMsg,
  6858. })
  6859. return
  6860. } else {
  6861. c.ServeSuccessJSON(map[string]interface{}{
  6862. "msg": "上传成功",
  6863. })
  6864. return
  6865. }
  6866. }
  6867. func (c *HisApiController) Get3269() {
  6868. admin_user_id, _ := c.GetInt64("admin_user_id")
  6869. startTime := c.GetString("start_time")
  6870. //endTime, _ := c.GetString("end_time")
  6871. times := strings.Split(startTime, "-")
  6872. setl_mon := times[0] + times[1]
  6873. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6874. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6875. var result3263 models.JSResult3263
  6876. data := make(map[string]interface{})
  6877. data["org_name"] = miConfig.OrgName
  6878. data["doctor"] = curRoles.UserName
  6879. data["doctor_name"] = curRoles.UserName
  6880. data["fixmedins_code"] = miConfig.Code
  6881. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6882. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6883. data["secret_key"] = miConfig.SecretKey
  6884. data["url"] = miConfig.Url
  6885. data["ak"] = miConfig.AccessKey
  6886. data["cainfo"] = miConfig.Cainfo
  6887. data["setl_mon"] = setl_mon
  6888. data["stmt_loc"] = "2"
  6889. client := &http.Client{}
  6890. bytesData, _ := json.Marshal(data)
  6891. var req *http.Request
  6892. if miConfig.MdtrtareaAdmvs == "320921" {
  6893. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6894. } else {
  6895. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6896. }
  6897. resp, _ := client.Do(req)
  6898. defer resp.Body.Close()
  6899. body, ioErr := ioutil.ReadAll(resp.Body)
  6900. if ioErr != nil {
  6901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6903. }
  6904. var respJSON map[string]interface{}
  6905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6908. }
  6909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6910. fmt.Println(respJSON)
  6911. result, _ := json.Marshal(respJSON)
  6912. fmt.Println(result)
  6913. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6914. utils.ErrorLog("解析失败:%v", err)
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. }
  6917. if result3263.Infcode != "0" {
  6918. c.ServeSuccessJSON(map[string]interface{}{
  6919. "failed_code": -10,
  6920. "msg": result3263.ErrMsg,
  6921. })
  6922. return
  6923. } else {
  6924. c.ServeSuccessJSON(map[string]interface{}{
  6925. "msg": "上传成功",
  6926. })
  6927. return
  6928. }
  6929. }
  6930. func (c *HisApiController) Get3270() {
  6931. admin_user_id, _ := c.GetInt64("admin_user_id")
  6932. startTime := c.GetString("start_time")
  6933. //endTime, _ := c.GetString("end_time")
  6934. times := strings.Split(startTime, "-")
  6935. setl_mon := times[0] + times[1]
  6936. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6937. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6938. var result3263 models.JSResult3263
  6939. data2 := make(map[string]interface{})
  6940. data2["org_name"] = miConfig.OrgName
  6941. data2["doctor"] = curRoles.UserName
  6942. data2["doctor_name"] = curRoles.UserName
  6943. data2["fixmedins_code"] = miConfig.Code
  6944. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6945. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6946. data2["secret_key"] = miConfig.SecretKey
  6947. data2["url"] = miConfig.Url
  6948. data2["ak"] = miConfig.AccessKey
  6949. data2["cainfo"] = miConfig.Cainfo
  6950. data2["setl_mon"] = setl_mon
  6951. data2["stmt_loc"] = "2"
  6952. client2 := &http.Client{}
  6953. bytesData2, _ := json.Marshal(data2)
  6954. var req3263 *http.Request
  6955. if miConfig.MdtrtareaAdmvs == "320921" {
  6956. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6957. } else {
  6958. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6959. }
  6960. resp2, _ := client2.Do(req3263)
  6961. defer resp2.Body.Close()
  6962. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6963. if ioErr2 != nil {
  6964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6966. }
  6967. var respJSON3263 map[string]interface{}
  6968. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6971. }
  6972. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6973. fmt.Println(respJSON3263)
  6974. result2, _ := json.Marshal(respJSON3263)
  6975. fmt.Println(result2)
  6976. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6977. utils.ErrorLog("解析失败:%v", err)
  6978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6979. }
  6980. var ids []string
  6981. for _, item := range result3263.Output {
  6982. ids = append(ids, item.SolidifyID)
  6983. }
  6984. var result3264 models.JSResult3264
  6985. data := make(map[string]interface{})
  6986. data["org_name"] = miConfig.OrgName
  6987. data["doctor"] = curRoles.UserName
  6988. data["doctor_name"] = curRoles.UserName
  6989. data["fixmedins_code"] = miConfig.Code
  6990. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6991. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6992. data["secret_key"] = miConfig.SecretKey
  6993. data["url"] = miConfig.Url
  6994. data["ak"] = miConfig.AccessKey
  6995. data["cainfo"] = miConfig.Cainfo
  6996. data["setl_mon"] = setl_mon
  6997. data["stmt_loc"] = "2"
  6998. data["solidify_id"] = ids
  6999. client := &http.Client{}
  7000. bytesData, _ := json.Marshal(data)
  7001. var req *http.Request
  7002. if miConfig.MdtrtareaAdmvs == "320921" {
  7003. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7004. } else {
  7005. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7006. }
  7007. resp, _ := client.Do(req)
  7008. defer resp.Body.Close()
  7009. body, ioErr := ioutil.ReadAll(resp.Body)
  7010. if ioErr != nil {
  7011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7013. }
  7014. var respJSON map[string]interface{}
  7015. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7018. }
  7019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7020. fmt.Println(respJSON)
  7021. result, _ := json.Marshal(respJSON)
  7022. fmt.Println(result)
  7023. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7024. utils.ErrorLog("解析失败:%v", err)
  7025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7026. }
  7027. if result3264.Infcode != "0" {
  7028. c.ServeSuccessJSON(map[string]interface{}{
  7029. "failed_code": -10,
  7030. "msg": result3264.ErrMsg,
  7031. })
  7032. return
  7033. } else {
  7034. c.ServeSuccessJSON(map[string]interface{}{
  7035. "info": result3264.Output,
  7036. })
  7037. return
  7038. }
  7039. }
  7040. func (c *HisApiController) Get3271() {
  7041. admin_user_id, _ := c.GetInt64("admin_user_id")
  7042. startTime := c.GetString("start_time")
  7043. //endTime, _ := c.GetString("end_time")
  7044. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7045. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7046. times := strings.Split(startTime, "-")
  7047. setl_mon := times[0] + times[1]
  7048. //var empty models.JSResultEmpty
  7049. var result3265 models.JSResult3264
  7050. var result3263 models.JSResult3263
  7051. data2 := make(map[string]interface{})
  7052. data2["org_name"] = miConfig.OrgName
  7053. data2["doctor"] = curRoles.UserName
  7054. data2["doctor_name"] = curRoles.UserName
  7055. data2["fixmedins_code"] = miConfig.Code
  7056. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7057. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7058. data2["secret_key"] = miConfig.SecretKey
  7059. data2["url"] = miConfig.Url
  7060. data2["ak"] = miConfig.AccessKey
  7061. data2["cainfo"] = miConfig.Cainfo
  7062. data2["setl_mon"] = setl_mon
  7063. data2["stmt_loc"] = "2"
  7064. client2 := &http.Client{}
  7065. bytesData2, _ := json.Marshal(data2)
  7066. var req3263 *http.Request
  7067. if miConfig.MdtrtareaAdmvs == "320921" {
  7068. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7069. } else {
  7070. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7071. }
  7072. resp2, _ := client2.Do(req3263)
  7073. defer resp2.Body.Close()
  7074. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7075. if ioErr2 != nil {
  7076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7078. }
  7079. var respJSON3263 map[string]interface{}
  7080. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7083. }
  7084. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7085. fmt.Println(respJSON3263)
  7086. result2, _ := json.Marshal(respJSON3263)
  7087. fmt.Println(result2)
  7088. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7089. utils.ErrorLog("解析失败:%v", err)
  7090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7091. }
  7092. var ids []string
  7093. for _, item := range result3263.Output {
  7094. ids = append(ids, item.SolidifyID)
  7095. }
  7096. data := make(map[string]interface{})
  7097. data["org_name"] = miConfig.OrgName
  7098. data["doctor"] = curRoles.UserName
  7099. data["doctor_name"] = curRoles.UserName
  7100. data["fixmedins_code"] = miConfig.Code
  7101. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7102. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7103. data["secret_key"] = miConfig.SecretKey
  7104. data["url"] = miConfig.Url
  7105. data["ak"] = miConfig.AccessKey
  7106. data["cainfo"] = miConfig.Cainfo
  7107. data["setl_mon"] = setl_mon
  7108. data["solidify_id"] = ids
  7109. month := time.Unix(1557042972, 0).Format("1")
  7110. year := time.Now().Format("2006")
  7111. month = time.Now().Format("01")
  7112. day := time.Now().Format("02")
  7113. hour := time.Now().Format("15")
  7114. min := time.Now().Format("04")
  7115. sec := time.Now().Format("05")
  7116. fix_fill_date := year + month + day + hour + min + sec
  7117. data["fix_fill_dept"] = miConfig.OrgName
  7118. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7119. data["fix_fill_psn"] = curRoles.UserName
  7120. data["fix_fill_date"] = fix_fill_date
  7121. data["stmt_loc"] = "2"
  7122. client := &http.Client{}
  7123. bytesData, _ := json.Marshal(data)
  7124. var req *http.Request
  7125. if miConfig.MdtrtareaAdmvs == "320921" {
  7126. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7127. } else {
  7128. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7129. }
  7130. resp, _ := client.Do(req)
  7131. defer resp.Body.Close()
  7132. body, ioErr := ioutil.ReadAll(resp.Body)
  7133. if ioErr != nil {
  7134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7136. }
  7137. var respJSON map[string]interface{}
  7138. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7141. }
  7142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7143. fmt.Println(respJSON)
  7144. result, _ := json.Marshal(respJSON)
  7145. fmt.Println(result)
  7146. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7147. utils.ErrorLog("解析失败:%v", err)
  7148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7149. }
  7150. if result3265.Infcode != "0" {
  7151. c.ServeSuccessJSON(map[string]interface{}{
  7152. "failed_code": -10,
  7153. "msg": result3265.ErrMsg,
  7154. })
  7155. return
  7156. } else {
  7157. c.ServeSuccessJSON(map[string]interface{}{
  7158. "info": result3265.Output.Data,
  7159. })
  7160. return
  7161. }
  7162. }
  7163. func (c *HisApiController) Get3272() {
  7164. admin_user_id, _ := c.GetInt64("admin_user_id")
  7165. startTime := c.GetString("start_time")
  7166. //endTime, _ := c.GetString("end_time")
  7167. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7169. times := strings.Split(startTime, "-")
  7170. setl_mon := times[0] + times[1]
  7171. var upld_btch string
  7172. //var empty models.JSResultEmpty
  7173. var result3265 models.JSResult3264
  7174. data := make(map[string]interface{})
  7175. data["org_name"] = miConfig.OrgName
  7176. data["doctor"] = curRoles.UserName
  7177. data["doctor_name"] = curRoles.UserName
  7178. data["fixmedins_code"] = miConfig.Code
  7179. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7180. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7181. data["secret_key"] = miConfig.SecretKey
  7182. data["url"] = miConfig.Url
  7183. data["ak"] = miConfig.AccessKey
  7184. data["cainfo"] = miConfig.Cainfo
  7185. data["setl_mon"] = setl_mon
  7186. month := time.Unix(1557042972, 0).Format("1")
  7187. year := time.Now().Format("2006")
  7188. month = time.Now().Format("01")
  7189. day := time.Now().Format("02")
  7190. hour := time.Now().Format("15")
  7191. min := time.Now().Format("04")
  7192. sec := time.Now().Format("05")
  7193. fix_fill_date := year + month + day + hour + min + sec
  7194. data["fix_fill_dept"] = miConfig.OrgName
  7195. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7196. data["fix_fill_psn"] = curRoles.UserName
  7197. data["fix_fill_date"] = fix_fill_date
  7198. data["stmt_loc"] = "2"
  7199. data["upld_btch"] = upld_btch
  7200. client := &http.Client{}
  7201. bytesData, _ := json.Marshal(data)
  7202. var req *http.Request
  7203. if miConfig.MdtrtareaAdmvs == "320921" {
  7204. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7205. } else {
  7206. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7207. }
  7208. resp, _ := client.Do(req)
  7209. defer resp.Body.Close()
  7210. body, ioErr := ioutil.ReadAll(resp.Body)
  7211. if ioErr != nil {
  7212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7214. }
  7215. var respJSON map[string]interface{}
  7216. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7219. }
  7220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7221. fmt.Println(respJSON)
  7222. result, _ := json.Marshal(respJSON)
  7223. fmt.Println(result)
  7224. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7225. utils.ErrorLog("解析失败:%v", err)
  7226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7227. }
  7228. if result3265.Infcode != "0" {
  7229. c.ServeSuccessJSON(map[string]interface{}{
  7230. "failed_code": -10,
  7231. "msg": result3265.ErrMsg,
  7232. })
  7233. return
  7234. } else {
  7235. c.ServeSuccessJSON(map[string]interface{}{
  7236. "info": result3265.Output,
  7237. })
  7238. return
  7239. }
  7240. }
  7241. func (c *HisApiController) Get3273() {
  7242. admin_user_id, _ := c.GetInt64("admin_user_id")
  7243. startTime := c.GetString("start_time")
  7244. //endTime, _ := c.GetString("end_time")
  7245. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7246. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7247. times := strings.Split(startTime, "-")
  7248. setl_mon := times[0] + times[1]
  7249. var result3265 models.JSResult3264
  7250. data := make(map[string]interface{})
  7251. data["org_name"] = miConfig.OrgName
  7252. data["doctor"] = curRoles.UserName
  7253. data["doctor_name"] = curRoles.UserName
  7254. data["fixmedins_code"] = miConfig.Code
  7255. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7256. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7257. data["secret_key"] = miConfig.SecretKey
  7258. data["url"] = miConfig.Url
  7259. data["ak"] = miConfig.AccessKey
  7260. data["cainfo"] = miConfig.Cainfo
  7261. data["setl_mon"] = setl_mon
  7262. data["stmt_loc"] = "2"
  7263. client := &http.Client{}
  7264. bytesData, _ := json.Marshal(data)
  7265. var req *http.Request
  7266. if miConfig.MdtrtareaAdmvs == "320921" {
  7267. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7268. } else {
  7269. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7270. }
  7271. resp, _ := client.Do(req)
  7272. defer resp.Body.Close()
  7273. body, ioErr := ioutil.ReadAll(resp.Body)
  7274. if ioErr != nil {
  7275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7277. }
  7278. var respJSON map[string]interface{}
  7279. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7282. }
  7283. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7284. fmt.Println(respJSON)
  7285. result, _ := json.Marshal(respJSON)
  7286. fmt.Println(result)
  7287. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7288. utils.ErrorLog("解析失败:%v", err)
  7289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7290. }
  7291. if result3265.Infcode != "0" {
  7292. c.ServeSuccessJSON(map[string]interface{}{
  7293. "failed_code": -10,
  7294. "msg": result3265.ErrMsg,
  7295. })
  7296. return
  7297. } else {
  7298. c.ServeSuccessJSON(map[string]interface{}{
  7299. "info": result3265.Output.Data,
  7300. })
  7301. return
  7302. }
  7303. }
  7304. func (c *HisApiController) Get3274() {
  7305. //if miConfig.MdtrtareaAdmvs == "320921" {
  7306. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7307. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7308. // "&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
  7309. //
  7310. //} else {
  7311. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7312. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7313. // "&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
  7314. //
  7315. //}
  7316. }
  7317. func (c *HisApiController) Get3275() {
  7318. //if miConfig.MdtrtareaAdmvs == "320921" {
  7319. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7320. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7321. // "&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
  7322. //
  7323. //} else {
  7324. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7325. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7326. // "&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
  7327. //
  7328. //}
  7329. }
  7330. func (c *HisApiController) Get3276() {
  7331. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7332. //month := c.GetString("month")
  7333. //
  7334. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7335. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7336. //var api string
  7337. //var res Result5301
  7338. //
  7339. //if miConfig.MdtrtareaAdmvs == "320921" {
  7340. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7341. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7342. //} else {
  7343. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7344. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7345. //}
  7346. //
  7347. //resp, requestErr := http.Get(api)
  7348. //if requestErr != nil {
  7349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7350. // return
  7351. //}
  7352. //
  7353. //body, ioErr := ioutil.ReadAll(resp.Body)
  7354. //if ioErr != nil {
  7355. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7357. // return
  7358. //}
  7359. //var respJSON map[string]interface{}
  7360. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7361. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7363. // return
  7364. //}
  7365. //
  7366. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7367. //result, _ := json.Marshal(respJSON)
  7368. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7369. // utils.ErrorLog("解析失败:%v", err)
  7370. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7371. // return
  7372. //}
  7373. }
  7374. func (c *HisApiController) Get3277() {
  7375. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7376. //month := c.GetString("month")
  7377. //
  7378. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7379. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7380. //var api string
  7381. //var res Result5301
  7382. //
  7383. //if miConfig.MdtrtareaAdmvs == "320921" {
  7384. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7385. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7386. //} else {
  7387. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7388. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7389. //}
  7390. //
  7391. //resp, requestErr := http.Get(api)
  7392. //if requestErr != nil {
  7393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7394. // return
  7395. //}
  7396. //
  7397. //body, ioErr := ioutil.ReadAll(resp.Body)
  7398. //if ioErr != nil {
  7399. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7401. // return
  7402. //}
  7403. //var respJSON map[string]interface{}
  7404. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7405. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7407. // return
  7408. //}
  7409. //
  7410. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7411. //result, _ := json.Marshal(respJSON)
  7412. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7413. // utils.ErrorLog("解析失败:%v", err)
  7414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7415. // return
  7416. //}
  7417. }
  7418. //func (c *HisApiController) GetCFYLJG001() {
  7419. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7420. // patient_id, _ := c.GetInt64("patient_id")
  7421. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7422. // record_time := c.GetString("record_time")
  7423. // admin_user_id = 3626
  7424. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7425. // psn, _ := service.GetPsnByPatientId(patient_id)
  7426. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7427. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7428. // var cFYLJG001 models.CFYLJG001
  7429. //
  7430. // timeLayout := "2006-01-02"
  7431. // loc, _ := time.LoadLocation("Local")
  7432. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7433. // if err != nil {
  7434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7435. // return
  7436. // }
  7437. // recordDateTime := theTime.Unix()
  7438. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7439. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7440. //
  7441. // //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7442. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7443. //
  7444. // //dept, _ := service.GetDepartMentDetail(info.Departments)
  7445. //
  7446. // for _, item := range prescriptions {
  7447. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7448. // if his.IdCardType == 1 {
  7449. // bas := strings.Split(psn.CardInfo, "|")
  7450. // basNumber := bas[1]
  7451. // fmt.Println(basNumber)
  7452. // card_sn := bas[3]
  7453. // card_no := bas[2]
  7454. // cFYLJG001.MdtrtCertType = "03"
  7455. // cFYLJG001.CardSn = card_sn
  7456. // cFYLJG001.MdtrtCertNo = card_no
  7457. // cFYLJG001.EcToken = ""
  7458. // cFYLJG001.AuthNo = ""
  7459. // } else if his.IdCardType == 2 {
  7460. // cFYLJG001.MdtrtCertType = "02"
  7461. // cFYLJG001.CardSn = ""
  7462. // cFYLJG001.MdtrtCertNo = his.IdCardNo
  7463. // cFYLJG001.EcToken = ""
  7464. // cFYLJG001.AuthNo = ""
  7465. // } else if his.IdCardType == 4 {
  7466. // cFYLJG001.MdtrtCertType = "01"
  7467. // cFYLJG001.CardSn = ""
  7468. // cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7469. // cFYLJG001.EcToken = psn.VerifyNumber
  7470. // cFYLJG001.AuthNo = ""
  7471. // }
  7472. // cFYLJG001.BizTypeCode = "01"
  7473. // cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7474. // cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7475. // cFYLJG001.RxTypeCode = "1"
  7476. // tempTime := time.Unix(item.PreTime, 0)
  7477. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7478. // cFYLJG001.PrscTime = timeFormatOne
  7479. // var count float64
  7480. // if item.Type == 1 {
  7481. // for _, sumItem := range item.HisDoctorAdviceInfo {
  7482. // count = count + sumItem.PrescribingNumber
  7483. // }
  7484. // }
  7485. // cFYLJG001.RxDrugCnt = count
  7486. // cFYLJG001.ValiDays = "5"
  7487. // ts := time.Unix(item.PreTime, 0)
  7488. // record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7489. // tempTime3 := time.Unix(record_time2, 0)
  7490. // timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7491. // cFYLJG001.ValiEndTime = timeFormat3
  7492. // cFYLJG001.RxCotnFlag = "0"
  7493. // for _, subItem := range item.HisDoctorAdviceInfo {
  7494. // var drug models.RxDrug
  7495. // drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7496. // drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7497. // drug.RxItemTypeCode = "11"
  7498. //
  7499. // drug.DrugDosform = "乳膏剂" //TODO
  7500. // if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7501. // drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7502. // }
  7503. //
  7504. // drug.MedcWayDscr = subItem.DeliveryWay
  7505. //
  7506. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7507. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7508. // drug.MedcBegntime = timeFormatTwo
  7509. // if subItem.Day > 0 {
  7510. // ts := time.Unix(subItem.StartTime, 0)
  7511. // record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7512. // tempTime4 := time.Unix(record_time, 0)
  7513. // timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7514. // drug.MedcEndtime = timeFormat5
  7515. // } else {
  7516. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7517. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7518. // drug.MedcEndtime = timeFormatTwo
  7519. // }
  7520. //
  7521. // drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7522. // drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7523. // drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7524. // drug.DrugCnt = subItem.PrescribingNumber
  7525. // drug.DrugDosunt = subItem.PrescribingNumberUnit
  7526. // drug.DrugGenname = subItem.AdviceName
  7527. // drug.MedcWayCodg = subItem.DeliveryWay
  7528. // //drug.DrugTotlcnt = subItem.PrescribingNumber
  7529. // drug.SinDoscnt = subItem.SingleDose
  7530. // drug.SinDosunt = subItem.SingleDoseUnit
  7531. // drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7532. // drug.UsedFrquName = subItem.ExecutionFrequency
  7533. // drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7534. // drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7535. // drug.HospApprFlag = "1"
  7536. // cFYLJG001.List = append(cFYLJG001.List, drug)
  7537. // }
  7538. // cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7539. // cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7540. // cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7541. // cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7542. // cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7543. // cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7544. // cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7545. // cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7546. // cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7547. // cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7548. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7549. // cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7550. // cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7551. // cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7552. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7553. // cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7554. // cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7555. // cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7556. // cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7557. // cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7558. // cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7559. // cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7560. // cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7561. // cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7562. // tempTime2 := time.Now().Unix()
  7563. // tempTime6 := time.Unix(tempTime2, 0)
  7564. // timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7565. // cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7566. // cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7567. // cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7568. // cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7569. // cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7570. //
  7571. // //memo := make(map[string]interface{})
  7572. // //inputData := make(map[string]interface{}, 0)
  7573. //
  7574. // //type MyData struct {
  7575. // // Insutype string `json:"insutype"`
  7576. // //}
  7577. // //
  7578. // // data := MyData{
  7579. // // Insutype: his.Insutype,
  7580. // //}
  7581. // //
  7582. //
  7583. // diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7584. // var config []*models.HisXtDiagnoseConfig
  7585. // for _, item := range diagnosis_ids {
  7586. // id, _ := strconv.ParseInt(item, 10, 64)
  7587. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  7588. // config = append(config, &diagnosisConfig)
  7589. // }
  7590. // for index, subitem := range config {
  7591. // if index == 0 {
  7592. // var dia models.DiseInfo
  7593. // dia.DiagType = "1"
  7594. // dia.MaindiagFlag = "1"
  7595. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7596. // dia.DiagCode = subitem.CountryCode
  7597. // dia.DiagName = subitem.ClassName
  7598. // dia.DiagDept = "肾内科"
  7599. // dia.DiagDrNo = doctor.DoctorNumber
  7600. // dia.DiagDrName = doctor.UserName
  7601. // tempTime3 := time.Unix(item.PreTime, 0)
  7602. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7603. // dia.DiagTime = timeFormatTwo
  7604. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7605. // } else {
  7606. // var dia models.DiseInfo
  7607. // dia.DiagType = "1"
  7608. // dia.MaindiagFlag = "0"
  7609. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7610. // dia.DiagCode = subitem.CountryCode
  7611. // dia.DiagName = subitem.ClassName
  7612. // dia.DiagDept = "肾内科"
  7613. // dia.DiagDrNo = doctor.DoctorNumber
  7614. // dia.DiagDrName = doctor.UserName
  7615. // tempTime3 := time.Unix(item.PreTime, 0)
  7616. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7617. // dia.DiagTime = timeFormatTwo
  7618. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7619. // }
  7620. // }
  7621. // if miConfig.MdtrtareaAdmvs == "340699" {
  7622. // //result, request := service.GetAHCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7623. // //saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7624. //
  7625. // } else {
  7626. // result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7627. // saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7628. //
  7629. // }
  7630. //
  7631. // var res ResultCFYLJG001
  7632. // var respJSON2 map[string]interface{}
  7633. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7634. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7636. // return
  7637. // }
  7638. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7639. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7640. // utils.ErrorLog("解析失败:%v", err)
  7641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7642. // return
  7643. // }
  7644. // if res.Infcode == -1 {
  7645. // c.ServeSuccessJSON(map[string]interface{}{
  7646. // "failed_code": -10,
  7647. // "msg": res.ErrMsg,
  7648. // })
  7649. // return
  7650. //
  7651. // } else {
  7652. // var flow models.HisPrescriptionFlow
  7653. // flow.Ctime = time.Now().Unix()
  7654. // flow.SignDigest = ""
  7655. // flow.RxTraceCode = res.Output.RxTraceCode
  7656. // flow.HiRxno = res.Output.HiRxno
  7657. // flow.MID = his.Number
  7658. // flow.Status = 1
  7659. // flow.DCode = doctor_info.DoctorNumber
  7660. // flow.OriginalRxFile = ""
  7661. // flow.OriginalValue = ""
  7662. // flow.SignCertDn = ""
  7663. // flow.UserOrgId = 10454
  7664. // flow.SignCertSn = ""
  7665. // flow.Mtime = time.Now().Unix()
  7666. //
  7667. // service.Createflow(&flow)
  7668. // c.ServeSuccessJSON(map[string]interface{}{
  7669. // "msg": "上传成功",
  7670. // })
  7671. // }
  7672. // }
  7673. //}
  7674. //func (c *HisApiController) GetCFYLJG002() {
  7675. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7676. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7677. // record_time := c.GetString("record_time")
  7678. // admin_user_id = 3626
  7679. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7680. // //id, _ := c.GetInt64("id")
  7681. // admin_user_id = 3626
  7682. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7683. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7684. //
  7685. // flow, _ := service.Getflowtwo(his.Number)
  7686. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  7687. // //record_time := c.GetString("record_time")
  7688. // patient_id, _ := c.GetInt64("patient_id")
  7689. // //patient_id = 23834
  7690. // //record_time = "2023-09-18"
  7691. // timeLayout := "2006-01-02"
  7692. // loc, _ := time.LoadLocation("Local")
  7693. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7694. // if err != nil {
  7695. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7696. // return
  7697. // }
  7698. // recordDateTime := theTime.Unix()
  7699. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7700. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7701. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7702. //
  7703. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7704. //
  7705. // inputData := make(map[string]interface{})
  7706. // inputData["rxTraceCode"] = flow.RxTraceCode
  7707. // inputData["hiRxno"] = flow.HiRxno
  7708. // inputData["mdtrtId"] = flow.MID
  7709. // inputData["patnName"] = his.PsnName
  7710. // inputData["psnCertType"] = his.PsnCertType
  7711. // inputData["certno"] = his.Certno
  7712. // inputData["fixmedinsName"] = miConfig.OrgName
  7713. // inputData["fixmedinsCode"] = miConfig.Code
  7714. // inputData["drCode"] = doctor_info.DoctorNumber
  7715. // inputData["prscDrName"] = doctor_info.UserName
  7716. // inputData["pharDeptName"] = dept.Name
  7717. // inputData["pharDeptCode"] = dept.Number
  7718. // inputData["pharProfttlCodg"] = dept.Name
  7719. // inputData["pharProfttlName"] = ""
  7720. // inputData["pharCode"] = "HY440309002107"
  7721. // inputData["pharCertType"] = "01"
  7722. // inputData["pharCertno"] = "430482199408260023"
  7723. // inputData["pharName"] = "彭斯遥"
  7724. // inputData["pharPracCertNo"] = ""
  7725. // tempTime2 := time.Unix(info.Ctime, 0)
  7726. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7727. // inputData["pharChkTime"] = timeFormatTwo
  7728. //
  7729. // bytesData, _ := json.Marshal(inputData)
  7730. // fmt.Println(string(bytesData))
  7731. // encoded := base64.StdEncoding.EncodeToString(bytesData)
  7732. // pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7733. // if err != nil {
  7734. // fmt.Println("Error reading PDF file:", err)
  7735. // return
  7736. // }
  7737. //
  7738. // // 将 PDF 文件内容进行 Base64 编码
  7739. // rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7740. //
  7741. // fmt.Println(err)
  7742. //
  7743. // if miConfig.MdtrtareaAdmvs == "340699" {
  7744. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7745. // //saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7746. //
  7747. // } else {
  7748. // result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7749. // //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7750. // saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7751. //
  7752. // }
  7753. //
  7754. // var res2 Result002
  7755. // var respJSON2 map[string]interface{}
  7756. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7757. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7759. // return
  7760. // }
  7761. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7762. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7763. // utils.ErrorLog("解析失败:%v", err)
  7764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7765. // return
  7766. // }
  7767. // if res2.Infcode == 0 {
  7768. // flow.Ctime = time.Now().Unix()
  7769. // flow.SignDigest = res2.Output.SignDigest
  7770. // flow.RxFile = res2.Output.RxFile
  7771. // flow.MID = his.Number
  7772. // flow.Status = 1
  7773. // flow.DCode = doctor_info.DoctorNumber
  7774. // flow.OriginalRxFile = rx_encoded
  7775. // flow.OriginalValue = encoded
  7776. // flow.SignCertDn = res2.Output.SignCertDn
  7777. // flow.SignCertSn = res2.Output.SignCertSn
  7778. // flow.Mtime = time.Now().Unix()
  7779. // service.Saveflow(flow)
  7780. // c.ServeSuccessJSON(map[string]interface{}{
  7781. // "msg": "预签名成功",
  7782. // })
  7783. // } else {
  7784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. // return
  7786. // }
  7787. //}
  7788. //func (c *HisApiController) GetCFYLJG003() {
  7789. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7790. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7791. // record_time := c.GetString("record_time")
  7792. // admin_user_id = 3626
  7793. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7794. // //id, _ := c.GetInt64("id")
  7795. // admin_user_id = 3626
  7796. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7797. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7798. //
  7799. // flow, _ := service.Getflowtwo(his.Number)
  7800. // //id = 3
  7801. // patient_id, _ := c.GetInt64("patient_id")
  7802. // //patient_id = 23834
  7803. // //record_time = "2023-09-18"
  7804. // timeLayout := "2006-01-02"
  7805. // loc, _ := time.LoadLocation("Local")
  7806. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7807. // if err != nil {
  7808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7809. // return
  7810. // }
  7811. // recordDateTime := theTime.Unix()
  7812. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7813. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7814. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7815. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7816. //
  7817. // //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7818. //
  7819. // var cFYLJG003 models.CFYLJG003
  7820. //
  7821. // cFYLJG003.RxTraceCode = flow.RxTraceCode
  7822. // cFYLJG003.HiRxno = flow.HiRxno
  7823. // cFYLJG003.MdtrtID = flow.MID
  7824. // cFYLJG003.PatnName = his.Name
  7825. // cFYLJG003.Certno = his.Certno
  7826. // cFYLJG003.FixmedinsName = miConfig.OrgName
  7827. // cFYLJG003.FixmedinsCode = miConfig.Code
  7828. //
  7829. // cFYLJG003.DrCode = doctor_info.DoctorNumber
  7830. // cFYLJG003.PrscDrName = doctor_info.UserName
  7831. // cFYLJG003.PharDeptName = dept.Name
  7832. // cFYLJG003.PharDeptCode = dept.Number
  7833. // cFYLJG003.PharCode = "HY440309002107"
  7834. // cFYLJG003.PharCertType = "01"
  7835. // cFYLJG003.PharCertno = "430482199408260023"
  7836. // cFYLJG003.PharName = "彭斯遥"
  7837. // cFYLJG003.PsnCertType = "01"
  7838. // cFYLJG003.RxFile = flow.RxFile
  7839. // cFYLJG003.SignDigest = flow.SignDigest
  7840. // cFYLJG003.FixmedinsCode = miConfig.Code
  7841. // cFYLJG003.PsnCertType = "01"
  7842. // cFYLJG003.PharProfttlCodg = dept.Name
  7843. // //inputData["pharProfttlCodg"] =dept.Name
  7844. //
  7845. // tempTime2 := time.Unix(info.Ctime, 0)
  7846. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7847. // cFYLJG003.PharChkTime = timeFormatTwo
  7848. //
  7849. // if miConfig.MdtrtareaAdmvs == "340699" {
  7850. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7851. // //result, request := service.GetAHCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7852. // //saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  7853. // } else {
  7854. // result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7855. // saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7856. //
  7857. // }
  7858. //
  7859. // var res ResultCFYLJG003
  7860. // var respJSON2 map[string]interface{}
  7861. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7862. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7864. // return
  7865. // }
  7866. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7867. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7868. // utils.ErrorLog("解析失败:%v", err)
  7869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7870. // return
  7871. // }
  7872. // if res.Infcode == -1 {
  7873. // c.ServeSuccessJSON(map[string]interface{}{
  7874. // "failed_code": -10,
  7875. // "msg": res.ErrMsg,
  7876. // })
  7877. // return
  7878. // } else {
  7879. // c.ServeSuccessJSON(map[string]interface{}{
  7880. // "info": res.Output,
  7881. // })
  7882. // }
  7883. //
  7884. //}
  7885. //func (c *HisApiController) GetCFYLJG004() {
  7886. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7887. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7888. // record_time := c.GetString("record_time")
  7889. // admin_user_id = 3626
  7890. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7891. // //id, _ := c.GetInt64("id")
  7892. // admin_user_id = 3626
  7893. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7894. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7895. //
  7896. // flow, _ := service.Getflowtwo(his.Number)
  7897. // //id = 3
  7898. // patient_id, _ := c.GetInt64("patient_id")
  7899. // //patient_id = 23834
  7900. // //record_time = "2023-09-18"
  7901. // timeLayout := "2006-01-02"
  7902. // loc, _ := time.LoadLocation("Local")
  7903. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7904. // if err != nil {
  7905. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7906. // return
  7907. // }
  7908. // recordDateTime := theTime.Unix()
  7909. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7910. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7911. // var cFYLJG004 models.CFYLJG004
  7912. // cFYLJG004.HiRxno = flow.HiRxno
  7913. // cFYLJG004.FixmedinsCode = miConfig.Code
  7914. // cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7915. // cFYLJG004.UndoDrCertType = "01"
  7916. // cFYLJG004.UndoRea = "撤销处方"
  7917. // cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7918. // cFYLJG004.UndoDrName = doctor_info.UserName
  7919. // cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7920. //
  7921. // if miConfig.MdtrtareaAdmvs == "340699" {
  7922. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7923. // //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7924. // //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  7925. //
  7926. // } else {
  7927. // result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7928. // saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7929. //
  7930. // }
  7931. //
  7932. // var res ResultCFYLJG004
  7933. // var respJSON2 map[string]interface{}
  7934. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7935. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7937. // return
  7938. // }
  7939. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7940. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7941. // utils.ErrorLog("解析失败:%v", err)
  7942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7943. // return
  7944. // }
  7945. // if res.Infcode == -1 {
  7946. // c.ServeSuccessJSON(map[string]interface{}{
  7947. // "failed_code": -10,
  7948. // "msg": res.ErrMsg,
  7949. // })
  7950. // return
  7951. // } else {
  7952. // flow.Status = 0
  7953. // service.Saveflow(flow)
  7954. // c.ServeSuccessJSON(map[string]interface{}{
  7955. // "msg": "撤销成功",
  7956. // })
  7957. // return
  7958. //
  7959. // }
  7960. //}
  7961. //func (c *HisApiController) GetCFYLJG005() {
  7962. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7963. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7964. // //record_time := c.GetString("record_time")
  7965. // admin_user_id = 3626
  7966. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7967. // //id, _ := c.GetInt64("id")
  7968. // admin_user_id = 3626
  7969. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7970. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7971. //
  7972. // flow, _ := service.Getflowtwo(his.Number)
  7973. // //id = 3
  7974. // var cFYLJG005 models.CFYLJG005
  7975. //
  7976. // //patient_id, _ := c.GetInt64("patient_id")
  7977. // cFYLJG005.HiRxno = flow.HiRxno
  7978. // cFYLJG005.MdtrtID = flow.MID
  7979. // cFYLJG005.EcToken = ""
  7980. // cFYLJG005.PsnName = his.Name
  7981. // cFYLJG005.PsnCertType = "01"
  7982. // cFYLJG005.Certno = his.IdCardNo
  7983. //
  7984. // if miConfig.MdtrtareaAdmvs == "340699" {
  7985. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7986. //
  7987. // //result, request := service.GetAHCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7988. // //saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7989. //
  7990. // } else {
  7991. // result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7992. // saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7993. //
  7994. // }
  7995. //
  7996. // var res ResultCFYLJG005
  7997. // var respJSON2 map[string]interface{}
  7998. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7999. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8001. // return
  8002. // }
  8003. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8004. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8005. // utils.ErrorLog("解析失败:%v", err)
  8006. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8007. // return
  8008. // }
  8009. // if res.Infcode == -1 {
  8010. // c.ServeSuccessJSON(map[string]interface{}{
  8011. // "failed_code": -10,
  8012. // "msg": res.ErrMsg,
  8013. // })
  8014. // return
  8015. // } else {
  8016. // c.ServeSuccessJSON(map[string]interface{}{
  8017. // "info": res.Output,
  8018. // })
  8019. // return
  8020. // }
  8021. //}
  8022. //func (c *HisApiController) GetCFYLJG006() {
  8023. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8024. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8025. // admin_user_id = 3626
  8026. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8027. // //id, _ := c.GetInt64("id")
  8028. // admin_user_id = 3626
  8029. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8030. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8031. //
  8032. // flow, _ := service.Getflowtwo(his.Number)
  8033. // //id = 3
  8034. // patient_id, _ := c.GetInt64("patient_id")
  8035. // var cFYLJG006 models.CFYLJG006
  8036. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8037. // cFYLJG006.HiRxno = flow.HiRxno
  8038. // cFYLJG006.MdtrtID = flow.MID
  8039. // cFYLJG006.PsnName = patient.Name
  8040. // cFYLJG006.PsnCertType = "01"
  8041. // cFYLJG006.Certno = patient.IdCardNo
  8042. //
  8043. // if miConfig.MdtrtareaAdmvs == "340699" {
  8044. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8045. //
  8046. // result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8047. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8048. // } else {
  8049. // result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8050. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8051. // }
  8052. //
  8053. // var res ResultCFYLJG006
  8054. // var respJSON2 map[string]interface{}
  8055. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8056. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8057. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8058. // return
  8059. // }
  8060. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8061. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8062. // utils.ErrorLog("解析失败:%v", err)
  8063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8064. // return
  8065. // }
  8066. // if res.Infcode == -1 {
  8067. // c.ServeSuccessJSON(map[string]interface{}{
  8068. // "failed_code": -10,
  8069. // "msg": res.ErrMsg,
  8070. // })
  8071. // return
  8072. // } else {
  8073. // c.ServeSuccessJSON(map[string]interface{}{
  8074. // "info": res.Output,
  8075. // })
  8076. // return
  8077. // }
  8078. //}
  8079. //func (c *HisApiController) GetCFYLJG007() {
  8080. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8081. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8082. // admin_user_id = 3626
  8083. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8084. // //id, _ := c.GetInt64("id")
  8085. // admin_user_id = 3626
  8086. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8087. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8088. //
  8089. // flow, _ := service.Getflowtwo(his.Number)
  8090. // //id = 3
  8091. // patient_id, _ := c.GetInt64("patient_id")
  8092. // var cFYLJG007 models.CFYLJG007
  8093. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8094. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8095. //
  8096. // cFYLJG007.HiRxno = flow.HiRxno
  8097. // cFYLJG007.MdtrtID = flow.MID
  8098. // cFYLJG007.PsnNo = his.PsnNo
  8099. // cFYLJG007.PsnCertType = "01"
  8100. // cFYLJG007.Certno = patient.IdCardNo
  8101. // cFYLJG007.PsnName = patient.Name
  8102. //
  8103. // if miConfig.MdtrtareaAdmvs == "340699" {
  8104. // result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8105. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8106. // } else {
  8107. // result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8108. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8109. // }
  8110. //
  8111. // var res ResultCFYLJG007
  8112. // var respJSON2 map[string]interface{}
  8113. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8114. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8116. // return
  8117. // }
  8118. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8119. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8120. // utils.ErrorLog("解析失败:%v", err)
  8121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8122. // return
  8123. // }
  8124. // if res.Infcode == -1 {
  8125. // c.ServeSuccessJSON(map[string]interface{}{
  8126. // "failed_code": -10,
  8127. // "msg": res.ErrMsg,
  8128. // })
  8129. // return
  8130. // } else {
  8131. // c.ServeSuccessJSON(map[string]interface{}{
  8132. // "info": res,
  8133. // })
  8134. // return
  8135. // }
  8136. //}
  8137. //
  8138. //func (c *HisApiController) GetCFYLJG008() {
  8139. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8140. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8141. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8142. // var cFYLJG008 models.CFYLJG008
  8143. // //id, _ := c.GetInt64("id")
  8144. // patient_id, _ := c.GetInt64("patient_id")
  8145. // //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8146. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8147. // //id = 3
  8148. // //flow, _ := service.Getflow(id)
  8149. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  8150. //
  8151. // //
  8152. // //admin_user_id, _ := c.GetInt64("admin_user_id")
  8153. // //patient_id, _ := c.GetInt64("patient_id")
  8154. // //his_patient_id, _ := c.GetInt64("his_patient_id")
  8155. // record_time := c.GetString("record_time")
  8156. //
  8157. // admin_user_id = 3626
  8158. // patient_id = 19424
  8159. // //his_patient_id = 263947
  8160. // record_time = "2023-08-29"
  8161. //
  8162. // timeLayout := "2006-01-02"
  8163. // loc, _ := time.LoadLocation("Local")
  8164. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8165. // if err != nil {
  8166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8167. // return
  8168. // }
  8169. // recordDateTime := theTime.Unix()
  8170. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8171. //
  8172. // cFYLJG008.FixmedinsName = ""
  8173. // cFYLJG008.Lat = ""
  8174. // cFYLJG008.Lng = ""
  8175. // cFYLJG008.OrderType = "1"
  8176. // cFYLJG008.PoolareaNo = ""
  8177. // cFYLJG008.Lng = ""
  8178. // cFYLJG008.PageNum = 1
  8179. // cFYLJG008.PageSize = 10
  8180. // var MPI models.MedinsProdInvChgDDTO
  8181. // MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8182. // MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8183. // cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8184. //
  8185. // if miConfig.MdtrtareaAdmvs == "340699" {
  8186. // result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8187. // saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8188. //
  8189. // } else {
  8190. // result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8191. // saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8192. //
  8193. // var res ResultCFYLJG008
  8194. // var respJSON2 map[string]interface{}
  8195. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8196. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8198. // return
  8199. // }
  8200. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8201. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8202. // utils.ErrorLog("解析失败:%v", err)
  8203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8204. // return
  8205. // }
  8206. // if res.Infcode == -1 {
  8207. // c.ServeSuccessJSON(map[string]interface{}{
  8208. // "failed_code": -10,
  8209. // "msg": res.ErrMsg,
  8210. // })
  8211. // return
  8212. // } else {
  8213. // c.ServeSuccessJSON(map[string]interface{}{
  8214. // "info": res.Output,
  8215. // })
  8216. // return
  8217. // }
  8218. // }
  8219. //
  8220. //}
  8221. func (c *HisApiController) GetBL4201A() {
  8222. order_id, _ := c.GetInt64("order_id")
  8223. admin_user_id, _ := c.GetInt64("admin_user_id")
  8224. order, _ := service.GetHisOrderByIDTwo(order_id)
  8225. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8226. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8227. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8228. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8229. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8230. department, _ := service.GetDepartMentDetail(his.Departments)
  8231. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8232. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8233. if order.ID == 0 {
  8234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8235. return
  8236. }
  8237. var struct4201A models.Struct4201A
  8238. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8239. for _, items := range order_info {
  8240. memo := make(map[string]interface{})
  8241. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8242. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8243. fsiOPFLD.MedType = "14"
  8244. fsiOPFLD.BkkpSn = items.FeedetlSn
  8245. fsiOPFLD.FixmedinsCode = miConfig.Code
  8246. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8247. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8248. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8249. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8250. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8251. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8252. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8253. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8254. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8255. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8256. fsiOPFLD.BilgDeptName = department.Name
  8257. fsiOPFLD.BilgDeptCodg = department.Number
  8258. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8259. fsiOPFLD.BilgDrName = doctor.UserName
  8260. fsiOPFLD.MedChrgitmType = "09"
  8261. memo["hosp_appr_flag"] = "1"
  8262. memo["invoice_no"] = order.MdtrtId
  8263. memo["memo"] = "自费"
  8264. bytesData, _ := json.Marshal(memo)
  8265. fsiOPFLD.Memo = string(bytesData)
  8266. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8267. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8268. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8269. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8270. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8271. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8272. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8273. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8274. fsiOPFLD.BilgDeptName = department.Name
  8275. fsiOPFLD.BilgDeptCodg = department.Number
  8276. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8277. fsiOPFLD.BilgDrName = doctor.UserName
  8278. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8279. case 0:
  8280. break
  8281. case 1:
  8282. fsiOPFLD.MedChrgitmType = "14"
  8283. break
  8284. case 2:
  8285. fsiOPFLD.MedChrgitmType = "05"
  8286. break
  8287. case 3:
  8288. fsiOPFLD.MedChrgitmType = "03"
  8289. break
  8290. case 4:
  8291. fsiOPFLD.MedChrgitmType = "03"
  8292. break
  8293. case 5:
  8294. fsiOPFLD.MedChrgitmType = "08"
  8295. break
  8296. case 6:
  8297. fsiOPFLD.MedChrgitmType = "14"
  8298. break
  8299. case 7:
  8300. fsiOPFLD.MedChrgitmType = "14"
  8301. break
  8302. case 8:
  8303. fsiOPFLD.MedChrgitmType = "03"
  8304. break
  8305. case 9:
  8306. fsiOPFLD.MedChrgitmType = "14"
  8307. break
  8308. case 10:
  8309. fsiOPFLD.MedChrgitmType = "14"
  8310. break
  8311. case 11:
  8312. fsiOPFLD.MedChrgitmType = "06"
  8313. break
  8314. case 12:
  8315. fsiOPFLD.MedChrgitmType = "12"
  8316. break
  8317. case 13:
  8318. fsiOPFLD.MedChrgitmType = "01"
  8319. break
  8320. case 14:
  8321. fsiOPFLD.MedChrgitmType = "04"
  8322. break
  8323. case 15:
  8324. fsiOPFLD.MedChrgitmType = "14"
  8325. break
  8326. }
  8327. memo["hosp_appr_flag"] = "1"
  8328. memo["invoice_no"] = order.MdtrtId
  8329. memo["memo"] = "自费"
  8330. bytesData, _ := json.Marshal(memo)
  8331. fsiOPFLD.Memo = string(bytesData)
  8332. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8333. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8334. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8335. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8336. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8337. fsiOPFLD.BilgDeptName = department.Name
  8338. fsiOPFLD.BilgDeptCodg = department.Number
  8339. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8340. fsiOPFLD.BilgDrName = doctor.UserName
  8341. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8342. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8343. fsiOPFLD.MedChrgitmType = "08"
  8344. memo["hosp_appr_flag"] = "1"
  8345. memo["invoice_no"] = order.MdtrtId
  8346. memo["memo"] = "自费"
  8347. bytesData, _ := json.Marshal(memo)
  8348. fsiOPFLD.Memo = string(bytesData)
  8349. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8350. }
  8351. }
  8352. }
  8353. for _, items := range order_info_two {
  8354. memo := make(map[string]interface{})
  8355. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8356. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8357. fsiOPFLD.MedType = "14"
  8358. fsiOPFLD.BkkpSn = items.FeedetlSn
  8359. fsiOPFLD.FixmedinsCode = miConfig.Code
  8360. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8361. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8362. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8363. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8364. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8365. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8366. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8367. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8368. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8369. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8370. fsiOPFLD.BilgDeptName = department.Name
  8371. fsiOPFLD.BilgDeptCodg = department.Number
  8372. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8373. fsiOPFLD.BilgDrName = doctor.UserName
  8374. fsiOPFLD.MedChrgitmType = "09"
  8375. memo["hosp_appr_flag"] = "1"
  8376. memo["invoice_no"] = order.MdtrtId
  8377. memo["memo"] = "自费"
  8378. bytesData, _ := json.Marshal(memo)
  8379. fsiOPFLD.Memo = string(bytesData)
  8380. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8381. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8382. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8383. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8384. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8385. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8386. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8387. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8388. fsiOPFLD.BilgDeptName = department.Name
  8389. fsiOPFLD.BilgDeptCodg = department.Number
  8390. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8391. fsiOPFLD.BilgDrName = doctor.UserName
  8392. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8393. case 0:
  8394. break
  8395. case 1:
  8396. fsiOPFLD.MedChrgitmType = "14"
  8397. break
  8398. case 2:
  8399. fsiOPFLD.MedChrgitmType = "05"
  8400. break
  8401. case 3:
  8402. fsiOPFLD.MedChrgitmType = "03"
  8403. break
  8404. case 4:
  8405. fsiOPFLD.MedChrgitmType = "03"
  8406. break
  8407. case 5:
  8408. fsiOPFLD.MedChrgitmType = "08"
  8409. break
  8410. case 6:
  8411. fsiOPFLD.MedChrgitmType = "14"
  8412. break
  8413. case 7:
  8414. fsiOPFLD.MedChrgitmType = "14"
  8415. break
  8416. case 8:
  8417. fsiOPFLD.MedChrgitmType = "03"
  8418. break
  8419. case 9:
  8420. fsiOPFLD.MedChrgitmType = "14"
  8421. break
  8422. case 10:
  8423. fsiOPFLD.MedChrgitmType = "14"
  8424. break
  8425. case 11:
  8426. fsiOPFLD.MedChrgitmType = "06"
  8427. break
  8428. case 12:
  8429. fsiOPFLD.MedChrgitmType = "12"
  8430. break
  8431. case 13:
  8432. fsiOPFLD.MedChrgitmType = "01"
  8433. break
  8434. case 14:
  8435. fsiOPFLD.MedChrgitmType = "04"
  8436. break
  8437. case 15:
  8438. fsiOPFLD.MedChrgitmType = "14"
  8439. break
  8440. }
  8441. memo["hosp_appr_flag"] = "1"
  8442. memo["invoice_no"] = order.MdtrtId
  8443. memo["memo"] = "自费"
  8444. bytesData, _ := json.Marshal(memo)
  8445. fsiOPFLD.Memo = string(bytesData)
  8446. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8447. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8448. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8449. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8450. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8451. fsiOPFLD.BilgDeptName = department.Name
  8452. fsiOPFLD.BilgDeptCodg = department.Number
  8453. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8454. fsiOPFLD.BilgDrName = doctor.UserName
  8455. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8456. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8457. fsiOPFLD.MedChrgitmType = "08"
  8458. memo["hosp_appr_flag"] = "1"
  8459. memo["invoice_no"] = order.MdtrtId
  8460. memo["memo"] = "自费"
  8461. bytesData, _ := json.Marshal(memo)
  8462. fsiOPFLD.Memo = string(bytesData)
  8463. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8464. }
  8465. }
  8466. }
  8467. fmt.Println(fsiOPFLDs)
  8468. struct4201A.Fopfd = fsiOPFLDs
  8469. fmt.Println(struct4201A.Fopfd)
  8470. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8471. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8472. var res2 ResultSix
  8473. var respJSON2 map[string]interface{}
  8474. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8477. return
  8478. }
  8479. userJSONBytes2, _ := json.Marshal(respJSON2)
  8480. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8481. utils.ErrorLog("解析失败:%v", err)
  8482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8483. return
  8484. }
  8485. if res2.Infcode != 0 {
  8486. c.ServeSuccessJSON(map[string]interface{}{
  8487. "failed_code": -10,
  8488. "msg": res2.ErrMsg,
  8489. })
  8490. return
  8491. } else {
  8492. order.IsUploadOrderInfo = 1
  8493. service.UpdateOrder(order)
  8494. c.ServeSuccessJSON(map[string]interface{}{
  8495. "msg": "上传成功",
  8496. })
  8497. }
  8498. }
  8499. func (c *HisApiController) Get3103() {
  8500. admin_user_id, _ := c.GetInt64("admin_user_id")
  8501. warm_type, _ := c.GetInt64("warm_type")
  8502. fk_state, _ := c.GetInt64("fk_state")
  8503. warm_ids := c.GetString("warm_ids")
  8504. desc := c.GetString("desc")
  8505. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8506. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8507. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  8508. saveLog(result, requestLog, "3103", "反馈")
  8509. var res2 ResultSix
  8510. var respJSON2 map[string]interface{}
  8511. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8514. return
  8515. }
  8516. userJSONBytes2, _ := json.Marshal(respJSON2)
  8517. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8518. utils.ErrorLog("解析失败:%v", err)
  8519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8520. return
  8521. }
  8522. if res2.Infcode != 0 {
  8523. c.ServeSuccessJSON(map[string]interface{}{
  8524. "failed_code": -10,
  8525. "msg": res2.ErrMsg,
  8526. })
  8527. return
  8528. } else {
  8529. c.ServeSuccessJSON(map[string]interface{}{
  8530. "msg": "反馈成功",
  8531. })
  8532. return
  8533. }
  8534. }
  8535. func (c *HisApiController) Get3103() {
  8536. admin_user_id, _ := c.GetInt64("admin_user_id")
  8537. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8538. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8539. 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)
  8540. }
  8541. func (c *HisApiController) Get4201A() {
  8542. order_id, _ := c.GetInt64("order_id")
  8543. admin_user_id, _ := c.GetInt64("admin_user_id")
  8544. order, _ := service.GetHisOrderByIDTwo(order_id)
  8545. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8546. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8547. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8548. //order_info = append(order_info, order_info_two...)
  8549. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8550. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8551. department, _ := service.GetDepartMentDetail(his.Departments)
  8552. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8553. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8554. if order.ID == 0 {
  8555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8556. return
  8557. }
  8558. var struct4201A models.Struct4201A
  8559. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8560. for _, items := range order_info {
  8561. memo := make(map[string]interface{})
  8562. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8563. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8564. fsiOPFLD.MedType = "14"
  8565. fsiOPFLD.BkkpSn = items.FeedetlSn
  8566. fsiOPFLD.FixmedinsCode = miConfig.Code
  8567. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8568. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8569. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8570. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8571. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8572. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8573. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8574. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8575. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8576. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8577. fsiOPFLD.BilgDeptName = department.Name
  8578. fsiOPFLD.BilgDeptCodg = department.Number
  8579. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8580. fsiOPFLD.BilgDrName = doctor.UserName
  8581. fsiOPFLD.MedChrgitmType = "09"
  8582. memo["hosp_appr_flag"] = "1"
  8583. memo["invoice_no"] = order.MdtrtId
  8584. memo["memo"] = "自费"
  8585. bytesData, _ := json.Marshal(memo)
  8586. fsiOPFLD.Memo = string(bytesData)
  8587. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8588. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8589. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8590. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8591. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8592. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8593. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8594. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8595. fsiOPFLD.BilgDeptName = department.Name
  8596. fsiOPFLD.BilgDeptCodg = department.Number
  8597. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8598. fsiOPFLD.BilgDrName = doctor.UserName
  8599. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8600. case 0:
  8601. break
  8602. case 1:
  8603. fsiOPFLD.MedChrgitmType = "14"
  8604. break
  8605. case 2:
  8606. fsiOPFLD.MedChrgitmType = "05"
  8607. break
  8608. case 3:
  8609. fsiOPFLD.MedChrgitmType = "03"
  8610. break
  8611. case 4:
  8612. fsiOPFLD.MedChrgitmType = "03"
  8613. break
  8614. case 5:
  8615. fsiOPFLD.MedChrgitmType = "08"
  8616. break
  8617. case 6:
  8618. fsiOPFLD.MedChrgitmType = "14"
  8619. break
  8620. case 7:
  8621. fsiOPFLD.MedChrgitmType = "14"
  8622. break
  8623. case 8:
  8624. fsiOPFLD.MedChrgitmType = "03"
  8625. break
  8626. case 9:
  8627. fsiOPFLD.MedChrgitmType = "14"
  8628. break
  8629. case 10:
  8630. fsiOPFLD.MedChrgitmType = "14"
  8631. break
  8632. case 11:
  8633. fsiOPFLD.MedChrgitmType = "06"
  8634. break
  8635. case 12:
  8636. fsiOPFLD.MedChrgitmType = "12"
  8637. break
  8638. case 13:
  8639. fsiOPFLD.MedChrgitmType = "01"
  8640. break
  8641. case 14:
  8642. fsiOPFLD.MedChrgitmType = "04"
  8643. break
  8644. case 15:
  8645. fsiOPFLD.MedChrgitmType = "14"
  8646. break
  8647. }
  8648. memo["hosp_appr_flag"] = "1"
  8649. memo["invoice_no"] = order.MdtrtId
  8650. memo["memo"] = "自费"
  8651. bytesData, _ := json.Marshal(memo)
  8652. fsiOPFLD.Memo = string(bytesData)
  8653. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8654. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8655. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8656. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8657. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8658. fsiOPFLD.BilgDeptName = department.Name
  8659. fsiOPFLD.BilgDeptCodg = department.Number
  8660. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8661. fsiOPFLD.BilgDrName = doctor.UserName
  8662. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8663. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8664. fsiOPFLD.MedChrgitmType = "08"
  8665. memo["hosp_appr_flag"] = "1"
  8666. memo["invoice_no"] = order.MdtrtId
  8667. memo["memo"] = "自费"
  8668. bytesData, _ := json.Marshal(memo)
  8669. fsiOPFLD.Memo = string(bytesData)
  8670. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8671. }
  8672. }
  8673. }
  8674. for _, items := range order_info_two {
  8675. memo := make(map[string]interface{})
  8676. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8677. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8678. fsiOPFLD.MedType = "14"
  8679. fsiOPFLD.BkkpSn = items.FeedetlSn
  8680. fsiOPFLD.FixmedinsCode = miConfig.Code
  8681. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8682. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8683. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8684. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8685. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8686. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8687. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8688. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8689. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8690. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8691. fsiOPFLD.BilgDeptName = department.Name
  8692. fsiOPFLD.BilgDeptCodg = department.Number
  8693. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8694. fsiOPFLD.BilgDrName = doctor.UserName
  8695. fsiOPFLD.MedChrgitmType = "09"
  8696. memo["hosp_appr_flag"] = "1"
  8697. memo["invoice_no"] = order.MdtrtId
  8698. memo["memo"] = "自费"
  8699. bytesData, _ := json.Marshal(memo)
  8700. fsiOPFLD.Memo = string(bytesData)
  8701. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8702. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8703. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8704. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8705. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8706. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8707. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8708. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8709. fsiOPFLD.BilgDeptName = department.Name
  8710. fsiOPFLD.BilgDeptCodg = department.Number
  8711. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8712. fsiOPFLD.BilgDrName = doctor.UserName
  8713. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8714. case 0:
  8715. break
  8716. case 1:
  8717. fsiOPFLD.MedChrgitmType = "14"
  8718. break
  8719. case 2:
  8720. fsiOPFLD.MedChrgitmType = "05"
  8721. break
  8722. case 3:
  8723. fsiOPFLD.MedChrgitmType = "03"
  8724. break
  8725. case 4:
  8726. fsiOPFLD.MedChrgitmType = "03"
  8727. break
  8728. case 5:
  8729. fsiOPFLD.MedChrgitmType = "08"
  8730. break
  8731. case 6:
  8732. fsiOPFLD.MedChrgitmType = "14"
  8733. break
  8734. case 7:
  8735. fsiOPFLD.MedChrgitmType = "14"
  8736. break
  8737. case 8:
  8738. fsiOPFLD.MedChrgitmType = "03"
  8739. break
  8740. case 9:
  8741. fsiOPFLD.MedChrgitmType = "14"
  8742. break
  8743. case 10:
  8744. fsiOPFLD.MedChrgitmType = "14"
  8745. break
  8746. case 11:
  8747. fsiOPFLD.MedChrgitmType = "06"
  8748. break
  8749. case 12:
  8750. fsiOPFLD.MedChrgitmType = "12"
  8751. break
  8752. case 13:
  8753. fsiOPFLD.MedChrgitmType = "01"
  8754. break
  8755. case 14:
  8756. fsiOPFLD.MedChrgitmType = "04"
  8757. break
  8758. case 15:
  8759. fsiOPFLD.MedChrgitmType = "14"
  8760. break
  8761. }
  8762. memo["hosp_appr_flag"] = "1"
  8763. memo["invoice_no"] = order.MdtrtId
  8764. memo["memo"] = "自费"
  8765. bytesData, _ := json.Marshal(memo)
  8766. fsiOPFLD.Memo = string(bytesData)
  8767. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8768. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8769. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8770. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8771. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8772. fsiOPFLD.BilgDeptName = department.Name
  8773. fsiOPFLD.BilgDeptCodg = department.Number
  8774. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8775. fsiOPFLD.BilgDrName = doctor.UserName
  8776. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8777. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8778. fsiOPFLD.MedChrgitmType = "08"
  8779. memo["hosp_appr_flag"] = "1"
  8780. memo["invoice_no"] = order.MdtrtId
  8781. memo["memo"] = "自费"
  8782. bytesData, _ := json.Marshal(memo)
  8783. fsiOPFLD.Memo = string(bytesData)
  8784. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8785. }
  8786. }
  8787. }
  8788. fmt.Println(fsiOPFLDs)
  8789. struct4201A.Fopfd = fsiOPFLDs
  8790. fmt.Println(struct4201A.Fopfd)
  8791. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8792. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8793. var res2 ResultSix
  8794. var respJSON2 map[string]interface{}
  8795. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8798. return
  8799. }
  8800. userJSONBytes2, _ := json.Marshal(respJSON2)
  8801. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8802. utils.ErrorLog("解析失败:%v", err)
  8803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8804. return
  8805. }
  8806. if res2.Infcode != 0 {
  8807. c.ServeSuccessJSON(map[string]interface{}{
  8808. "failed_code": -10,
  8809. "msg": res2.ErrMsg,
  8810. })
  8811. return
  8812. } else {
  8813. order.IsUploadOrderInfo = 1
  8814. service.UpdateOrder(order)
  8815. c.ServeSuccessJSON(map[string]interface{}{
  8816. "msg": "上传成功",
  8817. })
  8818. }
  8819. }
  8820. func (c *HisApiController) Get4202() {
  8821. order_id, _ := c.GetInt64("order_id")
  8822. admin_user_id, _ := c.GetInt64("admin_user_id")
  8823. order, _ := service.GetHisOrderByIDTwo(order_id)
  8824. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8825. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8826. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8827. if order.ID == 0 {
  8828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8829. return
  8830. }
  8831. var struct4202 models.Struct4202
  8832. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8833. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8834. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8835. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8836. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8837. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8838. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8839. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8840. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8841. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8842. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8843. var config []*models.HisXtDiagnoseConfig
  8844. for _, item := range diagnosis_ids {
  8845. id, _ := strconv.ParseInt(item, 10, 64)
  8846. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8847. config = append(config, &diagnosisConfig)
  8848. }
  8849. var tempDiaginfos []models.OwnPayPatnDiagListD
  8850. for index, item := range config {
  8851. if index == 0 {
  8852. var tempDiaginfo models.OwnPayPatnDiagListD
  8853. tempDiaginfo.InoutDiagType = "1"
  8854. tempDiaginfo.DiagCode = item.CountryCode
  8855. tempDiaginfo.DiagName = item.CountryContentName
  8856. tempDiaginfo.DiagType = "1"
  8857. tempDiaginfo.DiagSrtNo = "1"
  8858. tempDiaginfo.MaindiagFlag = "1"
  8859. tempDiaginfo.ValiFlag = "1"
  8860. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8861. } else {
  8862. var tempDiaginfo models.OwnPayPatnDiagListD
  8863. tempDiaginfo.DiagCode = item.CountryCode
  8864. tempDiaginfo.DiagName = item.CountryContentName
  8865. tempDiaginfo.DiagType = "2"
  8866. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8867. tempDiaginfo.MaindiagFlag = "0"
  8868. tempDiaginfo.ValiFlag = "1"
  8869. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8870. }
  8871. }
  8872. struct4202.ODiagListD = tempDiaginfos
  8873. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8874. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8875. var res2 ResultSix
  8876. var respJSON2 map[string]interface{}
  8877. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8880. return
  8881. }
  8882. userJSONBytes2, _ := json.Marshal(respJSON2)
  8883. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8884. utils.ErrorLog("解析失败:%v", err)
  8885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8886. return
  8887. }
  8888. if res2.Infcode != 0 {
  8889. c.ServeSuccessJSON(map[string]interface{}{
  8890. "failed_code": -10,
  8891. "msg": res2.ErrMsg,
  8892. })
  8893. return
  8894. } else {
  8895. order.IsUploadDiagnose = 1
  8896. service.UpdateOrder(order)
  8897. c.ServeSuccessJSON(map[string]interface{}{
  8898. "msg": "上传成功",
  8899. })
  8900. }
  8901. }
  8902. func (c *HisApiController) Get4203() {
  8903. admin_user_id, _ := c.GetInt64("admin_user_id")
  8904. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8905. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8906. order_id, _ := c.GetInt64("order_id")
  8907. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8908. number := ""
  8909. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8910. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8911. if his.ID == 0 {
  8912. number = hospital.Number
  8913. } else {
  8914. number = his.Number
  8915. }
  8916. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8917. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8918. var res2 ResultSix
  8919. var respJSON2 map[string]interface{}
  8920. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8923. return
  8924. }
  8925. userJSONBytes2, _ := json.Marshal(respJSON2)
  8926. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8927. utils.ErrorLog("解析失败:%v", err)
  8928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8929. return
  8930. }
  8931. if res2.Infcode != 0 {
  8932. c.ServeSuccessJSON(map[string]interface{}{
  8933. "failed_code": -10,
  8934. "msg": res2.ErrMsg,
  8935. })
  8936. return
  8937. } else {
  8938. order.IsUploadSuccess = 1
  8939. service.UpdateOrderTwo(order)
  8940. c.ServeSuccessJSON(map[string]interface{}{
  8941. "msg": "上传成功",
  8942. })
  8943. }
  8944. }
  8945. func (c *HisApiController) Get4205() {
  8946. order_id, _ := c.GetInt64("order_id")
  8947. admin_user_id, _ := c.GetInt64("admin_user_id")
  8948. fapiao_code := c.GetString("fapiao_code")
  8949. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8950. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8951. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8952. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8953. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8954. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8955. //order_info = append(order_info, order_info_two...)
  8956. department, _ := service.GetDepartMentDetail(his.Departments)
  8957. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8958. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8959. if order.ID == 0 {
  8960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8961. return
  8962. }
  8963. var struct4201A models.Struct4201A
  8964. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8965. for _, items := range order_info {
  8966. memo := make(map[string]interface{})
  8967. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8968. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8969. fsiOPFLD.MedType = pre.MedType
  8970. fsiOPFLD.FixmedinsCode = miConfig.Code
  8971. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8972. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8973. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8974. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8975. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8976. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8977. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8978. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8979. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8980. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8981. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8982. fsiOPFLD.BilgDeptName = department.Name
  8983. fsiOPFLD.BilgDeptCodg = department.Number
  8984. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8985. fsiOPFLD.BilgDrName = doctor.UserName
  8986. fsiOPFLD.MedChrgitmType = "09"
  8987. memo["hosp_appr_flag"] = "1"
  8988. memo["invoice_no"] = fapiao_code
  8989. memo["memo"] = "自费"
  8990. bytesData, _ := json.Marshal(memo)
  8991. fsiOPFLD.Memo = string(bytesData)
  8992. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8993. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8994. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8995. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8996. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8997. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8998. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8999. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9000. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9001. fsiOPFLD.BilgDeptName = department.Name
  9002. fsiOPFLD.BilgDeptCodg = department.Number
  9003. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9004. fsiOPFLD.BilgDrName = doctor.UserName
  9005. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9006. case 0:
  9007. break
  9008. case 1:
  9009. fsiOPFLD.MedChrgitmType = "14"
  9010. break
  9011. case 2:
  9012. fsiOPFLD.MedChrgitmType = "05"
  9013. break
  9014. case 3:
  9015. fsiOPFLD.MedChrgitmType = "03"
  9016. break
  9017. case 4:
  9018. fsiOPFLD.MedChrgitmType = "03"
  9019. break
  9020. case 5:
  9021. fsiOPFLD.MedChrgitmType = "08"
  9022. break
  9023. case 6:
  9024. fsiOPFLD.MedChrgitmType = "14"
  9025. break
  9026. case 7:
  9027. fsiOPFLD.MedChrgitmType = "14"
  9028. break
  9029. case 8:
  9030. fsiOPFLD.MedChrgitmType = "03"
  9031. break
  9032. case 9:
  9033. fsiOPFLD.MedChrgitmType = "14"
  9034. break
  9035. case 10:
  9036. fsiOPFLD.MedChrgitmType = "14"
  9037. break
  9038. case 11:
  9039. fsiOPFLD.MedChrgitmType = "06"
  9040. break
  9041. case 12:
  9042. fsiOPFLD.MedChrgitmType = "12"
  9043. break
  9044. case 13:
  9045. fsiOPFLD.MedChrgitmType = "01"
  9046. break
  9047. case 14:
  9048. fsiOPFLD.MedChrgitmType = "04"
  9049. break
  9050. case 15:
  9051. fsiOPFLD.MedChrgitmType = "14"
  9052. break
  9053. }
  9054. memo["hosp_appr_flag"] = "1"
  9055. memo["invoice_no"] = fapiao_code
  9056. memo["memo"] = "自费"
  9057. bytesData, _ := json.Marshal(memo)
  9058. fsiOPFLD.Memo = string(bytesData)
  9059. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9060. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9061. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9062. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9063. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9064. fsiOPFLD.BilgDeptName = department.Name
  9065. fsiOPFLD.BilgDeptCodg = department.Number
  9066. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9067. fsiOPFLD.BilgDrName = doctor.UserName
  9068. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9069. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9070. fsiOPFLD.MedChrgitmType = "08"
  9071. memo["hosp_appr_flag"] = "1"
  9072. memo["invoice_no"] = fapiao_code
  9073. memo["memo"] = "自费"
  9074. bytesData, _ := json.Marshal(memo)
  9075. fsiOPFLD.Memo = string(bytesData)
  9076. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9077. }
  9078. }
  9079. }
  9080. for _, items := range order_info_two {
  9081. memo := make(map[string]interface{})
  9082. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9083. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9084. fsiOPFLD.MedType = pre.MedType
  9085. fsiOPFLD.BkkpSn = items.FeedetlSn
  9086. fsiOPFLD.FixmedinsCode = miConfig.Code
  9087. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9088. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9089. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9090. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9091. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9092. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9093. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9094. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9095. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9096. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9097. fsiOPFLD.BilgDeptName = department.Name
  9098. fsiOPFLD.BilgDeptCodg = department.Number
  9099. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9100. fsiOPFLD.BilgDrName = doctor.UserName
  9101. fsiOPFLD.MedChrgitmType = "09"
  9102. memo["hosp_appr_flag"] = "1"
  9103. memo["invoice_no"] = fapiao_code
  9104. memo["memo"] = "自费"
  9105. bytesData, _ := json.Marshal(memo)
  9106. fsiOPFLD.Memo = string(bytesData)
  9107. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9108. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9109. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9110. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9111. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9112. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9113. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9114. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9115. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9116. fsiOPFLD.BilgDeptName = department.Name
  9117. fsiOPFLD.BilgDeptCodg = department.Number
  9118. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9119. fsiOPFLD.BilgDrName = doctor.UserName
  9120. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9121. case 0:
  9122. break
  9123. case 1:
  9124. fsiOPFLD.MedChrgitmType = "14"
  9125. break
  9126. case 2:
  9127. fsiOPFLD.MedChrgitmType = "05"
  9128. break
  9129. case 3:
  9130. fsiOPFLD.MedChrgitmType = "03"
  9131. break
  9132. case 4:
  9133. fsiOPFLD.MedChrgitmType = "03"
  9134. break
  9135. case 5:
  9136. fsiOPFLD.MedChrgitmType = "08"
  9137. break
  9138. case 6:
  9139. fsiOPFLD.MedChrgitmType = "14"
  9140. break
  9141. case 7:
  9142. fsiOPFLD.MedChrgitmType = "14"
  9143. break
  9144. case 8:
  9145. fsiOPFLD.MedChrgitmType = "03"
  9146. break
  9147. case 9:
  9148. fsiOPFLD.MedChrgitmType = "14"
  9149. break
  9150. case 10:
  9151. fsiOPFLD.MedChrgitmType = "14"
  9152. break
  9153. case 11:
  9154. fsiOPFLD.MedChrgitmType = "06"
  9155. break
  9156. case 12:
  9157. fsiOPFLD.MedChrgitmType = "12"
  9158. break
  9159. case 13:
  9160. fsiOPFLD.MedChrgitmType = "01"
  9161. break
  9162. case 14:
  9163. fsiOPFLD.MedChrgitmType = "04"
  9164. break
  9165. case 15:
  9166. fsiOPFLD.MedChrgitmType = "14"
  9167. break
  9168. }
  9169. memo["hosp_appr_flag"] = "1"
  9170. memo["invoice_no"] = fapiao_code
  9171. memo["memo"] = "自费"
  9172. bytesData, _ := json.Marshal(memo)
  9173. fsiOPFLD.Memo = string(bytesData)
  9174. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9175. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9176. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9177. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9178. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9179. fsiOPFLD.BilgDeptName = department.Name
  9180. fsiOPFLD.BilgDeptCodg = department.Number
  9181. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9182. fsiOPFLD.BilgDrName = doctor.UserName
  9183. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9184. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9185. fsiOPFLD.MedChrgitmType = "08"
  9186. memo["hosp_appr_flag"] = "1"
  9187. memo["invoice_no"] = fapiao_code
  9188. memo["memo"] = "自费"
  9189. bytesData, _ := json.Marshal(memo)
  9190. fsiOPFLD.Memo = string(bytesData)
  9191. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9192. }
  9193. }
  9194. }
  9195. fmt.Println(fsiOPFLDs)
  9196. struct4201A.Fopfd = fsiOPFLDs
  9197. fmt.Println(struct4201A.Fopfd)
  9198. var struct4202 models.Struct4202
  9199. timeLayout := "2006-01-02 15:04:05"
  9200. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9201. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9202. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9203. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9204. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9205. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9206. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9207. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9208. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9209. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9210. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9211. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9212. var config []*models.HisXtDiagnoseConfig
  9213. for _, item := range diagnosis_ids {
  9214. id, _ := strconv.ParseInt(item, 10, 64)
  9215. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9216. config = append(config, &diagnosisConfig)
  9217. }
  9218. var tempDiaginfos []models.OwnPayPatnDiagListD
  9219. for index, item := range config {
  9220. if index == 0 {
  9221. var tempDiaginfo models.OwnPayPatnDiagListD
  9222. tempDiaginfo.InoutDiagType = "1"
  9223. tempDiaginfo.DiagCode = item.CountryCode
  9224. tempDiaginfo.DiagName = item.CountryContentName
  9225. tempDiaginfo.DiagType = "1"
  9226. tempDiaginfo.DiagSrtNo = "1"
  9227. tempDiaginfo.MaindiagFlag = "1"
  9228. tempDiaginfo.ValiFlag = "1"
  9229. tempDiaginfo.DiagDrName = doctor.UserName
  9230. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9231. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9232. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9233. } else {
  9234. var tempDiaginfo models.OwnPayPatnDiagListD
  9235. tempDiaginfo.DiagCode = item.CountryCode
  9236. tempDiaginfo.DiagName = item.CountryContentName
  9237. tempDiaginfo.DiagType = "2"
  9238. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9239. tempDiaginfo.MaindiagFlag = "0"
  9240. tempDiaginfo.ValiFlag = "1"
  9241. tempDiaginfo.DiagDrName = doctor.UserName
  9242. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9243. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9244. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9245. }
  9246. }
  9247. struct4202.ODiagListD = tempDiaginfos
  9248. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9249. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9250. var res2 ResultSix
  9251. var respJSON2 map[string]interface{}
  9252. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9255. return
  9256. }
  9257. userJSONBytes2, _ := json.Marshal(respJSON2)
  9258. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9259. utils.ErrorLog("解析失败:%v", err)
  9260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9261. return
  9262. }
  9263. if res2.Infcode != 0 {
  9264. c.ServeSuccessJSON(map[string]interface{}{
  9265. "failed_code": -10,
  9266. "msg": res2.ErrMsg,
  9267. })
  9268. return
  9269. } else {
  9270. order.IsUploadDiagnose = 1
  9271. order.IsUploadOrderInfo = 1
  9272. service.UpdateOrderTwo(order)
  9273. c.ServeSuccessJSON(map[string]interface{}{
  9274. "msg": "上传成功",
  9275. })
  9276. }
  9277. }
  9278. func (c *HisApiController) Get4207() {
  9279. admin_user_id, _ := c.GetInt64("admin_user_id")
  9280. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9281. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9282. order_id, _ := c.GetInt64("order_id")
  9283. order, _ := service.GetHisOrderByIDTwo(order_id)
  9284. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9285. var struct4207 models.Struct4207
  9286. struct4207.PageNum = "1"
  9287. struct4207.PageSize = "1000"
  9288. struct4207.FixmedinsCode = miConfig.Code
  9289. struct4207.FixmedinsMdtrtID = order.Number
  9290. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9291. saveLog(result, requestLog, "4207", "查询")
  9292. var res2 ResultSix
  9293. var respJSON2 map[string]interface{}
  9294. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9297. return
  9298. }
  9299. userJSONBytes2, _ := json.Marshal(respJSON2)
  9300. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9301. utils.ErrorLog("解析失败:%v", err)
  9302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9303. return
  9304. }
  9305. if res2.Infcode != 0 {
  9306. c.ServeSuccessJSON(map[string]interface{}{
  9307. "failed_code": -10,
  9308. "msg": res2.ErrMsg,
  9309. })
  9310. return
  9311. } else {
  9312. c.ServeSuccessJSON(map[string]interface{}{
  9313. "msg": "查询成功",
  9314. })
  9315. }
  9316. }
  9317. func (c *HisApiController) Get4208() {
  9318. admin_user_id, _ := c.GetInt64("admin_user_id")
  9319. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9320. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9321. order_id, _ := c.GetInt64("order_id")
  9322. order, _ := service.GetHisOrderByIDTwo(order_id)
  9323. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9324. var struct4208 models.Struct4208
  9325. struct4208.PageNum = "1"
  9326. struct4208.PageSize = "1000"
  9327. struct4208.PsnCertType = "01"
  9328. struct4208.Certno = his.Certno
  9329. struct4208.MedType = order.MedType
  9330. struct4208.PsnName = his.Name
  9331. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9332. saveLog(result, requestLog, "4208", "查询")
  9333. var res2 ResultSix
  9334. var respJSON2 map[string]interface{}
  9335. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9338. return
  9339. }
  9340. userJSONBytes2, _ := json.Marshal(respJSON2)
  9341. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9342. utils.ErrorLog("解析失败:%v", err)
  9343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9344. return
  9345. }
  9346. if res2.Infcode != 0 {
  9347. c.ServeSuccessJSON(map[string]interface{}{
  9348. "failed_code": -10,
  9349. "msg": res2.ErrMsg,
  9350. })
  9351. return
  9352. } else {
  9353. c.ServeSuccessJSON(map[string]interface{}{
  9354. "msg": "查询成功",
  9355. })
  9356. }
  9357. }
  9358. func (c *HisApiController) Get4209() {
  9359. admin_user_id, _ := c.GetInt64("admin_user_id")
  9360. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9361. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9362. order_id, _ := c.GetInt64("order_id")
  9363. order, _ := service.GetHisOrderByIDTwo(order_id)
  9364. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9365. var struct4209 models.Struct4209
  9366. struct4209.FixmedinsMdtrtID = order.Number
  9367. struct4209.FixmedinsCode = miConfig.Code
  9368. struct4209.PageSize = "1000"
  9369. struct4209.PageNum = "1"
  9370. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9371. saveLog(result, requestLog, "4209", "查询")
  9372. var res2 ResultSix
  9373. var respJSON2 map[string]interface{}
  9374. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9377. return
  9378. }
  9379. userJSONBytes2, _ := json.Marshal(respJSON2)
  9380. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9381. utils.ErrorLog("解析失败:%v", err)
  9382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9383. return
  9384. }
  9385. if res2.Infcode != 0 {
  9386. c.ServeSuccessJSON(map[string]interface{}{
  9387. "failed_code": -10,
  9388. "msg": res2.ErrMsg,
  9389. })
  9390. return
  9391. } else {
  9392. c.ServeSuccessJSON(map[string]interface{}{
  9393. "msg": "查询成功",
  9394. })
  9395. }
  9396. }
  9397. type Result3101 struct {
  9398. Infcode string `json:"infcode"`
  9399. InfRefmsgid string `json:"inf_refmsgid"`
  9400. RefmsgTime string `json:"refmsg_time"`
  9401. RespondTime string `json:"respond_time"`
  9402. Enctype string `json:"enctype"`
  9403. Signtype string `json:"signtype"`
  9404. ErrMsg string `json:"err_msg"`
  9405. Output struct {
  9406. Result []struct {
  9407. JudgeResultDetailDtos []struct {
  9408. VolaItemType string `json:"vola_item_type"`
  9409. MdtrtID string `json:"mdtrt_id"`
  9410. JrdID string `json:"jrd_id"`
  9411. PatnID string `json:"patn_id"`
  9412. RxID string `json:"rx_id"`
  9413. VolaAmt interface{} `json:"vola_amt"`
  9414. } `json:"judge_result_detail_dtos"`
  9415. RuleID string `json:"rule_id"`
  9416. VolaEvid string `json:"vola_evid"`
  9417. MdtrtID string `json:"mdtrt_id"`
  9418. RuleName string `json:"rule_name"`
  9419. VolaAmtStas string `json:"vola_amt_stas"`
  9420. JrID string `json:"jr_id"`
  9421. PatnID string `json:"patn_id"`
  9422. SevDeg string `json:"sev_deg"`
  9423. VolaAmt float64 `json:"vola_amt"`
  9424. VolaBhvrType string `json:"vola_bhvr_type"`
  9425. VolaCont string `json:"vola_cont"`
  9426. } `json:"result"`
  9427. } `json:"output"`
  9428. }
  9429. type Resultgd3101 struct {
  9430. Infcode int64 `json:"infcode"`
  9431. InfRefmsgid string `json:"inf_refmsgid"`
  9432. RefmsgTime string `json:"refmsg_time"`
  9433. RespondTime string `json:"respond_time"`
  9434. Enctype string `json:"enctype"`
  9435. Signtype string `json:"signtype"`
  9436. ErrMsg string `json:"err_msg"`
  9437. Output struct {
  9438. Result []struct {
  9439. JudgeResultDetailDtos []struct {
  9440. VolaItemType string `json:"vola_item_type"`
  9441. MdtrtID string `json:"mdtrt_id"`
  9442. JrdID string `json:"jrd_id"`
  9443. PatnID string `json:"patn_id"`
  9444. RxID string `json:"rx_id"`
  9445. VolaAmt interface{} `json:"vola_amt"`
  9446. } `json:"judge_result_detail_dtos"`
  9447. RuleID string `json:"rule_id"`
  9448. VolaEvid string `json:"vola_evid"`
  9449. MdtrtID string `json:"mdtrt_id"`
  9450. RuleName string `json:"rule_name"`
  9451. VolaAmtStas string `json:"vola_amt_stas"`
  9452. JrID string `json:"jr_id"`
  9453. PatnID string `json:"patn_id"`
  9454. SevDeg string `json:"sev_deg"`
  9455. VolaAmt float64 `json:"vola_amt"`
  9456. VolaBhvrType string `json:"vola_bhvr_type"`
  9457. VolaCont string `json:"vola_cont"`
  9458. } `json:"result"`
  9459. } `json:"output"`
  9460. }
  9461. func (c *HisApiController) ReadEleToken() {
  9462. admin_user_id, _ := c.GetInt64("admin_user_id")
  9463. his_patient_id, _ := c.GetInt64("his_patient_id")
  9464. adminUser := c.GetAdminUserInfo()
  9465. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9466. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9467. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9468. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9469. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9470. if len(tokens) > 0 {
  9471. c.ServeSuccessJSON(map[string]interface{}{
  9472. "msg": "读取成功",
  9473. })
  9474. } else {
  9475. c.ServeSuccessJSON(map[string]interface{}{
  9476. "failed_code": -10,
  9477. "msg": "读取失败",
  9478. })
  9479. }
  9480. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9481. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9482. if len(tokens) > 0 {
  9483. c.ServeSuccessJSON(map[string]interface{}{
  9484. "msg": "读取成功",
  9485. })
  9486. } else {
  9487. c.ServeSuccessJSON(map[string]interface{}{
  9488. "failed_code": -10,
  9489. "msg": "读取失败",
  9490. })
  9491. }
  9492. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9493. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9494. if len(tokens) > 0 {
  9495. c.ServeSuccessJSON(map[string]interface{}{
  9496. "msg": "读取成功",
  9497. })
  9498. } else {
  9499. c.ServeSuccessJSON(map[string]interface{}{
  9500. "failed_code": -10,
  9501. "msg": "读取失败",
  9502. })
  9503. }
  9504. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9505. var api string
  9506. 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 +
  9507. "&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"
  9508. resp, requestErr := http.Get(api)
  9509. if requestErr != nil {
  9510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9511. }
  9512. body, ioErr := ioutil.ReadAll(resp.Body)
  9513. if ioErr != nil {
  9514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9516. }
  9517. var respJSON map[string]interface{}
  9518. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9521. return
  9522. }
  9523. var status string
  9524. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9525. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9526. var token string
  9527. var res ResultTwo //1101结果
  9528. var res10265 ResultTwo10265 //1101结果
  9529. if status == "0" { //读卡成功
  9530. var card_info string //卡信息
  9531. var busi_card_info string
  9532. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9533. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9534. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9535. fmt.Println(card_info)
  9536. fmt.Println(busi_card_info)
  9537. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9538. result, _ := json.Marshal(respJSON)
  9539. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9540. utils.ErrorLog("解析失败:%v", err)
  9541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9542. return
  9543. }
  9544. res.ErrMsg = res10265.ErrMsg
  9545. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9546. res.Infcode = infocode
  9547. res.Output = res10265.Output
  9548. res.InfRefmsgid = res10265.InfRefmsgid
  9549. if res.Infcode == 0 {
  9550. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9551. if err == gorm.ErrRecordNotFound {
  9552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9553. return
  9554. } else if err != nil {
  9555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9556. return
  9557. } else {
  9558. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9559. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9560. infoStr := string(Iinfos)
  9561. idetinfoStr := string(Idetinfos)
  9562. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9563. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9564. psn := &models.HisPsn{
  9565. PsnNo: res.Output.Baseinfo.PsnNo,
  9566. PatientId: patient.ID,
  9567. Certno: res.Output.Baseinfo.Certno,
  9568. Gend: res.Output.Baseinfo.Gend,
  9569. Naty: res.Output.Baseinfo.Naty,
  9570. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9571. PsnName: res.Output.Baseinfo.PsnName,
  9572. Age: float64(age),
  9573. Brdy: b,
  9574. Idetinfo: idetinfoStr,
  9575. Insuinfo: infoStr,
  9576. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9577. CardInfo: card_info,
  9578. VerifyNumber: token,
  9579. IdCardType: 4,
  9580. }
  9581. var rf []*ResultFive
  9582. json.Unmarshal([]byte(infoStr), &rf)
  9583. var insutypes []*ResultFive
  9584. var insutype string
  9585. var is390 int = 0
  9586. var is310 int = 0
  9587. for _, item := range rf {
  9588. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9589. insutypes = append(insutypes, item)
  9590. }
  9591. }
  9592. if len(insutypes) == 1 {
  9593. insutype = insutypes[0].Insutype
  9594. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9595. } else {
  9596. for _, i := range insutypes {
  9597. if i.Insutype == "390" {
  9598. is390 = 1
  9599. }
  9600. if i.Insutype == "310" {
  9601. is310 = 1
  9602. }
  9603. }
  9604. }
  9605. if is390 == 1 {
  9606. insutype = "390"
  9607. }
  9608. if is310 == 1 {
  9609. insutype = "310"
  9610. }
  9611. if len(insutypes) == 0 {
  9612. insutype = "310"
  9613. }
  9614. service.CreateHisPsn(psn)
  9615. c.ServeSuccessJSON(map[string]interface{}{
  9616. "patient": patient,
  9617. "number": token,
  9618. "insutype": insutype,
  9619. })
  9620. }
  9621. } else {
  9622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9623. return
  9624. }
  9625. } else { //读卡失败
  9626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9627. return
  9628. }
  9629. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9630. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9631. if len(errMsg) == 0 {
  9632. type ELeData struct {
  9633. Data struct {
  9634. IdNo string `json:"idNo"`
  9635. IdType string `json:"idType"`
  9636. UserName string `json:"userName"`
  9637. EcToken string `json:"ecToken"`
  9638. InsuOrg string `json:"insuOrg"`
  9639. Gender string `json:"gender"`
  9640. Birthday string `json:"birthday"`
  9641. Nationality string `json:"nationality"`
  9642. Email string `json:"email"`
  9643. Extra string `json:"extra"`
  9644. } `json:"data"`
  9645. Code int `json:"code"`
  9646. Message string `json:"message"`
  9647. }
  9648. var ele ELeData
  9649. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9650. if err != nil {
  9651. utils.ErrorLog("解析失败:%v", err)
  9652. }
  9653. token := ele.Data.EcToken
  9654. if len(token) > 0 {
  9655. psn := &models.HisPsn{
  9656. PsnNo: his.PsnNo,
  9657. Age: 0,
  9658. PatientId: his.PatientId,
  9659. Certno: his.Certno,
  9660. Brdy: his.Brdy,
  9661. Gend: his.Gend,
  9662. Naty: his.Naty,
  9663. PsnCertType: his.PsnCertType,
  9664. PsnName: his.PsnName,
  9665. Idetinfo: his.Idetinfo,
  9666. Insuinfo: his.Iinfo,
  9667. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9668. CardInfo: outPutInfo,
  9669. VerifyNumber: token,
  9670. }
  9671. service.CreateHisPsn(psn)
  9672. }
  9673. if len(token) > 0 {
  9674. c.ServeSuccessJSON(map[string]interface{}{
  9675. "msg": "读取成功",
  9676. })
  9677. } else {
  9678. c.ServeSuccessJSON(map[string]interface{}{
  9679. "failed_code": -10,
  9680. "msg": "读取失败",
  9681. })
  9682. }
  9683. }
  9684. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9685. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9686. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9687. type ELeData struct {
  9688. Data struct {
  9689. IdNo string `json:"idNo"`
  9690. IdType string `json:"idType"`
  9691. UserName string `json:"userName"`
  9692. EcToken string `json:"ecToken"`
  9693. InsuOrg string `json:"insuOrg"`
  9694. Gender string `json:"gender"`
  9695. Birthday string `json:"birthday"`
  9696. Nationality string `json:"nationality"`
  9697. Email string `json:"email"`
  9698. Extra string `json:"extra"`
  9699. } `json:"data"`
  9700. Code int `json:"code"`
  9701. Message string `json:"message"`
  9702. }
  9703. var ele ELeData
  9704. err := json.Unmarshal([]byte(result), &ele)
  9705. if err != nil {
  9706. utils.ErrorLog("解析失败:%v", err)
  9707. }
  9708. token := ele.Data.EcToken
  9709. token = Remove0000(token)
  9710. fmt.Println(ele.Data.UserName)
  9711. 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)
  9712. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9713. var res ResultTwo
  9714. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9715. utils.ErrorLog("解析失败:%v", err)
  9716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9717. return
  9718. }
  9719. if res.Infcode == 0 {
  9720. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9721. if err == gorm.ErrRecordNotFound {
  9722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9723. return
  9724. } else if err != nil {
  9725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9726. return
  9727. } else {
  9728. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9729. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9730. infoStr := string(Iinfos)
  9731. idetinfoStr := string(Idetinfos)
  9732. psn := &models.HisPsn{
  9733. PsnNo: res.Output.Baseinfo.PsnNo,
  9734. PatientId: patient.ID,
  9735. Certno: res.Output.Baseinfo.Certno,
  9736. Gend: res.Output.Baseinfo.Gend,
  9737. Naty: res.Output.Baseinfo.Naty,
  9738. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9739. PsnName: res.Output.Baseinfo.PsnName,
  9740. Idetinfo: idetinfoStr,
  9741. Insuinfo: infoStr,
  9742. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9743. CardInfo: "",
  9744. VerifyNumber: token,
  9745. }
  9746. service.CreateHisPsn(psn)
  9747. c.ServeSuccessJSON(map[string]interface{}{
  9748. "patient": patient,
  9749. "number": token,
  9750. })
  9751. }
  9752. } else {
  9753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9754. return
  9755. }
  9756. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9757. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9758. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9759. type ELeData struct {
  9760. Data struct {
  9761. IdNo string `json:"idNo"`
  9762. IdType string `json:"idType"`
  9763. UserName string `json:"userName"`
  9764. EcToken string `json:"ecToken"`
  9765. InsuOrg string `json:"insuOrg"`
  9766. Gender string `json:"gender"`
  9767. Birthday string `json:"birthday"`
  9768. Nationality string `json:"nationality"`
  9769. Email string `json:"email"`
  9770. Extra string `json:"extra"`
  9771. } `json:"data"`
  9772. Code int `json:"code"`
  9773. Message string `json:"message"`
  9774. }
  9775. var ele ELeData
  9776. err := json.Unmarshal([]byte(result), &ele)
  9777. if err != nil {
  9778. utils.ErrorLog("解析失败:%v", err)
  9779. }
  9780. token := ele.Data.EcToken
  9781. token = Remove0000(token)
  9782. fmt.Println(ele.Data.UserName)
  9783. 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)
  9784. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9785. var res ResultTwo
  9786. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9787. utils.ErrorLog("解析失败:%v", err)
  9788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9789. return
  9790. }
  9791. if res.Infcode == 0 {
  9792. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9793. if err == gorm.ErrRecordNotFound {
  9794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9795. return
  9796. } else if err != nil {
  9797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9798. return
  9799. } else {
  9800. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9801. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9802. infoStr := string(Iinfos)
  9803. idetinfoStr := string(Idetinfos)
  9804. psn := &models.HisPsn{
  9805. PsnNo: res.Output.Baseinfo.PsnNo,
  9806. PatientId: patient.ID,
  9807. Certno: res.Output.Baseinfo.Certno,
  9808. Gend: res.Output.Baseinfo.Gend,
  9809. Naty: res.Output.Baseinfo.Naty,
  9810. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9811. PsnName: res.Output.Baseinfo.PsnName,
  9812. Idetinfo: idetinfoStr,
  9813. Insuinfo: infoStr,
  9814. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9815. CardInfo: "",
  9816. VerifyNumber: token,
  9817. }
  9818. service.CreateHisPsn(psn)
  9819. c.ServeSuccessJSON(map[string]interface{}{
  9820. "patient": patient,
  9821. "number": token,
  9822. })
  9823. }
  9824. } else {
  9825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9826. return
  9827. }
  9828. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9829. //if initFlag == 0 {
  9830. //c.TestGetJiangXiBasBaseInit()
  9831. //}
  9832. //if initEleFlag == 0 {
  9833. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9834. //}
  9835. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9836. utils.ErrorLog("解析失败:%v", json_result)
  9837. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9838. type ELeData struct {
  9839. Data struct {
  9840. IdNo string `json:"idNo"`
  9841. IdType string `json:"idType"`
  9842. UserName string `json:"userName"`
  9843. EcToken string `json:"ecToken"`
  9844. InsuOrg string `json:"insuOrg"`
  9845. Gender string `json:"gender"`
  9846. Birthday string `json:"birthday"`
  9847. Nationality string `json:"nationality"`
  9848. Email string `json:"email"`
  9849. Extra string `json:"extra"`
  9850. } `json:"data"`
  9851. Code int `json:"code"`
  9852. Message string `json:"message"`
  9853. }
  9854. var ele ELeData
  9855. err := json.Unmarshal([]byte(json_result), &ele)
  9856. if err != nil {
  9857. utils.ErrorLog("解析失败:%v", err)
  9858. }
  9859. token := ele.Data.EcToken
  9860. token = Remove0000(token)
  9861. //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)
  9862. 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)
  9863. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9864. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9865. var res ResultTwo
  9866. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9867. utils.ErrorLog("解析失败:%v", err)
  9868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9869. return
  9870. }
  9871. if res.Infcode == 0 {
  9872. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9873. if err == gorm.ErrRecordNotFound {
  9874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9875. return
  9876. } else if err != nil {
  9877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9878. return
  9879. } else {
  9880. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9881. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9882. infoStr := string(Iinfos)
  9883. idetinfoStr := string(Idetinfos)
  9884. psn := &models.HisPsn{
  9885. PsnNo: res.Output.Baseinfo.PsnNo,
  9886. PatientId: patient.ID,
  9887. Certno: res.Output.Baseinfo.Certno,
  9888. Gend: res.Output.Baseinfo.Gend,
  9889. Naty: res.Output.Baseinfo.Naty,
  9890. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9891. PsnName: res.Output.Baseinfo.PsnName,
  9892. Idetinfo: idetinfoStr,
  9893. Insuinfo: infoStr,
  9894. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9895. CardInfo: "",
  9896. VerifyNumber: token,
  9897. InsuplcAdmdvs: ele.Data.InsuOrg,
  9898. }
  9899. service.CreateHisPsn(psn)
  9900. c.ServeSuccessJSON(map[string]interface{}{
  9901. "patient": patient,
  9902. "number": token,
  9903. })
  9904. }
  9905. } else {
  9906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9907. return
  9908. }
  9909. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9910. res := c.GetoleInfo()
  9911. if res.Infcode == 0 {
  9912. var result string
  9913. if res.Output.MdtrtCertType == "01" {
  9914. 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)
  9915. } else if res.Output.MdtrtCertType == "02" {
  9916. 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)
  9917. } else if res.Output.MdtrtCertType == "03" {
  9918. 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)
  9919. }
  9920. var dat map[string]interface{}
  9921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9922. fmt.Println(dat)
  9923. } else {
  9924. fmt.Println(err)
  9925. }
  9926. userJSONBytes, _ := json.Marshal(dat)
  9927. var res2 ResultTwo
  9928. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9929. utils.ErrorLog("解析失败:%v", err)
  9930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9931. return
  9932. }
  9933. if res2.Infcode == 0 {
  9934. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9935. if err == gorm.ErrRecordNotFound {
  9936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9937. return
  9938. } else if err != nil {
  9939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9940. return
  9941. } else {
  9942. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9943. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9944. infoStr := string(Iinfos)
  9945. idetinfoStr := string(Idetinfos)
  9946. var rf []*ResultFive
  9947. json.Unmarshal([]byte(infoStr), &rf)
  9948. var insutypes []*ResultFive
  9949. var insutype string
  9950. var is390 int = 0
  9951. var is310 int = 0
  9952. //var insuplc_admdvs string
  9953. for _, item := range rf {
  9954. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9955. insutypes = append(insutypes, item)
  9956. }
  9957. }
  9958. if len(insutypes) == 1 {
  9959. insutype = insutypes[0].Insutype
  9960. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9961. } else {
  9962. for _, i := range insutypes {
  9963. if i.Insutype == "390" {
  9964. is390 = 1
  9965. }
  9966. if i.Insutype == "310" {
  9967. is310 = 1
  9968. }
  9969. }
  9970. }
  9971. if is390 == 1 {
  9972. insutype = "390"
  9973. }
  9974. if is310 == 1 {
  9975. insutype = "310"
  9976. }
  9977. if len(insutypes) == 0 {
  9978. insutype = "310"
  9979. }
  9980. psn := &models.HisPsn{
  9981. PsnNo: res2.Output.Baseinfo.PsnNo,
  9982. PatientId: patient.ID,
  9983. Certno: res2.Output.Baseinfo.Certno,
  9984. Gend: res2.Output.Baseinfo.Gend,
  9985. Naty: res2.Output.Baseinfo.Naty,
  9986. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9987. PsnName: res2.Output.Baseinfo.PsnName,
  9988. Idetinfo: idetinfoStr,
  9989. Insuinfo: infoStr,
  9990. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9991. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9992. VerifyNumber: res.Output.EcToken,
  9993. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9994. }
  9995. service.CreateHisPsn(psn)
  9996. c.ServeSuccessJSON(map[string]interface{}{
  9997. "patient": patient,
  9998. "number": res.Output.CardNo,
  9999. "insutype": insutype,
  10000. })
  10001. }
  10002. } else {
  10003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10004. return
  10005. }
  10006. } else {
  10007. c.ServeSuccessJSON(map[string]interface{}{
  10008. "failed_code": -10,
  10009. "msg": res.ErrMsg,
  10010. })
  10011. }
  10012. } else {
  10013. //if initFlag == 0 {
  10014. // c.TestGetBasBaseInit()
  10015. //}
  10016. //token := c.GetEleBaseInfo()
  10017. //token = Remove0000(token)
  10018. type ELeData struct {
  10019. Code string `json:"code"`
  10020. Data struct {
  10021. Aac002 string `json:"aac002"`
  10022. Aaz500 string `json:"aaz500"`
  10023. ActCardNo string `json:"actCardNo"`
  10024. Bab520 string `json:"bab520"`
  10025. Bkz543 string `json:"bkz543"`
  10026. BusinessType string `json:"businessType"`
  10027. CertfCodg string `json:"certfCodg"`
  10028. EcIndexNo string `json:"ecIndexNo"`
  10029. EcToken string `json:"ecToken"`
  10030. ID0000 string `json:"id0000"`
  10031. IDNo string `json:"idNo"`
  10032. IDType string `json:"idType"`
  10033. Idcode string `json:"idcode"`
  10034. IdentityToken string `json:"identity_token"`
  10035. InsuOrg string `json:"insuOrg"`
  10036. OfficeID string `json:"officeId"`
  10037. OfficeName string `json:"officeName"`
  10038. OperatorID string `json:"operatorId"`
  10039. OperatorName string `json:"operatorName"`
  10040. OrgID string `json:"orgId"`
  10041. UserName string `json:"userName"`
  10042. } `json:"data"`
  10043. Infno interface{} `json:"infno"`
  10044. Message string `json:"message"`
  10045. OrgID string `json:"orgId"`
  10046. TransType string `json:"transType"`
  10047. }
  10048. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10049. fmt.Println(result)
  10050. outPutInfo := Remove0000(result)
  10051. fmt.Println(outPutInfo)
  10052. var ele ELeData
  10053. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10054. if err != nil {
  10055. utils.ErrorLog("解析失败:%v", err)
  10056. }
  10057. token := ele.Data.EcToken
  10058. var result2 string
  10059. var requestLog2 string
  10060. if len(token) > 0 {
  10061. if strings.Contains(ele.Data.IDNo, "HKG") {
  10062. 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)
  10063. } else {
  10064. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10065. }
  10066. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10067. var res ResultTwo
  10068. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10069. utils.ErrorLog("解析失败:%v", err)
  10070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10071. return
  10072. }
  10073. if res.Infcode == 0 {
  10074. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10075. if err == gorm.ErrRecordNotFound {
  10076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10077. return
  10078. } else if err != nil {
  10079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10080. return
  10081. } else {
  10082. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10083. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10084. infoStr := string(Iinfos)
  10085. idetinfoStr := string(Idetinfos)
  10086. psn := &models.HisPsn{
  10087. PsnNo: res.Output.Baseinfo.PsnNo,
  10088. PatientId: patient.ID,
  10089. Certno: res.Output.Baseinfo.Certno,
  10090. Gend: res.Output.Baseinfo.Gend,
  10091. Naty: res.Output.Baseinfo.Naty,
  10092. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10093. PsnName: res.Output.Baseinfo.PsnName,
  10094. Idetinfo: idetinfoStr,
  10095. Insuinfo: infoStr,
  10096. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10097. CardInfo: "",
  10098. VerifyNumber: token,
  10099. }
  10100. service.CreateHisPsn(psn)
  10101. c.ServeSuccessJSON(map[string]interface{}{
  10102. "msg": "读取成功",
  10103. })
  10104. }
  10105. } else {
  10106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10107. return
  10108. }
  10109. } else {
  10110. c.ServeSuccessJSON(map[string]interface{}{
  10111. "failed_code": -10,
  10112. "msg": "读取失败",
  10113. })
  10114. }
  10115. }
  10116. }
  10117. func (c *HisApiController) ReadEleFace() {
  10118. admin_user_id, _ := c.GetInt64("admin_user_id")
  10119. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10120. adminUser := c.GetAdminUserInfo()
  10121. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10122. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10123. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10124. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10125. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10126. if len(tokens) > 0 {
  10127. c.ServeSuccessJSON(map[string]interface{}{
  10128. "msg": "读取成功",
  10129. })
  10130. } else {
  10131. c.ServeSuccessJSON(map[string]interface{}{
  10132. "failed_code": -10,
  10133. "msg": "读取失败",
  10134. })
  10135. }
  10136. }
  10137. }
  10138. func (c *HisApiController) Get9001() {
  10139. adminUser := c.GetAdminUserInfo()
  10140. admin_user_id, _ := c.GetInt64("admin_user_id")
  10141. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10142. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10143. if miConfig.MdtrtareaAdmvs == "350500" {
  10144. service.GetFjAuthorizationInfo(miConfig.Code)
  10145. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10146. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10147. var dat map[string]interface{}
  10148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10149. fmt.Println(dat)
  10150. } else {
  10151. fmt.Println(err)
  10152. }
  10153. userJSONBytes, _ := json.Marshal(dat)
  10154. var res models.Result9001
  10155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10156. utils.ErrorLog("解析失败:%v", err)
  10157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10158. return
  10159. }
  10160. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10161. fmt.Println(miConfig.SecretKey)
  10162. var res models.Result9001Two
  10163. 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 +
  10164. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10165. resp, requestErr := http.Get(api)
  10166. if requestErr != nil {
  10167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10168. return
  10169. }
  10170. body, ioErr := ioutil.ReadAll(resp.Body)
  10171. if ioErr != nil {
  10172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10174. return
  10175. }
  10176. var respJSON map[string]interface{}
  10177. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10180. return
  10181. }
  10182. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10183. if status == "0" {
  10184. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10185. c.ServeSuccessJSON(map[string]interface{}{
  10186. "failed_code": -10,
  10187. "msg": err_msg,
  10188. })
  10189. return
  10190. }
  10191. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10192. result, _ := json.Marshal(respJSON)
  10193. fmt.Println("log")
  10194. fmt.Println(string(result))
  10195. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10196. utils.ErrorLog("解析失败:%v", err)
  10197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10198. return
  10199. }
  10200. if res.Infcode == 0 {
  10201. sign := models.HisSignIn{
  10202. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10203. SignNo: res.Output.Signinoutb.SignNo,
  10204. SignTime: "",
  10205. Ctime: time.Now().Unix(),
  10206. Mtime: time.Now().Unix(),
  10207. Status: 1,
  10208. InputLog: "",
  10209. OutputLog: "",
  10210. FixmedinsCode: miConfig.Code,
  10211. }
  10212. err := service.CreateSignIn(&sign)
  10213. if err == nil {
  10214. c.ServeSuccessJSON(map[string]interface{}{
  10215. "msg": "签到成功",
  10216. })
  10217. }
  10218. } else {
  10219. c.ServeSuccessJSON(map[string]interface{}{
  10220. "failed_code": -10,
  10221. "msg": res.ErrMsg,
  10222. })
  10223. return
  10224. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10225. //return
  10226. }
  10227. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10228. fmt.Println(miConfig.SecretKey)
  10229. var res models.Result9001Two
  10230. 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 +
  10231. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10232. resp, requestErr := http.Get(api)
  10233. if requestErr != nil {
  10234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10235. return
  10236. }
  10237. body, ioErr := ioutil.ReadAll(resp.Body)
  10238. if ioErr != nil {
  10239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10241. return
  10242. }
  10243. var respJSON map[string]interface{}
  10244. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10247. return
  10248. }
  10249. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10250. if status == "0" {
  10251. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10252. c.ServeSuccessJSON(map[string]interface{}{
  10253. "failed_code": -10,
  10254. "msg": err_msg,
  10255. })
  10256. return
  10257. }
  10258. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10259. result, _ := json.Marshal(respJSON)
  10260. fmt.Println("log")
  10261. fmt.Println(string(result))
  10262. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10263. utils.ErrorLog("解析失败:%v", err)
  10264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10265. return
  10266. }
  10267. if res.Infcode == 0 {
  10268. sign := models.HisSignIn{
  10269. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10270. SignNo: res.Output.Signinoutb.SignNo,
  10271. SignTime: "",
  10272. Ctime: time.Now().Unix(),
  10273. Mtime: time.Now().Unix(),
  10274. Status: 1,
  10275. InputLog: "",
  10276. OutputLog: "",
  10277. FixmedinsCode: miConfig.Code,
  10278. }
  10279. err := service.CreateSignIn(&sign)
  10280. if err == nil {
  10281. c.ServeSuccessJSON(map[string]interface{}{
  10282. "msg": "签到成功",
  10283. })
  10284. }
  10285. } else {
  10286. c.ServeSuccessJSON(map[string]interface{}{
  10287. "failed_code": -10,
  10288. "msg": res.ErrMsg,
  10289. })
  10290. return
  10291. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10292. //return
  10293. }
  10294. } else {
  10295. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10296. var dat map[string]interface{}
  10297. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10298. fmt.Println(dat)
  10299. } else {
  10300. fmt.Println(err)
  10301. }
  10302. userJSONBytes, _ := json.Marshal(dat)
  10303. var res models.Result9001
  10304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10305. utils.ErrorLog("解析失败:%v", err)
  10306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10307. return
  10308. }
  10309. if res.Infcode == 0 {
  10310. sign := models.HisSignIn{
  10311. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10312. SignNo: res.Output.Signinoutb.SignNo,
  10313. SignTime: res.Output.Signinoutb.SignTime,
  10314. Ctime: time.Now().Unix(),
  10315. Mtime: time.Now().Unix(),
  10316. Status: 1,
  10317. InputLog: "",
  10318. OutputLog: "",
  10319. FixmedinsCode: miConfig.Code,
  10320. }
  10321. err := service.CreateSignIn(&sign)
  10322. if err == nil {
  10323. c.ServeSuccessJSON(map[string]interface{}{
  10324. "msg": "签到成功",
  10325. })
  10326. }
  10327. }
  10328. }
  10329. }
  10330. 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) {
  10331. var res Result3101
  10332. adminUser := c.GetAdminUserInfo()
  10333. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10334. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10335. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10336. //record_time := c.GetString("record_time")
  10337. //trig_scen := c.GetString("trig_scen")
  10338. timeLayout := "2006-01-02"
  10339. loc, _ := time.LoadLocation("Local")
  10340. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10341. if err != nil {
  10342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10343. return res
  10344. }
  10345. recordDateTime := theTime.Unix()
  10346. var patientPrescription models.HisPrescriptionInfo
  10347. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10348. //if patientPrescription.ID == 0 {
  10349. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10350. //}
  10351. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10352. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10353. //
  10354. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10355. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10356. var pp models.PublicParams
  10357. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10358. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10359. pp.FixmedinsName = miConfig.OrgName
  10360. pp.FixmedinsCode = miConfig.Code
  10361. pp.RequestUrl = miConfig.Url
  10362. pp.Cainfo = miConfig.Cainfo
  10363. pp.SecretKey = miConfig.SecretKey
  10364. pp.AccessKey = miConfig.AccessKey
  10365. pp.OpterName = roles.UserName
  10366. var config []*models.HisXtDiagnoseConfig
  10367. for _, item := range diagnosis_ids {
  10368. id, _ := strconv.ParseInt(item, 10, 64)
  10369. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10370. config = append(config, &diagnosisConfig)
  10371. }
  10372. var pd models.PatientDtos
  10373. pd.PatnID = his.PsnNo
  10374. pd.PatnName = his.Name
  10375. pd.Gend = his.Gend
  10376. pd.Brdy = his.Brdy
  10377. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10378. pd.CurrMdtrtID = his.Number
  10379. var fed models.FsiEncounterDtos
  10380. fed.MdtrtID = his.Number
  10381. fed.MedinsID = miConfig.Code
  10382. fed.MedinsName = miConfig.OrgName
  10383. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10384. fed.MedMdtrtType = "1"
  10385. fed.MedinsType = "1"
  10386. fed.MedinsLv = "11"
  10387. tm := time.Unix(his.RecordDate, 0)
  10388. s_tm := tm.Format("2006-01-02 15:04:05")
  10389. fed.AdmDate = s_tm
  10390. fed.DscgDate = s_tm
  10391. fed.DscgMainDiseCodg = config[0].CountryCode
  10392. fed.DscgMainDiseName = config[0].CountryContentName
  10393. //诊断信息
  10394. var fdds []*models.FsiDiagnoseDtos
  10395. for index, item := range config {
  10396. if index == 0 {
  10397. var fdd models.FsiDiagnoseDtos
  10398. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10399. fdd.InoutDiseType = "1"
  10400. fdd.MaindiseFlag = "1"
  10401. fdd.DiseDate = s_tm
  10402. fdd.DiasSrtNo = "1"
  10403. fdd.DiseName = item.CountryContentName
  10404. fdd.DiseCodg = item.CountryCode
  10405. fdds = append(fdds, &fdd)
  10406. } else {
  10407. var fdd models.FsiDiagnoseDtos
  10408. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10409. fdd.InoutDiseType = "1"
  10410. fdd.MaindiseFlag = "1"
  10411. fdd.DiseDate = s_tm
  10412. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10413. fdd.DiseName = item.CountryContentName
  10414. fdd.DiseCodg = item.CountryCode
  10415. fdds = append(fdds, &fdd)
  10416. }
  10417. }
  10418. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10419. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10420. fed.AdmDeptName = de.Name
  10421. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10422. fed.DscgDeptName = de.Name
  10423. fed.MedMdtrtType = "1"
  10424. fed.MedType = "11"
  10425. //if his.Insutype == "390" {
  10426. // fed.MedType = "1402"
  10427. //} else {
  10428. // fed.MedType = "9933"
  10429. //}
  10430. var orders []*models.FsiOrderDtos
  10431. if trig_scen == "2" {
  10432. //处方医嘱信息
  10433. for _, item := range prescriptions {
  10434. for _, subItem := range item.HisDoctorAdviceInfo {
  10435. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10436. var order models.FsiOrderDtos
  10437. order.RxID = strconv.FormatInt(item.ID, 10)
  10438. order.Rxno = strconv.FormatInt(item.ID, 10)
  10439. order.LongDrordFlag = "0"
  10440. order.HilistType = "1"
  10441. order.ChrgType = "1"
  10442. order.DrordBhvr = "-"
  10443. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10444. order.HosplistName = subItem.BaseDrugLib.DrugName
  10445. order.HilistLv = "1"
  10446. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10447. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10448. order.HosplistName = subItem.BaseDrugLib.DrugName
  10449. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10450. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10451. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10452. order.OwnpayAmt = ""
  10453. order.SelfpayAmt = ""
  10454. order.Spec = ""
  10455. order.SpecUnt = ""
  10456. order.DrordBegnDate = s_tm
  10457. order.DrordStopDate = ""
  10458. order.DrordDrCodg = doctor_info.DoctorNumber
  10459. order.DrordDeptName = department.Name
  10460. order.DrordDeptCodg = department.Number
  10461. order.DrordDrName = doctor_info.UserName
  10462. order.DrordDrProfttl = "234"
  10463. order.CurrDrordFlag = "1"
  10464. orders = append(orders, &order)
  10465. }
  10466. }
  10467. for _, subItem := range item.HisPrescriptionProject {
  10468. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10469. var order models.FsiOrderDtos
  10470. order.RxID = strconv.FormatInt(item.ID, 10)
  10471. order.Rxno = strconv.FormatInt(item.ID, 10)
  10472. order.LongDrordFlag = "0"
  10473. order.HilistType = "1"
  10474. order.ChrgType = "1"
  10475. order.DrordBhvr = "-"
  10476. order.HilistCode = subItem.HisProject.MedicalCode
  10477. order.HosplistName = subItem.HisProject.ProjectName
  10478. order.HilistLv = "1"
  10479. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10480. order.HosplistCode = subItem.HisProject.MedicalCode
  10481. order.HosplistName = subItem.HisProject.ProjectName
  10482. order.Cnt = subItem.Count
  10483. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10484. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10485. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10486. order.OwnpayAmt = ""
  10487. order.SelfpayAmt = ""
  10488. order.Spec = ""
  10489. order.SpecUnt = ""
  10490. order.DrordBegnDate = s_tm
  10491. order.DrordStopDate = ""
  10492. order.DrordDrCodg = doctor_info.DoctorNumber
  10493. order.DrordDeptName = department.Name
  10494. order.DrordDeptCodg = department.Number
  10495. order.DrordDrName = doctor_info.UserName
  10496. order.DrordDrProfttl = "234"
  10497. order.CurrDrordFlag = "1"
  10498. orders = append(orders, &order)
  10499. }
  10500. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10501. var order models.FsiOrderDtos
  10502. order.RxID = strconv.FormatInt(item.ID, 10)
  10503. order.Rxno = strconv.FormatInt(item.ID, 10)
  10504. order.LongDrordFlag = "0"
  10505. order.HilistType = "1"
  10506. order.ChrgType = "1"
  10507. order.DrordBhvr = "-"
  10508. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10509. order.HosplistName = subItem.GoodInfo.GoodName
  10510. order.HilistLv = "1"
  10511. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10512. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10513. order.HosplistName = subItem.GoodInfo.GoodName
  10514. order.Cnt = subItem.Count
  10515. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10516. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10517. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10518. order.OwnpayAmt = ""
  10519. order.SelfpayAmt = ""
  10520. order.Spec = ""
  10521. order.SpecUnt = ""
  10522. order.DrordBegnDate = s_tm
  10523. order.DrordStopDate = ""
  10524. order.DrordDrCodg = doctor_info.DoctorNumber
  10525. order.DrordDeptName = department.Name
  10526. order.DrordDeptCodg = department.Number
  10527. order.DrordDrName = doctor_info.UserName
  10528. order.DrordDrProfttl = "234"
  10529. order.CurrDrordFlag = "1"
  10530. orders = append(orders, &order)
  10531. }
  10532. }
  10533. }
  10534. //处方医嘱信息
  10535. }
  10536. fed.MatnStas = "0"
  10537. fed.MedfeeSumamt = "0"
  10538. fed.OwnpayAmt = "0"
  10539. fed.SelfpayAmt = "0"
  10540. fed.AcctPayamt = "0"
  10541. fed.MaAmt = "0"
  10542. fed.HifpPayamt = "0"
  10543. fed.SetlTotlnum = "1"
  10544. fed.Insutype = his.Insutype
  10545. fed.ReimFlag = "0"
  10546. fed.OutSetlFlag = "0"
  10547. var fopd []*models.FsiOperationDtosData
  10548. data := make(map[string]interface{})
  10549. data["fed"] = fed
  10550. data["fdd"] = fdds
  10551. data["fod"] = orders
  10552. data["pd"] = pd
  10553. data["pp"] = pp
  10554. data["fopd"] = fopd
  10555. data["trig_scen"] = trig_scen
  10556. fmt.Println(data)
  10557. fmt.Println(fed)
  10558. fmt.Println(fdds)
  10559. fmt.Println(orders)
  10560. fmt.Println(pd)
  10561. fmt.Println(pp)
  10562. fmt.Println(fopd)
  10563. client := &http.Client{}
  10564. bytesData, _ := json.Marshal(data)
  10565. var req *http.Request
  10566. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10567. if miConfig.MdtrtareaAdmvs == "320921" {
  10568. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10569. } else {
  10570. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10571. }
  10572. resp, _ := client.Do(req)
  10573. defer resp.Body.Close()
  10574. body, ioErr := ioutil.ReadAll(resp.Body)
  10575. if ioErr != nil {
  10576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10578. return res
  10579. }
  10580. var respJSON map[string]interface{}
  10581. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10584. return res
  10585. }
  10586. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10587. fmt.Println(respJSON)
  10588. result, _ := json.Marshal(respJSON)
  10589. fmt.Println(result)
  10590. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10591. utils.ErrorLog("解析失败:%v", err)
  10592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10593. return res
  10594. }
  10595. return res
  10596. } else {
  10597. //if miConfig.MdtrtareaAdmvs == "441202" {
  10598. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10599. saveLog(output, input, "3101", "事前")
  10600. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10601. utils.ErrorLog("解析失败:%v", err)
  10602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10603. return
  10604. }
  10605. return res
  10606. //}
  10607. }
  10608. }
  10609. 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) {
  10610. adminUser := c.GetAdminUserInfo()
  10611. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10612. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10613. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10614. //record_time := c.GetString("record_time")
  10615. //trig_scen := c.GetString("trig_scen")
  10616. timeLayout := "2006-01-02"
  10617. loc, _ := time.LoadLocation("Local")
  10618. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10619. if err != nil {
  10620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10621. return res
  10622. }
  10623. recordDateTime := theTime.Unix()
  10624. var patientPrescription models.HisPrescriptionInfo
  10625. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10626. if patientPrescription.ID == 0 {
  10627. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10628. }
  10629. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10630. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10631. //
  10632. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10633. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10634. var pp models.PublicParams
  10635. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10636. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10637. pp.FixmedinsName = miConfig.OrgName
  10638. pp.FixmedinsCode = miConfig.Code
  10639. pp.RequestUrl = miConfig.Url
  10640. pp.Cainfo = miConfig.Cainfo
  10641. pp.SecretKey = miConfig.SecretKey
  10642. pp.AccessKey = miConfig.AccessKey
  10643. pp.OpterName = roles.UserName
  10644. var config []*models.HisXtDiagnoseConfig
  10645. for _, item := range diagnosis_ids {
  10646. id, _ := strconv.ParseInt(item, 10, 64)
  10647. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10648. config = append(config, &diagnosisConfig)
  10649. }
  10650. var pd models.PatientDtos
  10651. pd.PatnID = his.PsnNo
  10652. pd.PatnName = his.Name
  10653. pd.Gend = his.Gend
  10654. pd.Brdy = his.Brdy
  10655. pd.Poolarea = his.InsuplcAdmdvs
  10656. pd.CurrMdtrtID = his.Number
  10657. var fed models.FsiEncounterDtos
  10658. fed.MdtrtID = his.Number
  10659. fed.MedinsID = miConfig.Code
  10660. fed.MedinsName = miConfig.OrgName
  10661. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10662. fed.MedMdtrtType = "1"
  10663. fed.MedinsType = "1"
  10664. fed.MedinsLv = "11"
  10665. tm := time.Unix(his.RecordDate, 0)
  10666. s_tm := tm.Format("2006-01-02 15:04:05")
  10667. fed.AdmDate = s_tm
  10668. fed.DscgDate = s_tm
  10669. fed.DscgMainDiseCodg = config[0].CountryCode
  10670. fed.DscgMainDiseName = config[0].CountryContentName
  10671. //诊断信息
  10672. var fdds []*models.FsiDiagnoseDtos
  10673. for index, item := range config {
  10674. if index == 0 {
  10675. var fdd models.FsiDiagnoseDtos
  10676. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10677. fdd.InoutDiseType = "1"
  10678. fdd.MaindiseFlag = "1"
  10679. fdd.DiseDate = s_tm
  10680. fdd.DiasSrtNo = "1"
  10681. fdd.DiseName = item.CountryContentName
  10682. fdd.DiseCodg = item.CountryCode
  10683. fdds = append(fdds, &fdd)
  10684. } else {
  10685. var fdd models.FsiDiagnoseDtos
  10686. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10687. fdd.InoutDiseType = "1"
  10688. fdd.MaindiseFlag = "1"
  10689. fdd.DiseDate = s_tm
  10690. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10691. fdd.DiseName = item.CountryContentName
  10692. fdd.DiseCodg = item.CountryCode
  10693. fdds = append(fdds, &fdd)
  10694. }
  10695. }
  10696. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10697. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10698. fed.AdmDeptName = department.Name
  10699. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10700. fed.DscgDeptName = department.Name
  10701. fed.MedMdtrtType = "1"
  10702. fed.MedType = "11"
  10703. //if his.Insutype == "390" {
  10704. // fed.MedType = "1402"
  10705. //} else {
  10706. // fed.MedType = "9933"
  10707. //}
  10708. var orders []*models.FsiOrderDtos
  10709. if trig_scen == "2" {
  10710. //处方医嘱信息
  10711. for _, item := range prescriptions {
  10712. for _, subItem := range item.HisDoctorAdviceInfo {
  10713. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10714. var order models.FsiOrderDtos
  10715. order.RxID = strconv.FormatInt(item.ID, 10)
  10716. order.Rxno = strconv.FormatInt(item.ID, 10)
  10717. order.LongDrordFlag = "0"
  10718. order.HilistType = "1"
  10719. order.ChrgType = "1"
  10720. order.DrordBhvr = "-"
  10721. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10722. order.HosplistName = subItem.BaseDrugLib.DrugName
  10723. order.HilistLv = "1"
  10724. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10725. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10726. order.HosplistName = subItem.BaseDrugLib.DrugName
  10727. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10728. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10729. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10730. order.OwnpayAmt = ""
  10731. order.SelfpayAmt = ""
  10732. order.Spec = ""
  10733. order.SpecUnt = ""
  10734. order.DrordBegnDate = s_tm
  10735. order.DrordStopDate = ""
  10736. order.DrordDrCodg = doctor_info.DoctorNumber
  10737. order.DrordDeptName = department.Name
  10738. order.DrordDeptCodg = department.Number
  10739. order.DrordDrName = doctor_info.UserName
  10740. order.DrordDrProfttl = "234"
  10741. order.CurrDrordFlag = "1"
  10742. orders = append(orders, &order)
  10743. }
  10744. }
  10745. for _, subItem := range item.HisPrescriptionProject {
  10746. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10747. var order models.FsiOrderDtos
  10748. order.RxID = strconv.FormatInt(item.ID, 10)
  10749. order.Rxno = strconv.FormatInt(item.ID, 10)
  10750. order.LongDrordFlag = "0"
  10751. order.HilistType = "1"
  10752. order.ChrgType = "1"
  10753. order.DrordBhvr = "-"
  10754. order.HilistCode = subItem.HisProject.MedicalCode
  10755. order.HosplistName = subItem.HisProject.ProjectName
  10756. order.HilistLv = "1"
  10757. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10758. order.HosplistCode = subItem.HisProject.MedicalCode
  10759. order.HosplistName = subItem.HisProject.ProjectName
  10760. order.Cnt = subItem.Count
  10761. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10762. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10763. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10764. order.OwnpayAmt = ""
  10765. order.SelfpayAmt = ""
  10766. order.Spec = ""
  10767. order.SpecUnt = ""
  10768. order.DrordBegnDate = s_tm
  10769. order.DrordStopDate = ""
  10770. order.DrordDrCodg = doctor_info.DoctorNumber
  10771. order.DrordDeptName = department.Name
  10772. order.DrordDeptCodg = department.Number
  10773. order.DrordDrName = doctor_info.UserName
  10774. order.DrordDrProfttl = "234"
  10775. order.CurrDrordFlag = "1"
  10776. orders = append(orders, &order)
  10777. }
  10778. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10779. var order models.FsiOrderDtos
  10780. order.RxID = strconv.FormatInt(item.ID, 10)
  10781. order.Rxno = strconv.FormatInt(item.ID, 10)
  10782. order.LongDrordFlag = "0"
  10783. order.HilistType = "1"
  10784. order.ChrgType = "1"
  10785. order.DrordBhvr = "-"
  10786. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10787. order.HosplistName = subItem.GoodInfo.GoodName
  10788. order.HilistLv = "1"
  10789. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10790. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10791. order.HosplistName = subItem.GoodInfo.GoodName
  10792. order.Cnt = subItem.Count
  10793. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10794. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10795. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10796. order.OwnpayAmt = ""
  10797. order.SelfpayAmt = ""
  10798. order.Spec = ""
  10799. order.SpecUnt = ""
  10800. order.DrordBegnDate = s_tm
  10801. order.DrordStopDate = ""
  10802. order.DrordDrCodg = doctor_info.DoctorNumber
  10803. order.DrordDeptName = department.Name
  10804. order.DrordDeptCodg = department.Number
  10805. order.DrordDrName = doctor_info.UserName
  10806. order.DrordDrProfttl = "234"
  10807. order.CurrDrordFlag = "1"
  10808. orders = append(orders, &order)
  10809. }
  10810. }
  10811. }
  10812. //处方医嘱信息
  10813. }
  10814. fed.MatnStas = "0"
  10815. fed.MedfeeSumamt = "0"
  10816. fed.OwnpayAmt = "0"
  10817. fed.SelfpayAmt = "0"
  10818. fed.AcctPayamt = "0"
  10819. fed.MaAmt = "0"
  10820. fed.HifpPayamt = "0"
  10821. fed.SetlTotlnum = "1"
  10822. fed.Insutype = his.Insutype
  10823. fed.ReimFlag = "0"
  10824. fed.OutSetlFlag = "0"
  10825. var fopd []*models.FsiOperationDtosData
  10826. data := make(map[string]interface{})
  10827. data["fed"] = fed
  10828. data["fdd"] = fdds
  10829. data["fod"] = orders
  10830. data["pd"] = pd
  10831. data["pp"] = pp
  10832. data["fopd"] = fopd
  10833. data["trig_scen"] = trig_scen
  10834. fmt.Println(data)
  10835. fmt.Println(fed)
  10836. fmt.Println(fdds)
  10837. fmt.Println(orders)
  10838. fmt.Println(pd)
  10839. fmt.Println(pp)
  10840. fmt.Println(fopd)
  10841. client := &http.Client{}
  10842. bytesData, _ := json.Marshal(data)
  10843. var req *http.Request
  10844. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10845. if miConfig.MdtrtareaAdmvs == "320921" {
  10846. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10847. } else {
  10848. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10849. }
  10850. resp, _ := client.Do(req)
  10851. defer resp.Body.Close()
  10852. body, ioErr := ioutil.ReadAll(resp.Body)
  10853. if ioErr != nil {
  10854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10856. return res
  10857. }
  10858. var respJSON map[string]interface{}
  10859. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10862. return res
  10863. }
  10864. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10865. fmt.Println(respJSON)
  10866. result, _ := json.Marshal(respJSON)
  10867. fmt.Println(result)
  10868. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10869. utils.ErrorLog("解析失败:%v", err)
  10870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10871. return res
  10872. }
  10873. return res
  10874. } else {
  10875. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10876. saveLog(output, input, "3101", "事前")
  10877. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10878. utils.ErrorLog("解析失败:%v", err)
  10879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10880. return
  10881. }
  10882. return res
  10883. }
  10884. return res
  10885. }
  10886. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10887. ////patient_id, _ := c.GetInt64("patient_id")
  10888. //order_id, _ := c.GetInt64("order_id")
  10889. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10890. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10891. //trig_scen := c.GetString("trig_scen")
  10892. adminUser := c.GetAdminUserInfo()
  10893. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10894. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10895. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10896. record_time := c.GetString("record_time")
  10897. order, _ := service.GetHisOrderByID(order_id)
  10898. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10899. timeLayout := "2006-01-02"
  10900. loc, _ := time.LoadLocation("Local")
  10901. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10902. if err != nil {
  10903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10904. return
  10905. }
  10906. recordDateTime := theTime.Unix()
  10907. var patientPrescription models.HisPrescriptionInfo
  10908. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10909. if patientPrescription.ID == 0 {
  10910. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10911. }
  10912. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10913. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10914. //
  10915. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10916. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10917. var pp models.PublicParams
  10918. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10919. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10920. pp.FixmedinsName = miConfig.OrgName
  10921. pp.FixmedinsCode = miConfig.Code
  10922. pp.RequestUrl = miConfig.Url
  10923. pp.Cainfo = miConfig.Cainfo
  10924. pp.SecretKey = miConfig.SecretKey
  10925. pp.AccessKey = miConfig.AccessKey
  10926. pp.OpterName = roles.UserName
  10927. var config []*models.HisXtDiagnoseConfig
  10928. for _, item := range diagnosis_ids {
  10929. id, _ := strconv.ParseInt(item, 10, 64)
  10930. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10931. config = append(config, &diagnosisConfig)
  10932. }
  10933. var pd models.PatientDtos
  10934. pd.PatnID = his.PsnNo
  10935. pd.PatnName = his.Name
  10936. pd.Gend = his.Gend
  10937. pd.Brdy = psn_info.Brdy
  10938. pd.Poolarea = his.InsuplcAdmdvs
  10939. pd.CurrMdtrtID = his.Number
  10940. var fed models.FsiEncounterDtos
  10941. fed.MdtrtID = his.Number
  10942. fed.MedinsID = miConfig.Code
  10943. fed.MedinsName = miConfig.OrgName
  10944. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10945. fed.MedMdtrtType = "1"
  10946. fed.MedinsType = "1"
  10947. fed.MedinsLv = "11"
  10948. tm := time.Unix(his.RecordDate, 0)
  10949. s_tm := tm.Format("2006-01-02 15:04:05")
  10950. fed.AdmDate = s_tm
  10951. fed.DscgDate = s_tm
  10952. fed.DscgMainDiseCodg = config[0].CountryCode
  10953. fed.DscgMainDiseName = config[0].CountryContentName
  10954. //诊断信息
  10955. var fdds []*models.FsiDiagnoseDtos
  10956. for index, item := range config {
  10957. if index == 0 {
  10958. var fdd models.FsiDiagnoseDtos
  10959. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10960. fdd.InoutDiseType = "1"
  10961. fdd.MaindiseFlag = "1"
  10962. fdd.DiseDate = s_tm
  10963. fdd.DiasSrtNo = "1"
  10964. fdd.DiseName = item.CountryContentName
  10965. fdd.DiseCodg = item.CountryCode
  10966. fdds = append(fdds, &fdd)
  10967. } else {
  10968. var fdd models.FsiDiagnoseDtos
  10969. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10970. fdd.InoutDiseType = "1"
  10971. fdd.MaindiseFlag = "1"
  10972. fdd.DiseDate = s_tm
  10973. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10974. fdd.DiseName = item.CountryContentName
  10975. fdd.DiseCodg = item.CountryCode
  10976. fdds = append(fdds, &fdd)
  10977. }
  10978. }
  10979. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10980. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10981. fed.AdmDeptName = department.Name
  10982. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10983. fed.DscgDeptName = department.Name
  10984. fed.MedType = order.MedType
  10985. //处方医嘱信息
  10986. var orders []*models.FsiOrderDtos
  10987. //for _, item := range prescriptions {
  10988. // for _, subItem := range item.HisDoctorAdviceInfo {
  10989. // var order models.FsiOrderDtos
  10990. // order.RxID = strconv.FormatInt(item.ID, 10)
  10991. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10992. // order.LongDrordFlag = "0"
  10993. // order.HilistType = "1"
  10994. // order.ChrgType = "1"
  10995. // order.DrordBhvr = "-"
  10996. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10997. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10998. // order.HilistLv = "1"
  10999. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11000. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11001. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11002. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11003. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11004. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11005. // order.OwnpayAmt = ""
  11006. // order.SelfpayAmt = ""
  11007. // order.Spec = ""
  11008. // order.SpecUnt = ""
  11009. // order.DrordBegnDate = s_tm
  11010. // order.DrordStopDate = ""
  11011. // order.DrordDrCodg = "1"
  11012. // order.DrordDeptName = department.Name
  11013. // order.DrordDrCodg = "1"
  11014. // order.DrordDrName = doctor_info.UserName
  11015. // order.DrordDrProfttl = ""
  11016. // order.CurrDrordFlag = "1"
  11017. // orders = append(orders, &order)
  11018. // }
  11019. // for _, subItem := range item.HisPrescriptionProject {
  11020. // if subItem.Type == 2 {
  11021. // var order models.FsiOrderDtos
  11022. // order.RxID = strconv.FormatInt(item.ID, 10)
  11023. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11024. // order.LongDrordFlag = "0"
  11025. // order.HilistType = "1"
  11026. // order.ChrgType = "1"
  11027. // order.DrordBhvr = "-"
  11028. // order.HilistCode = subItem.HisProject.MedicalCode
  11029. // order.HosplistName = subItem.HisProject.ProjectName
  11030. // order.HilistLv = "1"
  11031. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11032. // order.HosplistCode = subItem.HisProject.MedicalCode
  11033. // order.HosplistName = subItem.HisProject.ProjectName
  11034. // order.Cnt = subItem.Count
  11035. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11036. //
  11037. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11038. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11039. // order.OwnpayAmt = ""
  11040. // order.SelfpayAmt = ""
  11041. // order.Spec = ""
  11042. // order.SpecUnt = ""
  11043. // order.DrordBegnDate = s_tm
  11044. // order.DrordStopDate = ""
  11045. // order.DrordDrCodg = "1"
  11046. // order.DrordDeptName = department.Name
  11047. // order.DrordDrCodg = "1"
  11048. // order.DrordDrName = doctor_info.UserName
  11049. // order.DrordDrProfttl = ""
  11050. // order.CurrDrordFlag = "1"
  11051. // orders = append(orders, &order)
  11052. //
  11053. // }
  11054. // if subItem.Type == 3 {
  11055. //
  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.GoodInfo.MedicalInsuranceNumber
  11064. // order.HosplistName = subItem.GoodInfo.GoodName
  11065. // order.HilistLv = "1"
  11066. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11067. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11068. // order.HosplistName = subItem.GoodInfo.GoodName
  11069. // order.Cnt = subItem.Count
  11070. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11071. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11072. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11073. // order.OwnpayAmt = ""
  11074. // order.SelfpayAmt = ""
  11075. // order.Spec = ""
  11076. // order.SpecUnt = ""
  11077. // order.DrordBegnDate = s_tm
  11078. // order.DrordStopDate = ""
  11079. // order.DrordDrCodg = "1"
  11080. // order.DrordDeptName = department.Name
  11081. // order.DrordDrCodg = "1"
  11082. // order.DrordDrName = doctor_info.UserName
  11083. // order.DrordDrProfttl = ""
  11084. // order.CurrDrordFlag = "1"
  11085. // orders = append(orders, &order)
  11086. //
  11087. // }
  11088. // }
  11089. //}
  11090. for _, item := range prescriptions {
  11091. for _, subItem := range item.HisDoctorAdviceInfo {
  11092. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11093. var order models.FsiOrderDtos
  11094. order.RxID = strconv.FormatInt(item.ID, 10)
  11095. order.Rxno = strconv.FormatInt(item.ID, 10)
  11096. order.LongDrordFlag = "0"
  11097. order.HilistType = "1"
  11098. order.ChrgType = "1"
  11099. order.DrordBhvr = "-"
  11100. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11101. order.HosplistName = subItem.BaseDrugLib.DrugName
  11102. order.HilistLv = "1"
  11103. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11104. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11105. order.HosplistName = subItem.BaseDrugLib.DrugName
  11106. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11107. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11108. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11109. order.OwnpayAmt = ""
  11110. order.SelfpayAmt = ""
  11111. order.Spec = ""
  11112. order.SpecUnt = ""
  11113. order.DrordBegnDate = s_tm
  11114. order.DrordStopDate = ""
  11115. order.DrordDrCodg = doctor_info.DoctorNumber
  11116. order.DrordDeptName = department.Name
  11117. order.DrordDeptCodg = department.Number
  11118. order.DrordDrName = doctor_info.UserName
  11119. order.DrordDrProfttl = "234"
  11120. order.CurrDrordFlag = "1"
  11121. orders = append(orders, &order)
  11122. }
  11123. }
  11124. for _, subItem := range item.HisPrescriptionProject {
  11125. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11126. var order models.FsiOrderDtos
  11127. order.RxID = strconv.FormatInt(item.ID, 10)
  11128. order.Rxno = strconv.FormatInt(item.ID, 10)
  11129. order.LongDrordFlag = "0"
  11130. order.HilistType = "1"
  11131. order.ChrgType = "1"
  11132. order.DrordBhvr = "-"
  11133. order.HilistCode = subItem.HisProject.MedicalCode
  11134. order.HosplistName = subItem.HisProject.ProjectName
  11135. order.HilistLv = "1"
  11136. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11137. order.HosplistCode = subItem.HisProject.MedicalCode
  11138. order.HosplistName = subItem.HisProject.ProjectName
  11139. order.Cnt = subItem.Count
  11140. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11141. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11142. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11143. order.OwnpayAmt = ""
  11144. order.SelfpayAmt = ""
  11145. order.Spec = ""
  11146. order.SpecUnt = ""
  11147. order.DrordBegnDate = s_tm
  11148. order.DrordStopDate = ""
  11149. order.DrordDrCodg = doctor_info.DoctorNumber
  11150. order.DrordDeptName = department.Name
  11151. order.DrordDeptCodg = department.Number
  11152. order.DrordDrName = doctor_info.UserName
  11153. order.DrordDrProfttl = "234"
  11154. order.CurrDrordFlag = "1"
  11155. orders = append(orders, &order)
  11156. }
  11157. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11158. var order models.FsiOrderDtos
  11159. order.RxID = strconv.FormatInt(item.ID, 10)
  11160. order.Rxno = strconv.FormatInt(item.ID, 10)
  11161. order.LongDrordFlag = "0"
  11162. order.HilistType = "1"
  11163. order.ChrgType = "1"
  11164. order.DrordBhvr = "0"
  11165. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11166. order.HosplistName = subItem.GoodInfo.GoodName
  11167. order.HilistLv = "1"
  11168. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11169. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11170. order.HosplistName = subItem.GoodInfo.GoodName
  11171. order.Cnt = subItem.Count
  11172. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11173. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11174. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11175. order.OwnpayAmt = ""
  11176. order.SelfpayAmt = ""
  11177. order.Spec = ""
  11178. order.SpecUnt = ""
  11179. order.DrordBegnDate = s_tm
  11180. order.DrordStopDate = ""
  11181. order.DrordDrCodg = doctor_info.DoctorNumber
  11182. order.DrordDeptName = department.Name
  11183. order.DrordDeptCodg = department.Number
  11184. order.DrordDrName = doctor_info.UserName
  11185. order.DrordDrProfttl = "234"
  11186. order.CurrDrordFlag = "1"
  11187. orders = append(orders, &order)
  11188. }
  11189. }
  11190. }
  11191. //处方医嘱信息
  11192. fed.MatnStas = "0"
  11193. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11194. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11195. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11196. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11197. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11198. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11199. fed.SetlTotlnum = "1"
  11200. fed.Insutype = his.Insutype
  11201. fed.ReimFlag = "0"
  11202. fed.OutSetlFlag = "0"
  11203. var fopd []*models.FsiOperationDtosData
  11204. data := make(map[string]interface{})
  11205. data["fed"] = fed
  11206. data["fdd"] = fdds
  11207. data["fod"] = orders
  11208. data["pd"] = pd
  11209. data["pp"] = pp
  11210. data["fopd"] = fopd
  11211. data["trig_scen"] = trig_scen
  11212. client := &http.Client{}
  11213. bytesData, _ := json.Marshal(data)
  11214. var req *http.Request
  11215. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11216. if miConfig.MdtrtareaAdmvs == "320921" {
  11217. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11218. } else {
  11219. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11220. }
  11221. resp, _ := client.Do(req)
  11222. defer resp.Body.Close()
  11223. body, ioErr := ioutil.ReadAll(resp.Body)
  11224. if ioErr != nil {
  11225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11227. return res
  11228. }
  11229. var respJSON map[string]interface{}
  11230. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11233. return res
  11234. }
  11235. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11236. result, _ := json.Marshal(respJSON)
  11237. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11238. utils.ErrorLog("解析失败:%v", err)
  11239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11240. return res
  11241. }
  11242. return res
  11243. } else {
  11244. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11245. saveLog(output, input, "3102", "事中")
  11246. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11247. utils.ErrorLog("解析失败:%v", err)
  11248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11249. return
  11250. }
  11251. return res
  11252. }
  11253. return res
  11254. }
  11255. 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) {
  11256. var res Resultgd3101
  11257. adminUser := c.GetAdminUserInfo()
  11258. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11259. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11260. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11261. //record_time := c.GetString("record_time")
  11262. //trig_scen := c.GetString("trig_scen")
  11263. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11264. //psn_info, _ := service.GetPatientId(patient_id)
  11265. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11266. timeLayout := "2006-01-02"
  11267. loc, _ := time.LoadLocation("Local")
  11268. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11269. if err != nil {
  11270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11271. return res
  11272. }
  11273. recordDateTime := theTime.Unix()
  11274. var patientPrescription models.HisPrescriptionInfo
  11275. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11276. //if patientPrescription.ID == 0 {
  11277. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11278. //}
  11279. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11280. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11281. //
  11282. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11283. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11284. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11285. var pp models.PublicParams
  11286. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11287. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11288. pp.FixmedinsName = miConfig.OrgName
  11289. pp.FixmedinsCode = miConfig.Code
  11290. pp.RequestUrl = miConfig.Url
  11291. pp.Cainfo = miConfig.Cainfo
  11292. pp.SecretKey = miConfig.SecretKey
  11293. pp.AccessKey = miConfig.AccessKey
  11294. pp.OpterName = roles.UserName
  11295. var config []*models.HisXtDiagnoseConfig
  11296. for _, item := range diagnosis_ids {
  11297. id, _ := strconv.ParseInt(item, 10, 64)
  11298. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11299. config = append(config, &diagnosisConfig)
  11300. }
  11301. var pd models.PatientDtos
  11302. pd.PatnID = his.PsnNo
  11303. pd.PatnName = his.Name
  11304. pd.Gend = his.Gend
  11305. pd.Brdy = str
  11306. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11307. pd.CurrMdtrtID = his.Number
  11308. var fed models.FsiEncounterDtos
  11309. fed.MdtrtID = his.Number
  11310. fed.MedinsID = miConfig.Code
  11311. fed.MedinsName = miConfig.OrgName
  11312. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11313. fed.MedMdtrtType = "1"
  11314. fed.MedinsType = "1"
  11315. fed.MedinsLv = "11"
  11316. tm := time.Unix(his.RecordDate, 0)
  11317. s_tm := tm.Format("2006-01-02 15:04:05")
  11318. fed.AdmDate = s_tm
  11319. fed.DscgDate = s_tm
  11320. fed.DscgMainDiseCodg = config[0].CountryCode
  11321. fed.DscgMainDiseName = config[0].CountryContentName
  11322. //诊断信息
  11323. var fdds []*models.FsiDiagnoseDtos
  11324. for index, item := range config {
  11325. if index == 0 {
  11326. var fdd models.FsiDiagnoseDtos
  11327. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11328. fdd.InoutDiseType = "1"
  11329. fdd.MaindiseFlag = "1"
  11330. fdd.DiseDate = s_tm
  11331. fdd.DiasSrtNo = "1"
  11332. fdd.DiseName = item.CountryContentName
  11333. fdd.DiseCodg = item.CountryCode
  11334. fdds = append(fdds, &fdd)
  11335. } else {
  11336. var fdd models.FsiDiagnoseDtos
  11337. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11338. fdd.InoutDiseType = "1"
  11339. fdd.MaindiseFlag = "1"
  11340. fdd.DiseDate = s_tm
  11341. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11342. fdd.DiseName = item.CountryContentName
  11343. fdd.DiseCodg = item.CountryCode
  11344. fdds = append(fdds, &fdd)
  11345. }
  11346. }
  11347. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11348. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11349. fed.AdmDeptName = de.Name
  11350. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11351. fed.DscgDeptName = de.Name
  11352. fed.MedMdtrtType = "1"
  11353. fed.MedType = "11"
  11354. //if his.Insutype == "390" {
  11355. // fed.MedType = "1402"
  11356. //} else {
  11357. // fed.MedType = "9933"
  11358. //}
  11359. var orders []*models.FsiOrderDtos
  11360. if trig_scen == "2" {
  11361. //处方医嘱信息
  11362. for _, item := range prescriptions {
  11363. for _, subItem := range item.HisDoctorAdviceInfo {
  11364. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11365. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11366. var order models.FsiOrderDtos
  11367. order.RxID = strconv.FormatInt(item.ID, 10)
  11368. order.Rxno = strconv.FormatInt(item.ID, 10)
  11369. order.LongDrordFlag = "0"
  11370. order.HilistType = "1"
  11371. order.ChrgType = "1"
  11372. order.DrordBhvr = "0"
  11373. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11374. order.HosplistName = subItem.BaseDrugLib.DrugName
  11375. order.HilistLv = "1"
  11376. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11377. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11378. order.HosplistName = subItem.BaseDrugLib.DrugName
  11379. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11380. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11381. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11382. order.OwnpayAmt = ""
  11383. order.SelfpayAmt = ""
  11384. order.Spec = spec
  11385. order.SpecUnt = subItem.PrescribingNumberUnit
  11386. order.DrordBegnDate = s_tm
  11387. order.DrordStopDate = ""
  11388. order.DrordDrCodg = doctor_info.DoctorNumber
  11389. order.DrordDeptName = department.Name
  11390. order.DrordDeptCodg = department.Number
  11391. order.DrordDrName = doctor_info.UserName
  11392. order.DrordDrProfttl = "234"
  11393. order.CurrDrordFlag = "1"
  11394. orders = append(orders, &order)
  11395. }
  11396. }
  11397. for _, subItem := range item.HisPrescriptionProject {
  11398. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11399. var order models.FsiOrderDtos
  11400. order.RxID = strconv.FormatInt(item.ID, 10)
  11401. order.Rxno = strconv.FormatInt(item.ID, 10)
  11402. order.LongDrordFlag = "0"
  11403. order.HilistType = "1"
  11404. order.ChrgType = "1"
  11405. order.DrordBhvr = "0"
  11406. order.HilistCode = subItem.HisProject.MedicalCode
  11407. order.HosplistName = subItem.HisProject.ProjectName
  11408. order.HilistLv = "1"
  11409. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11410. order.HosplistCode = subItem.HisProject.MedicalCode
  11411. order.HosplistName = subItem.HisProject.ProjectName
  11412. order.Cnt = subItem.Count
  11413. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11414. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11415. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11416. order.OwnpayAmt = ""
  11417. order.SelfpayAmt = ""
  11418. order.Spec = subItem.Unit
  11419. order.SpecUnt = subItem.Unit
  11420. order.DrordBegnDate = s_tm
  11421. order.DrordStopDate = ""
  11422. order.DrordDrCodg = doctor_info.DoctorNumber
  11423. order.DrordDeptName = department.Name
  11424. order.DrordDeptCodg = department.Number
  11425. order.DrordDrName = doctor_info.UserName
  11426. order.DrordDrProfttl = "234"
  11427. order.CurrDrordFlag = "1"
  11428. orders = append(orders, &order)
  11429. }
  11430. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11431. var order models.FsiOrderDtos
  11432. order.RxID = strconv.FormatInt(item.ID, 10)
  11433. order.Rxno = strconv.FormatInt(item.ID, 10)
  11434. order.LongDrordFlag = "0"
  11435. order.HilistType = "1"
  11436. order.ChrgType = "1"
  11437. order.DrordBhvr = "0"
  11438. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11439. order.HosplistName = subItem.GoodInfo.GoodName
  11440. order.HilistLv = "1"
  11441. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11442. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11443. order.HosplistName = subItem.GoodInfo.GoodName
  11444. order.Cnt = subItem.Count
  11445. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11446. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11447. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11448. order.OwnpayAmt = ""
  11449. order.SelfpayAmt = ""
  11450. order.Spec = subItem.GoodInfo.SpecificationName
  11451. order.SpecUnt = subItem.Unit
  11452. order.DrordBegnDate = s_tm
  11453. order.DrordStopDate = ""
  11454. order.DrordDrCodg = doctor_info.DoctorNumber
  11455. order.DrordDeptName = department.Name
  11456. order.DrordDeptCodg = department.Number
  11457. order.DrordDrName = doctor_info.UserName
  11458. order.DrordDrProfttl = "234"
  11459. order.CurrDrordFlag = "1"
  11460. orders = append(orders, &order)
  11461. }
  11462. }
  11463. }
  11464. //处方医嘱信息
  11465. }
  11466. fed.MatnStas = "0"
  11467. fed.MedfeeSumamt = "0"
  11468. fed.OwnpayAmt = "0"
  11469. fed.SelfpayAmt = "0"
  11470. fed.AcctPayamt = "0"
  11471. fed.MaAmt = "0"
  11472. fed.HifpPayamt = "0"
  11473. fed.SetlTotlnum = "1"
  11474. fed.Insutype = his.Insutype
  11475. fed.ReimFlag = "0"
  11476. fed.OutSetlFlag = "0"
  11477. var fopd []*models.FsiOperationDtosData
  11478. data := make(map[string]interface{})
  11479. data["fed"] = fed
  11480. data["fdd"] = fdds
  11481. data["fod"] = orders
  11482. data["pd"] = pd
  11483. data["pp"] = pp
  11484. data["fopd"] = fopd
  11485. data["trig_scen"] = trig_scen
  11486. fmt.Println(data)
  11487. fmt.Println(fed)
  11488. fmt.Println(fdds)
  11489. fmt.Println(orders)
  11490. fmt.Println(pd)
  11491. fmt.Println(pp)
  11492. fmt.Println(fopd)
  11493. client := &http.Client{}
  11494. bytesData, _ := json.Marshal(data)
  11495. var req *http.Request
  11496. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11497. if miConfig.MdtrtareaAdmvs == "320921" {
  11498. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11499. } else {
  11500. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11501. }
  11502. resp, _ := client.Do(req)
  11503. defer resp.Body.Close()
  11504. body, ioErr := ioutil.ReadAll(resp.Body)
  11505. if ioErr != nil {
  11506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11508. return res
  11509. }
  11510. var respJSON map[string]interface{}
  11511. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11514. return res
  11515. }
  11516. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11517. fmt.Println(respJSON)
  11518. result, _ := json.Marshal(respJSON)
  11519. fmt.Println(result)
  11520. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11521. utils.ErrorLog("解析失败:%v", err)
  11522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11523. return res
  11524. }
  11525. return res
  11526. } else {
  11527. //if miConfig.MdtrtareaAdmvs == "441202" {
  11528. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11529. saveLog(output, input, "3101", "事前")
  11530. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11531. utils.ErrorLog("解析失败:%v", err)
  11532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11533. return
  11534. }
  11535. return res
  11536. //}
  11537. }
  11538. }
  11539. 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) {
  11540. adminUser := c.GetAdminUserInfo()
  11541. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11542. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11543. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11544. //record_time := c.GetString("record_time")
  11545. //trig_scen := c.GetString("trig_scen")
  11546. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11547. timeLayout := "2006-01-02"
  11548. loc, _ := time.LoadLocation("Local")
  11549. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11550. if err != nil {
  11551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11552. return res
  11553. }
  11554. recordDateTime := theTime.Unix()
  11555. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11556. var patientPrescription models.HisPrescriptionInfo
  11557. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11558. if patientPrescription.ID == 0 {
  11559. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11560. }
  11561. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11562. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11563. //
  11564. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11565. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11566. var pp models.PublicParams
  11567. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11568. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11569. pp.FixmedinsName = miConfig.OrgName
  11570. pp.FixmedinsCode = miConfig.Code
  11571. pp.RequestUrl = miConfig.Url
  11572. pp.Cainfo = miConfig.Cainfo
  11573. pp.SecretKey = miConfig.SecretKey
  11574. pp.AccessKey = miConfig.AccessKey
  11575. pp.OpterName = roles.UserName
  11576. var config []*models.HisXtDiagnoseConfig
  11577. for _, item := range diagnosis_ids {
  11578. id, _ := strconv.ParseInt(item, 10, 64)
  11579. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11580. config = append(config, &diagnosisConfig)
  11581. }
  11582. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11583. var pd models.PatientDtos
  11584. pd.PatnID = his.PsnNo
  11585. pd.PatnName = his.Name
  11586. pd.Gend = his.Gend
  11587. pd.Brdy = str
  11588. pd.Poolarea = his.InsuplcAdmdvs
  11589. pd.CurrMdtrtID = his.Number
  11590. var fed models.FsiEncounterDtos
  11591. fed.MdtrtID = his.Number
  11592. fed.MedinsID = miConfig.Code
  11593. fed.MedinsName = miConfig.OrgName
  11594. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11595. fed.MedMdtrtType = "1"
  11596. fed.MedinsType = "1"
  11597. fed.MedinsLv = "11"
  11598. tm := time.Unix(his.RecordDate, 0)
  11599. s_tm := tm.Format("2006-01-02 15:04:05")
  11600. fed.AdmDate = s_tm
  11601. fed.DscgDate = s_tm
  11602. fed.DscgMainDiseCodg = config[0].CountryCode
  11603. fed.DscgMainDiseName = config[0].CountryContentName
  11604. //诊断信息
  11605. var fdds []*models.FsiDiagnoseDtos
  11606. for index, item := range config {
  11607. if index == 0 {
  11608. var fdd models.FsiDiagnoseDtos
  11609. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11610. fdd.InoutDiseType = "1"
  11611. fdd.MaindiseFlag = "1"
  11612. fdd.DiseDate = s_tm
  11613. fdd.DiasSrtNo = "1"
  11614. fdd.DiseName = item.CountryContentName
  11615. fdd.DiseCodg = item.CountryCode
  11616. fdds = append(fdds, &fdd)
  11617. } else {
  11618. var fdd models.FsiDiagnoseDtos
  11619. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11620. fdd.InoutDiseType = "1"
  11621. fdd.MaindiseFlag = "1"
  11622. fdd.DiseDate = s_tm
  11623. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11624. fdd.DiseName = item.CountryContentName
  11625. fdd.DiseCodg = item.CountryCode
  11626. fdds = append(fdds, &fdd)
  11627. }
  11628. }
  11629. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11630. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11631. fed.AdmDeptName = department.Name
  11632. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11633. fed.DscgDeptName = department.Name
  11634. fed.MedMdtrtType = "1"
  11635. fed.MedType = "11"
  11636. //if his.Insutype == "390" {
  11637. // fed.MedType = "1402"
  11638. //} else {
  11639. // fed.MedType = "9933"
  11640. //}
  11641. var orders []*models.FsiOrderDtos
  11642. if trig_scen == "2" {
  11643. //处方医嘱信息
  11644. for _, item := range prescriptions {
  11645. for _, subItem := range item.HisDoctorAdviceInfo {
  11646. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11647. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11648. var order models.FsiOrderDtos
  11649. order.RxID = strconv.FormatInt(item.ID, 10)
  11650. order.Rxno = strconv.FormatInt(item.ID, 10)
  11651. order.LongDrordFlag = "0"
  11652. order.HilistType = "1"
  11653. order.ChrgType = "1"
  11654. order.DrordBhvr = "0"
  11655. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11656. order.HosplistName = subItem.BaseDrugLib.DrugName
  11657. order.HilistLv = "1"
  11658. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11659. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11660. order.HosplistName = subItem.BaseDrugLib.DrugName
  11661. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11662. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11663. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11664. order.OwnpayAmt = ""
  11665. order.SelfpayAmt = ""
  11666. order.Spec = spec
  11667. order.SpecUnt = subItem.PrescribingNumberUnit
  11668. order.DrordBegnDate = s_tm
  11669. order.DrordStopDate = ""
  11670. order.DrordDrCodg = doctor_info.DoctorNumber
  11671. order.DrordDeptName = department.Name
  11672. order.DrordDeptCodg = department.Number
  11673. order.DrordDrName = doctor_info.UserName
  11674. order.DrordDrProfttl = "234"
  11675. order.CurrDrordFlag = "1"
  11676. orders = append(orders, &order)
  11677. }
  11678. }
  11679. for _, subItem := range item.HisPrescriptionProject {
  11680. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11681. var order models.FsiOrderDtos
  11682. order.RxID = strconv.FormatInt(item.ID, 10)
  11683. order.Rxno = strconv.FormatInt(item.ID, 10)
  11684. order.LongDrordFlag = "0"
  11685. order.HilistType = "1"
  11686. order.ChrgType = "1"
  11687. order.DrordBhvr = "0"
  11688. order.HilistCode = subItem.HisProject.MedicalCode
  11689. order.HosplistName = subItem.HisProject.ProjectName
  11690. order.HilistLv = "1"
  11691. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11692. order.HosplistCode = subItem.HisProject.MedicalCode
  11693. order.HosplistName = subItem.HisProject.ProjectName
  11694. order.Cnt = subItem.Count
  11695. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11696. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11697. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11698. order.OwnpayAmt = ""
  11699. order.SelfpayAmt = ""
  11700. order.Spec = subItem.Unit
  11701. order.SpecUnt = subItem.Unit
  11702. order.DrordBegnDate = s_tm
  11703. order.DrordStopDate = ""
  11704. order.DrordDrCodg = doctor_info.DoctorNumber
  11705. order.DrordDeptName = department.Name
  11706. order.DrordDeptCodg = department.Number
  11707. order.DrordDrName = doctor_info.UserName
  11708. order.DrordDrProfttl = "234"
  11709. order.CurrDrordFlag = "1"
  11710. orders = append(orders, &order)
  11711. }
  11712. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11713. var order models.FsiOrderDtos
  11714. order.RxID = strconv.FormatInt(item.ID, 10)
  11715. order.Rxno = strconv.FormatInt(item.ID, 10)
  11716. order.LongDrordFlag = "0"
  11717. order.HilistType = "1"
  11718. order.ChrgType = "1"
  11719. order.DrordBhvr = "0"
  11720. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11721. order.HosplistName = subItem.GoodInfo.GoodName
  11722. order.HilistLv = "1"
  11723. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11724. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11725. order.HosplistName = subItem.GoodInfo.GoodName
  11726. order.Cnt = subItem.Count
  11727. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11728. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11729. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11730. order.OwnpayAmt = ""
  11731. order.SelfpayAmt = ""
  11732. order.Spec = subItem.GoodInfo.SpecificationName
  11733. order.SpecUnt = subItem.Unit
  11734. order.DrordBegnDate = s_tm
  11735. order.DrordStopDate = ""
  11736. order.DrordDrCodg = doctor_info.DoctorNumber
  11737. order.DrordDeptName = department.Name
  11738. order.DrordDeptCodg = department.Number
  11739. order.DrordDrName = doctor_info.UserName
  11740. order.DrordDrProfttl = "234"
  11741. order.CurrDrordFlag = "1"
  11742. orders = append(orders, &order)
  11743. }
  11744. }
  11745. }
  11746. //处方医嘱信息
  11747. }
  11748. fed.MatnStas = "0"
  11749. fed.MedfeeSumamt = "0"
  11750. fed.OwnpayAmt = "0"
  11751. fed.SelfpayAmt = "0"
  11752. fed.AcctPayamt = "0"
  11753. fed.MaAmt = "0"
  11754. fed.HifpPayamt = "0"
  11755. fed.SetlTotlnum = "1"
  11756. fed.Insutype = his.Insutype
  11757. fed.ReimFlag = "0"
  11758. fed.OutSetlFlag = "0"
  11759. var fopd []*models.FsiOperationDtosData
  11760. data := make(map[string]interface{})
  11761. data["fed"] = fed
  11762. data["fdd"] = fdds
  11763. data["fod"] = orders
  11764. data["pd"] = pd
  11765. data["pp"] = pp
  11766. data["fopd"] = fopd
  11767. data["trig_scen"] = trig_scen
  11768. fmt.Println(data)
  11769. fmt.Println(fed)
  11770. fmt.Println(fdds)
  11771. fmt.Println(orders)
  11772. fmt.Println(pd)
  11773. fmt.Println(pp)
  11774. fmt.Println(fopd)
  11775. client := &http.Client{}
  11776. bytesData, _ := json.Marshal(data)
  11777. var req *http.Request
  11778. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11779. if miConfig.MdtrtareaAdmvs == "320921" {
  11780. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11781. } else {
  11782. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11783. }
  11784. resp, _ := client.Do(req)
  11785. defer resp.Body.Close()
  11786. body, ioErr := ioutil.ReadAll(resp.Body)
  11787. if ioErr != nil {
  11788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11790. return res
  11791. }
  11792. var respJSON map[string]interface{}
  11793. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11796. return res
  11797. }
  11798. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11799. fmt.Println(respJSON)
  11800. result, _ := json.Marshal(respJSON)
  11801. fmt.Println(result)
  11802. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11803. utils.ErrorLog("解析失败:%v", err)
  11804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11805. return res
  11806. }
  11807. return res
  11808. } else {
  11809. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11810. saveLog(output, input, "3101", "事前")
  11811. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11812. utils.ErrorLog("解析失败:%v", err)
  11813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11814. return
  11815. }
  11816. return res
  11817. }
  11818. return res
  11819. }
  11820. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11821. adminUser := c.GetAdminUserInfo()
  11822. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11823. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11824. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11825. record_time := c.GetString("record_time")
  11826. order, _ := service.GetHisOrderByID(order_id)
  11827. timeLayout := "2006-01-02"
  11828. loc, _ := time.LoadLocation("Local")
  11829. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11830. if err != nil {
  11831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11832. return
  11833. }
  11834. recordDateTime := theTime.Unix()
  11835. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11836. var patientPrescription models.HisPrescriptionInfo
  11837. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11838. if patientPrescription.ID == 0 {
  11839. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11840. }
  11841. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11842. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11843. //
  11844. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11845. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11846. var pp models.PublicParams
  11847. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11848. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11849. pp.FixmedinsName = miConfig.OrgName
  11850. pp.FixmedinsCode = miConfig.Code
  11851. pp.RequestUrl = miConfig.Url
  11852. pp.Cainfo = miConfig.Cainfo
  11853. pp.SecretKey = miConfig.SecretKey
  11854. pp.AccessKey = miConfig.AccessKey
  11855. pp.OpterName = roles.UserName
  11856. var config []*models.HisXtDiagnoseConfig
  11857. for _, item := range diagnosis_ids {
  11858. id, _ := strconv.ParseInt(item, 10, 64)
  11859. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11860. config = append(config, &diagnosisConfig)
  11861. }
  11862. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11863. var pd models.PatientDtos
  11864. pd.PatnID = his.PsnNo
  11865. pd.PatnName = his.Name
  11866. pd.Gend = his.Gend
  11867. pd.Brdy = str
  11868. pd.Poolarea = his.InsuplcAdmdvs
  11869. pd.CurrMdtrtID = his.Number
  11870. var fed models.FsiEncounterDtos
  11871. fed.MdtrtID = his.Number
  11872. fed.MedinsID = miConfig.Code
  11873. fed.MedinsName = miConfig.OrgName
  11874. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11875. fed.MedMdtrtType = "1"
  11876. fed.MedinsType = "1"
  11877. fed.MedinsLv = "11"
  11878. tm := time.Unix(his.RecordDate, 0)
  11879. s_tm := tm.Format("2006-01-02 15:04:05")
  11880. fed.AdmDate = s_tm
  11881. fed.DscgDate = s_tm
  11882. fed.DscgMainDiseCodg = config[0].CountryCode
  11883. fed.DscgMainDiseName = config[0].CountryContentName
  11884. //诊断信息
  11885. var fdds []*models.FsiDiagnoseDtos
  11886. for index, item := range config {
  11887. if index == 0 {
  11888. var fdd models.FsiDiagnoseDtos
  11889. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11890. fdd.InoutDiseType = "1"
  11891. fdd.MaindiseFlag = "1"
  11892. fdd.DiseDate = s_tm
  11893. fdd.DiasSrtNo = "1"
  11894. fdd.DiseName = item.CountryContentName
  11895. fdd.DiseCodg = item.CountryCode
  11896. fdds = append(fdds, &fdd)
  11897. } else {
  11898. var fdd models.FsiDiagnoseDtos
  11899. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11900. fdd.InoutDiseType = "1"
  11901. fdd.MaindiseFlag = "1"
  11902. fdd.DiseDate = s_tm
  11903. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11904. fdd.DiseName = item.CountryContentName
  11905. fdd.DiseCodg = item.CountryCode
  11906. fdds = append(fdds, &fdd)
  11907. }
  11908. }
  11909. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11910. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11911. fed.AdmDeptName = department.Name
  11912. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11913. fed.DscgDeptName = department.Name
  11914. fed.MedType = order.MedType
  11915. //处方医嘱信息
  11916. var orders []*models.FsiOrderDtos
  11917. //for _, item := range prescriptions {
  11918. // for _, subItem := range item.HisDoctorAdviceInfo {
  11919. // var order models.FsiOrderDtos
  11920. // order.RxID = strconv.FormatInt(item.ID, 10)
  11921. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11922. // order.LongDrordFlag = "0"
  11923. // order.HilistType = "1"
  11924. // order.ChrgType = "1"
  11925. // order.DrordBhvr = "-"
  11926. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11927. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11928. // order.HilistLv = "1"
  11929. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11930. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11931. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11932. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11933. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11934. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11935. // order.OwnpayAmt = ""
  11936. // order.SelfpayAmt = ""
  11937. // order.Spec = ""
  11938. // order.SpecUnt = ""
  11939. // order.DrordBegnDate = s_tm
  11940. // order.DrordStopDate = ""
  11941. // order.DrordDrCodg = "1"
  11942. // order.DrordDeptName = department.Name
  11943. // order.DrordDrCodg = "1"
  11944. // order.DrordDrName = doctor_info.UserName
  11945. // order.DrordDrProfttl = ""
  11946. // order.CurrDrordFlag = "1"
  11947. // orders = append(orders, &order)
  11948. // }
  11949. // for _, subItem := range item.HisPrescriptionProject {
  11950. // if subItem.Type == 2 {
  11951. // var order models.FsiOrderDtos
  11952. // order.RxID = strconv.FormatInt(item.ID, 10)
  11953. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11954. // order.LongDrordFlag = "0"
  11955. // order.HilistType = "1"
  11956. // order.ChrgType = "1"
  11957. // order.DrordBhvr = "-"
  11958. // order.HilistCode = subItem.HisProject.MedicalCode
  11959. // order.HosplistName = subItem.HisProject.ProjectName
  11960. // order.HilistLv = "1"
  11961. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11962. // order.HosplistCode = subItem.HisProject.MedicalCode
  11963. // order.HosplistName = subItem.HisProject.ProjectName
  11964. // order.Cnt = subItem.Count
  11965. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11966. //
  11967. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11968. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11969. // order.OwnpayAmt = ""
  11970. // order.SelfpayAmt = ""
  11971. // order.Spec = ""
  11972. // order.SpecUnt = ""
  11973. // order.DrordBegnDate = s_tm
  11974. // order.DrordStopDate = ""
  11975. // order.DrordDrCodg = "1"
  11976. // order.DrordDeptName = department.Name
  11977. // order.DrordDrCodg = "1"
  11978. // order.DrordDrName = doctor_info.UserName
  11979. // order.DrordDrProfttl = ""
  11980. // order.CurrDrordFlag = "1"
  11981. // orders = append(orders, &order)
  11982. //
  11983. // }
  11984. // if subItem.Type == 3 {
  11985. //
  11986. // var order models.FsiOrderDtos
  11987. // order.RxID = strconv.FormatInt(item.ID, 10)
  11988. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11989. // order.LongDrordFlag = "0"
  11990. // order.HilistType = "1"
  11991. // order.ChrgType = "1"
  11992. // order.DrordBhvr = "-"
  11993. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11994. // order.HosplistName = subItem.GoodInfo.GoodName
  11995. // order.HilistLv = "1"
  11996. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11997. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11998. // order.HosplistName = subItem.GoodInfo.GoodName
  11999. // order.Cnt = subItem.Count
  12000. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12001. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12002. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12003. // order.OwnpayAmt = ""
  12004. // order.SelfpayAmt = ""
  12005. // order.Spec = ""
  12006. // order.SpecUnt = ""
  12007. // order.DrordBegnDate = s_tm
  12008. // order.DrordStopDate = ""
  12009. // order.DrordDrCodg = "1"
  12010. // order.DrordDeptName = department.Name
  12011. // order.DrordDrCodg = "1"
  12012. // order.DrordDrName = doctor_info.UserName
  12013. // order.DrordDrProfttl = ""
  12014. // order.CurrDrordFlag = "1"
  12015. // orders = append(orders, &order)
  12016. //
  12017. // }
  12018. // }
  12019. //}
  12020. for _, item := range prescriptions {
  12021. for _, subItem := range item.HisDoctorAdviceInfo {
  12022. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12023. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12024. var order models.FsiOrderDtos
  12025. order.RxID = strconv.FormatInt(item.ID, 10)
  12026. order.Rxno = strconv.FormatInt(item.ID, 10)
  12027. order.LongDrordFlag = "0"
  12028. order.HilistType = "1"
  12029. order.ChrgType = "1"
  12030. order.DrordBhvr = "0"
  12031. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12032. order.HosplistName = subItem.BaseDrugLib.DrugName
  12033. order.HilistLv = "1"
  12034. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12035. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12036. order.HosplistName = subItem.BaseDrugLib.DrugName
  12037. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12038. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12039. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12040. order.OwnpayAmt = ""
  12041. order.SelfpayAmt = ""
  12042. order.Spec = spec
  12043. order.SpecUnt = subItem.PrescribingNumberUnit
  12044. order.DrordBegnDate = s_tm
  12045. order.DrordStopDate = ""
  12046. order.DrordDrCodg = doctor_info.DoctorNumber
  12047. order.DrordDeptName = department.Name
  12048. order.DrordDeptCodg = department.Number
  12049. order.DrordDrName = doctor_info.UserName
  12050. order.DrordDrProfttl = "234"
  12051. order.CurrDrordFlag = "1"
  12052. orders = append(orders, &order)
  12053. }
  12054. }
  12055. for _, subItem := range item.HisPrescriptionProject {
  12056. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12057. var order models.FsiOrderDtos
  12058. order.RxID = strconv.FormatInt(item.ID, 10)
  12059. order.Rxno = strconv.FormatInt(item.ID, 10)
  12060. order.LongDrordFlag = "0"
  12061. order.HilistType = "1"
  12062. order.ChrgType = "1"
  12063. order.DrordBhvr = "0"
  12064. order.HilistCode = subItem.HisProject.MedicalCode
  12065. order.HosplistName = subItem.HisProject.ProjectName
  12066. order.HilistLv = "1"
  12067. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12068. order.HosplistCode = subItem.HisProject.MedicalCode
  12069. order.HosplistName = subItem.HisProject.ProjectName
  12070. order.Cnt = subItem.Count
  12071. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12072. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12073. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12074. order.OwnpayAmt = ""
  12075. order.SelfpayAmt = ""
  12076. order.Spec = subItem.Unit
  12077. order.SpecUnt = subItem.Unit
  12078. order.DrordBegnDate = s_tm
  12079. order.DrordStopDate = ""
  12080. order.DrordDrCodg = doctor_info.DoctorNumber
  12081. order.DrordDeptName = department.Name
  12082. order.DrordDeptCodg = department.Number
  12083. order.DrordDrName = doctor_info.UserName
  12084. order.DrordDrProfttl = "234"
  12085. order.CurrDrordFlag = "1"
  12086. orders = append(orders, &order)
  12087. }
  12088. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12089. var order models.FsiOrderDtos
  12090. order.RxID = strconv.FormatInt(item.ID, 10)
  12091. order.Rxno = strconv.FormatInt(item.ID, 10)
  12092. order.LongDrordFlag = "0"
  12093. order.HilistType = "1"
  12094. order.ChrgType = "1"
  12095. order.DrordBhvr = "0"
  12096. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12097. order.HosplistName = subItem.GoodInfo.GoodName
  12098. order.HilistLv = "1"
  12099. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12100. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12101. order.HosplistName = subItem.GoodInfo.GoodName
  12102. order.Cnt = subItem.Count
  12103. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12104. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12105. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12106. order.OwnpayAmt = ""
  12107. order.SelfpayAmt = ""
  12108. order.Spec = subItem.GoodInfo.SpecificationName
  12109. order.SpecUnt = subItem.Unit
  12110. order.DrordBegnDate = s_tm
  12111. order.DrordStopDate = ""
  12112. order.DrordDrCodg = doctor_info.DoctorNumber
  12113. order.DrordDeptName = department.Name
  12114. order.DrordDeptCodg = department.Number
  12115. order.DrordDrName = doctor_info.UserName
  12116. order.DrordDrProfttl = "234"
  12117. order.CurrDrordFlag = "1"
  12118. orders = append(orders, &order)
  12119. }
  12120. }
  12121. }
  12122. //处方医嘱信息
  12123. fed.MatnStas = "0"
  12124. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12125. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12126. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12127. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12128. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12129. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12130. fed.SetlTotlnum = "1"
  12131. fed.Insutype = his.Insutype
  12132. fed.ReimFlag = "0"
  12133. fed.OutSetlFlag = "0"
  12134. var fopd []*models.FsiOperationDtosData
  12135. data := make(map[string]interface{})
  12136. data["fed"] = fed
  12137. data["fdd"] = fdds
  12138. data["fod"] = orders
  12139. data["pd"] = pd
  12140. data["pp"] = pp
  12141. data["fopd"] = fopd
  12142. data["trig_scen"] = trig_scen
  12143. client := &http.Client{}
  12144. bytesData, _ := json.Marshal(data)
  12145. var req *http.Request
  12146. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12147. if miConfig.MdtrtareaAdmvs == "320921" {
  12148. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12149. } else {
  12150. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12151. }
  12152. resp, _ := client.Do(req)
  12153. defer resp.Body.Close()
  12154. body, ioErr := ioutil.ReadAll(resp.Body)
  12155. if ioErr != nil {
  12156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12158. return res
  12159. }
  12160. var respJSON map[string]interface{}
  12161. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12164. return res
  12165. }
  12166. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12167. result, _ := json.Marshal(respJSON)
  12168. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12169. utils.ErrorLog("解析失败:%v", err)
  12170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12171. return res
  12172. }
  12173. return res
  12174. } else {
  12175. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12176. saveLog(output, input, "3102", "事中")
  12177. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12178. utils.ErrorLog("解析失败:%v", err)
  12179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12180. return
  12181. }
  12182. return res
  12183. }
  12184. return res
  12185. }
  12186. func (c *HisApiController) Check() {
  12187. psn_no := c.GetString("psn_no")
  12188. in := c.GetString("in")
  12189. mt := c.GetString("mt")
  12190. baseParams := models.BaseParams{
  12191. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12192. FixmedinsCode: "H15049901371",
  12193. InsuplcAdmdvs: "150499",
  12194. MdtrtareaAdmvs: "150499",
  12195. OrgName: "赤峰费森血液透析中心",
  12196. Doctor: "1111",
  12197. }
  12198. service.Gdyb2001(baseParams, psn_no, in, mt)
  12199. }
  12200. func (c *HisApiController) GetPsnNcdsInfo() {
  12201. admin_user_id, _ := c.GetInt64("admin_user_id")
  12202. patient_id, _ := c.GetInt64("patient_id")
  12203. //id, _ := c.GetInt64("id")
  12204. adminUser := c.GetAdminUserInfo()
  12205. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12206. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12207. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12208. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12209. //psn_record, _ := service.GetP(id)
  12210. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12211. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12212. //
  12213. //if psn_record.ID == 0 {
  12214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12215. // return
  12216. //}
  12217. var res Result5301
  12218. var res10265 Result5301For10265
  12219. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12220. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12221. var api string
  12222. if miConfig.MdtrtareaAdmvs == "320921" {
  12223. 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 +
  12224. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12225. } else {
  12226. 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 +
  12227. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12228. }
  12229. resp, requestErr := http.Get(api)
  12230. if requestErr != nil {
  12231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12232. return
  12233. }
  12234. body, ioErr := ioutil.ReadAll(resp.Body)
  12235. if ioErr != nil {
  12236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12238. return
  12239. }
  12240. var respJSON map[string]interface{}
  12241. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12244. return
  12245. }
  12246. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12247. result, _ := json.Marshal(respJSON)
  12248. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12249. utils.ErrorLog("解析失败:%v", err)
  12250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12251. return
  12252. }
  12253. res.ErrMsg = res10265.ErrMsg
  12254. res.Output = res10265.Output
  12255. res.InfRefmsgid = res10265.InfRefmsgid
  12256. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12257. res.Infcode = infocode
  12258. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12259. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12260. var api string
  12261. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12262. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12263. resp, requestErr := http.Get(api)
  12264. if requestErr != nil {
  12265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12266. return
  12267. }
  12268. body, ioErr := ioutil.ReadAll(resp.Body)
  12269. if ioErr != nil {
  12270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12272. return
  12273. }
  12274. var respJSON map[string]interface{}
  12275. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12278. return
  12279. }
  12280. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12281. if status == "0" {
  12282. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12283. c.ServeSuccessJSON(map[string]interface{}{
  12284. "failed_code": -10,
  12285. "msg": err_msg,
  12286. })
  12287. return
  12288. }
  12289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12290. result, _ := json.Marshal(respJSON)
  12291. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12292. utils.ErrorLog("解析失败:%v", err)
  12293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12294. return
  12295. }
  12296. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12297. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12298. var api string
  12299. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12300. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12301. resp, requestErr := http.Get(api)
  12302. if requestErr != nil {
  12303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12304. return
  12305. }
  12306. body, ioErr := ioutil.ReadAll(resp.Body)
  12307. if ioErr != nil {
  12308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12310. return
  12311. }
  12312. var respJSON map[string]interface{}
  12313. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12314. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12316. return
  12317. }
  12318. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12319. if status == "0" {
  12320. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12321. c.ServeSuccessJSON(map[string]interface{}{
  12322. "failed_code": -10,
  12323. "msg": err_msg,
  12324. })
  12325. return
  12326. }
  12327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12328. result, _ := json.Marshal(respJSON)
  12329. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12330. utils.ErrorLog("解析失败:%v", err)
  12331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12332. return
  12333. }
  12334. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12335. p, _ := service.GetHisPatientById(patient_id)
  12336. result, _ := service.Jxyb5301(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 == "361025" {
  12350. p, _ := service.GetHisPatientById(patient_id)
  12351. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12352. var dat map[string]interface{}
  12353. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12354. fmt.Println(dat)
  12355. } else {
  12356. fmt.Println(err)
  12357. }
  12358. userJSONBytes, _ := json.Marshal(dat)
  12359. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12360. utils.ErrorLog("解析失败:%v", err)
  12361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12362. return
  12363. }
  12364. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12365. p, _ := service.GetHisPatientById(patient_id)
  12366. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12367. var dat map[string]interface{}
  12368. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12369. fmt.Println(dat)
  12370. } else {
  12371. fmt.Println(err)
  12372. }
  12373. userJSONBytes, _ := json.Marshal(dat)
  12374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12375. utils.ErrorLog("解析失败:%v", err)
  12376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12377. return
  12378. }
  12379. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12380. p, _ := service.GetHisPatientById(patient_id)
  12381. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12382. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12383. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12384. resp, requestErr := http.Get(api)
  12385. if requestErr != nil {
  12386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12387. return
  12388. }
  12389. body, ioErr := ioutil.ReadAll(resp.Body)
  12390. if ioErr != nil {
  12391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12393. return
  12394. }
  12395. var respJSON map[string]interface{}
  12396. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12399. return
  12400. }
  12401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12402. result, _ := json.Marshal(respJSON)
  12403. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12404. utils.ErrorLog("解析失败:%v", err)
  12405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12406. return
  12407. }
  12408. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12409. p, _ := service.GetHisPatientById(patient_id)
  12410. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12411. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12412. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12413. resp, requestErr := http.Get(api)
  12414. if requestErr != nil {
  12415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12416. return
  12417. }
  12418. body, ioErr := ioutil.ReadAll(resp.Body)
  12419. if ioErr != nil {
  12420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12422. return
  12423. }
  12424. var respJSON map[string]interface{}
  12425. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12428. return
  12429. }
  12430. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12431. result, _ := json.Marshal(respJSON)
  12432. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12433. utils.ErrorLog("解析失败:%v", err)
  12434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12435. return
  12436. }
  12437. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12438. p, _ := service.GetHisPatientById(patient_id)
  12439. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12440. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12441. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12442. resp, requestErr := http.Get(api)
  12443. if requestErr != nil {
  12444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12445. return
  12446. }
  12447. body, ioErr := ioutil.ReadAll(resp.Body)
  12448. if ioErr != nil {
  12449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12451. return
  12452. }
  12453. var respJSON map[string]interface{}
  12454. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12457. return
  12458. }
  12459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12460. result, _ := json.Marshal(respJSON)
  12461. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12462. utils.ErrorLog("解析失败:%v", err)
  12463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12464. return
  12465. }
  12466. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12467. p, _ := service.GetHisPatientById(patient_id)
  12468. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12469. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12470. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12471. resp, requestErr := http.Get(api)
  12472. if requestErr != nil {
  12473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12474. return
  12475. }
  12476. body, ioErr := ioutil.ReadAll(resp.Body)
  12477. if ioErr != nil {
  12478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12480. return
  12481. }
  12482. var respJSON map[string]interface{}
  12483. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12486. return
  12487. }
  12488. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12489. result, _ := json.Marshal(respJSON)
  12490. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12491. utils.ErrorLog("解析失败:%v", err)
  12492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12493. return
  12494. }
  12495. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12496. p, _ := service.GetHisPatientById(patient_id)
  12497. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12498. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12499. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12500. resp, requestErr := http.Get(api)
  12501. if requestErr != nil {
  12502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12503. return
  12504. }
  12505. body, ioErr := ioutil.ReadAll(resp.Body)
  12506. if ioErr != nil {
  12507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12509. return
  12510. }
  12511. var respJSON map[string]interface{}
  12512. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12515. return
  12516. }
  12517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12518. result, _ := json.Marshal(respJSON)
  12519. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12520. utils.ErrorLog("解析失败:%v", err)
  12521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12522. return
  12523. }
  12524. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12525. p, _ := service.GetHisPatientById(patient_id)
  12526. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12527. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12528. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12529. resp, requestErr := http.Get(api)
  12530. if requestErr != nil {
  12531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12532. return
  12533. }
  12534. body, ioErr := ioutil.ReadAll(resp.Body)
  12535. if ioErr != nil {
  12536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12538. return
  12539. }
  12540. var respJSON map[string]interface{}
  12541. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12544. return
  12545. }
  12546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12547. result, _ := json.Marshal(respJSON)
  12548. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12549. utils.ErrorLog("解析失败:%v", err)
  12550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12551. return
  12552. }
  12553. } else {
  12554. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12555. var dat map[string]interface{}
  12556. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12557. fmt.Println(dat)
  12558. } else {
  12559. fmt.Println(err)
  12560. }
  12561. userJSONBytes, _ := json.Marshal(dat)
  12562. if miConfig.Code == "H15049901371" {
  12563. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12564. utils.ErrorLog("解析失败:%v", err)
  12565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12566. return
  12567. }
  12568. res.InfRefmsgid = res10265.InfRefmsgid
  12569. res.Output = res10265.Output
  12570. res.ErrMsg = res10265.ErrMsg
  12571. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12572. res.Infcode = infocode
  12573. } else {
  12574. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12575. utils.ErrorLog("解析失败:%v", err)
  12576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12577. return
  12578. }
  12579. }
  12580. }
  12581. if res.Infcode == 0 {
  12582. c.ServeSuccessJSON(map[string]interface{}{
  12583. "result": res.Output.Result,
  12584. })
  12585. }
  12586. }
  12587. func (c *HisApiController) CheckInsutype() {
  12588. his_patient_id, _ := c.GetInt64("his_patient_id")
  12589. admin_user_id, _ := c.GetInt64("admin_user_id")
  12590. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12591. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12592. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12593. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12594. var dat map[string]interface{}
  12595. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12596. fmt.Println(dat)
  12597. } else {
  12598. fmt.Println(err)
  12599. }
  12600. userJSONBytes, _ := json.Marshal(dat)
  12601. var res Result90100
  12602. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12603. utils.ErrorLog("解析失败:%v", err)
  12604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12605. return
  12606. }
  12607. if res.Infcode != 0 {
  12608. c.ServeSuccessJSON(map[string]interface{}{
  12609. "failed_code": -10,
  12610. "msg": res.ErrMsg,
  12611. })
  12612. return
  12613. } else {
  12614. fmt.Println(res)
  12615. }
  12616. }
  12617. func (c *HisApiController) CheckCardPWD() {
  12618. card_pwd := c.GetString("card_pwd")
  12619. his_patient_id, _ := c.GetInt64("his_patient_id")
  12620. admin_user_id, _ := c.GetInt64("admin_user_id")
  12621. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12622. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12623. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12624. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12625. bas := strings.Split(psn.CardInfo, "|")
  12626. basNumber := bas[2]
  12627. if psn.InsuplcAdmdvs[:4] == "4403" {
  12628. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12629. var dat map[string]interface{}
  12630. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12631. fmt.Println(dat)
  12632. } else {
  12633. fmt.Println(err)
  12634. }
  12635. userJSONBytes, _ := json.Marshal(dat)
  12636. var res Result90991
  12637. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12638. utils.ErrorLog("解析失败:%v", err)
  12639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12640. return
  12641. }
  12642. if res.Infcode != 0 {
  12643. c.ServeSuccessJSON(map[string]interface{}{
  12644. "failed_code": -10,
  12645. "msg": res.ErrMsg,
  12646. })
  12647. return
  12648. } else {
  12649. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12650. var msg string
  12651. switch res.Output.Result.CardStat {
  12652. case "00":
  12653. msg = "未激活"
  12654. break
  12655. case "10":
  12656. msg = "激活"
  12657. break
  12658. case "20":
  12659. msg = "窗口挂失"
  12660. break
  12661. case "21":
  12662. msg = "电话挂失"
  12663. break
  12664. case "22":
  12665. msg = "单位网上申报挂失"
  12666. break
  12667. case "23":
  12668. msg = "保健办挂失"
  12669. break
  12670. case "24":
  12671. msg = "个人网上挂失"
  12672. break
  12673. case "25":
  12674. msg = "网上服务大厅挂失"
  12675. break
  12676. case "30":
  12677. msg = "注销"
  12678. break
  12679. case "40":
  12680. msg = "回收"
  12681. break
  12682. case "99":
  12683. msg = "制卡中(无效卡)"
  12684. break
  12685. }
  12686. c.ServeSuccessJSON(map[string]interface{}{
  12687. "failed_code": -10,
  12688. "msg": msg,
  12689. })
  12690. return
  12691. } else {
  12692. c.ServeSuccessJSON(map[string]interface{}{
  12693. "msg": "校验成功",
  12694. })
  12695. return
  12696. }
  12697. }
  12698. } else {
  12699. c.ServeSuccessJSON(map[string]interface{}{
  12700. "msg": "校验成功",
  12701. })
  12702. return
  12703. }
  12704. }
  12705. func (c *HisApiController) CheckCardPWDTwo() {
  12706. //card_pwd := c.GetString("card_pwd")
  12707. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12708. admin_user_id, _ := c.GetInt64("admin_user_id")
  12709. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12710. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12711. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12712. var dat map[string]interface{}
  12713. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12714. fmt.Println(dat)
  12715. } else {
  12716. fmt.Println(err)
  12717. }
  12718. userJSONBytes, _ := json.Marshal(dat)
  12719. var res Result90991
  12720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12721. utils.ErrorLog("解析失败:%v", err)
  12722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12723. return
  12724. }
  12725. if res.Infcode != 0 {
  12726. c.ServeSuccessJSON(map[string]interface{}{
  12727. "failed_code": -10,
  12728. "msg": res.ErrMsg,
  12729. })
  12730. return
  12731. } else {
  12732. if res.Output.Result.SscnoCheckStat == "0" {
  12733. var msg string
  12734. switch res.Output.Result.CardStat {
  12735. case "00":
  12736. msg = "未激活"
  12737. break
  12738. case "10":
  12739. msg = "激活"
  12740. break
  12741. case "20":
  12742. msg = "窗口挂失"
  12743. break
  12744. case "21":
  12745. msg = "电话挂失"
  12746. break
  12747. case "22":
  12748. msg = "单位网上申报挂失"
  12749. break
  12750. case "23":
  12751. msg = "保健办挂失"
  12752. break
  12753. case "24":
  12754. msg = "个人网上挂失"
  12755. break
  12756. case "25":
  12757. msg = "网上服务大厅挂失"
  12758. break
  12759. case "30":
  12760. msg = "注销"
  12761. break
  12762. case "40":
  12763. msg = "回收"
  12764. break
  12765. case "99":
  12766. msg = "制卡中(无效卡)"
  12767. break
  12768. }
  12769. c.ServeSuccessJSON(map[string]interface{}{
  12770. "failed_code": -10,
  12771. "msg": msg,
  12772. })
  12773. return
  12774. } else {
  12775. c.ServeSuccessJSON(map[string]interface{}{
  12776. "msg": "校验成功",
  12777. })
  12778. return
  12779. }
  12780. }
  12781. }
  12782. type ELeCertData struct {
  12783. Data struct {
  12784. Extra string `json:"extra"`
  12785. IDNo string `json:"idNo"`
  12786. IDType string `json:"idType"`
  12787. EcToken string `json:"ecToken"`
  12788. InsuOrg string `json:"insuOrg"`
  12789. UserName string `json:"userName"`
  12790. EcIndexNo string `json:"ecIndexNo"`
  12791. Gender string `json:"gender"`
  12792. Birthday string `json:"birthday"`
  12793. Nationality string `json:"nationality"`
  12794. Email string `json:"email"`
  12795. } `json:"OutData"`
  12796. }
  12797. func (c *HisApiController) ReadCard() {
  12798. id_card_type, _ := c.GetInt64("id_card_type")
  12799. admin_user_id, _ := c.GetInt64("admin_user_id")
  12800. certificates, _ := c.GetInt64("certificates")
  12801. //
  12802. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12803. id_card_no := c.GetString("id_card_no")
  12804. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12805. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12806. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12807. switch id_card_type {
  12808. case 1:
  12809. if miConfig.MdtrtareaAdmvs == "421300" {
  12810. var res ResultTwo
  12811. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12812. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12813. "&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)
  12814. resp, requestErr := http.Get(api)
  12815. if requestErr != nil {
  12816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12817. return
  12818. }
  12819. body, ioErr := ioutil.ReadAll(resp.Body)
  12820. if ioErr != nil {
  12821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12823. return
  12824. }
  12825. var respJSON map[string]interface{}
  12826. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12829. return
  12830. }
  12831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12832. result, _ := json.Marshal(respJSON)
  12833. fmt.Println("log")
  12834. fmt.Println(string(result))
  12835. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12836. utils.ErrorLog("解析失败:%v", err)
  12837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12838. return
  12839. }
  12840. if res.Infcode == 0 {
  12841. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12842. if err == gorm.ErrRecordNotFound {
  12843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12844. return
  12845. } else if err != nil {
  12846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12847. return
  12848. } else {
  12849. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12850. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12851. infoStr := string(Iinfos)
  12852. idetinfoStr := string(Idetinfos)
  12853. var rf []*ResultFive
  12854. json.Unmarshal([]byte(infoStr), &rf)
  12855. var insutypes []*ResultFive
  12856. var insutype string
  12857. var is390 int = 0
  12858. var is310 int = 0
  12859. for _, item := range rf {
  12860. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12861. insutypes = append(insutypes, item)
  12862. }
  12863. }
  12864. if len(insutypes) == 1 {
  12865. insutype = insutypes[0].Insutype
  12866. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12867. } else {
  12868. for _, i := range insutypes {
  12869. if i.Insutype == "390" {
  12870. is390 = 1
  12871. }
  12872. if i.Insutype == "310" {
  12873. is310 = 1
  12874. }
  12875. }
  12876. }
  12877. if is390 == 1 {
  12878. insutype = "390"
  12879. }
  12880. if is310 == 1 {
  12881. insutype = "310"
  12882. }
  12883. if len(insutypes) == 0 {
  12884. insutype = "390"
  12885. }
  12886. var insuplc_admdvs string
  12887. for _, item := range rf {
  12888. if item.Insutype == insutype {
  12889. insuplc_admdvs = item.InsuplcAdmdvs
  12890. }
  12891. }
  12892. if strings.Contains(insuplc_admdvs, "4213") {
  12893. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12894. }
  12895. psn := &models.HisPsn{
  12896. PsnNo: res.Output.Baseinfo.PsnNo,
  12897. PatientId: patient.ID,
  12898. Certno: res.Output.Baseinfo.Certno,
  12899. Gend: res.Output.Baseinfo.Gend,
  12900. Naty: res.Output.Baseinfo.Naty,
  12901. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12902. PsnName: res.Output.Baseinfo.PsnName,
  12903. Idetinfo: idetinfoStr,
  12904. Insuinfo: infoStr,
  12905. InsuplcAdmdvs: insuplc_admdvs,
  12906. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12907. }
  12908. service.CreateHisPsn(psn)
  12909. c.ServeSuccessJSON(map[string]interface{}{
  12910. "patient": patient,
  12911. "number": res.Output.Baseinfo.Certno,
  12912. })
  12913. }
  12914. } else {
  12915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12916. return
  12917. }
  12918. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12919. var res ResultTwo
  12920. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12921. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12922. "&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)
  12923. resp, requestErr := http.Get(api)
  12924. if requestErr != nil {
  12925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12926. return
  12927. }
  12928. body, ioErr := ioutil.ReadAll(resp.Body)
  12929. if ioErr != nil {
  12930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12932. return
  12933. }
  12934. var respJSON map[string]interface{}
  12935. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12938. return
  12939. }
  12940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12941. result, _ := json.Marshal(respJSON)
  12942. fmt.Println("log")
  12943. fmt.Println(string(result))
  12944. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12945. utils.ErrorLog("解析失败:%v", err)
  12946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12947. return
  12948. }
  12949. if res.Infcode == 0 {
  12950. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12951. if err == gorm.ErrRecordNotFound {
  12952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12953. return
  12954. } else if err != nil {
  12955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12956. return
  12957. } else {
  12958. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12959. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12960. infoStr := string(Iinfos)
  12961. idetinfoStr := string(Idetinfos)
  12962. psn := &models.HisPsn{
  12963. PsnNo: res.Output.Baseinfo.PsnNo,
  12964. PatientId: patient.ID,
  12965. Certno: res.Output.Baseinfo.Certno,
  12966. Gend: res.Output.Baseinfo.Gend,
  12967. Naty: res.Output.Baseinfo.Naty,
  12968. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12969. PsnName: res.Output.Baseinfo.PsnName,
  12970. Idetinfo: idetinfoStr,
  12971. Insuinfo: infoStr,
  12972. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12973. }
  12974. service.CreateHisPsn(psn)
  12975. var rf []*ResultFive
  12976. json.Unmarshal([]byte(infoStr), &rf)
  12977. var insutypes []*ResultFive
  12978. var insutype string
  12979. var is390 int = 0
  12980. var is310 int = 0
  12981. for _, item := range rf {
  12982. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12983. insutypes = append(insutypes, item)
  12984. }
  12985. }
  12986. if len(insutypes) == 1 {
  12987. insutype = insutypes[0].Insutype
  12988. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12989. } else {
  12990. for _, i := range insutypes {
  12991. if i.Insutype == "390" {
  12992. is390 = 1
  12993. }
  12994. if i.Insutype == "310" {
  12995. is310 = 1
  12996. }
  12997. }
  12998. }
  12999. if is390 == 1 {
  13000. insutype = "390"
  13001. }
  13002. if is310 == 1 {
  13003. insutype = "310"
  13004. }
  13005. if len(insutypes) == 0 {
  13006. insutype = "310"
  13007. }
  13008. c.ServeSuccessJSON(map[string]interface{}{
  13009. "patient": patient,
  13010. "number": res.Output.Baseinfo.Certno,
  13011. "insutype": insutype,
  13012. })
  13013. }
  13014. } else {
  13015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13016. return
  13017. }
  13018. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13019. var res ResultTwo
  13020. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13021. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13022. "&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)
  13023. resp, requestErr := http.Get(api)
  13024. if requestErr != nil {
  13025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13026. return
  13027. }
  13028. body, ioErr := ioutil.ReadAll(resp.Body)
  13029. if ioErr != nil {
  13030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13032. return
  13033. }
  13034. var respJSON map[string]interface{}
  13035. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13038. return
  13039. }
  13040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13041. result, _ := json.Marshal(respJSON)
  13042. fmt.Println("log")
  13043. fmt.Println(string(result))
  13044. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13045. utils.ErrorLog("解析失败:%v", err)
  13046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13047. return
  13048. }
  13049. if res.Infcode == 0 {
  13050. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13051. if err == gorm.ErrRecordNotFound {
  13052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13053. return
  13054. } else if err != nil {
  13055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13056. return
  13057. } else {
  13058. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13059. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13060. infoStr := string(Iinfos)
  13061. idetinfoStr := string(Idetinfos)
  13062. var rf []*ResultFive
  13063. json.Unmarshal([]byte(infoStr), &rf)
  13064. var insutypes []*ResultFive
  13065. var insutype string
  13066. var is390 int = 0
  13067. var is310 int = 0
  13068. for _, item := range rf {
  13069. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13070. insutypes = append(insutypes, item)
  13071. }
  13072. }
  13073. if len(insutypes) == 1 {
  13074. insutype = insutypes[0].Insutype
  13075. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13076. } else {
  13077. for _, i := range insutypes {
  13078. if i.Insutype == "390" {
  13079. is390 = 1
  13080. }
  13081. if i.Insutype == "310" {
  13082. is310 = 1
  13083. }
  13084. }
  13085. }
  13086. if is390 == 1 {
  13087. insutype = "390"
  13088. }
  13089. if is310 == 1 {
  13090. insutype = "310"
  13091. }
  13092. if len(insutypes) == 0 {
  13093. insutype = "390"
  13094. }
  13095. var insuplc_admdvs string
  13096. for _, item := range rf {
  13097. if item.Insutype == insutype {
  13098. insuplc_admdvs = item.InsuplcAdmdvs
  13099. }
  13100. }
  13101. psn := &models.HisPsn{
  13102. PsnNo: res.Output.Baseinfo.PsnNo,
  13103. PatientId: patient.ID,
  13104. Certno: res.Output.Baseinfo.Certno,
  13105. Gend: res.Output.Baseinfo.Gend,
  13106. Naty: res.Output.Baseinfo.Naty,
  13107. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13108. PsnName: res.Output.Baseinfo.PsnName,
  13109. Idetinfo: idetinfoStr,
  13110. Insuinfo: infoStr,
  13111. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13112. InsuplcAdmdvs: insuplc_admdvs,
  13113. }
  13114. service.CreateHisPsn(psn)
  13115. for _, item := range rf {
  13116. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13117. insutypes = append(insutypes, item)
  13118. }
  13119. }
  13120. if len(insutypes) == 1 {
  13121. insutype = insutypes[0].Insutype
  13122. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13123. } else {
  13124. for _, i := range insutypes {
  13125. if i.Insutype == "390" {
  13126. is390 = 1
  13127. }
  13128. if i.Insutype == "310" {
  13129. is310 = 1
  13130. }
  13131. }
  13132. }
  13133. if is390 == 1 {
  13134. insutype = "390"
  13135. }
  13136. if is310 == 1 {
  13137. insutype = "310"
  13138. }
  13139. if len(insutypes) == 0 {
  13140. insutype = "310"
  13141. }
  13142. c.ServeSuccessJSON(map[string]interface{}{
  13143. "patient": patient,
  13144. "number": res.Output.Baseinfo.Certno,
  13145. "insutype": insutype,
  13146. })
  13147. }
  13148. } else {
  13149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13150. return
  13151. }
  13152. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13153. var res ResultTwo
  13154. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13155. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13156. "&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)
  13157. resp, requestErr := http.Get(api)
  13158. if requestErr != nil {
  13159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13160. return
  13161. }
  13162. body, ioErr := ioutil.ReadAll(resp.Body)
  13163. if ioErr != nil {
  13164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13166. return
  13167. }
  13168. var respJSON map[string]interface{}
  13169. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13172. return
  13173. }
  13174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13175. result, _ := json.Marshal(respJSON)
  13176. fmt.Println("log")
  13177. fmt.Println(string(result))
  13178. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13179. utils.ErrorLog("解析失败:%v", err)
  13180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13181. return
  13182. }
  13183. if res.Infcode == 0 {
  13184. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13185. if err == gorm.ErrRecordNotFound {
  13186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13187. return
  13188. } else if err != nil {
  13189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13190. return
  13191. } else {
  13192. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13193. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13194. infoStr := string(Iinfos)
  13195. idetinfoStr := string(Idetinfos)
  13196. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13197. psn := &models.HisPsn{
  13198. PsnNo: res.Output.Baseinfo.PsnNo,
  13199. PatientId: patient.ID,
  13200. Certno: res.Output.Baseinfo.Certno,
  13201. Brdy: b,
  13202. Age: float64(age),
  13203. Gend: res.Output.Baseinfo.Gend,
  13204. Naty: res.Output.Baseinfo.Naty,
  13205. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13206. PsnName: res.Output.Baseinfo.PsnName,
  13207. Idetinfo: idetinfoStr,
  13208. Insuinfo: infoStr,
  13209. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13210. }
  13211. service.CreateHisPsn(psn)
  13212. var rf []*ResultFive
  13213. json.Unmarshal([]byte(infoStr), &rf)
  13214. var insutypes []*ResultFive
  13215. var insutype string
  13216. var is390 int = 0
  13217. var is310 int = 0
  13218. for _, item := range rf {
  13219. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13220. insutypes = append(insutypes, item)
  13221. }
  13222. }
  13223. if len(insutypes) == 1 {
  13224. insutype = insutypes[0].Insutype
  13225. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13226. } else {
  13227. for _, i := range insutypes {
  13228. if i.Insutype == "390" {
  13229. is390 = 1
  13230. }
  13231. if i.Insutype == "310" {
  13232. is310 = 1
  13233. }
  13234. }
  13235. }
  13236. if is390 == 1 {
  13237. insutype = "390"
  13238. }
  13239. if is310 == 1 {
  13240. insutype = "310"
  13241. }
  13242. if len(insutypes) == 0 {
  13243. insutype = "310"
  13244. }
  13245. c.ServeSuccessJSON(map[string]interface{}{
  13246. "patient": patient,
  13247. "number": res.Output.Baseinfo.Certno,
  13248. "insutype": insutype,
  13249. })
  13250. }
  13251. } else {
  13252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13253. return
  13254. }
  13255. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13256. var api string
  13257. if miConfig.MdtrtareaAdmvs == "320921" {
  13258. 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 +
  13259. "&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
  13260. fmt.Println(api)
  13261. } else {
  13262. 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 +
  13263. "&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)
  13264. }
  13265. resp, requestErr := http.Get(api)
  13266. if requestErr != nil {
  13267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13268. return
  13269. }
  13270. body, ioErr := ioutil.ReadAll(resp.Body)
  13271. if ioErr != nil {
  13272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13274. return
  13275. }
  13276. var respJSON map[string]interface{}
  13277. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13280. return
  13281. }
  13282. var status string
  13283. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13284. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13285. //console.log()
  13286. fmt.Println("type===")
  13287. fmt.Println(card_type)
  13288. var token string
  13289. var res ResultTwo //1101结果
  13290. var res10265 ResultTwo10265 //1101结果
  13291. var card_info string //卡信息
  13292. var busi_card_info string
  13293. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13294. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13295. if status == "0" { //读卡成功
  13296. if card_type == "1" {
  13297. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13298. result, _ := json.Marshal(respJSON)
  13299. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13300. utils.ErrorLog("解析失败:%v", err)
  13301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13302. return
  13303. }
  13304. res.ErrMsg = res10265.ErrMsg
  13305. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13306. res.Infcode = infocode
  13307. res.Output = res10265.Output
  13308. res.InfRefmsgid = res10265.InfRefmsgid
  13309. } else {
  13310. //var card_info string //卡信息
  13311. //var busi_card_info string
  13312. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13313. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13314. //fmt.Println(card_info)
  13315. //fmt.Println(busi_card_info)
  13316. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13317. result, _ := json.Marshal(respJSON)
  13318. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13319. utils.ErrorLog("解析失败:%v", err)
  13320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13321. return
  13322. }
  13323. res.ErrMsg = res10265.ErrMsg
  13324. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13325. res.Infcode = infocode
  13326. res.Output = res10265.Output
  13327. res.InfRefmsgid = res10265.InfRefmsgid
  13328. }
  13329. if res.Infcode == 0 {
  13330. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13331. if err == gorm.ErrRecordNotFound {
  13332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13333. return
  13334. } else if err != nil {
  13335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13336. return
  13337. } else {
  13338. if card_type == "1" {
  13339. bas := strings.Split(card_info, "|")
  13340. basNumber := bas[2]
  13341. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13342. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13343. infoStr := string(Iinfos)
  13344. idetinfoStr := string(Idetinfos)
  13345. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13346. psn := &models.HisPsn{
  13347. PsnNo: res.Output.Baseinfo.PsnNo,
  13348. PatientId: patient.ID,
  13349. Certno: res.Output.Baseinfo.Certno,
  13350. Brdy: b,
  13351. Age: float64(age),
  13352. Gend: res.Output.Baseinfo.Gend,
  13353. Naty: res.Output.Baseinfo.Naty,
  13354. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13355. PsnName: res.Output.Baseinfo.PsnName,
  13356. Idetinfo: idetinfoStr,
  13357. Insuinfo: infoStr,
  13358. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13359. CardInfo: card_info,
  13360. VerifyNumber: busi_card_info,
  13361. }
  13362. service.CreateHisPsn(psn)
  13363. var rf []*ResultFive
  13364. json.Unmarshal([]byte(infoStr), &rf)
  13365. var insutypes []*ResultFive
  13366. var insutype string
  13367. var is390 int = 0
  13368. var is310 int = 0
  13369. for _, item := range rf {
  13370. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13371. insutypes = append(insutypes, item)
  13372. }
  13373. }
  13374. if len(insutypes) == 1 {
  13375. insutype = insutypes[0].Insutype
  13376. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13377. } else {
  13378. for _, i := range insutypes {
  13379. if i.Insutype == "390" {
  13380. is390 = 1
  13381. }
  13382. if i.Insutype == "310" {
  13383. is310 = 1
  13384. }
  13385. }
  13386. }
  13387. if is390 == 1 {
  13388. insutype = "390"
  13389. }
  13390. if is310 == 1 {
  13391. insutype = "310"
  13392. }
  13393. if len(insutypes) == 0 {
  13394. insutype = "310"
  13395. }
  13396. c.ServeSuccessJSON(map[string]interface{}{
  13397. "patient": patient,
  13398. "number": basNumber,
  13399. "insutype": insutype,
  13400. })
  13401. } else {
  13402. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13403. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13404. infoStr := string(Iinfos)
  13405. idetinfoStr := string(Idetinfos)
  13406. psn := &models.HisPsn{
  13407. PsnNo: res.Output.Baseinfo.PsnNo,
  13408. PatientId: patient.ID,
  13409. Certno: res.Output.Baseinfo.Certno,
  13410. Gend: res.Output.Baseinfo.Gend,
  13411. Naty: res.Output.Baseinfo.Naty,
  13412. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13413. PsnName: res.Output.Baseinfo.PsnName,
  13414. Idetinfo: idetinfoStr,
  13415. Insuinfo: infoStr,
  13416. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13417. CardInfo: card_info,
  13418. VerifyNumber: token,
  13419. }
  13420. service.CreateHisPsn(psn)
  13421. c.ServeSuccessJSON(map[string]interface{}{
  13422. "patient": patient,
  13423. "number": token,
  13424. })
  13425. }
  13426. }
  13427. } else {
  13428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13429. return
  13430. }
  13431. } else { //读卡失败
  13432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13433. return
  13434. }
  13435. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13436. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13437. cardnum = DeleteExtraSpaceTwo(cardnum)
  13438. cardCode = DeleteExtraSpaceTwo(cardCode)
  13439. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13440. name = DeleteExtraSpaceTwo(name)
  13441. errmsg = DeleteExtraSpaceTwo(errmsg)
  13442. cardnum = Remove0000(cardnum)
  13443. cardCode = Remove0000(cardCode)
  13444. id_card_no = Remove0000(id_card_no)
  13445. name = Remove0000(name)
  13446. errmsg = Remove0000(errmsg)
  13447. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13448. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13449. //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)
  13450. //fmt.Println(result2)
  13451. //fmt.Println(requestLog2)
  13452. //fmt.Println(errMsgLog2)
  13453. 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)
  13454. saveLog(result, requestLog, "1101", "获取人员信息")
  13455. fmt.Println(errMsgLog)
  13456. if len(errMsgLog) > 0 {
  13457. } else {
  13458. var dat map[string]interface{}
  13459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13460. fmt.Println(dat)
  13461. } else {
  13462. fmt.Println(err)
  13463. }
  13464. userJSONBytes, _ := json.Marshal(dat)
  13465. var res ResultTwo
  13466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13467. utils.ErrorLog("解析失败:%v", err)
  13468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13469. return
  13470. }
  13471. res.ErrMsg = errMsgLog
  13472. if res.Infcode == 0 {
  13473. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13474. if err == gorm.ErrRecordNotFound {
  13475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13476. return
  13477. } else if err != nil {
  13478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13479. return
  13480. } else {
  13481. fmt.Println(res)
  13482. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13483. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13484. infoStr := string(Iinfos)
  13485. idetinfoStr := string(Idetinfos)
  13486. var rf []*ResultFive
  13487. json.Unmarshal([]byte(infoStr), &rf)
  13488. var insutypes []*ResultFive
  13489. var insutype string
  13490. var is390 int = 0
  13491. var is310 int = 0
  13492. for _, item := range rf {
  13493. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13494. insutypes = append(insutypes, item)
  13495. }
  13496. }
  13497. if len(insutypes) == 1 {
  13498. insutype = insutypes[0].Insutype
  13499. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13500. } else {
  13501. for _, i := range insutypes {
  13502. if i.Insutype == "390" {
  13503. is390 = 1
  13504. }
  13505. if i.Insutype == "310" {
  13506. is310 = 1
  13507. }
  13508. }
  13509. }
  13510. if is390 == 1 {
  13511. insutype = "390"
  13512. }
  13513. if is310 == 1 {
  13514. insutype = "310"
  13515. }
  13516. if len(insutypes) == 0 {
  13517. insutype = "390"
  13518. }
  13519. var insuplc_admdvs string
  13520. for _, item := range rf {
  13521. if item.Insutype == insutype {
  13522. insuplc_admdvs = item.InsuplcAdmdvs
  13523. }
  13524. }
  13525. psn := &models.HisPsn{
  13526. PsnNo: res.Output.Baseinfo.PsnNo,
  13527. PatientId: patient.ID,
  13528. Certno: res.Output.Baseinfo.Certno,
  13529. Gend: res.Output.Baseinfo.Gend,
  13530. Naty: res.Output.Baseinfo.Naty,
  13531. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13532. PsnName: res.Output.Baseinfo.PsnName,
  13533. Idetinfo: idetinfoStr,
  13534. Insuinfo: infoStr,
  13535. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13536. CardInfo: basStr,
  13537. VerifyNumber: "",
  13538. InsuplcAdmdvs: insuplc_admdvs,
  13539. }
  13540. service.CreateHisPsn(psn)
  13541. c.ServeSuccessJSON(map[string]interface{}{
  13542. "patient": patient,
  13543. "number": cardnum,
  13544. "insutype": insutype,
  13545. })
  13546. }
  13547. } else {
  13548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13549. return
  13550. }
  13551. }
  13552. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13553. fmt.Println(initFlag)
  13554. fmt.Println("initFlag")
  13555. if initFlag == 0 {
  13556. c.TestGetJiangXiBasBaseInit()
  13557. }
  13558. basStr := c.GetBasBaseInfo()
  13559. if len(basStr) == 0 {
  13560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13561. return
  13562. }
  13563. fmt.Println(basStr)
  13564. bas := strings.Split(basStr, "|")
  13565. basNumber := bas[1]
  13566. fmt.Println(basNumber)
  13567. card_sn := bas[3]
  13568. fmt.Println(card_sn)
  13569. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13570. 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)
  13571. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13572. var dat map[string]interface{}
  13573. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13574. fmt.Println(dat)
  13575. } else {
  13576. fmt.Println(err)
  13577. }
  13578. userJSONBytes, _ := json.Marshal(dat)
  13579. var res ResultTwo
  13580. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13581. utils.ErrorLog("解析失败:%v", err)
  13582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13583. return
  13584. }
  13585. if res.Infcode == 0 {
  13586. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13587. if err == gorm.ErrRecordNotFound {
  13588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13589. return
  13590. } else if err != nil {
  13591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13592. return
  13593. } else {
  13594. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13595. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13596. infoStr := string(Iinfos)
  13597. idetinfoStr := string(Idetinfos)
  13598. var rf []*ResultFive
  13599. json.Unmarshal([]byte(infoStr), &rf)
  13600. var insutypes []*ResultFive
  13601. var insutype string
  13602. var is390 int = 0
  13603. var is310 int = 0
  13604. var insuplc_admdvs string
  13605. for _, item := range rf {
  13606. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13607. insutypes = append(insutypes, item)
  13608. }
  13609. }
  13610. if len(insutypes) == 1 {
  13611. insutype = insutypes[0].Insutype
  13612. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13613. } else {
  13614. for _, i := range insutypes {
  13615. if i.Insutype == "390" {
  13616. is390 = 1
  13617. }
  13618. if i.Insutype == "310" {
  13619. is310 = 1
  13620. }
  13621. }
  13622. }
  13623. if is390 == 1 {
  13624. insutype = "390"
  13625. }
  13626. if is310 == 1 {
  13627. insutype = "310"
  13628. }
  13629. if len(insutypes) == 0 {
  13630. insutype = "310"
  13631. }
  13632. for _, item := range rf {
  13633. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13634. insuplc_admdvs = item.InsuplcAdmdvs
  13635. }
  13636. }
  13637. psn := &models.HisPsn{
  13638. PsnNo: res.Output.Baseinfo.PsnNo,
  13639. PatientId: patient.ID,
  13640. Certno: res.Output.Baseinfo.Certno,
  13641. Gend: res.Output.Baseinfo.Gend,
  13642. Naty: res.Output.Baseinfo.Naty,
  13643. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13644. PsnName: res.Output.Baseinfo.PsnName,
  13645. Idetinfo: idetinfoStr,
  13646. Insuinfo: infoStr,
  13647. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13648. CardInfo: basStr,
  13649. InsuplcAdmdvs: insuplc_admdvs,
  13650. VerifyNumber: "",
  13651. }
  13652. service.CreateHisPsn(psn)
  13653. c.ServeSuccessJSON(map[string]interface{}{
  13654. "patient": patient,
  13655. "number": basNumber,
  13656. "insutype": insutype,
  13657. })
  13658. }
  13659. } else {
  13660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13661. return
  13662. }
  13663. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13664. basStr := c.GetBasBaseInfo22222()
  13665. fmt.Println(basStr)
  13666. if len(basStr) == 0 {
  13667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13668. return
  13669. }
  13670. fmt.Println(basStr)
  13671. bas := strings.Split(basStr, "|")
  13672. basNumber := bas[2] //卡号
  13673. card_sn := bas[3] //
  13674. id_card_No := bas[1] //卡号
  13675. fmt.Println(basNumber)
  13676. fmt.Println(card_sn)
  13677. fmt.Println(id_card_No)
  13678. var patient service.Patients
  13679. if len(id_card_No) == 0 {
  13680. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13681. } else {
  13682. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13683. }
  13684. 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)
  13685. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13686. var dat map[string]interface{}
  13687. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13688. fmt.Println(dat)
  13689. } else {
  13690. fmt.Println(err)
  13691. }
  13692. userJSONBytes, _ := json.Marshal(dat)
  13693. var res ResultTwo
  13694. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13695. utils.ErrorLog("解析失败:%v", err)
  13696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13697. return
  13698. }
  13699. if res.Infcode == 0 {
  13700. var pateint2 service.Patients
  13701. var err error
  13702. if len(id_card_No) == 0 {
  13703. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13704. } else {
  13705. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13706. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13707. }
  13708. if err == gorm.ErrRecordNotFound {
  13709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13710. return
  13711. } else if err != nil {
  13712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13713. return
  13714. } else {
  13715. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13716. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13717. infoStr := string(Iinfos)
  13718. idetinfoStr := string(Idetinfos)
  13719. var rf []*ResultFive
  13720. json.Unmarshal([]byte(infoStr), &rf)
  13721. var insutypes []*ResultFive
  13722. var insutype string
  13723. var is390 int = 0
  13724. var is310 int = 0
  13725. var insuplc_admdvs string
  13726. for _, item := range rf {
  13727. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13728. insutypes = append(insutypes, item)
  13729. }
  13730. }
  13731. if len(insutypes) == 1 {
  13732. insutype = insutypes[0].Insutype
  13733. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13734. } else {
  13735. for _, i := range insutypes {
  13736. if i.Insutype == "390" {
  13737. is390 = 1
  13738. }
  13739. if i.Insutype == "310" {
  13740. is310 = 1
  13741. }
  13742. }
  13743. }
  13744. if is390 == 1 {
  13745. insutype = "390"
  13746. }
  13747. if is310 == 1 {
  13748. insutype = "310"
  13749. }
  13750. if len(insutypes) == 0 {
  13751. insutype = "310"
  13752. }
  13753. for _, item := range rf {
  13754. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13755. insuplc_admdvs = item.InsuplcAdmdvs
  13756. }
  13757. }
  13758. psn := &models.HisPsn{
  13759. PsnNo: res.Output.Baseinfo.PsnNo,
  13760. PatientId: pateint2.ID,
  13761. Certno: res.Output.Baseinfo.Certno,
  13762. Gend: res.Output.Baseinfo.Gend,
  13763. Naty: res.Output.Baseinfo.Naty,
  13764. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13765. PsnName: res.Output.Baseinfo.PsnName,
  13766. Idetinfo: idetinfoStr,
  13767. Insuinfo: infoStr,
  13768. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13769. CardInfo: basStr,
  13770. InsuplcAdmdvs: insuplc_admdvs,
  13771. VerifyNumber: "",
  13772. }
  13773. service.CreateHisPsn(psn)
  13774. c.ServeSuccessJSON(map[string]interface{}{
  13775. "patient": patient,
  13776. "number": basNumber,
  13777. "insutype": insutype,
  13778. })
  13779. }
  13780. } else {
  13781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13782. return
  13783. }
  13784. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13785. fmt.Println(initFlag)
  13786. fmt.Println("initFlag")
  13787. if initFlag == 0 {
  13788. c.TestGetHnBasBaseInit()
  13789. }
  13790. basStr := c.GetBasBaseInfo()
  13791. if len(basStr) == 0 {
  13792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13793. return
  13794. }
  13795. fmt.Println(basStr)
  13796. bas := strings.Split(basStr, "|")
  13797. basNumber := bas[1]
  13798. fmt.Println(basNumber)
  13799. card_sn := bas[3]
  13800. card_no := bas[2]
  13801. fmt.Println(card_sn)
  13802. name := bas[4]
  13803. name = ConvertToString(name, "gbk", "utf-8")
  13804. 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)
  13805. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13806. var dat map[string]interface{}
  13807. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13808. fmt.Println(dat)
  13809. } else {
  13810. fmt.Println(err)
  13811. }
  13812. userJSONBytes, _ := json.Marshal(dat)
  13813. var res ResultTwo
  13814. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13815. utils.ErrorLog("解析失败:%v", err)
  13816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13817. return
  13818. }
  13819. if res.Infcode == 0 {
  13820. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13821. if err == gorm.ErrRecordNotFound {
  13822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13823. return
  13824. } else if err != nil {
  13825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13826. return
  13827. } else {
  13828. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13829. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13830. infoStr := string(Iinfos)
  13831. idetinfoStr := string(Idetinfos)
  13832. psn := &models.HisPsn{
  13833. PsnNo: res.Output.Baseinfo.PsnNo,
  13834. PatientId: patient.ID,
  13835. Certno: res.Output.Baseinfo.Certno,
  13836. Gend: res.Output.Baseinfo.Gend,
  13837. Naty: res.Output.Baseinfo.Naty,
  13838. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13839. PsnName: res.Output.Baseinfo.PsnName,
  13840. Idetinfo: idetinfoStr,
  13841. Insuinfo: infoStr,
  13842. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13843. CardInfo: basStr,
  13844. VerifyNumber: "",
  13845. }
  13846. service.CreateHisPsn(psn)
  13847. var rf []*ResultFive
  13848. json.Unmarshal([]byte(infoStr), &rf)
  13849. var insutypes []*ResultFive
  13850. var insutype string
  13851. var is390 int = 0
  13852. var is310 int = 0
  13853. for _, item := range rf {
  13854. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13855. insutypes = append(insutypes, item)
  13856. }
  13857. }
  13858. if len(insutypes) == 1 {
  13859. insutype = insutypes[0].Insutype
  13860. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13861. } else {
  13862. for _, i := range insutypes {
  13863. if i.Insutype == "390" {
  13864. is390 = 1
  13865. }
  13866. if i.Insutype == "310" {
  13867. is310 = 1
  13868. }
  13869. }
  13870. }
  13871. if is390 == 1 {
  13872. insutype = "390"
  13873. }
  13874. if is310 == 1 {
  13875. insutype = "310"
  13876. }
  13877. if len(insutypes) == 0 {
  13878. insutype = "310"
  13879. }
  13880. c.ServeSuccessJSON(map[string]interface{}{
  13881. "patient": patient,
  13882. "number": basNumber,
  13883. "insutype": insutype,
  13884. })
  13885. }
  13886. } else {
  13887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13888. return
  13889. }
  13890. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13891. var api string
  13892. 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 +
  13893. "&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
  13894. fmt.Println(api)
  13895. resp, requestErr := http.Get(api)
  13896. if requestErr != nil {
  13897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13898. return
  13899. }
  13900. body, ioErr := ioutil.ReadAll(resp.Body)
  13901. if ioErr != nil {
  13902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13904. return
  13905. }
  13906. var respJSON map[string]interface{}
  13907. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13910. return
  13911. }
  13912. var res ResultTwo //1101结果
  13913. var res10265 ResultTwo10265 //1101结果
  13914. var card_info string //卡信息
  13915. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13916. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13917. result, _ := json.Marshal(respJSON)
  13918. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13919. utils.ErrorLog("解析失败:%v", err)
  13920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13921. return
  13922. }
  13923. res.ErrMsg = res10265.ErrMsg
  13924. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13925. res.Infcode = infocode
  13926. res.Output = res10265.Output
  13927. res.InfRefmsgid = res10265.InfRefmsgid
  13928. if res.Infcode == 0 {
  13929. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13930. if err == gorm.ErrRecordNotFound {
  13931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13932. return
  13933. } else if err != nil {
  13934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13935. return
  13936. } else {
  13937. bas := strings.Split(card_info, "|")
  13938. basNumber := bas[2]
  13939. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13940. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13941. infoStr := string(Iinfos)
  13942. idetinfoStr := string(Idetinfos)
  13943. psn := &models.HisPsn{
  13944. PsnNo: res.Output.Baseinfo.PsnNo,
  13945. PatientId: patient.ID,
  13946. Certno: res.Output.Baseinfo.Certno,
  13947. Gend: res.Output.Baseinfo.Gend,
  13948. Naty: res.Output.Baseinfo.Naty,
  13949. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13950. PsnName: res.Output.Baseinfo.PsnName,
  13951. Idetinfo: idetinfoStr,
  13952. Insuinfo: infoStr,
  13953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13954. CardInfo: card_info,
  13955. VerifyNumber: token,
  13956. }
  13957. service.CreateHisPsn(psn)
  13958. var rf []*ResultFive
  13959. json.Unmarshal([]byte(infoStr), &rf)
  13960. var insutypes []*ResultFive
  13961. var insutype string
  13962. var is390 int = 0
  13963. var is310 int = 0
  13964. for _, item := range rf {
  13965. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13966. insutypes = append(insutypes, item)
  13967. }
  13968. }
  13969. if len(insutypes) == 1 {
  13970. insutype = insutypes[0].Insutype
  13971. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13972. } else {
  13973. for _, i := range insutypes {
  13974. if i.Insutype == "390" {
  13975. is390 = 1
  13976. }
  13977. if i.Insutype == "310" {
  13978. is310 = 1
  13979. }
  13980. }
  13981. }
  13982. if is390 == 1 {
  13983. insutype = "390"
  13984. }
  13985. if is310 == 1 {
  13986. insutype = "310"
  13987. }
  13988. if len(insutypes) == 0 {
  13989. insutype = "310"
  13990. }
  13991. c.ServeSuccessJSON(map[string]interface{}{
  13992. "patient": patient,
  13993. "number": basNumber,
  13994. "insutype": insutype,
  13995. })
  13996. }
  13997. } else {
  13998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13999. return
  14000. }
  14001. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14002. res := c.GetoleInfo()
  14003. if res.Infcode == 0 {
  14004. var result string
  14005. if res.Output.MdtrtCertType == "01" {
  14006. 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)
  14007. } else if res.Output.MdtrtCertType == "02" {
  14008. 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)
  14009. } else if res.Output.MdtrtCertType == "03" {
  14010. 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)
  14011. }
  14012. var dat map[string]interface{}
  14013. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14014. fmt.Println(dat)
  14015. } else {
  14016. fmt.Println(err)
  14017. }
  14018. userJSONBytes, _ := json.Marshal(dat)
  14019. var res2 ResultTwo
  14020. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14021. utils.ErrorLog("解析失败:%v", err)
  14022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14023. return
  14024. }
  14025. if res2.Infcode == 0 {
  14026. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14027. if err == gorm.ErrRecordNotFound {
  14028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14029. return
  14030. } else if err != nil {
  14031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14032. return
  14033. } else {
  14034. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14035. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14036. infoStr := string(Iinfos)
  14037. idetinfoStr := string(Idetinfos)
  14038. var rf []*ResultFive
  14039. json.Unmarshal([]byte(infoStr), &rf)
  14040. var insutypes []*ResultFive
  14041. var insutype string
  14042. var is390 int = 0
  14043. var is310 int = 0
  14044. //var insuplc_admdvs string
  14045. for _, item := range rf {
  14046. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14047. insutypes = append(insutypes, item)
  14048. }
  14049. }
  14050. if len(insutypes) == 1 {
  14051. insutype = insutypes[0].Insutype
  14052. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14053. } else {
  14054. for _, i := range insutypes {
  14055. if i.Insutype == "390" {
  14056. is390 = 1
  14057. }
  14058. if i.Insutype == "310" {
  14059. is310 = 1
  14060. }
  14061. }
  14062. }
  14063. if is390 == 1 {
  14064. insutype = "390"
  14065. }
  14066. if is310 == 1 {
  14067. insutype = "310"
  14068. }
  14069. if len(insutypes) == 0 {
  14070. insutype = "310"
  14071. }
  14072. psn := &models.HisPsn{
  14073. PsnNo: res2.Output.Baseinfo.PsnNo,
  14074. PatientId: patient.ID,
  14075. Certno: res2.Output.Baseinfo.Certno,
  14076. Gend: res2.Output.Baseinfo.Gend,
  14077. Naty: res2.Output.Baseinfo.Naty,
  14078. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14079. PsnName: res2.Output.Baseinfo.PsnName,
  14080. Idetinfo: idetinfoStr,
  14081. Insuinfo: infoStr,
  14082. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14083. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14084. VerifyNumber: res.Output.EcToken,
  14085. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14086. }
  14087. if res.Output.MdtrtCertType == "01" {
  14088. psn.VerifyNumber = res.Output.EcToken
  14089. //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)
  14090. } else if res.Output.MdtrtCertType == "02" {
  14091. psn.VerifyNumber = res.Output.MdtrtCertNo
  14092. //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)
  14093. } else if res.Output.MdtrtCertType == "03" {
  14094. psn.VerifyNumber = res.Output.MdtrtCertNo
  14095. //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)
  14096. }
  14097. var balc float64
  14098. for _, item := range rf {
  14099. if item.Insutype == insutype {
  14100. balc = item.Balc
  14101. }
  14102. }
  14103. service.CreateHisPsn(psn)
  14104. c.ServeSuccessJSON(map[string]interface{}{
  14105. "patient": patient,
  14106. "number": res.Output.CardNo,
  14107. "insutype": insutype,
  14108. "blac": balc,
  14109. "desc": idetinfoStr,
  14110. })
  14111. }
  14112. } else {
  14113. c.ServeSuccessJSON(map[string]interface{}{
  14114. "failed_code": -10,
  14115. "msg": res2.ErrMsg,
  14116. })
  14117. }
  14118. } else {
  14119. c.ServeSuccessJSON(map[string]interface{}{
  14120. "failed_code": -10,
  14121. "msg": res.ErrMsg,
  14122. })
  14123. }
  14124. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14125. var api string
  14126. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14127. "&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
  14128. fmt.Println(api)
  14129. resp, requestErr := http.Get(api)
  14130. if requestErr != nil {
  14131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14132. return
  14133. }
  14134. body, ioErr := ioutil.ReadAll(resp.Body)
  14135. if ioErr != nil {
  14136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14138. return
  14139. }
  14140. var respJSON map[string]interface{}
  14141. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14144. return
  14145. }
  14146. var status string
  14147. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14148. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14149. //console.log()
  14150. fmt.Println("type===")
  14151. fmt.Println(card_type)
  14152. var token string
  14153. var res ResultTwo //1101结果
  14154. //var res10265 ResultTwoesultTwo10265 //1101结果
  14155. var card_info string //卡信息
  14156. var busi_card_info string
  14157. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14158. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14159. if status == "0" { //读卡成功
  14160. if card_type == "1" {
  14161. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14162. result, _ := json.Marshal(respJSON)
  14163. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14164. utils.ErrorLog("解析失败:%v", err)
  14165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14166. return
  14167. }
  14168. } else {
  14169. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14170. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14171. result, _ := json.Marshal(respJSON)
  14172. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14173. utils.ErrorLog("解析失败:%v", err)
  14174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14175. return
  14176. }
  14177. }
  14178. if res.Infcode == 0 {
  14179. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14180. if err == gorm.ErrRecordNotFound {
  14181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14182. return
  14183. } else if err != nil {
  14184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14185. return
  14186. } else {
  14187. if card_type == "1" {
  14188. bas := strings.Split(card_info, "|")
  14189. basNumber := bas[2]
  14190. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14191. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14192. infoStr := string(Iinfos)
  14193. idetinfoStr := string(Idetinfos)
  14194. psn := &models.HisPsn{
  14195. PsnNo: res.Output.Baseinfo.PsnNo,
  14196. PatientId: patient.ID,
  14197. Certno: res.Output.Baseinfo.Certno,
  14198. Gend: res.Output.Baseinfo.Gend,
  14199. Naty: res.Output.Baseinfo.Naty,
  14200. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14201. PsnName: res.Output.Baseinfo.PsnName,
  14202. Idetinfo: idetinfoStr,
  14203. Insuinfo: infoStr,
  14204. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14205. CardInfo: card_info,
  14206. VerifyNumber: busi_card_info,
  14207. }
  14208. service.CreateHisPsn(psn)
  14209. var rf []*ResultFive
  14210. json.Unmarshal([]byte(infoStr), &rf)
  14211. var insutypes []*ResultFive
  14212. var insutype string
  14213. var is390 int = 0
  14214. var is310 int = 0
  14215. for _, item := range rf {
  14216. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14217. insutypes = append(insutypes, item)
  14218. }
  14219. }
  14220. if len(insutypes) == 1 {
  14221. insutype = insutypes[0].Insutype
  14222. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14223. } else {
  14224. for _, i := range insutypes {
  14225. if i.Insutype == "390" {
  14226. is390 = 1
  14227. }
  14228. if i.Insutype == "310" {
  14229. is310 = 1
  14230. }
  14231. }
  14232. }
  14233. if is390 == 1 {
  14234. insutype = "390"
  14235. }
  14236. if is310 == 1 {
  14237. insutype = "310"
  14238. }
  14239. if len(insutypes) == 0 {
  14240. insutype = "310"
  14241. }
  14242. c.ServeSuccessJSON(map[string]interface{}{
  14243. "patient": patient,
  14244. "number": basNumber,
  14245. "insutype": insutype,
  14246. })
  14247. } else {
  14248. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14249. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14250. infoStr := string(Iinfos)
  14251. idetinfoStr := string(Idetinfos)
  14252. psn := &models.HisPsn{
  14253. PsnNo: res.Output.Baseinfo.PsnNo,
  14254. PatientId: patient.ID,
  14255. Certno: res.Output.Baseinfo.Certno,
  14256. Gend: res.Output.Baseinfo.Gend,
  14257. Naty: res.Output.Baseinfo.Naty,
  14258. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14259. PsnName: res.Output.Baseinfo.PsnName,
  14260. Idetinfo: idetinfoStr,
  14261. Insuinfo: infoStr,
  14262. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14263. CardInfo: card_info,
  14264. VerifyNumber: token,
  14265. }
  14266. service.CreateHisPsn(psn)
  14267. c.ServeSuccessJSON(map[string]interface{}{
  14268. "patient": patient,
  14269. "number": token,
  14270. })
  14271. }
  14272. }
  14273. } else {
  14274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14275. return
  14276. }
  14277. } else { //读卡失败
  14278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14279. return
  14280. }
  14281. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14282. var api string
  14283. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14284. "&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
  14285. fmt.Println(api)
  14286. resp, requestErr := http.Get(api)
  14287. if requestErr != nil {
  14288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14289. return
  14290. }
  14291. body, ioErr := ioutil.ReadAll(resp.Body)
  14292. if ioErr != nil {
  14293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14295. return
  14296. }
  14297. var respJSON map[string]interface{}
  14298. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14301. return
  14302. }
  14303. var status string
  14304. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14305. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14306. //console.log()
  14307. fmt.Println("type===")
  14308. fmt.Println(card_type)
  14309. var token string
  14310. var res ResultTwo //1101结果
  14311. //var res10265 ResultTwoesultTwo10265 //1101结果
  14312. var card_info string //卡信息
  14313. //var busi_card_info string
  14314. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14315. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14316. if status == "0" { //读卡成功
  14317. if card_type == "1" {
  14318. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14319. result, _ := json.Marshal(respJSON)
  14320. fmt.Println(result)
  14321. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14322. utils.ErrorLog("解析失败:%v", err)
  14323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14324. return
  14325. }
  14326. fmt.Println(res)
  14327. } else {
  14328. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14329. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14330. result, _ := json.Marshal(respJSON)
  14331. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14332. utils.ErrorLog("解析失败:%v", err)
  14333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14334. return
  14335. }
  14336. }
  14337. if res.Infcode == 0 {
  14338. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14339. if err == gorm.ErrRecordNotFound {
  14340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14341. return
  14342. } else if err != nil {
  14343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14344. return
  14345. } else {
  14346. if card_type == "1" {
  14347. bas := strings.Split(card_info, "|")
  14348. basNumber := bas[2]
  14349. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14350. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14351. infoStr := string(Iinfos)
  14352. idetinfoStr := string(Idetinfos)
  14353. psn := &models.HisPsn{
  14354. PsnNo: res.Output.Baseinfo.PsnNo,
  14355. PatientId: patient.ID,
  14356. Certno: res.Output.Baseinfo.Certno,
  14357. Gend: res.Output.Baseinfo.Gend,
  14358. Naty: res.Output.Baseinfo.Naty,
  14359. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14360. PsnName: res.Output.Baseinfo.PsnName,
  14361. Idetinfo: idetinfoStr,
  14362. Insuinfo: infoStr,
  14363. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14364. CardInfo: card_info,
  14365. //VerifyNumber: busi_card_info,
  14366. }
  14367. service.CreateHisPsn(psn)
  14368. var rf []*ResultFive
  14369. json.Unmarshal([]byte(infoStr), &rf)
  14370. var insutypes []*ResultFive
  14371. var insutype string
  14372. var is390 int = 0
  14373. var is310 int = 0
  14374. for _, item := range rf {
  14375. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14376. insutypes = append(insutypes, item)
  14377. }
  14378. }
  14379. if len(insutypes) == 1 {
  14380. insutype = insutypes[0].Insutype
  14381. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14382. } else {
  14383. for _, i := range insutypes {
  14384. if i.Insutype == "390" {
  14385. is390 = 1
  14386. }
  14387. if i.Insutype == "310" {
  14388. is310 = 1
  14389. }
  14390. }
  14391. }
  14392. if is390 == 1 {
  14393. insutype = "390"
  14394. }
  14395. if is310 == 1 {
  14396. insutype = "310"
  14397. }
  14398. if len(insutypes) == 0 {
  14399. insutype = "310"
  14400. }
  14401. c.ServeSuccessJSON(map[string]interface{}{
  14402. "patient": patient,
  14403. "number": basNumber,
  14404. "insutype": insutype,
  14405. })
  14406. } else {
  14407. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14408. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14409. infoStr := string(Iinfos)
  14410. idetinfoStr := string(Idetinfos)
  14411. psn := &models.HisPsn{
  14412. PsnNo: res.Output.Baseinfo.PsnNo,
  14413. PatientId: patient.ID,
  14414. Certno: res.Output.Baseinfo.Certno,
  14415. Gend: res.Output.Baseinfo.Gend,
  14416. Naty: res.Output.Baseinfo.Naty,
  14417. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14418. PsnName: res.Output.Baseinfo.PsnName,
  14419. Idetinfo: idetinfoStr,
  14420. Insuinfo: infoStr,
  14421. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14422. CardInfo: card_info,
  14423. VerifyNumber: token,
  14424. }
  14425. service.CreateHisPsn(psn)
  14426. c.ServeSuccessJSON(map[string]interface{}{
  14427. "patient": patient,
  14428. "number": token,
  14429. })
  14430. }
  14431. }
  14432. } else {
  14433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14434. return
  14435. }
  14436. } else { //读卡失败
  14437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14438. return
  14439. }
  14440. } else {
  14441. if initFlag == 0 {
  14442. c.TestGetBasBaseInit()
  14443. }
  14444. basStr := c.GetBasBaseInfo()
  14445. if len(basStr) == 0 {
  14446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14447. return
  14448. }
  14449. fmt.Println(basStr)
  14450. bas := strings.Split(basStr, "|")
  14451. basNumber := bas[1]
  14452. fmt.Println(basNumber)
  14453. card_sn := bas[3]
  14454. fmt.Println(card_sn)
  14455. cardNumber := bas[2]
  14456. fmt.Println(cardNumber)
  14457. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14458. var result string
  14459. if bas[0][:2] == "44" {
  14460. 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)
  14461. } else {
  14462. 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)
  14463. }
  14464. var dat map[string]interface{}
  14465. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14466. fmt.Println(dat)
  14467. } else {
  14468. fmt.Println(err)
  14469. }
  14470. userJSONBytes, _ := json.Marshal(dat)
  14471. var res ResultTwo
  14472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14473. utils.ErrorLog("解析失败:%v", err)
  14474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14475. return
  14476. }
  14477. if res.Infcode == 0 {
  14478. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14479. if err == gorm.ErrRecordNotFound {
  14480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14481. return
  14482. } else if err != nil {
  14483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14484. return
  14485. } else {
  14486. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14487. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14488. infoStr := string(Iinfos)
  14489. idetinfoStr := string(Idetinfos)
  14490. var rf []*ResultFive
  14491. json.Unmarshal([]byte(infoStr), &rf)
  14492. var insutypes []*ResultFive
  14493. var insutype string
  14494. var is390 int = 0
  14495. var is310 int = 0
  14496. var insuplc_admdvs string
  14497. for _, item := range rf {
  14498. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14499. insutypes = append(insutypes, item)
  14500. }
  14501. }
  14502. if len(insutypes) == 1 {
  14503. insutype = insutypes[0].Insutype
  14504. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14505. } else {
  14506. for _, i := range insutypes {
  14507. if i.Insutype == "390" {
  14508. is390 = 1
  14509. }
  14510. if i.Insutype == "310" {
  14511. is310 = 1
  14512. }
  14513. }
  14514. }
  14515. if is390 == 1 {
  14516. insutype = "390"
  14517. }
  14518. if is310 == 1 {
  14519. insutype = "310"
  14520. }
  14521. if len(insutypes) == 0 {
  14522. insutype = "310"
  14523. }
  14524. for _, item := range rf {
  14525. if item.Insutype == insutype {
  14526. insuplc_admdvs = item.InsuplcAdmdvs
  14527. }
  14528. }
  14529. psn := &models.HisPsn{
  14530. PsnNo: res.Output.Baseinfo.PsnNo,
  14531. PatientId: patient.ID,
  14532. Certno: res.Output.Baseinfo.Certno,
  14533. Gend: res.Output.Baseinfo.Gend,
  14534. Naty: res.Output.Baseinfo.Naty,
  14535. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14536. PsnName: res.Output.Baseinfo.PsnName,
  14537. Idetinfo: idetinfoStr,
  14538. Insuinfo: infoStr,
  14539. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14540. CardInfo: basStr,
  14541. VerifyNumber: "",
  14542. InsuplcAdmdvs: insuplc_admdvs,
  14543. }
  14544. service.CreateHisPsn(psn)
  14545. c.ServeSuccessJSON(map[string]interface{}{
  14546. "patient": patient,
  14547. "number": basNumber,
  14548. })
  14549. }
  14550. } else {
  14551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14552. return
  14553. }
  14554. break
  14555. }
  14556. case 2:
  14557. if miConfig.MdtrtareaAdmvs == "430800" {
  14558. if initFlag == 0 {
  14559. c.TestGetHnBasBaseInit()
  14560. }
  14561. SFZStr := c.GetSFZBaseInfo()
  14562. if len(SFZStr) == 0 {
  14563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14564. return
  14565. }
  14566. fmt.Println(SFZStr)
  14567. id_card_str := strings.Split(SFZStr, "^")
  14568. card_no := id_card_str[0]
  14569. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14570. //name := id_card_str[1]
  14571. //name = ConvertToString(name, "gbk", "utf-8")
  14572. 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)
  14573. var dat map[string]interface{}
  14574. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14575. fmt.Println(dat)
  14576. } else {
  14577. fmt.Println(err)
  14578. }
  14579. userJSONBytes, _ := json.Marshal(dat)
  14580. var res ResultTwo
  14581. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14582. utils.ErrorLog("解析失败:%v", err)
  14583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14584. return
  14585. }
  14586. if res.Infcode == 0 {
  14587. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14588. if err == gorm.ErrRecordNotFound {
  14589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14590. return
  14591. } else if err != nil {
  14592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14593. return
  14594. } else {
  14595. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14596. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14597. infoStr := string(Iinfos)
  14598. idetinfoStr := string(Idetinfos)
  14599. var rf []*ResultFive
  14600. json.Unmarshal([]byte(infoStr), &rf)
  14601. var insutypes []*ResultFive
  14602. var insutype string
  14603. var is390 int = 0
  14604. var is310 int = 0
  14605. for _, item := range rf {
  14606. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14607. insutypes = append(insutypes, item)
  14608. }
  14609. }
  14610. if len(insutypes) == 1 {
  14611. insutype = insutypes[0].Insutype
  14612. } else {
  14613. for _, i := range insutypes {
  14614. if i.Insutype == "390" {
  14615. is390 = 1
  14616. }
  14617. if i.Insutype == "310" {
  14618. is310 = 1
  14619. }
  14620. }
  14621. }
  14622. if is390 == 1 {
  14623. insutype = "390"
  14624. }
  14625. if is310 == 1 {
  14626. insutype = "310"
  14627. }
  14628. if len(insutypes) == 0 {
  14629. insutype = "310"
  14630. }
  14631. var InsuplcAdmdvs string
  14632. for _, item := range rf {
  14633. if item.Insutype == insutype {
  14634. InsuplcAdmdvs = item.InsuplcAdmdvs
  14635. }
  14636. }
  14637. psn := &models.HisPsn{
  14638. PsnNo: res.Output.Baseinfo.PsnNo,
  14639. PatientId: patient.ID,
  14640. Certno: res.Output.Baseinfo.Certno,
  14641. Gend: res.Output.Baseinfo.Gend,
  14642. Naty: res.Output.Baseinfo.Naty,
  14643. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14644. PsnName: res.Output.Baseinfo.PsnName,
  14645. Idetinfo: idetinfoStr,
  14646. Insuinfo: infoStr,
  14647. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14648. CardInfo: SFZStr,
  14649. VerifyNumber: "",
  14650. InsuplcAdmdvs: InsuplcAdmdvs,
  14651. }
  14652. service.CreateHisPsn(psn)
  14653. c.ServeSuccessJSON(map[string]interface{}{
  14654. "patient": patient,
  14655. "number": card_no,
  14656. "insutype": insutype,
  14657. })
  14658. }
  14659. } else {
  14660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14661. return
  14662. }
  14663. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14664. var res ResultTwo
  14665. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14666. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14667. "&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)
  14668. resp, requestErr := http.Get(api)
  14669. if requestErr != nil {
  14670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14671. return
  14672. }
  14673. body, ioErr := ioutil.ReadAll(resp.Body)
  14674. if ioErr != nil {
  14675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14677. return
  14678. }
  14679. var respJSON map[string]interface{}
  14680. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14683. return
  14684. }
  14685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14686. result, _ := json.Marshal(respJSON)
  14687. fmt.Println("log")
  14688. fmt.Println(string(result))
  14689. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14690. utils.ErrorLog("解析失败:%v", err)
  14691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14692. return
  14693. }
  14694. if res.Infcode == 0 {
  14695. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14696. if err == gorm.ErrRecordNotFound {
  14697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14698. return
  14699. } else if err != nil {
  14700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14701. return
  14702. } else {
  14703. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14704. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14705. infoStr := string(Iinfos)
  14706. idetinfoStr := string(Idetinfos)
  14707. psn := &models.HisPsn{
  14708. PsnNo: res.Output.Baseinfo.PsnNo,
  14709. PatientId: patient.ID,
  14710. Certno: res.Output.Baseinfo.Certno,
  14711. Gend: res.Output.Baseinfo.Gend,
  14712. Naty: res.Output.Baseinfo.Naty,
  14713. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14714. PsnName: res.Output.Baseinfo.PsnName,
  14715. Idetinfo: idetinfoStr,
  14716. Insuinfo: infoStr,
  14717. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14718. }
  14719. service.CreateHisPsn(psn)
  14720. c.ServeSuccessJSON(map[string]interface{}{
  14721. "patient": patient,
  14722. "number": res.Output.Baseinfo.Certno,
  14723. })
  14724. }
  14725. } else {
  14726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14727. return
  14728. }
  14729. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14730. var res ResultTwo
  14731. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14732. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14733. "&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)
  14734. resp, requestErr := http.Get(api)
  14735. if requestErr != nil {
  14736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14737. return
  14738. }
  14739. body, ioErr := ioutil.ReadAll(resp.Body)
  14740. if ioErr != nil {
  14741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14743. return
  14744. }
  14745. var respJSON map[string]interface{}
  14746. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14749. return
  14750. }
  14751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14752. result, _ := json.Marshal(respJSON)
  14753. fmt.Println("log")
  14754. fmt.Println(string(result))
  14755. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14756. utils.ErrorLog("解析失败:%v", err)
  14757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14758. return
  14759. }
  14760. if res.Infcode == 0 {
  14761. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14762. if err == gorm.ErrRecordNotFound {
  14763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14764. return
  14765. } else if err != nil {
  14766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14767. return
  14768. } else {
  14769. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14770. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14771. infoStr := string(Iinfos)
  14772. idetinfoStr := string(Idetinfos)
  14773. psn := &models.HisPsn{
  14774. PsnNo: res.Output.Baseinfo.PsnNo,
  14775. PatientId: patient.ID,
  14776. Certno: res.Output.Baseinfo.Certno,
  14777. Gend: res.Output.Baseinfo.Gend,
  14778. Naty: res.Output.Baseinfo.Naty,
  14779. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14780. PsnName: res.Output.Baseinfo.PsnName,
  14781. Idetinfo: idetinfoStr,
  14782. Insuinfo: infoStr,
  14783. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14784. }
  14785. service.CreateHisPsn(psn)
  14786. c.ServeSuccessJSON(map[string]interface{}{
  14787. "patient": patient,
  14788. "number": res.Output.Baseinfo.Certno,
  14789. })
  14790. }
  14791. } else {
  14792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14793. return
  14794. }
  14795. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14796. var res ResultTwo
  14797. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14798. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14799. "&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)
  14800. resp, requestErr := http.Get(api)
  14801. if requestErr != nil {
  14802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14803. return
  14804. }
  14805. body, ioErr := ioutil.ReadAll(resp.Body)
  14806. if ioErr != nil {
  14807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14809. return
  14810. }
  14811. var respJSON map[string]interface{}
  14812. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14815. return
  14816. }
  14817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14818. result, _ := json.Marshal(respJSON)
  14819. fmt.Println("log")
  14820. fmt.Println(string(result))
  14821. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14822. utils.ErrorLog("解析失败:%v", err)
  14823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14824. return
  14825. }
  14826. if res.Infcode == 0 {
  14827. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14828. if err == gorm.ErrRecordNotFound {
  14829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14830. return
  14831. } else if err != nil {
  14832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14833. return
  14834. } else {
  14835. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14836. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14837. infoStr := string(Iinfos)
  14838. idetinfoStr := string(Idetinfos)
  14839. var rf []*ResultFive
  14840. json.Unmarshal([]byte(infoStr), &rf)
  14841. var insutypes []*ResultFive
  14842. var insutype string
  14843. var is390 int = 0
  14844. var is310 int = 0
  14845. for _, item := range rf {
  14846. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14847. insutypes = append(insutypes, item)
  14848. }
  14849. }
  14850. if len(insutypes) == 1 {
  14851. insutype = insutypes[0].Insutype
  14852. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14853. } else {
  14854. for _, i := range insutypes {
  14855. if i.Insutype == "390" {
  14856. is390 = 1
  14857. }
  14858. if i.Insutype == "310" {
  14859. is310 = 1
  14860. }
  14861. }
  14862. }
  14863. if is390 == 1 {
  14864. insutype = "390"
  14865. }
  14866. if is310 == 1 {
  14867. insutype = "310"
  14868. }
  14869. if len(insutypes) == 0 {
  14870. insutype = "390"
  14871. }
  14872. var insuplc_admdvs string
  14873. for _, item := range rf {
  14874. if item.Insutype == insutype {
  14875. insuplc_admdvs = item.InsuplcAdmdvs
  14876. }
  14877. }
  14878. psn := &models.HisPsn{
  14879. PsnNo: res.Output.Baseinfo.PsnNo,
  14880. PatientId: patient.ID,
  14881. Certno: res.Output.Baseinfo.Certno,
  14882. Gend: res.Output.Baseinfo.Gend,
  14883. Naty: res.Output.Baseinfo.Naty,
  14884. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14885. PsnName: res.Output.Baseinfo.PsnName,
  14886. Idetinfo: idetinfoStr,
  14887. Insuinfo: infoStr,
  14888. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14889. InsuplcAdmdvs: insuplc_admdvs,
  14890. }
  14891. service.CreateHisPsn(psn)
  14892. c.ServeSuccessJSON(map[string]interface{}{
  14893. "patient": patient,
  14894. "number": res.Output.Baseinfo.Certno,
  14895. })
  14896. }
  14897. } else {
  14898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14899. return
  14900. }
  14901. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14902. res := c.GetoleInfo()
  14903. if res.Infcode == 0 {
  14904. var result string
  14905. if res.Output.MdtrtCertType == "01" {
  14906. 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)
  14907. } else if res.Output.MdtrtCertType == "02" {
  14908. 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)
  14909. } else if res.Output.MdtrtCertType == "03" {
  14910. 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)
  14911. }
  14912. var dat map[string]interface{}
  14913. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14914. fmt.Println(dat)
  14915. } else {
  14916. fmt.Println(err)
  14917. }
  14918. userJSONBytes, _ := json.Marshal(dat)
  14919. var res2 ResultTwo
  14920. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14921. utils.ErrorLog("解析失败:%v", err)
  14922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14923. return
  14924. }
  14925. if res2.Infcode == 0 {
  14926. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14927. if err == gorm.ErrRecordNotFound {
  14928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14929. return
  14930. } else if err != nil {
  14931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14932. return
  14933. } else {
  14934. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14935. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14936. infoStr := string(Iinfos)
  14937. idetinfoStr := string(Idetinfos)
  14938. var rf []*ResultFive
  14939. json.Unmarshal([]byte(infoStr), &rf)
  14940. var insutypes []*ResultFive
  14941. var insutype string
  14942. var is390 int = 0
  14943. var is310 int = 0
  14944. //var insuplc_admdvs string
  14945. for _, item := range rf {
  14946. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14947. insutypes = append(insutypes, item)
  14948. }
  14949. }
  14950. if len(insutypes) == 1 {
  14951. insutype = insutypes[0].Insutype
  14952. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14953. } else {
  14954. for _, i := range insutypes {
  14955. if i.Insutype == "390" {
  14956. is390 = 1
  14957. }
  14958. if i.Insutype == "310" {
  14959. is310 = 1
  14960. }
  14961. }
  14962. }
  14963. if is390 == 1 {
  14964. insutype = "390"
  14965. }
  14966. if is310 == 1 {
  14967. insutype = "310"
  14968. }
  14969. if len(insutypes) == 0 {
  14970. insutype = "310"
  14971. }
  14972. psn := &models.HisPsn{
  14973. PsnNo: res2.Output.Baseinfo.PsnNo,
  14974. PatientId: patient.ID,
  14975. //Brdy: res2.Output.Baseinfo.Brdy,
  14976. Certno: res2.Output.Baseinfo.Certno,
  14977. Gend: res2.Output.Baseinfo.Gend,
  14978. Naty: res2.Output.Baseinfo.Naty,
  14979. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14980. PsnName: res2.Output.Baseinfo.PsnName,
  14981. Idetinfo: idetinfoStr,
  14982. Insuinfo: infoStr,
  14983. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14984. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14985. VerifyNumber: res.Output.EcToken,
  14986. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14987. }
  14988. service.CreateHisPsn(psn)
  14989. var balc float64
  14990. for _, item := range rf {
  14991. if item.Insutype == insutype {
  14992. balc = item.Balc
  14993. }
  14994. }
  14995. c.ServeSuccessJSON(map[string]interface{}{
  14996. "patient": patient,
  14997. "number": res.Output.CardNo,
  14998. "insutype": insutype,
  14999. "blac": balc,
  15000. "desc": idetinfoStr,
  15001. })
  15002. }
  15003. } else {
  15004. c.ServeSuccessJSON(map[string]interface{}{
  15005. "failed_code": -10,
  15006. "msg": res2.ErrMsg,
  15007. })
  15008. }
  15009. } else {
  15010. c.ServeSuccessJSON(map[string]interface{}{
  15011. "failed_code": -10,
  15012. "msg": res.ErrMsg,
  15013. })
  15014. }
  15015. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15016. var insuplc_admdvs string
  15017. if len(patient.InsuplcAdmdvs) > 0 {
  15018. insuplc_admdvs = patient.InsuplcAdmdvs
  15019. } else {
  15020. if len(insuplc_admdvs_str) > 0 {
  15021. insuplc_admdvs = insuplc_admdvs_str
  15022. } else {
  15023. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15024. }
  15025. }
  15026. //请求内网数据
  15027. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15028. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15029. "&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=" + ""
  15030. resp, requestErr := http.Get(api)
  15031. if requestErr != nil {
  15032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15033. return
  15034. }
  15035. body, ioErr := ioutil.ReadAll(resp.Body)
  15036. if ioErr != nil {
  15037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15039. return
  15040. }
  15041. var respJSON map[string]interface{}
  15042. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15045. return
  15046. }
  15047. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15048. if status == "0" {
  15049. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15050. c.ServeSuccessJSON(map[string]interface{}{
  15051. "failed_code": -10,
  15052. "msg": err_msg,
  15053. })
  15054. return
  15055. }
  15056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15057. var res ResultTwo
  15058. result, _ := json.Marshal(respJSON)
  15059. fmt.Println("log")
  15060. fmt.Println(string(result))
  15061. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15062. utils.ErrorLog("解析失败:%v", err)
  15063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15064. return
  15065. }
  15066. if res.Infcode == 0 {
  15067. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15068. if err == gorm.ErrRecordNotFound {
  15069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15070. return
  15071. } else if err != nil {
  15072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15073. return
  15074. } else {
  15075. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15076. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15077. infoStr := string(Iinfos)
  15078. idetinfoStr := string(Idetinfos)
  15079. psn := &models.HisPsn{
  15080. PsnNo: res.Output.Baseinfo.PsnNo,
  15081. PatientId: patient.ID,
  15082. Certno: res.Output.Baseinfo.Certno,
  15083. Gend: res.Output.Baseinfo.Gend,
  15084. Naty: res.Output.Baseinfo.Naty,
  15085. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15086. PsnName: res.Output.Baseinfo.PsnName,
  15087. Idetinfo: idetinfoStr,
  15088. Insuinfo: infoStr,
  15089. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15090. }
  15091. service.CreateHisPsn(psn)
  15092. var rf []*ResultFive
  15093. json.Unmarshal([]byte(infoStr), &rf)
  15094. var insutypes []*ResultFive
  15095. var is390 int = 0
  15096. var is310 int = 0
  15097. var insutype string
  15098. for _, item := range rf {
  15099. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15100. insutypes = append(insutypes, item)
  15101. }
  15102. }
  15103. if len(insutypes) == 1 {
  15104. insutype = insutypes[0].Insutype
  15105. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15106. } else {
  15107. for _, i := range insutypes {
  15108. if i.Insutype == "390" {
  15109. is390 = 1
  15110. }
  15111. if i.Insutype == "310" {
  15112. is310 = 1
  15113. }
  15114. }
  15115. }
  15116. if is390 == 1 {
  15117. insutype = "390"
  15118. }
  15119. if is310 == 1 {
  15120. insutype = "310"
  15121. }
  15122. if len(insutypes) == 0 {
  15123. insutype = "390"
  15124. }
  15125. c.ServeSuccessJSON(map[string]interface{}{
  15126. "patient": patient,
  15127. "insutype": insutype,
  15128. "number": res.Output.Baseinfo.Certno,
  15129. "info": res,
  15130. })
  15131. }
  15132. } else {
  15133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15134. return
  15135. }
  15136. } else {
  15137. SFZStr := c.GetSFZBaseInfo()
  15138. id_card_str := strings.Split(SFZStr, "^")
  15139. id_card_number := id_card_str[0]
  15140. card_sn := ""
  15141. 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)
  15142. var dat map[string]interface{}
  15143. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15144. fmt.Println(dat)
  15145. } else {
  15146. fmt.Println(err)
  15147. }
  15148. userJSONBytes, _ := json.Marshal(dat)
  15149. var res ResultTwo
  15150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15151. utils.ErrorLog("解析失败:%v", err)
  15152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15153. return
  15154. }
  15155. if res.Infcode == 0 {
  15156. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15157. if err == gorm.ErrRecordNotFound {
  15158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15159. return
  15160. } else if err != nil {
  15161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15162. return
  15163. } else {
  15164. c.ServeSuccessJSON(map[string]interface{}{
  15165. "patient": patient,
  15166. "number": id_card_number,
  15167. })
  15168. }
  15169. } else {
  15170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15171. return
  15172. }
  15173. }
  15174. break
  15175. case 3:
  15176. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15177. var api string
  15178. if miConfig.MdtrtareaAdmvs == "320921" {
  15179. 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 +
  15180. "&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
  15181. fmt.Println(api)
  15182. } else {
  15183. 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 +
  15184. "&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)
  15185. }
  15186. resp, requestErr := http.Get(api)
  15187. if requestErr != nil {
  15188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15189. return
  15190. }
  15191. body, ioErr := ioutil.ReadAll(resp.Body)
  15192. if ioErr != nil {
  15193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15195. return
  15196. }
  15197. var respJSON map[string]interface{}
  15198. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15201. return
  15202. }
  15203. var status string
  15204. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15205. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15206. var token string
  15207. var res ResultTwo //1101结果
  15208. var res10265 ResultTwo10265 //1101结果
  15209. var card_info string //卡信息
  15210. var busi_card_info string
  15211. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15212. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15213. if status == "0" { //读卡成功
  15214. if card_type == "1" {
  15215. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15216. result, _ := json.Marshal(respJSON)
  15217. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15218. utils.ErrorLog("解析失败:%v", err)
  15219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15220. return
  15221. }
  15222. res.ErrMsg = res10265.ErrMsg
  15223. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15224. res.Infcode = infocode
  15225. res.Output = res10265.Output
  15226. res.InfRefmsgid = res10265.InfRefmsgid
  15227. } else {
  15228. //var card_info string //卡信息
  15229. //var busi_card_info string
  15230. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15231. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15232. //fmt.Println(card_info)
  15233. //fmt.Println(busi_card_info)
  15234. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15235. result, _ := json.Marshal(respJSON)
  15236. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15237. utils.ErrorLog("解析失败:%v", err)
  15238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15239. return
  15240. }
  15241. res.ErrMsg = res10265.ErrMsg
  15242. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15243. res.Infcode = infocode
  15244. res.Output = res10265.Output
  15245. res.InfRefmsgid = res10265.InfRefmsgid
  15246. }
  15247. if res.Infcode == 0 {
  15248. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15249. if err == gorm.ErrRecordNotFound {
  15250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15251. return
  15252. } else if err != nil {
  15253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15254. return
  15255. } else {
  15256. if card_type == "1" {
  15257. bas := strings.Split(card_info, "|")
  15258. basNumber := bas[2]
  15259. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15260. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15261. infoStr := string(Iinfos)
  15262. idetinfoStr := string(Idetinfos)
  15263. psn := &models.HisPsn{
  15264. PsnNo: res.Output.Baseinfo.PsnNo,
  15265. PatientId: patient.ID,
  15266. Certno: res.Output.Baseinfo.Certno,
  15267. //Brdy: res.Output.Baseinfo.Brdy,
  15268. Gend: res.Output.Baseinfo.Gend,
  15269. Naty: res.Output.Baseinfo.Naty,
  15270. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15271. PsnName: res.Output.Baseinfo.PsnName,
  15272. Idetinfo: idetinfoStr,
  15273. Insuinfo: infoStr,
  15274. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15275. CardInfo: card_info,
  15276. VerifyNumber: busi_card_info,
  15277. }
  15278. service.CreateHisPsn(psn)
  15279. c.ServeSuccessJSON(map[string]interface{}{
  15280. "patient": patient,
  15281. "number": basNumber,
  15282. })
  15283. } else {
  15284. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15285. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15286. infoStr := string(Iinfos)
  15287. idetinfoStr := string(Idetinfos)
  15288. psn := &models.HisPsn{
  15289. PsnNo: res.Output.Baseinfo.PsnNo,
  15290. PatientId: patient.ID,
  15291. Certno: res.Output.Baseinfo.Certno,
  15292. Gend: res.Output.Baseinfo.Gend,
  15293. Naty: res.Output.Baseinfo.Naty,
  15294. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15295. PsnName: res.Output.Baseinfo.PsnName,
  15296. Idetinfo: idetinfoStr,
  15297. Insuinfo: infoStr,
  15298. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15299. CardInfo: card_info,
  15300. VerifyNumber: token,
  15301. }
  15302. service.CreateHisPsn(psn)
  15303. var rf []*ResultFive
  15304. json.Unmarshal([]byte(infoStr), &rf)
  15305. var insutypes []*ResultFive
  15306. var insutype string
  15307. var is390 int = 0
  15308. var is310 int = 0
  15309. for _, item := range rf {
  15310. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15311. insutypes = append(insutypes, item)
  15312. }
  15313. }
  15314. if len(insutypes) == 1 {
  15315. insutype = insutypes[0].Insutype
  15316. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15317. } else {
  15318. for _, i := range insutypes {
  15319. if i.Insutype == "390" {
  15320. is390 = 1
  15321. }
  15322. if i.Insutype == "310" {
  15323. is310 = 1
  15324. }
  15325. }
  15326. }
  15327. if is390 == 1 {
  15328. insutype = "390"
  15329. }
  15330. if is310 == 1 {
  15331. insutype = "310"
  15332. }
  15333. if len(insutypes) == 0 {
  15334. insutype = "310"
  15335. }
  15336. c.ServeSuccessJSON(map[string]interface{}{
  15337. "patient": patient,
  15338. "number": token,
  15339. "insutype": insutype,
  15340. })
  15341. }
  15342. }
  15343. } else {
  15344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15345. return
  15346. }
  15347. } else { //读卡失败
  15348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15349. return
  15350. }
  15351. }
  15352. break
  15353. case 4:
  15354. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15355. var api string
  15356. if miConfig.MdtrtareaAdmvs == "320921" {
  15357. 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 +
  15358. "&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
  15359. fmt.Println(api)
  15360. } else {
  15361. 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 +
  15362. "&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)
  15363. }
  15364. resp, requestErr := http.Get(api)
  15365. if requestErr != nil {
  15366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15367. return
  15368. }
  15369. body, ioErr := ioutil.ReadAll(resp.Body)
  15370. if ioErr != nil {
  15371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15373. return
  15374. }
  15375. var respJSON map[string]interface{}
  15376. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15379. return
  15380. }
  15381. var status string
  15382. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15383. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15384. var token string
  15385. var res ResultTwo //1101结果
  15386. var res10265 ResultTwo10265 //1101结果
  15387. if status == "0" { //读卡成功
  15388. var card_info string //卡信息
  15389. var busi_card_info string
  15390. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15391. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15392. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15393. fmt.Println(card_info)
  15394. fmt.Println(busi_card_info)
  15395. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15396. result, _ := json.Marshal(respJSON)
  15397. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15398. utils.ErrorLog("解析失败:%v", err)
  15399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15400. return
  15401. }
  15402. res.ErrMsg = res10265.ErrMsg
  15403. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15404. res.Infcode = infocode
  15405. res.Output = res10265.Output
  15406. res.InfRefmsgid = res10265.InfRefmsgid
  15407. if res.Infcode == 0 {
  15408. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15409. if err == gorm.ErrRecordNotFound {
  15410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15411. return
  15412. } else if err != nil {
  15413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15414. return
  15415. } else {
  15416. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15417. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15418. infoStr := string(Iinfos)
  15419. idetinfoStr := string(Idetinfos)
  15420. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15421. psn := &models.HisPsn{
  15422. PsnNo: res.Output.Baseinfo.PsnNo,
  15423. PatientId: patient.ID,
  15424. Certno: res.Output.Baseinfo.Certno,
  15425. Brdy: b,
  15426. Age: float64(age),
  15427. //Brdy: res.Output.Baseinfo.Brdy,
  15428. Gend: res.Output.Baseinfo.Gend,
  15429. Naty: res.Output.Baseinfo.Naty,
  15430. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15431. PsnName: res.Output.Baseinfo.PsnName,
  15432. Idetinfo: idetinfoStr,
  15433. Insuinfo: infoStr,
  15434. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15435. CardInfo: card_info,
  15436. VerifyNumber: token,
  15437. }
  15438. var rf []*ResultFive
  15439. json.Unmarshal([]byte(infoStr), &rf)
  15440. var insutypes []*ResultFive
  15441. var insutype string
  15442. var is390 int = 0
  15443. var is310 int = 0
  15444. for _, item := range rf {
  15445. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15446. insutypes = append(insutypes, item)
  15447. }
  15448. }
  15449. if len(insutypes) == 1 {
  15450. insutype = insutypes[0].Insutype
  15451. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15452. } else {
  15453. for _, i := range insutypes {
  15454. if i.Insutype == "390" {
  15455. is390 = 1
  15456. }
  15457. if i.Insutype == "310" {
  15458. is310 = 1
  15459. }
  15460. }
  15461. }
  15462. if is390 == 1 {
  15463. insutype = "390"
  15464. }
  15465. if is310 == 1 {
  15466. insutype = "310"
  15467. }
  15468. if len(insutypes) == 0 {
  15469. insutype = "310"
  15470. }
  15471. service.CreateHisPsn(psn)
  15472. c.ServeSuccessJSON(map[string]interface{}{
  15473. "patient": patient,
  15474. "number": token,
  15475. "insutype": insutype,
  15476. })
  15477. }
  15478. } else {
  15479. c.ServeSuccessJSON(map[string]interface{}{
  15480. "failed_code": -10,
  15481. "msg": res.ErrMsg,
  15482. })
  15483. }
  15484. } else { //读卡失败
  15485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15486. return
  15487. }
  15488. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15489. var api string
  15490. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15491. "&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
  15492. resp, requestErr := http.Get(api)
  15493. if requestErr != nil {
  15494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15495. return
  15496. }
  15497. body, ioErr := ioutil.ReadAll(resp.Body)
  15498. if ioErr != nil {
  15499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15501. return
  15502. }
  15503. var respJSON map[string]interface{}
  15504. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15507. return
  15508. }
  15509. var status string
  15510. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15511. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15512. var token string
  15513. var res ResultTwo //1101结果
  15514. if status == "1" { //读卡成功
  15515. var card_info string //卡信息
  15516. var busi_card_info string
  15517. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15518. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15519. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15520. fmt.Println(card_info)
  15521. fmt.Println(busi_card_info)
  15522. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15523. result, _ := json.Marshal(respJSON)
  15524. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15525. utils.ErrorLog("解析失败:%v", err)
  15526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15527. return
  15528. }
  15529. if res.Infcode == 0 {
  15530. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15531. if err == gorm.ErrRecordNotFound {
  15532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15533. return
  15534. } else if err != nil {
  15535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15536. return
  15537. } else {
  15538. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15539. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15540. infoStr := string(Iinfos)
  15541. idetinfoStr := string(Idetinfos)
  15542. psn := &models.HisPsn{
  15543. PsnNo: res.Output.Baseinfo.PsnNo,
  15544. PatientId: patient.ID,
  15545. Certno: res.Output.Baseinfo.Certno,
  15546. Gend: res.Output.Baseinfo.Gend,
  15547. Naty: res.Output.Baseinfo.Naty,
  15548. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15549. PsnName: res.Output.Baseinfo.PsnName,
  15550. Idetinfo: idetinfoStr,
  15551. Insuinfo: infoStr,
  15552. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15553. CardInfo: card_info,
  15554. VerifyNumber: token,
  15555. }
  15556. var rf []*ResultFive
  15557. json.Unmarshal([]byte(infoStr), &rf)
  15558. var insutypes []*ResultFive
  15559. var insutype string
  15560. var is390 int = 0
  15561. var is310 int = 0
  15562. for _, item := range rf {
  15563. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15564. insutypes = append(insutypes, item)
  15565. }
  15566. }
  15567. if len(insutypes) == 1 {
  15568. insutype = insutypes[0].Insutype
  15569. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15570. } else {
  15571. for _, i := range insutypes {
  15572. if i.Insutype == "390" {
  15573. is390 = 1
  15574. }
  15575. if i.Insutype == "310" {
  15576. is310 = 1
  15577. }
  15578. }
  15579. }
  15580. if is390 == 1 {
  15581. insutype = "390"
  15582. }
  15583. if is310 == 1 {
  15584. insutype = "310"
  15585. }
  15586. if len(insutypes) == 0 {
  15587. insutype = "310"
  15588. }
  15589. service.CreateHisPsn(psn)
  15590. c.ServeSuccessJSON(map[string]interface{}{
  15591. "patient": patient,
  15592. "number": token,
  15593. "insutype": insutype,
  15594. })
  15595. }
  15596. } else {
  15597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15598. return
  15599. }
  15600. } else { //读卡失败
  15601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15602. return
  15603. }
  15604. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15605. var api string
  15606. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15607. "&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
  15608. resp, requestErr := http.Get(api)
  15609. if requestErr != nil {
  15610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15611. return
  15612. }
  15613. body, ioErr := ioutil.ReadAll(resp.Body)
  15614. if ioErr != nil {
  15615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15617. return
  15618. }
  15619. var respJSON map[string]interface{}
  15620. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15623. return
  15624. }
  15625. var status string
  15626. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15627. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15628. var token string
  15629. var res ResultTwo //1101结果
  15630. if status == "1" { //读卡成功
  15631. var card_info string //卡信息
  15632. var busi_card_info string
  15633. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15634. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15635. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15636. fmt.Println(card_info)
  15637. fmt.Println(busi_card_info)
  15638. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15639. result, _ := json.Marshal(respJSON)
  15640. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15641. utils.ErrorLog("解析失败:%v", err)
  15642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15643. return
  15644. }
  15645. if res.Infcode == 0 {
  15646. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15647. if err == gorm.ErrRecordNotFound {
  15648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15649. return
  15650. } else if err != nil {
  15651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15652. return
  15653. } else {
  15654. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15655. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15656. infoStr := string(Iinfos)
  15657. idetinfoStr := string(Idetinfos)
  15658. psn := &models.HisPsn{
  15659. PsnNo: res.Output.Baseinfo.PsnNo,
  15660. PatientId: patient.ID,
  15661. Certno: res.Output.Baseinfo.Certno,
  15662. Gend: res.Output.Baseinfo.Gend,
  15663. Naty: res.Output.Baseinfo.Naty,
  15664. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15665. PsnName: res.Output.Baseinfo.PsnName,
  15666. Idetinfo: idetinfoStr,
  15667. Insuinfo: infoStr,
  15668. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15669. CardInfo: card_info,
  15670. VerifyNumber: token,
  15671. }
  15672. var rf []*ResultFive
  15673. json.Unmarshal([]byte(infoStr), &rf)
  15674. var insutypes []*ResultFive
  15675. var insutype string
  15676. var is390 int = 0
  15677. var is310 int = 0
  15678. for _, item := range rf {
  15679. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15680. insutypes = append(insutypes, item)
  15681. }
  15682. }
  15683. if len(insutypes) == 1 {
  15684. insutype = insutypes[0].Insutype
  15685. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15686. } else {
  15687. for _, i := range insutypes {
  15688. if i.Insutype == "390" {
  15689. is390 = 1
  15690. }
  15691. if i.Insutype == "310" {
  15692. is310 = 1
  15693. }
  15694. }
  15695. }
  15696. if is390 == 1 {
  15697. insutype = "390"
  15698. }
  15699. if is310 == 1 {
  15700. insutype = "310"
  15701. }
  15702. if len(insutypes) == 0 {
  15703. insutype = "310"
  15704. }
  15705. service.CreateHisPsn(psn)
  15706. c.ServeSuccessJSON(map[string]interface{}{
  15707. "patient": patient,
  15708. "number": token,
  15709. "insutype": insutype,
  15710. })
  15711. }
  15712. } else {
  15713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15714. return
  15715. }
  15716. } else { //读卡失败
  15717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15718. return
  15719. }
  15720. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15721. //idNo := c.GetString("idNo")
  15722. //userName := c.GetString("userName")
  15723. //ecToken := c.GetString("ecToken")
  15724. //insuOrg := c.GetString("insuOrg")
  15725. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15726. utils.ErrorLog("解析失败:%v", json_result)
  15727. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15728. type ELeData struct {
  15729. Data struct {
  15730. IdNo string `json:"idNo"`
  15731. IdType string `json:"idType"`
  15732. UserName string `json:"userName"`
  15733. EcToken string `json:"ecToken"`
  15734. InsuOrg string `json:"insuOrg"`
  15735. Gender string `json:"gender"`
  15736. Birthday string `json:"birthday"`
  15737. Nationality string `json:"nationality"`
  15738. Email string `json:"email"`
  15739. Extra string `json:"extra"`
  15740. } `json:"data"`
  15741. Code int `json:"code"`
  15742. Message string `json:"message"`
  15743. }
  15744. var ele ELeData
  15745. err := json.Unmarshal([]byte(json_result), &ele)
  15746. if err != nil {
  15747. utils.ErrorLog("解析失败:%v", err)
  15748. }
  15749. token := ele.Data.EcToken
  15750. token = Remove0000(token)
  15751. 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)
  15752. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15753. var res ResultTwo
  15754. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15755. utils.ErrorLog("解析失败:%v", err)
  15756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15757. return
  15758. }
  15759. if res.Infcode == 0 {
  15760. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15761. if err == gorm.ErrRecordNotFound {
  15762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15763. return
  15764. } else if err != nil {
  15765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15766. return
  15767. } else {
  15768. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15769. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15770. infoStr := string(Iinfos)
  15771. idetinfoStr := string(Idetinfos)
  15772. psn := &models.HisPsn{
  15773. PsnNo: res.Output.Baseinfo.PsnNo,
  15774. PatientId: patient.ID,
  15775. Certno: res.Output.Baseinfo.Certno,
  15776. Gend: res.Output.Baseinfo.Gend,
  15777. Naty: res.Output.Baseinfo.Naty,
  15778. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15779. PsnName: res.Output.Baseinfo.PsnName,
  15780. Idetinfo: idetinfoStr,
  15781. Insuinfo: infoStr,
  15782. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15783. CardInfo: "",
  15784. Stage: "1",
  15785. VerifyNumber: token,
  15786. InsuplcAdmdvs: ele.Data.InsuOrg,
  15787. }
  15788. service.CreateHisPsn(psn)
  15789. var rf []*ResultFive
  15790. json.Unmarshal([]byte(infoStr), &rf)
  15791. var insutypes []*ResultFive
  15792. var insutype string
  15793. var is390 int = 0
  15794. var is310 int = 0
  15795. for _, item := range rf {
  15796. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15797. insutypes = append(insutypes, item)
  15798. }
  15799. }
  15800. if len(insutypes) == 1 {
  15801. insutype = insutypes[0].Insutype
  15802. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15803. } else {
  15804. for _, i := range insutypes {
  15805. if i.Insutype == "390" {
  15806. is390 = 1
  15807. }
  15808. if i.Insutype == "310" {
  15809. is310 = 1
  15810. }
  15811. }
  15812. }
  15813. if is390 == 1 {
  15814. insutype = "390"
  15815. }
  15816. if is310 == 1 {
  15817. insutype = "310"
  15818. }
  15819. if len(insutypes) == 0 {
  15820. insutype = "310"
  15821. }
  15822. c.ServeSuccessJSON(map[string]interface{}{
  15823. "patient": patient,
  15824. "number": token,
  15825. "insutype": insutype,
  15826. })
  15827. }
  15828. } else {
  15829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15830. return
  15831. }
  15832. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15833. //if initFlag == 0 {
  15834. //c.TestGetJiangXiBasBaseInit()
  15835. //}
  15836. //if initEleFlag == 0 {
  15837. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15838. //}
  15839. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15840. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15841. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15842. type ELeData struct {
  15843. Data struct {
  15844. IdNo string `json:"idNo"`
  15845. IdType string `json:"idType"`
  15846. UserName string `json:"userName"`
  15847. EcToken string `json:"ecToken"`
  15848. InsuOrg string `json:"insuOrg"`
  15849. Gender string `json:"gender"`
  15850. Birthday string `json:"birthday"`
  15851. Nationality string `json:"nationality"`
  15852. Email string `json:"email"`
  15853. Extra string `json:"extra"`
  15854. } `json:"data"`
  15855. Code int `json:"code"`
  15856. Message string `json:"message"`
  15857. }
  15858. var ele ELeData
  15859. err := json.Unmarshal([]byte(result), &ele)
  15860. if err != nil {
  15861. utils.ErrorLog("解析失败:%v", err)
  15862. }
  15863. token := ele.Data.EcToken
  15864. token = Remove0000(token)
  15865. 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)
  15866. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15867. var res ResultTwo
  15868. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15869. utils.ErrorLog("解析失败:%v", err)
  15870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15871. return
  15872. }
  15873. if res.Infcode == 0 {
  15874. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15875. if err == gorm.ErrRecordNotFound {
  15876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15877. return
  15878. } else if err != nil {
  15879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15880. return
  15881. } else {
  15882. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15883. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15884. infoStr := string(Iinfos)
  15885. idetinfoStr := string(Idetinfos)
  15886. psn := &models.HisPsn{
  15887. PsnNo: res.Output.Baseinfo.PsnNo,
  15888. PatientId: patient.ID,
  15889. Certno: res.Output.Baseinfo.Certno,
  15890. Gend: res.Output.Baseinfo.Gend,
  15891. Naty: res.Output.Baseinfo.Naty,
  15892. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15893. PsnName: res.Output.Baseinfo.PsnName,
  15894. Idetinfo: idetinfoStr,
  15895. Insuinfo: infoStr,
  15896. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15897. CardInfo: "",
  15898. VerifyNumber: token,
  15899. InsuplcAdmdvs: ele.Data.InsuOrg,
  15900. }
  15901. service.CreateHisPsn(psn)
  15902. var rf []*ResultFive
  15903. json.Unmarshal([]byte(infoStr), &rf)
  15904. var insutypes []*ResultFive
  15905. var insutype string
  15906. var is390 int = 0
  15907. var is310 int = 0
  15908. for _, item := range rf {
  15909. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15910. insutypes = append(insutypes, item)
  15911. }
  15912. }
  15913. if len(insutypes) == 1 {
  15914. insutype = insutypes[0].Insutype
  15915. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15916. } else {
  15917. for _, i := range insutypes {
  15918. if i.Insutype == "390" {
  15919. is390 = 1
  15920. }
  15921. if i.Insutype == "310" {
  15922. is310 = 1
  15923. }
  15924. }
  15925. }
  15926. if is390 == 1 {
  15927. insutype = "390"
  15928. }
  15929. if is310 == 1 {
  15930. insutype = "310"
  15931. }
  15932. if len(insutypes) == 0 {
  15933. insutype = "310"
  15934. }
  15935. c.ServeSuccessJSON(map[string]interface{}{
  15936. "patient": patient,
  15937. "number": token,
  15938. "insutype": insutype,
  15939. })
  15940. }
  15941. } else {
  15942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15943. return
  15944. }
  15945. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15946. //if initFlag == 0 {
  15947. //c.TestGetJiangXiBasBaseInit()
  15948. //}
  15949. //if initEleFlag == 0 {
  15950. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15951. //}
  15952. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15953. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15954. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15955. type ELeData struct {
  15956. Data struct {
  15957. IdNo string `json:"idNo"`
  15958. IdType string `json:"idType"`
  15959. UserName string `json:"userName"`
  15960. EcToken string `json:"ecToken"`
  15961. InsuOrg string `json:"insuOrg"`
  15962. Gender string `json:"gender"`
  15963. Birthday string `json:"birthday"`
  15964. Nationality string `json:"nationality"`
  15965. Email string `json:"email"`
  15966. Extra string `json:"extra"`
  15967. } `json:"data"`
  15968. Code int `json:"code"`
  15969. Message string `json:"message"`
  15970. }
  15971. var ele ELeData
  15972. err := json.Unmarshal([]byte(result), &ele)
  15973. if err != nil {
  15974. utils.ErrorLog("解析失败:%v", err)
  15975. }
  15976. token := ele.Data.EcToken
  15977. token = Remove0000(token)
  15978. 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)
  15979. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15980. var res ResultTwo
  15981. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15982. utils.ErrorLog("解析失败:%v", err)
  15983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15984. return
  15985. }
  15986. if res.Infcode == 0 {
  15987. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15988. if err == gorm.ErrRecordNotFound {
  15989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15990. return
  15991. } else if err != nil {
  15992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15993. return
  15994. } else {
  15995. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15996. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15997. infoStr := string(Iinfos)
  15998. idetinfoStr := string(Idetinfos)
  15999. psn := &models.HisPsn{
  16000. PsnNo: res.Output.Baseinfo.PsnNo,
  16001. PatientId: patient.ID,
  16002. Certno: res.Output.Baseinfo.Certno,
  16003. Gend: res.Output.Baseinfo.Gend,
  16004. Naty: res.Output.Baseinfo.Naty,
  16005. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16006. PsnName: res.Output.Baseinfo.PsnName,
  16007. Idetinfo: idetinfoStr,
  16008. Insuinfo: infoStr,
  16009. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16010. CardInfo: "",
  16011. VerifyNumber: token,
  16012. InsuplcAdmdvs: ele.Data.InsuOrg,
  16013. }
  16014. service.CreateHisPsn(psn)
  16015. var rf []*ResultFive
  16016. json.Unmarshal([]byte(infoStr), &rf)
  16017. var insutypes []*ResultFive
  16018. var insutype string
  16019. var is390 int = 0
  16020. var is310 int = 0
  16021. for _, item := range rf {
  16022. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16023. insutypes = append(insutypes, item)
  16024. }
  16025. }
  16026. if len(insutypes) == 1 {
  16027. insutype = insutypes[0].Insutype
  16028. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16029. } else {
  16030. for _, i := range insutypes {
  16031. if i.Insutype == "390" {
  16032. is390 = 1
  16033. }
  16034. if i.Insutype == "310" {
  16035. is310 = 1
  16036. }
  16037. }
  16038. }
  16039. if is390 == 1 {
  16040. insutype = "390"
  16041. }
  16042. if is310 == 1 {
  16043. insutype = "310"
  16044. }
  16045. if len(insutypes) == 0 {
  16046. insutype = "310"
  16047. }
  16048. c.ServeSuccessJSON(map[string]interface{}{
  16049. "patient": patient,
  16050. "number": token,
  16051. "insutype": insutype,
  16052. })
  16053. }
  16054. } else {
  16055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16056. return
  16057. }
  16058. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16059. //if initFlag == 0 {
  16060. c.TestGetJiangXiBasBaseInit()
  16061. //}
  16062. //if initEleFlag == 0 {
  16063. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16064. //}
  16065. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16066. type ELeData struct {
  16067. Data struct {
  16068. IdNo string `json:"idNo"`
  16069. IdType string `json:"idType"`
  16070. UserName string `json:"userName"`
  16071. EcToken string `json:"ecToken"`
  16072. InsuOrg string `json:"insuOrg"`
  16073. Gender string `json:"gender"`
  16074. Birthday string `json:"birthday"`
  16075. Nationality string `json:"nationality"`
  16076. Email string `json:"email"`
  16077. Extra string `json:"extra"`
  16078. } `json:"data"`
  16079. Code int `json:"code"`
  16080. Message string `json:"message"`
  16081. }
  16082. var ele ELeData
  16083. err := json.Unmarshal([]byte(json_result), &ele)
  16084. if err != nil {
  16085. utils.ErrorLog("解析失败:%v", err)
  16086. }
  16087. token := ele.Data.EcToken
  16088. token = Remove0000(token)
  16089. 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)
  16090. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16091. var res ResultTwo
  16092. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16093. utils.ErrorLog("解析失败:%v", err)
  16094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16095. return
  16096. }
  16097. if res.Infcode == 0 {
  16098. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16099. if err == gorm.ErrRecordNotFound {
  16100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16101. return
  16102. } else if err != nil {
  16103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16104. return
  16105. } else {
  16106. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16107. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16108. infoStr := string(Iinfos)
  16109. idetinfoStr := string(Idetinfos)
  16110. psn := &models.HisPsn{
  16111. PsnNo: res.Output.Baseinfo.PsnNo,
  16112. PatientId: patient.ID,
  16113. Certno: res.Output.Baseinfo.Certno,
  16114. Gend: res.Output.Baseinfo.Gend,
  16115. Naty: res.Output.Baseinfo.Naty,
  16116. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16117. PsnName: res.Output.Baseinfo.PsnName,
  16118. Idetinfo: idetinfoStr,
  16119. Insuinfo: infoStr,
  16120. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16121. CardInfo: "",
  16122. VerifyNumber: token,
  16123. }
  16124. service.CreateHisPsn(psn)
  16125. var rf []*ResultFive
  16126. json.Unmarshal([]byte(infoStr), &rf)
  16127. var insutypes []*ResultFive
  16128. var insutype string
  16129. var is390 int = 0
  16130. var is310 int = 0
  16131. for _, item := range rf {
  16132. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16133. insutypes = append(insutypes, item)
  16134. }
  16135. }
  16136. if len(insutypes) == 1 {
  16137. insutype = insutypes[0].Insutype
  16138. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16139. } else {
  16140. for _, i := range insutypes {
  16141. if i.Insutype == "390" {
  16142. is390 = 1
  16143. }
  16144. if i.Insutype == "310" {
  16145. is310 = 1
  16146. }
  16147. }
  16148. }
  16149. if is390 == 1 {
  16150. insutype = "390"
  16151. }
  16152. if is310 == 1 {
  16153. insutype = "310"
  16154. }
  16155. if len(insutypes) == 0 {
  16156. insutype = "310"
  16157. }
  16158. c.ServeSuccessJSON(map[string]interface{}{
  16159. "patient": patient,
  16160. "number": token,
  16161. "insutype": insutype,
  16162. })
  16163. }
  16164. } else {
  16165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16166. return
  16167. }
  16168. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16169. type ELeData struct {
  16170. Code string `json:"code"`
  16171. Data struct {
  16172. Aac002 string `json:"aac002"`
  16173. Aaz500 string `json:"aaz500"`
  16174. ActCardNo string `json:"actCardNo"`
  16175. Bab520 string `json:"bab520"`
  16176. Bkz543 string `json:"bkz543"`
  16177. BusinessType string `json:"businessType"`
  16178. CertfCodg string `json:"certfCodg"`
  16179. EcIndexNo string `json:"ecIndexNo"`
  16180. EcToken string `json:"ecToken"`
  16181. ID0000 string `json:"id0000"`
  16182. IDNo string `json:"idNo"`
  16183. IDType string `json:"idType"`
  16184. Idcode string `json:"idcode"`
  16185. IdentityToken string `json:"identity_token"`
  16186. InsuOrg string `json:"insuOrg"`
  16187. OfficeID string `json:"officeId"`
  16188. OfficeName string `json:"officeName"`
  16189. OperatorID string `json:"operatorId"`
  16190. OperatorName string `json:"operatorName"`
  16191. OrgID string `json:"orgId"`
  16192. UserName string `json:"userName"`
  16193. } `json:"data"`
  16194. Infno interface{} `json:"infno"`
  16195. Message string `json:"message"`
  16196. OrgID string `json:"orgId"`
  16197. TransType string `json:"transType"`
  16198. }
  16199. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16200. outPutInfo = Remove0000(outPutInfo)
  16201. if len(outPutInfo) > 0 {
  16202. var ele ELeData
  16203. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16204. if err != nil {
  16205. utils.ErrorLog("解析失败:%v", err)
  16206. }
  16207. token := ele.Data.EcToken
  16208. fmt.Println(inputInfo)
  16209. fmt.Println(outPutInfo)
  16210. 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)
  16211. saveLog(result, requestLog, "1101", "获取人员信息")
  16212. var dat map[string]interface{}
  16213. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16214. fmt.Println(dat)
  16215. } else {
  16216. fmt.Println(err)
  16217. }
  16218. userJSONBytes, _ := json.Marshal(dat)
  16219. var res ResultTwo
  16220. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16221. utils.ErrorLog("解析失败:%v", err)
  16222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16223. return
  16224. }
  16225. res.ErrMsg = errMsgLog
  16226. if res.Infcode == 0 {
  16227. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16228. if err == gorm.ErrRecordNotFound {
  16229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16230. return
  16231. } else if err != nil {
  16232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16233. return
  16234. } else {
  16235. fmt.Println(res)
  16236. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16237. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16238. infoStr := string(Iinfos)
  16239. idetinfoStr := string(Idetinfos)
  16240. psn := &models.HisPsn{
  16241. PsnNo: res.Output.Baseinfo.PsnNo,
  16242. PatientId: patient.ID,
  16243. Certno: res.Output.Baseinfo.Certno,
  16244. Gend: res.Output.Baseinfo.Gend,
  16245. Naty: res.Output.Baseinfo.Naty,
  16246. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16247. PsnName: res.Output.Baseinfo.PsnName,
  16248. Idetinfo: idetinfoStr,
  16249. Insuinfo: infoStr,
  16250. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16251. CardInfo: outPutInfo,
  16252. VerifyNumber: token,
  16253. InsuplcAdmdvs: ele.Data.InsuOrg,
  16254. }
  16255. service.CreateHisPsn(psn)
  16256. var rf []*ResultFive
  16257. json.Unmarshal([]byte(infoStr), &rf)
  16258. var insutypes []*ResultFive
  16259. var insutype string
  16260. var is390 int = 0
  16261. var is310 int = 0
  16262. for _, item := range rf {
  16263. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16264. insutypes = append(insutypes, item)
  16265. }
  16266. }
  16267. if len(insutypes) == 1 {
  16268. insutype = insutypes[0].Insutype
  16269. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16270. } else {
  16271. for _, i := range insutypes {
  16272. if i.Insutype == "390" {
  16273. is390 = 1
  16274. }
  16275. if i.Insutype == "310" {
  16276. is310 = 1
  16277. }
  16278. }
  16279. }
  16280. if is390 == 1 {
  16281. insutype = "390"
  16282. }
  16283. if is310 == 1 {
  16284. insutype = "310"
  16285. }
  16286. if len(insutypes) == 0 {
  16287. insutype = "310"
  16288. }
  16289. c.ServeSuccessJSON(map[string]interface{}{
  16290. "patient": patient,
  16291. "number": token,
  16292. "insutype": insutype,
  16293. })
  16294. }
  16295. } else {
  16296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16297. return
  16298. }
  16299. }
  16300. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16301. var api string
  16302. 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 +
  16303. "&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
  16304. resp, requestErr := http.Get(api)
  16305. if requestErr != nil {
  16306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16307. return
  16308. }
  16309. body, ioErr := ioutil.ReadAll(resp.Body)
  16310. if ioErr != nil {
  16311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16313. return
  16314. }
  16315. var respJSON map[string]interface{}
  16316. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16319. return
  16320. }
  16321. var status string
  16322. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16323. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16324. var token string
  16325. var res ResultTwo //1101结果
  16326. var res10265 ResultTwo10265 //1101结果
  16327. if status == "0" { //读卡成功
  16328. var card_info string //卡信息
  16329. var busi_card_info string
  16330. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16331. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16332. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16333. fmt.Println(card_info)
  16334. fmt.Println(busi_card_info)
  16335. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16336. result, _ := json.Marshal(respJSON)
  16337. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16338. utils.ErrorLog("解析失败:%v", err)
  16339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16340. return
  16341. }
  16342. res.ErrMsg = res10265.ErrMsg
  16343. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16344. res.Infcode = infocode
  16345. res.Output = res10265.Output
  16346. res.InfRefmsgid = res10265.InfRefmsgid
  16347. if res.Infcode == 0 {
  16348. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16349. if err == gorm.ErrRecordNotFound {
  16350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16351. return
  16352. } else if err != nil {
  16353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16354. return
  16355. } else {
  16356. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16357. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16358. infoStr := string(Iinfos)
  16359. idetinfoStr := string(Idetinfos)
  16360. psn := &models.HisPsn{
  16361. PsnNo: res.Output.Baseinfo.PsnNo,
  16362. PatientId: patient.ID,
  16363. Certno: res.Output.Baseinfo.Certno,
  16364. Gend: res.Output.Baseinfo.Gend,
  16365. Naty: res.Output.Baseinfo.Naty,
  16366. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16367. PsnName: res.Output.Baseinfo.PsnName,
  16368. Idetinfo: idetinfoStr,
  16369. Insuinfo: infoStr,
  16370. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16371. CardInfo: card_info,
  16372. VerifyNumber: token,
  16373. }
  16374. var rf []*ResultFive
  16375. json.Unmarshal([]byte(infoStr), &rf)
  16376. var insutypes []*ResultFive
  16377. var insutype string
  16378. var is390 int = 0
  16379. var is310 int = 0
  16380. for _, item := range rf {
  16381. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16382. insutypes = append(insutypes, item)
  16383. }
  16384. }
  16385. if len(insutypes) == 1 {
  16386. insutype = insutypes[0].Insutype
  16387. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16388. } else {
  16389. for _, i := range insutypes {
  16390. if i.Insutype == "390" {
  16391. is390 = 1
  16392. }
  16393. if i.Insutype == "310" {
  16394. is310 = 1
  16395. }
  16396. }
  16397. }
  16398. if is390 == 1 {
  16399. insutype = "390"
  16400. }
  16401. if is310 == 1 {
  16402. insutype = "310"
  16403. }
  16404. if len(insutypes) == 0 {
  16405. insutype = "310"
  16406. }
  16407. service.CreateHisPsn(psn)
  16408. c.ServeSuccessJSON(map[string]interface{}{
  16409. "patient": patient,
  16410. "number": token,
  16411. "insutype": insutype,
  16412. })
  16413. }
  16414. } else {
  16415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16416. return
  16417. }
  16418. } else { //读卡失败
  16419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16420. return
  16421. }
  16422. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16423. res := c.GetoleInfo()
  16424. if res.Infcode == 0 {
  16425. var result string
  16426. if res.Output.MdtrtCertType == "01" {
  16427. 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)
  16428. } else if res.Output.MdtrtCertType == "02" {
  16429. 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)
  16430. } else if res.Output.MdtrtCertType == "03" {
  16431. 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)
  16432. }
  16433. var dat map[string]interface{}
  16434. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16435. fmt.Println(dat)
  16436. } else {
  16437. fmt.Println(err)
  16438. }
  16439. userJSONBytes, _ := json.Marshal(dat)
  16440. var res2 ResultTwo
  16441. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16442. utils.ErrorLog("解析失败:%v", err)
  16443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16444. return
  16445. }
  16446. if res2.Infcode == 0 {
  16447. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16448. if err == gorm.ErrRecordNotFound {
  16449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16450. return
  16451. } else if err != nil {
  16452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16453. return
  16454. } else {
  16455. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16456. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16457. infoStr := string(Iinfos)
  16458. idetinfoStr := string(Idetinfos)
  16459. var rf []*ResultFive
  16460. json.Unmarshal([]byte(infoStr), &rf)
  16461. var insutypes []*ResultFive
  16462. var insutype string
  16463. var is390 int = 0
  16464. var is310 int = 0
  16465. //var insuplc_admdvs string
  16466. for _, item := range rf {
  16467. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16468. insutypes = append(insutypes, item)
  16469. }
  16470. }
  16471. if len(insutypes) == 1 {
  16472. insutype = insutypes[0].Insutype
  16473. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16474. } else {
  16475. for _, i := range insutypes {
  16476. if i.Insutype == "390" {
  16477. is390 = 1
  16478. }
  16479. if i.Insutype == "310" {
  16480. is310 = 1
  16481. }
  16482. }
  16483. }
  16484. if is390 == 1 {
  16485. insutype = "390"
  16486. }
  16487. if is310 == 1 {
  16488. insutype = "310"
  16489. }
  16490. if len(insutypes) == 0 {
  16491. insutype = "310"
  16492. }
  16493. psn := &models.HisPsn{
  16494. PsnNo: res2.Output.Baseinfo.PsnNo,
  16495. PatientId: patient.ID,
  16496. Certno: res2.Output.Baseinfo.Certno,
  16497. Gend: res2.Output.Baseinfo.Gend,
  16498. Naty: res2.Output.Baseinfo.Naty,
  16499. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16500. PsnName: res2.Output.Baseinfo.PsnName,
  16501. Idetinfo: idetinfoStr,
  16502. Insuinfo: infoStr,
  16503. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16504. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16505. VerifyNumber: res.Output.EcToken,
  16506. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16507. }
  16508. if res.Output.MdtrtCertType == "01" {
  16509. psn.VerifyNumber = res.Output.EcToken
  16510. //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)
  16511. } else if res.Output.MdtrtCertType == "02" {
  16512. psn.VerifyNumber = res.Output.CardNo
  16513. //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)
  16514. } else if res.Output.MdtrtCertType == "03" {
  16515. psn.VerifyNumber = res.Output.MdtrtCertNo
  16516. //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)
  16517. }
  16518. service.CreateHisPsn(psn)
  16519. var balc float64
  16520. for _, item := range rf {
  16521. if item.Insutype == insutype {
  16522. balc = item.Balc
  16523. }
  16524. }
  16525. c.ServeSuccessJSON(map[string]interface{}{
  16526. "patient": patient,
  16527. "number": res.Output.CardNo,
  16528. "insutype": insutype,
  16529. "blac": balc,
  16530. "desc": idetinfoStr,
  16531. })
  16532. }
  16533. } else {
  16534. c.ServeSuccessJSON(map[string]interface{}{
  16535. "failed_code": -10,
  16536. "msg": res2.ErrMsg,
  16537. })
  16538. }
  16539. } else {
  16540. c.ServeSuccessJSON(map[string]interface{}{
  16541. "failed_code": -10,
  16542. "msg": res.ErrMsg,
  16543. })
  16544. }
  16545. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16546. var res ResultTwo
  16547. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16548. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16549. "&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)
  16550. resp, requestErr := http.Get(api)
  16551. if requestErr != nil {
  16552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16553. return
  16554. }
  16555. body, ioErr := ioutil.ReadAll(resp.Body)
  16556. if ioErr != nil {
  16557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16559. return
  16560. }
  16561. var respJSON map[string]interface{}
  16562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16565. return
  16566. }
  16567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16568. result, _ := json.Marshal(respJSON)
  16569. fmt.Println("log")
  16570. fmt.Println(string(result))
  16571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16572. utils.ErrorLog("解析失败:%v", err)
  16573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16574. return
  16575. }
  16576. if res.Infcode == 0 {
  16577. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16578. if err == gorm.ErrRecordNotFound {
  16579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16580. return
  16581. } else if err != nil {
  16582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16583. return
  16584. } else {
  16585. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16586. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16587. infoStr := string(Iinfos)
  16588. idetinfoStr := string(Idetinfos)
  16589. var rf []*ResultFive
  16590. json.Unmarshal([]byte(infoStr), &rf)
  16591. var insutypes []*ResultFive
  16592. var insutype string
  16593. var is390 int = 0
  16594. var is310 int = 0
  16595. for _, item := range rf {
  16596. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16597. insutypes = append(insutypes, item)
  16598. }
  16599. }
  16600. if len(insutypes) == 1 {
  16601. insutype = insutypes[0].Insutype
  16602. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16603. } else {
  16604. for _, i := range insutypes {
  16605. if i.Insutype == "390" {
  16606. is390 = 1
  16607. }
  16608. if i.Insutype == "310" {
  16609. is310 = 1
  16610. }
  16611. }
  16612. }
  16613. if is390 == 1 {
  16614. insutype = "390"
  16615. }
  16616. if is310 == 1 {
  16617. insutype = "310"
  16618. }
  16619. if len(insutypes) == 0 {
  16620. insutype = "390"
  16621. }
  16622. var insuplc_admdvs string
  16623. for _, item := range rf {
  16624. if item.Insutype == insutype {
  16625. insuplc_admdvs = item.InsuplcAdmdvs
  16626. }
  16627. }
  16628. psn := &models.HisPsn{
  16629. PsnNo: res.Output.Baseinfo.PsnNo,
  16630. PatientId: patient.ID,
  16631. Certno: res.Output.Baseinfo.Certno,
  16632. Gend: res.Output.Baseinfo.Gend,
  16633. Naty: res.Output.Baseinfo.Naty,
  16634. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16635. PsnName: res.Output.Baseinfo.PsnName,
  16636. Idetinfo: idetinfoStr,
  16637. Insuinfo: infoStr,
  16638. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16639. InsuplcAdmdvs: insuplc_admdvs,
  16640. }
  16641. service.CreateHisPsn(psn)
  16642. c.ServeSuccessJSON(map[string]interface{}{
  16643. "patient": patient,
  16644. "number": res.Output.Baseinfo.Certno,
  16645. })
  16646. }
  16647. } else {
  16648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16649. return
  16650. }
  16651. } else {
  16652. type ELeData struct {
  16653. Code string `json:"code"`
  16654. Data struct {
  16655. Aac002 string `json:"aac002"`
  16656. Aaz500 string `json:"aaz500"`
  16657. ActCardNo string `json:"actCardNo"`
  16658. Bab520 string `json:"bab520"`
  16659. Bkz543 string `json:"bkz543"`
  16660. BusinessType string `json:"businessType"`
  16661. CertfCodg string `json:"certfCodg"`
  16662. EcIndexNo string `json:"ecIndexNo"`
  16663. EcToken string `json:"ecToken"`
  16664. ID0000 string `json:"id0000"`
  16665. IDNo string `json:"idNo"`
  16666. IDType string `json:"idType"`
  16667. Idcode string `json:"idcode"`
  16668. IdentityToken string `json:"identity_token"`
  16669. InsuOrg string `json:"insuOrg"`
  16670. OfficeID string `json:"officeId"`
  16671. OfficeName string `json:"officeName"`
  16672. OperatorID string `json:"operatorId"`
  16673. OperatorName string `json:"operatorName"`
  16674. OrgID string `json:"orgId"`
  16675. UserName string `json:"userName"`
  16676. } `json:"data"`
  16677. Infno interface{} `json:"infno"`
  16678. Message string `json:"message"`
  16679. OrgID string `json:"orgId"`
  16680. TransType string `json:"transType"`
  16681. }
  16682. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16683. fmt.Println(result)
  16684. outPutInfo := Remove0000(result)
  16685. fmt.Println(outPutInfo)
  16686. if len(outPutInfo) > 0 {
  16687. var ele ELeData
  16688. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16689. if err != nil {
  16690. utils.ErrorLog("解析失败:%v", err)
  16691. }
  16692. token := ele.Data.EcToken
  16693. fmt.Println(outPutInfo)
  16694. 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)
  16695. saveLog(result, requestLog, "1101", "获取人员信息")
  16696. var dat map[string]interface{}
  16697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16698. fmt.Println(dat)
  16699. } else {
  16700. fmt.Println(err)
  16701. }
  16702. userJSONBytes, _ := json.Marshal(dat)
  16703. var res ResultTwo
  16704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16705. utils.ErrorLog("解析失败:%v", err)
  16706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16707. return
  16708. }
  16709. if res.Infcode == 0 {
  16710. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16711. if err == gorm.ErrRecordNotFound {
  16712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16713. return
  16714. } else if err != nil {
  16715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16716. return
  16717. } else {
  16718. fmt.Println(res)
  16719. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16720. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16721. infoStr := string(Iinfos)
  16722. idetinfoStr := string(Idetinfos)
  16723. psn := &models.HisPsn{
  16724. PsnNo: res.Output.Baseinfo.PsnNo,
  16725. PatientId: patient.ID,
  16726. Certno: res.Output.Baseinfo.Certno,
  16727. Gend: res.Output.Baseinfo.Gend,
  16728. Naty: res.Output.Baseinfo.Naty,
  16729. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16730. PsnName: res.Output.Baseinfo.PsnName,
  16731. Idetinfo: idetinfoStr,
  16732. Insuinfo: infoStr,
  16733. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16734. CardInfo: outPutInfo,
  16735. VerifyNumber: token,
  16736. InsuplcAdmdvs: ele.Data.InsuOrg,
  16737. }
  16738. service.CreateHisPsn(psn)
  16739. var rf []*ResultFive
  16740. json.Unmarshal([]byte(infoStr), &rf)
  16741. var insutypes []*ResultFive
  16742. var insutype string
  16743. var is390 int = 0
  16744. var is310 int = 0
  16745. for _, item := range rf {
  16746. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16747. insutypes = append(insutypes, item)
  16748. }
  16749. }
  16750. if len(insutypes) == 1 {
  16751. insutype = insutypes[0].Insutype
  16752. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16753. } else {
  16754. for _, i := range insutypes {
  16755. if i.Insutype == "390" {
  16756. is390 = 1
  16757. }
  16758. if i.Insutype == "310" {
  16759. is310 = 1
  16760. }
  16761. }
  16762. }
  16763. if is390 == 1 {
  16764. insutype = "390"
  16765. }
  16766. if is310 == 1 {
  16767. insutype = "310"
  16768. }
  16769. if len(insutypes) == 0 {
  16770. insutype = "310"
  16771. }
  16772. c.ServeSuccessJSON(map[string]interface{}{
  16773. "patient": patient,
  16774. "number": token,
  16775. "insutype": insutype,
  16776. })
  16777. }
  16778. } else {
  16779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16780. return
  16781. }
  16782. }
  16783. //fmt.Println(result)
  16784. //
  16785. //if initFlag == 0 {
  16786. // c.TestGetBasBaseInit()
  16787. //}
  16788. //token := c.GetEleBaseInfo()
  16789. //
  16790. //token = Remove0000(token)
  16791. //
  16792. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16793. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16794. ////
  16795. //var res ResultTwo
  16796. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16797. // utils.ErrorLog("解析失败:%v", err)
  16798. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16799. // return
  16800. //}
  16801. //
  16802. //if res.Infcode == 0 {
  16803. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16804. // if err == gorm.ErrRecordNotFound {
  16805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16806. // return
  16807. // } else if err != nil {
  16808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16809. // return
  16810. //
  16811. // } else {
  16812. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16813. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16814. // infoStr := string(Iinfos)
  16815. // idetinfoStr := string(Idetinfos)
  16816. //
  16817. //
  16818. //
  16819. //
  16820. // var rf []*ResultFive
  16821. // json.Unmarshal([]byte(infoStr), &rf)
  16822. //
  16823. // var insutypes []*ResultFive
  16824. // var insutype string
  16825. // var is390 int = 0
  16826. // var is310 int = 0
  16827. // var insuplc_admdvs string
  16828. //
  16829. // for _, item := range rf {
  16830. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16831. // insutypes = append(insutypes, item)
  16832. // }
  16833. // }
  16834. //
  16835. // if len(insutypes) == 1 {
  16836. // insutype = insutypes[0].Insutype
  16837. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16838. // } else {
  16839. // for _, i := range insutypes {
  16840. // if i.Insutype == "390" {
  16841. // is390 = 1
  16842. // }
  16843. //
  16844. // if i.Insutype == "310" {
  16845. // is310 = 1
  16846. // }
  16847. // }
  16848. // }
  16849. // if is390 == 1 {
  16850. // insutype = "390"
  16851. // }
  16852. //
  16853. // if is310 == 1 {
  16854. // insutype = "310"
  16855. // }
  16856. // if len(insutypes) == 0 {
  16857. // insutype = "310"
  16858. // }
  16859. // for _, item := range rf {
  16860. // if item.Insutype == insutype {
  16861. // insuplc_admdvs = item.InsuplcAdmdvs
  16862. // }
  16863. // }
  16864. // psn := &models.HisPsn{
  16865. // PsnNo: res.Output.Baseinfo.PsnNo,
  16866. // Age: res.Output.Baseinfo.Age,
  16867. // PatientId: patient.ID,
  16868. // Certno: res.Output.Baseinfo.Certno,
  16869. // Brdy: res.Output.Baseinfo.Brdy,
  16870. // Gend: res.Output.Baseinfo.Gend,
  16871. // Naty: res.Output.Baseinfo.Naty,
  16872. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16873. // PsnName: res.Output.Baseinfo.PsnName,
  16874. // Idetinfo: idetinfoStr,
  16875. // Insuinfo: infoStr,
  16876. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16877. // CardInfo: "",
  16878. // VerifyNumber: token,
  16879. // InsuplcAdmdvs: insuplc_admdvs,
  16880. // }
  16881. // service.CreateHisPsn(psn)
  16882. //
  16883. // c.ServeSuccessJSON(map[string]interface{}{
  16884. // "patient": patient,
  16885. // "number": token,
  16886. // })
  16887. // }
  16888. //} else {
  16889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16890. // return
  16891. //}
  16892. }
  16893. break
  16894. case 5:
  16895. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16896. var api string
  16897. if miConfig.MdtrtareaAdmvs == "320921" {
  16898. 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 +
  16899. "&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
  16900. fmt.Println(api)
  16901. } else {
  16902. 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 +
  16903. "&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)
  16904. }
  16905. resp, requestErr := http.Get(api)
  16906. if requestErr != nil {
  16907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16908. return
  16909. }
  16910. body, ioErr := ioutil.ReadAll(resp.Body)
  16911. if ioErr != nil {
  16912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16914. return
  16915. }
  16916. var respJSON map[string]interface{}
  16917. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16920. return
  16921. }
  16922. var status string
  16923. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16924. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16925. var token string
  16926. var res ResultTwo //1101结果
  16927. var res10265 ResultTwo10265 //1101结果
  16928. if status == "0" { //读卡成功
  16929. var card_info string //卡信息
  16930. //var busi_card_info string
  16931. var auth_info string
  16932. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16933. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16934. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16935. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16936. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16937. result, _ := json.Marshal(respJSON)
  16938. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16939. utils.ErrorLog("解析失败:%v", err)
  16940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16941. return
  16942. }
  16943. res.ErrMsg = res10265.ErrMsg
  16944. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16945. res.Infcode = infocode
  16946. res.Output = res10265.Output
  16947. res.InfRefmsgid = res10265.InfRefmsgid
  16948. if res.Infcode == 0 {
  16949. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16950. if err == gorm.ErrRecordNotFound {
  16951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16952. return
  16953. } else if err != nil {
  16954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16955. return
  16956. } else {
  16957. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16958. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16959. infoStr := string(Iinfos)
  16960. idetinfoStr := string(Idetinfos)
  16961. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16962. psn := &models.HisPsn{
  16963. PsnNo: res.Output.Baseinfo.PsnNo,
  16964. PatientId: patient.ID,
  16965. Certno: res.Output.Baseinfo.Certno,
  16966. Gend: res.Output.Baseinfo.Gend,
  16967. Brdy: b,
  16968. Age: float64(age),
  16969. Naty: res.Output.Baseinfo.Naty,
  16970. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16971. PsnName: res.Output.Baseinfo.PsnName,
  16972. Idetinfo: idetinfoStr,
  16973. Insuinfo: infoStr,
  16974. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16975. CardInfo: card_info,
  16976. VerifyNumber: token,
  16977. AuthInfo: auth_info,
  16978. }
  16979. var rf []*ResultFive
  16980. json.Unmarshal([]byte(infoStr), &rf)
  16981. var insutypes []*ResultFive
  16982. var insutype string
  16983. var is390 int = 0
  16984. var is310 int = 0
  16985. for _, item := range rf {
  16986. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16987. insutypes = append(insutypes, item)
  16988. }
  16989. }
  16990. if len(insutypes) == 1 {
  16991. insutype = insutypes[0].Insutype
  16992. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16993. } else {
  16994. for _, i := range insutypes {
  16995. if i.Insutype == "390" {
  16996. is390 = 1
  16997. }
  16998. if i.Insutype == "310" {
  16999. is310 = 1
  17000. }
  17001. }
  17002. }
  17003. if is390 == 1 {
  17004. insutype = "390"
  17005. }
  17006. if is310 == 1 {
  17007. insutype = "310"
  17008. }
  17009. if len(insutypes) == 0 {
  17010. insutype = "310"
  17011. }
  17012. service.CreateHisPsn(psn)
  17013. c.ServeSuccessJSON(map[string]interface{}{
  17014. "patient": patient,
  17015. "number": token,
  17016. "insutype": insutype,
  17017. })
  17018. }
  17019. } else {
  17020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17021. return
  17022. }
  17023. } else { //读卡失败
  17024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17025. return
  17026. }
  17027. }
  17028. break
  17029. }
  17030. }
  17031. var initFlag int64 = 0
  17032. var initEleFlag int64 = 0
  17033. func (c *HisApiController) TestGetBasBaseInit() {
  17034. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17035. Iinit := DllDef.MustFindProc("Init")
  17036. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17037. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  17038. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  17039. if ret != 0 {
  17040. fmt.Println("SSCard的报错原因:", err)
  17041. fmt.Println("SSCard的运算结果为:", ret)
  17042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17043. return
  17044. }
  17045. result := int(ret)
  17046. fmt.Println("SSCard的运算结果为1:", result)
  17047. initFlag = 1
  17048. return
  17049. }
  17050. func (c *HisApiController) HandleJiangXiReadCard() {
  17051. fmt.Println("~~~~~~")
  17052. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17053. admin_user_id, _ := c.GetInt64("admin_user_id")
  17054. id_card_type, _ := c.GetInt64("id_card_type")
  17055. //certificates, _ := c.GetInt64("certificates")
  17056. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17057. if initFlag == 0 {
  17058. c.TestGetJiangXiBasBaseInit()
  17059. }
  17060. basStr := c.GetBasBaseInfo()
  17061. if len(basStr) == 0 {
  17062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17063. return
  17064. }
  17065. fmt.Println(basStr)
  17066. bas := strings.Split(basStr, "|")
  17067. basNumber := bas[1]
  17068. fmt.Println(basNumber)
  17069. card_sn := bas[3]
  17070. fmt.Println(card_sn)
  17071. 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, "")
  17072. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  17073. var dat map[string]interface{}
  17074. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17075. fmt.Println(dat)
  17076. } else {
  17077. fmt.Println(err)
  17078. }
  17079. userJSONBytes, _ := json.Marshal(dat)
  17080. var res ResultTwo
  17081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17082. utils.ErrorLog("解析失败:%v", err)
  17083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17084. return
  17085. }
  17086. if res.Infcode == 0 {
  17087. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  17088. if err == gorm.ErrRecordNotFound {
  17089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17090. return
  17091. } else if err != nil {
  17092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17093. return
  17094. } else {
  17095. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17096. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17097. infoStr := string(Iinfos)
  17098. idetinfoStr := string(Idetinfos)
  17099. psn := &models.HisPsn{
  17100. PsnNo: res.Output.Baseinfo.PsnNo,
  17101. PatientId: patient.ID,
  17102. Certno: res.Output.Baseinfo.Certno,
  17103. Gend: res.Output.Baseinfo.Gend,
  17104. Naty: res.Output.Baseinfo.Naty,
  17105. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17106. PsnName: res.Output.Baseinfo.PsnName,
  17107. Idetinfo: idetinfoStr,
  17108. Insuinfo: infoStr,
  17109. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17110. CardInfo: basStr,
  17111. VerifyNumber: "",
  17112. }
  17113. service.CreateHisPsn(psn)
  17114. c.ServeSuccessJSON(map[string]interface{}{
  17115. "patient": patient,
  17116. "number": basNumber,
  17117. })
  17118. }
  17119. } else {
  17120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17121. return
  17122. }
  17123. }
  17124. func (c *HisApiController) TestGetHnBasBaseInit() {
  17125. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17126. Iinit := DllDef.MustFindProc("Init")
  17127. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17128. //http://10.77.211.236/CSB/hsa-fsi-1303
  17129. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17130. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17131. // 调用 Init 函数
  17132. 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"))))
  17133. //if ret != 0 {
  17134. fmt.Println("SSCard的报错原因:", err)
  17135. fmt.Println("SSCard的运算结果为:", ret)
  17136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17137. // return
  17138. //}
  17139. result := int(ret)
  17140. fmt.Println("SSCard的运算结果为1:", result)
  17141. initFlag = 1
  17142. return
  17143. }
  17144. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17145. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17146. Iinit := DllDef.MustFindProc("Init")
  17147. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17148. //http://10.77.211.236/CSB/hsa-fsi-1303
  17149. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  17150. if ret != 0 {
  17151. fmt.Println("SSCard的报错原因:", err)
  17152. fmt.Println("SSCard的运算结果为:", ret)
  17153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17154. return
  17155. }
  17156. result := int(ret)
  17157. fmt.Println("SSCard的运算结果为1:", result)
  17158. initFlag = 1
  17159. return
  17160. }
  17161. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17162. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17163. Iinit := DllDef.MustFindProc("Init")
  17164. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17165. //http://10.77.211.236/CSB/hsa-fsi-1303
  17166. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17167. if ret != 0 {
  17168. fmt.Println("SSCard的报错原因:", err)
  17169. fmt.Println("SSCard的运算结果为:", ret)
  17170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17171. return
  17172. }
  17173. result := int(ret)
  17174. fmt.Println("SSCard的运算结果为1:", result)
  17175. initFlag = 1
  17176. return
  17177. }
  17178. func (c *HisApiController) GetSFZBaseInfo() string {
  17179. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17180. readCard := DllDef.MustFindProc("ReadSFZ")
  17181. if readCard == nil {
  17182. fmt.Println("readcard is nil")
  17183. readCard = DllDef.MustFindProc("ReadSFZ")
  17184. }
  17185. str := make([]byte, 8096)
  17186. str1 := make([]byte, 8096)
  17187. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17188. fmt.Println(r)
  17189. return Remove0000(string(str))
  17190. }
  17191. func (c *HisApiController) GetEleBaseInfo() string {
  17192. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17193. readCard := DllDef.MustFindProc("GetQRBase")
  17194. fmt.Println(readCard)
  17195. if readCard == nil {
  17196. fmt.Println("readcard is nil")
  17197. readCard = DllDef.MustFindProc("GetQRBase")
  17198. }
  17199. str := make([]byte, 1024)
  17200. str1 := make([]byte, 1024)
  17201. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17202. fmt.Println(ret2)
  17203. fmt.Println(string(str1))
  17204. fmt.Println(string(str))
  17205. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17206. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17207. if ret2 != 0 {
  17208. return ""
  17209. }
  17210. return string(str)
  17211. }
  17212. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17213. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17214. readCard := DllDef.MustFindProc("NationEcTrans")
  17215. fmt.Println(readCard)
  17216. fmt.Println("!!!!!")
  17217. pBusiCardInfo := make([]byte, 2048)
  17218. input := make(map[string]interface{})
  17219. inputData := make(map[string]interface{})
  17220. inputData["orgId"] = code
  17221. inputData["businessType"] = "01101"
  17222. inputData["operatorId"] = "1"
  17223. inputData["operatorName"] = "admin"
  17224. inputData["officeId"] = "001"
  17225. inputData["officeName"] = "血透室"
  17226. inputData["deviceType"] = ""
  17227. input["data"] = inputData
  17228. input["orgId"] = code
  17229. input["transType"] = "ec.query"
  17230. bytesData, _ := json.Marshal(input)
  17231. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17232. fmt.Println(ret2)
  17233. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17234. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17235. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17236. }
  17237. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17238. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17239. readCard := DllDef.MustFindProc("NationEcTrans")
  17240. fmt.Println(readCard)
  17241. fmt.Println("!!!!!")
  17242. pBusiCardInfo := make([]byte, 2048)
  17243. input := make(map[string]interface{})
  17244. inputData := make(map[string]interface{})
  17245. inputData["orgId"] = code
  17246. inputData["businessType"] = "01101"
  17247. inputData["operatorId"] = "9"
  17248. inputData["operatorName"] = "admin"
  17249. inputData["officeId"] = "001"
  17250. inputData["officeName"] = "血透室"
  17251. inputData["deviceType"] = ""
  17252. input["data"] = inputData
  17253. input["orgId"] = code
  17254. input["transType"] = "ec.query"
  17255. bytesData, _ := json.Marshal(input)
  17256. 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])))
  17257. fmt.Println(ret2)
  17258. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17259. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17260. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17261. }
  17262. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17263. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17264. readCard := DllDef.MustFindProc("NationEcTrans")
  17265. fmt.Println(readCard)
  17266. fmt.Println("!!!!!")
  17267. pBusiCardInfo := make([]byte, 2048)
  17268. input := make(map[string]interface{})
  17269. inputData := make(map[string]interface{})
  17270. inputData["orgId"] = code
  17271. inputData["businessType"] = "01301"
  17272. inputData["operatorId"] = "9"
  17273. inputData["operatorName"] = "admin"
  17274. inputData["officeId"] = "001"
  17275. inputData["officeName"] = "血透室"
  17276. inputData["deviceType"] = ""
  17277. input["data"] = inputData
  17278. input["orgId"] = code
  17279. input["transType"] = "ec.query"
  17280. bytesData, _ := json.Marshal(input)
  17281. 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])))
  17282. fmt.Println(ret2)
  17283. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17284. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17285. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17286. }
  17287. func GetJxEleBaseInfo(org_id int64) string {
  17288. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17289. readCard := DllDef.MustFindProc("NationEcTrans")
  17290. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17291. if readCard == nil {
  17292. fmt.Println("readcard is nil")
  17293. readCard = DllDef.MustFindProc("NationEcTrans")
  17294. }
  17295. str1 := make([]byte, 1024)
  17296. data := make(map[string]interface{})
  17297. inputData := make(map[string]interface{})
  17298. inputData["orgId"] = miConfig.Code
  17299. inputData["businessType"] = "01101"
  17300. inputData["operatorId"] = "test001"
  17301. inputData["operatorName"] = "cn"
  17302. inputData["officeId"] = "32760"
  17303. inputData["officeName"] = "waike"
  17304. inputData["deviceType"] = ""
  17305. data["data"] = inputData
  17306. data["transType"] = "ec.query"
  17307. data["extra "] = ""
  17308. data["orgId"] = miConfig.Code
  17309. bytesData, _ := json.Marshal(data)
  17310. //bytesData, _ := json.Marshal(data)
  17311. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17312. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17313. fmt.Println(ret2)
  17314. fmt.Println(string(str1))
  17315. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17316. if ret2 != 0 {
  17317. return ""
  17318. }
  17319. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17320. }
  17321. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17322. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17323. // readCard := DllDef.MustFindProc("NationEcTrans")
  17324. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17325. //
  17326. // if readCard == nil {
  17327. // fmt.Println("readcard is nil")
  17328. // readCard = DllDef.MustFindProc("NationEcTrans")
  17329. // }
  17330. // str1 := make([]byte, 1024)
  17331. //
  17332. // data := make(map[string]interface{})
  17333. //
  17334. // inputData := make(map[string]interface{})
  17335. // inputData["orgId"] = miConfig.Code
  17336. // inputData["businessType"] = "01101"
  17337. // inputData["operatorId"] = "test001"
  17338. // inputData["operatorName"] = "cn"
  17339. // inputData["officeId"] = "32760"
  17340. // inputData["officeName"] = "waike"
  17341. // inputData["deviceType"] = ""
  17342. //
  17343. // data["data"] = inputData
  17344. // data["transType"] = "ec.query"
  17345. // data["extra "] = ""
  17346. // data["orgId"] = miConfig.Code
  17347. // bytesData, _ := json.Marshal(data)
  17348. // //bytesData, _ := json.Marshal(data)
  17349. //
  17350. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17351. //
  17352. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17353. // fmt.Println(ret2)
  17354. // fmt.Println(string(str1))
  17355. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17356. //
  17357. // if ret2 != 0 {
  17358. // return ""
  17359. // }
  17360. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17361. //}
  17362. func GetJxEleBaseInitInfo(org_id int64) string {
  17363. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17364. readCard := DllDef.MustFindProc("NationEcTrans")
  17365. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17366. if readCard == nil {
  17367. fmt.Println("readcard is nil")
  17368. readCard = DllDef.MustFindProc("NationEcTrans")
  17369. }
  17370. str1 := make([]byte, 2048)
  17371. data := make(map[string]interface{})
  17372. inputData := make(map[string]interface{})
  17373. inputData["orgId"] = miConfig.Code
  17374. inputData["businessType"] = "01101"
  17375. inputData["operatorId"] = "1"
  17376. inputData["operatorName"] = "huangchuang"
  17377. inputData["officeId"] = "101"
  17378. inputData["officeName"] = "xuetou"
  17379. inputData["deviceType"] = ""
  17380. data["data"] = inputData
  17381. data["transType"] = "ec.query"
  17382. data["orgId"] = miConfig.Code
  17383. bytesData, _ := json.Marshal(data)
  17384. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17385. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17386. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17387. fmt.Println(ret2)
  17388. fmt.Println(string(str1))
  17389. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17390. if ret2 != 0 {
  17391. return ""
  17392. }
  17393. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17394. initEleFlag = 1
  17395. }
  17396. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17397. }
  17398. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17399. // // 构建命令
  17400. // cmd := exec.Command("python", "b.py")
  17401. //
  17402. // // 执行命令并等待完成
  17403. // output, err := cmd.CombinedOutput()
  17404. // if err != nil {
  17405. // fmt.Println("Error executing Python script:", err)
  17406. // return
  17407. // }
  17408. //
  17409. // // 打印Python脚本的输出
  17410. // fmt.Println(string(output))
  17411. //}
  17412. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17413. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17414. readCard := DllDef.MustFindProc("gxyb_call")
  17415. if readCard == nil {
  17416. fmt.Println("readcard is nil")
  17417. readCard = DllDef.MustFindProc("gxyb_call")
  17418. }
  17419. str := make([]byte, 1024)
  17420. str1 := make([]byte, 1024)
  17421. //data := make(map[string]interface{})
  17422. currentTime := time.Now()
  17423. // 格式化时间为 "YYYYMMDDHH24MISS"
  17424. formattedTime := currentTime.Format("20060102150405")
  17425. inputData := make(map[string]interface{})
  17426. inputData2 := make(map[string]interface{})
  17427. inputData["transNo"] = "1401"
  17428. inputData["transType"] = "passwordCheck"
  17429. inputData["timestamp"] = formattedTime
  17430. inputData2["fixmedinsCode"] = code
  17431. inputData2["psnNo"] = ""
  17432. inputData["data"] = inputData2
  17433. jsonBytes, err := json.Marshal(inputData)
  17434. if err != nil {
  17435. fmt.Println("Error encoding map to JSON:", err)
  17436. }
  17437. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17438. fmt.Println(string(str1))
  17439. fmt.Println(string(str))
  17440. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17441. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17442. if ret2 != 0 {
  17443. return ""
  17444. }
  17445. return string(str)
  17446. }
  17447. func (c *HisApiController) GetoleInfo() Response {
  17448. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17449. defer ole.CoUninitialize()
  17450. // Replace with the ProgID or CLSID of your COM object
  17451. progID := "YinHai.XJ.Actual.Interface.New"
  17452. // Create COM object
  17453. unknown, err := oleutil.CreateObject(progID)
  17454. if err != nil {
  17455. fmt.Println("Unable to create COM object:", err)
  17456. }
  17457. defer unknown.Release()
  17458. // Query for the IDispatch interface
  17459. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17460. if err != nil {
  17461. fmt.Println("Unable to get IDispatch interface:", err)
  17462. }
  17463. defer dispatch.Release()
  17464. // Prepare parameters
  17465. transNo := "1401"
  17466. transType := "passwordCheck"
  17467. timestamp := time.Now().Unix()
  17468. fixmedinsCode := "H45072101171"
  17469. psnNo := ""
  17470. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17471. result2 := ""
  17472. // Call COM object's method using the IDispatch interface
  17473. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17474. fmt.Println(resulr)
  17475. fmt.Println(result2)
  17476. if err != nil {
  17477. fmt.Println("调用COM对象方法失败:", err)
  17478. }
  17479. var response Response
  17480. err2 := json.Unmarshal([]byte(result2), &response)
  17481. if err2 != nil {
  17482. fmt.Println("解析JSON失败:", err)
  17483. }
  17484. return response
  17485. }
  17486. func (c *HisApiController) GetBasBaseInfo() string {
  17487. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17488. readCard := DllDef.MustFindProc("ReadCardBas")
  17489. if readCard == nil {
  17490. fmt.Println("readcard is nil")
  17491. readCard = DllDef.MustFindProc("ReadCardBas")
  17492. }
  17493. str := make([]byte, 1024)
  17494. str1 := make([]byte, 1024)
  17495. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17496. fmt.Println(string(str1))
  17497. fmt.Println(string(str))
  17498. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17499. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17500. if ret2 != 0 {
  17501. return ""
  17502. }
  17503. return string(str)
  17504. }
  17505. type Program struct {
  17506. FunctionID string `xml:"function_id"`
  17507. CardInfo string `xml:"cardinfo"`
  17508. User string `xml:"user"`
  17509. }
  17510. func (c *HisApiController) GetBasBaseInfo1111() string {
  17511. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17512. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17513. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17514. if readCard == nil {
  17515. fmt.Println("readcard is nil")
  17516. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17517. }
  17518. if readCard2 == nil {
  17519. fmt.Println("readcard is nil")
  17520. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17521. }
  17522. str := make([]byte, 1024)
  17523. str1 := make([]byte, 1024)
  17524. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17525. str3 := make([]byte, 1024)
  17526. str4 := make([]byte, 1024)
  17527. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17528. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17529. //if err != nil {
  17530. // fmt.Println("Error opening file:", err)
  17531. //}
  17532. //defer file.Close()
  17533. //
  17534. //var lastProgram Program
  17535. //scanner := bufio.NewScanner(file)
  17536. //inProgram := false
  17537. //
  17538. //for scanner.Scan() {
  17539. // line := scanner.Text()
  17540. // if strings.Contains(line, "<program>") {
  17541. // inProgram = true
  17542. // programXML := "<program>"
  17543. // for scanner.Scan() {
  17544. // line = scanner.Text()
  17545. // programXML += line
  17546. // if strings.Contains(line, "</program>") {
  17547. // programXML += "</program>"
  17548. // break
  17549. // }
  17550. // }
  17551. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17552. // // 解析成功,更新最后的 Program
  17553. // }
  17554. // inProgram = false
  17555. // }
  17556. //}
  17557. //
  17558. // fmt.Println("Error reading file:", inProgram)
  17559. //
  17560. //if err := scanner.Err(); err != nil {
  17561. // fmt.Println("Error reading file:", err)
  17562. //}
  17563. // 输出最后一次的 Program
  17564. //fmt.Printf("最后一次的 <program>:\n")
  17565. //fmt.Printf("<program>\n")
  17566. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17567. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17568. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17569. //fmt.Printf("</program>\n")
  17570. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17571. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17572. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17573. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17574. return ConvertToString(string(str), "gbk", "utf-8")
  17575. }
  17576. func (c *HisApiController) GetBasBaseInfo22222() string {
  17577. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17578. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17579. if readCard == nil {
  17580. fmt.Println("readcard is nil")
  17581. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17582. }
  17583. str := make([]byte, 1024)
  17584. str1 := make([]byte, 1024)
  17585. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17586. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17587. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17588. //if err != nil {
  17589. // fmt.Println("Error opening file:", err)
  17590. //}
  17591. //defer file.Close()
  17592. //
  17593. //var lastProgram Program
  17594. //scanner := bufio.NewScanner(file)
  17595. //inProgram := false
  17596. //
  17597. //for scanner.Scan() {
  17598. // line := scanner.Text()
  17599. // if strings.Contains(line, "<program>") {
  17600. // inProgram = true
  17601. // programXML := "<program>"
  17602. // for scanner.Scan() {
  17603. // line = scanner.Text()
  17604. // programXML += line
  17605. // if strings.Contains(line, "</program>") {
  17606. // programXML += "</program>"
  17607. // break
  17608. // }
  17609. // }
  17610. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17611. // // 解析成功,更新最后的 Program
  17612. // }
  17613. // inProgram = false
  17614. // }
  17615. //}
  17616. //
  17617. // fmt.Println("Error reading file:", inProgram)
  17618. //
  17619. //if err := scanner.Err(); err != nil {
  17620. // fmt.Println("Error reading file:", err)
  17621. //}
  17622. // 输出最后一次的 Program
  17623. //fmt.Printf("最后一次的 <program>:\n")
  17624. //fmt.Printf("<program>\n")
  17625. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17626. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17627. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17628. //fmt.Printf("</program>\n")
  17629. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17630. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17631. return ConvertToString(string(str1), "gbk", "utf-8")
  17632. }
  17633. func (c *HisApiController) GetahBasBaseInfo() string {
  17634. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17635. readCard := DllDef.MustFindProc("iReadCardBas")
  17636. if readCard == nil {
  17637. fmt.Println("readcard is nil")
  17638. readCard = DllDef.MustFindProc("iReadCardBas")
  17639. }
  17640. //str := make([]byte, 1024)
  17641. str1 := make([]byte, 1024)
  17642. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17643. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17644. //if err != nil {
  17645. // fmt.Println("Error opening file:", err)
  17646. //}
  17647. //defer file.Close()
  17648. //
  17649. //var lastProgram Program
  17650. //scanner := bufio.NewScanner(file)
  17651. //inProgram := false
  17652. //
  17653. //for scanner.Scan() {
  17654. // line := scanner.Text()
  17655. // if strings.Contains(line, "<program>") {
  17656. // inProgram = true
  17657. // programXML := "<program>"
  17658. // for scanner.Scan() {
  17659. // line = scanner.Text()
  17660. // programXML += line
  17661. // if strings.Contains(line, "</program>") {
  17662. // programXML += "</program>"
  17663. // break
  17664. // }
  17665. // }
  17666. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17667. // // 解析成功,更新最后的 Program
  17668. // }
  17669. // inProgram = false
  17670. // }
  17671. //}
  17672. //
  17673. // fmt.Println("Error reading file:", inProgram)
  17674. //
  17675. //if err := scanner.Err(); err != nil {
  17676. // fmt.Println("Error reading file:", err)
  17677. //}
  17678. // 输出最后一次的 Program
  17679. //fmt.Printf("最后一次的 <program>:\n")
  17680. //fmt.Printf("<program>\n")
  17681. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17682. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17683. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17684. //fmt.Printf("</program>\n")
  17685. fmt.Println(string(str1))
  17686. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17687. if ret2 != 0 {
  17688. return ""
  17689. }
  17690. return string(str1)
  17691. }
  17692. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17693. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17694. readCard := DllDef.MustFindProc("read_cardinfo")
  17695. if readCard == nil {
  17696. fmt.Println("readcard is nil")
  17697. readCard = DllDef.MustFindProc("read_cardinfo")
  17698. }
  17699. str := make([]byte, 1024) //卡号
  17700. str1 := make([]byte, 1024) //卡识别码
  17701. str2 := make([]byte, 1024) //身份证号
  17702. str3 := make([]byte, 1024) //姓名
  17703. str4 := make([]byte, 1024) //错误信息
  17704. 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])))
  17705. fmt.Println(string(str1))
  17706. fmt.Println(string(str))
  17707. fmt.Println(string(str2))
  17708. fmt.Println(string(str3))
  17709. fmt.Println(string(str4))
  17710. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17711. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17712. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17713. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17714. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17715. if ret2 != 0 {
  17716. return "", "", "", "", ""
  17717. }
  17718. return string(str), string(str1), string(str2), string(str3), string(str4)
  17719. }
  17720. type CustomFundPay struct {
  17721. FundPayType string `json:"fund_pay_type"`
  17722. FundPayamt float64 `json:"fund_payamt"`
  17723. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17724. }
  17725. //func (c *HisApiController) GetBatchSettleList() {
  17726. // start_time_str := c.GetString("start_time")
  17727. // //end_time_str := c.GetString("end_time")
  17728. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17729. //
  17730. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17731. //
  17732. // for _, item := range orders {
  17733. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17734. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17735. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17736. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17737. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17738. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17739. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17740. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17741. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17742. //
  17743. // if order.ID == 0 {
  17744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17745. // return
  17746. // }
  17747. //
  17748. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17749. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17750. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17751. // //fmt.Println(count)
  17752. // //var zero string
  17753. // //number := count + 1
  17754. // //if number >= 1000 {
  17755. // // zero = "0000" + strconv.FormatInt(number, 10)
  17756. // //} else if number >= 10000 {
  17757. // // zero = "000" + strconv.FormatInt(number, 10)
  17758. // //} else if number >= 100000 {
  17759. // // zero = "00" + strconv.FormatInt(number, 10)
  17760. // //} else if number >= 1000000 {
  17761. // // zero = "0" + strconv.FormatInt(number, 10)
  17762. // //} else {
  17763. // // zero = strconv.FormatInt(number, 10)
  17764. // //}
  17765. // //fmt.Println(zero)
  17766. //
  17767. // struct4101 := service.Struct4101{
  17768. // PsnNo: order.PsnNo,
  17769. // MdtrtId: order.MdtrtId,
  17770. // SetlId: order.SetlId,
  17771. // PsnName: order.PsnName,
  17772. // Gend: order.Gend,
  17773. // Brdy: his.Brdy,
  17774. // Age: his.Age,
  17775. // Naty: order.Naty,
  17776. // PatnCertType: "01",
  17777. // Certno: order.Certno,
  17778. // Prfs: "90",
  17779. // ConerName: roles[0].UserName,
  17780. // PatnRlts: "99",
  17781. // ConerAddr: miConfig.OrgName,
  17782. // ConerTel: admin.Mobile,
  17783. // HiType: order.Insutype,
  17784. // Insuplc: miConfig.InsuplcAdmdvs,
  17785. // MaindiagFlag: "1",
  17786. // BillCode: order.SetlId,
  17787. // BillNo: order.SetlId,
  17788. // BizSn: order.Number,
  17789. // PsnSelfPay: order.PsnPartAmt,
  17790. // PsnOwnPay: order.PsnPartAmt,
  17791. // AcctPay: order.AcctPay,
  17792. // PsnCashpay: order.PsnCashPay,
  17793. // HiPaymtd: "1",
  17794. // Hsorg: miConfig.InsuplcAdmdvs,
  17795. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17796. // MedinsFillPsn: curRoles.UserName,
  17797. // MedinsFillDept: miConfig.OrgName,
  17798. // IptMedType: "2",
  17799. // }
  17800. // struct4101.SetlBegnDate = order.SetlTime
  17801. // struct4101.SetlEndDate = order.SetlTime
  17802. // time_arr := strings.Split(order.SetlTime, " ")
  17803. // struct4101.AdmTime = time_arr[0]
  17804. // struct4101.AdmEndTime = time_arr[0]
  17805. //
  17806. // var rf []CustomFundPay
  17807. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17808. //
  17809. // var tempFunPays []service.CustomStruct
  17810. // for _, item := range rf {
  17811. // var tempFunPay service.CustomStruct
  17812. // tempFunPay.FundPayamt = item.FundPayamt
  17813. // tempFunPay.FundPayType = item.FundPayType
  17814. // tempFunPays = append(tempFunPays, tempFunPay)
  17815. // }
  17816. // struct4101.CustomStruct = tempFunPays
  17817. //
  17818. // var tempDiaginfos []service.DiaginfoStructTwo
  17819. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17820. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17821. //
  17822. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17823. // var config []*models.HisXtDiagnoseConfig
  17824. // for _, item := range diagnosis_ids {
  17825. // id, _ := strconv.ParseInt(item, 10, 64)
  17826. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17827. // config = append(config, &diagnosisConfig)
  17828. // }
  17829. //
  17830. // for index, item := range config {
  17831. // if index == 0 {
  17832. // var tempDiaginfo service.DiaginfoStructTwo
  17833. // tempDiaginfo.DiagCode = item.CountryCode
  17834. // tempDiaginfo.DiagName = item.CountryContentName
  17835. // tempDiaginfo.DiagType = "1"
  17836. // tempDiaginfo.MaindiagFlag = "1"
  17837. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17838. // } else {
  17839. // var tempDiaginfo service.DiaginfoStructTwo
  17840. // tempDiaginfo.DiagCode = item.CountryCode
  17841. // tempDiaginfo.DiagName = item.CountryContentName
  17842. // tempDiaginfo.DiagType = "1"
  17843. // tempDiaginfo.MaindiagFlag = "0"
  17844. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17845. // }
  17846. // }
  17847. // struct4101.Diseinfo = tempDiaginfos
  17848. //
  17849. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17850. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17851. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17852. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17853. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17854. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17855. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17856. //
  17857. // var iteminfo service.IteminfoStruct
  17858. //
  17859. // var bedCostTotal float64 = 0 //床位总费
  17860. // var bedCostSelfTotal float64 = 0 //床位自费
  17861. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17862. //
  17863. // var operationCostTotal float64 = 0 //手术费
  17864. // var operationCostSelfTotal float64 = 0 //手术费
  17865. // var operationCostPartSelfTotal float64 = 0 //手术费
  17866. //
  17867. // var otherCostTotal float64 = 0 //其他费用
  17868. // var otherCostSelfTotal float64 = 0 //其他费用
  17869. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17870. //
  17871. // var materialCostTotal float64 = 0 //材料费
  17872. // var materialCostSelfTotal float64 = 0 //材料费
  17873. // var materialCostPartSelfTotal float64 = 0 //材料费
  17874. //
  17875. // var westernMedicineCostTotal float64 = 0 //西药费
  17876. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17877. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17878. //
  17879. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17880. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17881. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17882. //
  17883. // var checkCostTotal float64 = 0 //检查费
  17884. // var checkCostSelfTotal float64 = 0 //检查费
  17885. // var checkCostPartSelfTotal float64 = 0 //检查费
  17886. //
  17887. // var laboratoryCostTotal float64 = 0 //化验费
  17888. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17889. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17890. //
  17891. // var treatCostTotal float64 = 0 //治疗费用
  17892. // var treatCostSelfTotal float64 = 0 //治疗费用
  17893. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17894. //
  17895. // decimal.DivisionPrecision = 2
  17896. //
  17897. // var bed_fulamt_ownpay_amt float64 = 0
  17898. // var operation_fulamt_ownpay_amt float64 = 0
  17899. // var other_fulamt_ownpay_amt float64 = 0
  17900. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17901. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17902. // var check_fulamt_ownpay_amt float64 = 0
  17903. // var material_fulamt_ownpay_amt float64 = 0
  17904. // var laboratory_fulamt_ownpay_amt float64 = 0
  17905. // var treat_fulamt_ownpay_amt float64 = 0
  17906. //
  17907. // var bed_claa_sunmfee float64 = 0
  17908. // var bed_clab_amt float64 = 0
  17909. // var bed_other_amt float64 = 0
  17910. //
  17911. // var operation_claa_sunmfee float64 = 0
  17912. // var operation_clab_amt float64 = 0
  17913. // var operation_other_amt float64 = 0
  17914. //
  17915. // var other_claa_sunmfee float64 = 0
  17916. // var other_clab_amt float64 = 0
  17917. // var other_other_amt float64 = 0
  17918. //
  17919. // var westernMedicine_claa_sunmfee float64 = 0
  17920. // var westernMedicine_clab_amt float64 = 0
  17921. // var westernMedicine_other_amt float64 = 0
  17922. //
  17923. // var chineseTraditional_claa_sunmfee float64 = 0
  17924. // var chineseTraditional_clab_amt float64 = 0
  17925. // var chineseTraditional_other_amt float64 = 0
  17926. //
  17927. // var check_claa_sunmfee float64 = 0
  17928. // var check_clab_amt float64 = 0
  17929. // var check_other_amt float64 = 0
  17930. //
  17931. // var material_claa_sunmfee float64 = 0
  17932. // var material_clab_amt float64 = 0
  17933. // var material_other_amt float64 = 0
  17934. //
  17935. // var laboratory_claa_sunmfee float64 = 0
  17936. // var laboratory_clab_amt float64 = 0
  17937. // var laboratory_other_amt float64 = 0
  17938. //
  17939. // var treat_claa_sunmfee float64 = 0
  17940. // var treat_clab_amt float64 = 0
  17941. // var treat_other_amt float64 = 0
  17942. //
  17943. // for _, item := range order.HisOrderInfo {
  17944. // if item.MedChrgitmType == "01" { //床位费
  17945. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17946. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17947. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17948. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17949. // if item.ChrgitmLv == "1" {
  17950. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17951. // }
  17952. // if item.ChrgitmLv == "2" {
  17953. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17954. //
  17955. // }
  17956. // if item.ChrgitmLv == "3" {
  17957. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17958. // }
  17959. //
  17960. // }
  17961. //
  17962. // if item.MedChrgitmType == "03" { //检查费
  17963. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17964. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17965. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17966. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17967. // if item.ChrgitmLv == "1" {
  17968. //
  17969. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17970. //
  17971. // }
  17972. // if item.ChrgitmLv == "2" {
  17973. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17974. //
  17975. // }
  17976. // if item.ChrgitmLv == "3" {
  17977. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17978. // }
  17979. // }
  17980. //
  17981. // if item.MedChrgitmType == "04" { //化验费
  17982. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17983. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17984. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17985. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17986. // if item.ChrgitmLv == "1" {
  17987. //
  17988. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17989. //
  17990. // }
  17991. // if item.ChrgitmLv == "2" {
  17992. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17993. //
  17994. // }
  17995. // if item.ChrgitmLv == "3" {
  17996. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17997. // }
  17998. // }
  17999. //
  18000. // if item.MedChrgitmType == "05" { //治疗费
  18001. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18002. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18003. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18004. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18005. // if item.ChrgitmLv == "1" {
  18006. //
  18007. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18008. //
  18009. // }
  18010. // if item.ChrgitmLv == "2" {
  18011. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18012. //
  18013. // }
  18014. // if item.ChrgitmLv == "3" {
  18015. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18016. // }
  18017. // }
  18018. //
  18019. // if item.MedChrgitmType == "06" { //手术费
  18020. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18021. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18022. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18023. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18024. //
  18025. // if item.ChrgitmLv == "1" {
  18026. //
  18027. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18028. //
  18029. // }
  18030. // if item.ChrgitmLv == "2" {
  18031. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18032. //
  18033. // }
  18034. // if item.ChrgitmLv == "3" {
  18035. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18036. // }
  18037. // }
  18038. //
  18039. // if item.MedChrgitmType == "08" { //材料费
  18040. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18041. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18042. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18043. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18044. // if item.ChrgitmLv == "1" {
  18045. //
  18046. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18047. //
  18048. // }
  18049. // if item.ChrgitmLv == "2" {
  18050. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18051. //
  18052. // }
  18053. // if item.ChrgitmLv == "3" {
  18054. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18055. // }
  18056. // }
  18057. //
  18058. // if item.MedChrgitmType == "09" { //西药费
  18059. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18060. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18061. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18062. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18063. // if item.ChrgitmLv == "1" {
  18064. //
  18065. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18066. //
  18067. // }
  18068. // if item.ChrgitmLv == "2" {
  18069. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18070. //
  18071. // }
  18072. // if item.ChrgitmLv == "3" {
  18073. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18074. // }
  18075. // }
  18076. //
  18077. // if item.MedChrgitmType == "11" { //中成费
  18078. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18079. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18080. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18081. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18082. // if item.ChrgitmLv == "1" {
  18083. //
  18084. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18085. //
  18086. // }
  18087. // if item.ChrgitmLv == "2" {
  18088. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18089. //
  18090. // }
  18091. // if item.ChrgitmLv == "3" {
  18092. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18093. // }
  18094. // }
  18095. //
  18096. // if item.MedChrgitmType == "14" { //其他费
  18097. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18098. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18099. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18100. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18101. // if item.ChrgitmLv == "1" {
  18102. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18103. //
  18104. // }
  18105. // if item.ChrgitmLv == "2" {
  18106. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18107. //
  18108. // }
  18109. // if item.ChrgitmLv == "3" {
  18110. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18111. // }
  18112. // }
  18113. //
  18114. // }
  18115. //
  18116. // var iteminfoStructs []service.IteminfoStruct
  18117. //
  18118. // if bedCostTotal != 0 {
  18119. // iteminfo.MedChrgitm = "01"
  18120. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18121. // iteminfo.Amt = bedCostTotal
  18122. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18123. // iteminfo.ClabAmt = bed_clab_amt
  18124. // iteminfo.OthAmt = bed_other_amt
  18125. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18126. // }
  18127. //
  18128. // if checkCostTotal != 0 {
  18129. // iteminfo.MedChrgitm = "03"
  18130. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18131. // iteminfo.Amt = checkCostTotal
  18132. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18133. // iteminfo.ClabAmt = check_clab_amt
  18134. // iteminfo.OthAmt = check_other_amt
  18135. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18136. //
  18137. // }
  18138. //
  18139. // if laboratoryCostTotal != 0 {
  18140. // iteminfo.MedChrgitm = "04"
  18141. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18142. // iteminfo.Amt = laboratoryCostTotal
  18143. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18144. // iteminfo.ClabAmt = laboratory_clab_amt
  18145. // iteminfo.OthAmt = laboratory_other_amt
  18146. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18147. //
  18148. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18149. //
  18150. // }
  18151. //
  18152. // if treatCostTotal != 0 {
  18153. // iteminfo.MedChrgitm = "05"
  18154. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18155. // iteminfo.Amt = treatCostTotal
  18156. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18157. // iteminfo.ClabAmt = treat_clab_amt
  18158. // iteminfo.OthAmt = treat_other_amt
  18159. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18160. // //(struct4101.IteminfoStruct, iteminfo)
  18161. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18162. // }
  18163. //
  18164. // if operationCostTotal != 0 {
  18165. // iteminfo.MedChrgitm = "06"
  18166. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18167. // iteminfo.Amt = operationCostTotal
  18168. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18169. // iteminfo.ClabAmt = operation_clab_amt
  18170. // iteminfo.OthAmt = operation_other_amt
  18171. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18172. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18173. // }
  18174. //
  18175. // if materialCostTotal != 0 {
  18176. // iteminfo.MedChrgitm = "08"
  18177. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18178. // iteminfo.Amt = materialCostTotal
  18179. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18180. // iteminfo.ClabAmt = material_clab_amt
  18181. // iteminfo.OthAmt = material_other_amt
  18182. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18183. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18184. // }
  18185. //
  18186. // if westernMedicineCostTotal != 0 {
  18187. // iteminfo.MedChrgitm = "09"
  18188. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18189. // iteminfo.Amt = westernMedicineCostTotal
  18190. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18191. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18192. // iteminfo.OthAmt = westernMedicine_other_amt
  18193. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18194. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18195. //
  18196. // }
  18197. // if chineseTraditionalMedicineCostTotal != 0 {
  18198. // iteminfo.MedChrgitm = "11"
  18199. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18200. // iteminfo.Amt = westernMedicineCostTotal
  18201. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18202. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18203. // iteminfo.OthAmt = westernMedicine_other_amt
  18204. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18205. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18206. //
  18207. // }
  18208. // if otherCostTotal != 0 {
  18209. // iteminfo.MedChrgitm = "14"
  18210. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18211. // iteminfo.Amt = otherCostTotal
  18212. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18213. // iteminfo.ClabAmt = other_clab_amt
  18214. // iteminfo.OthAmt = other_other_amt
  18215. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18216. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18217. //
  18218. // }
  18219. // struct4101.IteminfoStruct = iteminfoStructs
  18220. // struct4101.Ntly = "中国"
  18221. // struct4101.AdmCaty = "A03.06"
  18222. //
  18223. // struct4101.DoctorName = doctor.UserName
  18224. // struct4101.DoctorCode = doctor.DoctorNumber
  18225. //
  18226. // var res ResultSeventeen
  18227. //
  18228. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18229. // struct4101.BillCode = order.Number
  18230. // struct4101.BillNo = order.SetlId
  18231. // var resOther ResultSeventeenOther
  18232. // var pp models.PublicParams
  18233. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18234. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18235. // pp.FixmedinsName = miConfig.OrgName
  18236. // pp.FixmedinsCode = miConfig.Code
  18237. // pp.RequestUrl = miConfig.Url
  18238. // pp.Cainfo = miConfig.Cainfo
  18239. // pp.SecretKey = miConfig.SecretKey
  18240. // pp.AccessKey = miConfig.AccessKey
  18241. // pp.OpterName = curRoles.UserName
  18242. //
  18243. // client := &http.Client{}
  18244. // var req *http.Request
  18245. // data := make(map[string]interface{})
  18246. // data["struct4101"] = struct4101
  18247. // data["pp"] = pp
  18248. // bytesData, _ := json.Marshal(data)
  18249. // if miConfig.MdtrtareaAdmvs == "320921" {
  18250. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18251. // } else {
  18252. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18253. // }
  18254. // resp, _ := client.Do(req)
  18255. // defer resp.Body.Close()
  18256. // body, ioErr := ioutil.ReadAll(resp.Body)
  18257. // if ioErr != nil {
  18258. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18260. // return
  18261. // }
  18262. // var respJSON map[string]interface{}
  18263. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18264. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18265. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18266. // return
  18267. // }
  18268. //
  18269. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18270. // userJSONBytes, _ := json.Marshal(respJSON)
  18271. // fmt.Println("log")
  18272. // fmt.Println(string(userJSONBytes))
  18273. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18274. // utils.ErrorLog("解析失败:%v", err)
  18275. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18276. // return
  18277. // }
  18278. // res.InfRefmsgid = resOther.InfRefmsgid
  18279. // res.Output = resOther.Output
  18280. // res.ErrMsg = resOther.ErrMsg
  18281. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18282. // res.Infcode = infocode
  18283. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18284. //
  18285. // var pp models.PublicParams
  18286. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18287. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18288. // pp.FixmedinsName = miConfig.OrgName
  18289. // pp.FixmedinsCode = miConfig.Code
  18290. // pp.RequestUrl = miConfig.Url
  18291. // pp.Cainfo = miConfig.Cainfo
  18292. // pp.SecretKey = miConfig.SecretKey
  18293. // pp.AccessKey = miConfig.AccessKey
  18294. // pp.OpterName = curRoles.UserName
  18295. // result, _ := service.Jxyb4101(struct4101, pp)
  18296. // var dat map[string]interface{}
  18297. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18298. // fmt.Println(dat)
  18299. // } else {
  18300. // fmt.Println(err)
  18301. // }
  18302. // userJSONBytes, _ := json.Marshal(dat)
  18303. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18304. // utils.ErrorLog("解析失败:%v", err)
  18305. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18306. // return
  18307. // }
  18308. //
  18309. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18310. // var pp models.PublicParams
  18311. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18312. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18313. // pp.FixmedinsName = miConfig.OrgName
  18314. // pp.FixmedinsCode = miConfig.Code
  18315. // pp.RequestUrl = miConfig.Url
  18316. // pp.Cainfo = miConfig.Cainfo
  18317. // pp.SecretKey = miConfig.SecretKey
  18318. // pp.AccessKey = miConfig.AccessKey
  18319. // pp.OpterName = curRoles.UserName
  18320. // result, _ := service.Hnyb4101(struct4101, pp)
  18321. // var dat map[string]interface{}
  18322. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18323. // fmt.Println(dat)
  18324. // } else {
  18325. // fmt.Println(err)
  18326. // }
  18327. // userJSONBytes, _ := json.Marshal(dat)
  18328. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18329. // utils.ErrorLog("解析失败:%v", err)
  18330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18331. // return
  18332. // }
  18333. //
  18334. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18335. // var resOther ResultSeventeenOther
  18336. //
  18337. // var pp models.PublicParams
  18338. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18339. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18340. // pp.FixmedinsName = miConfig.OrgName
  18341. // pp.FixmedinsCode = miConfig.Code
  18342. // pp.RequestUrl = miConfig.Url
  18343. // pp.Cainfo = miConfig.Cainfo
  18344. // pp.SecretKey = miConfig.SecretKey
  18345. // pp.AccessKey = miConfig.AccessKey
  18346. // pp.OpterName = curRoles.UserName
  18347. // client := &http.Client{}
  18348. // var req *http.Request
  18349. // data := make(map[string]interface{})
  18350. // data["struct4101"] = struct4101
  18351. // data["pp"] = pp
  18352. // bytesData, _ := json.Marshal(data)
  18353. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18354. // resp, _ := client.Do(req)
  18355. // defer resp.Body.Close()
  18356. // body, ioErr := ioutil.ReadAll(resp.Body)
  18357. // if ioErr != nil {
  18358. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18359. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18360. // return
  18361. // }
  18362. // var respJSON map[string]interface{}
  18363. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18364. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18366. // return
  18367. // }
  18368. //
  18369. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18370. // userJSONBytes, _ := json.Marshal(respJSON)
  18371. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18372. // utils.ErrorLog("解析失败:%v", err)
  18373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18374. // return
  18375. // }
  18376. // res.InfRefmsgid = resOther.InfRefmsgid
  18377. // res.Output = resOther.Output
  18378. // res.ErrMsg = resOther.ErrMsg
  18379. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18380. // res.Infcode = infocode
  18381. //
  18382. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18383. // var pp models.PublicParams
  18384. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18385. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18386. // pp.FixmedinsName = miConfig.OrgName
  18387. // pp.FixmedinsCode = miConfig.Code
  18388. // pp.RequestUrl = miConfig.Url
  18389. // pp.Cainfo = miConfig.Cainfo
  18390. // pp.SecretKey = miConfig.SecretKey
  18391. // pp.AccessKey = miConfig.AccessKey
  18392. // pp.OpterName = curRoles.UserName
  18393. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18394. // fmt.Println(requestLog)
  18395. // fmt.Println(errMsgLog)
  18396. //
  18397. // saveLog(result, requestLog, "4101a", "上传清单")
  18398. //
  18399. // var dat map[string]interface{}
  18400. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18401. // fmt.Println(dat)
  18402. // } else {
  18403. // fmt.Println(err)
  18404. // }
  18405. // userJSONBytes, _ := json.Marshal(dat)
  18406. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18407. // utils.ErrorLog("解析失败:%v", err)
  18408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18409. // return
  18410. // }
  18411. //
  18412. // } else {
  18413. //
  18414. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18415. // var dat map[string]interface{}
  18416. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18417. // fmt.Println(dat)
  18418. // } else {
  18419. // fmt.Println(err)
  18420. // }
  18421. // userJSONBytes, _ := json.Marshal(dat)
  18422. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18423. // utils.ErrorLog("解析失败:%v", err)
  18424. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18425. // return
  18426. // }
  18427. // }
  18428. //
  18429. // if res.Infcode != 0 {
  18430. // adminUser := c.GetAdminUserInfo()
  18431. // errlog := &models.HisOrderError{
  18432. // UserOrgId: adminUser.CurrentOrgId,
  18433. // Ctime: time.Now().Unix(),
  18434. // Mtime: time.Now().Unix(),
  18435. // ErrMsg: res.ErrMsg,
  18436. // Status: 1,
  18437. // PatientId: order.ID,
  18438. // Stage: 10265,
  18439. // }
  18440. // service.CreateErrMsgLog(errlog)
  18441. // continue
  18442. // } else {
  18443. // //order.FaPiaoNumber = zero
  18444. // //order.FaPiaoCode = last_order.FaPiaoCode
  18445. // //service.UpdateOrder(order)
  18446. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18447. // Number: res.Output.SetlListId,
  18448. // Status: 1,
  18449. // Ctime: time.Now().Unix(),
  18450. // Mtime: time.Now().Unix(),
  18451. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18452. // IsUpload: 1,
  18453. // OrderId: order.ID,
  18454. // }
  18455. // service.CreateUploadRecord(hisFundSettleListResult)
  18456. // c.ServeSuccessJSON(map[string]interface{}{
  18457. // "msg": "上传成功",
  18458. // "result": hisFundSettleListResult,
  18459. // })
  18460. // continue
  18461. // }
  18462. // }
  18463. //}
  18464. func (c *HisApiController) GetbatchSettleList() {
  18465. //order_id, _ := c.GetInt64("order_id")
  18466. admin_user_id, _ := c.GetInt64("admin_user_id")
  18467. orders, _ := service.GetAllHisOrderTwo10485()
  18468. for _, item := range orders {
  18469. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18470. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18471. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18472. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18473. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18474. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18475. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18476. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18477. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18478. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18479. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18480. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18481. //fmt.Println(count)
  18482. //var zero string
  18483. //number := count + 1
  18484. //if number >= 1000 {
  18485. // zero = "0000" + strconv.FormatInt(number, 10)
  18486. //} else if number >= 10000 {
  18487. // zero = "000" + strconv.FormatInt(number, 10)
  18488. //} else if number >= 100000 {
  18489. // zero = "00" + strconv.FormatInt(number, 10)
  18490. //} else if number >= 1000000 {
  18491. // zero = "0" + strconv.FormatInt(number, 10)
  18492. //} else {
  18493. // zero = strconv.FormatInt(number, 10)
  18494. //}
  18495. //fmt.Println(zero)
  18496. struct4101 := service.Struct4101{
  18497. PsnNo: order.PsnNo,
  18498. MdtrtId: order.MdtrtId,
  18499. SetlId: order.SetlId,
  18500. PsnName: order.PsnName,
  18501. Gend: order.Gend,
  18502. Brdy: his.Brdy,
  18503. Age: his.Age,
  18504. Naty: order.Naty,
  18505. PatnCertType: "01",
  18506. Certno: order.Certno,
  18507. Prfs: "90",
  18508. ConerName: roles[0].UserName,
  18509. PatnRlts: "99",
  18510. ConerAddr: miConfig.OrgName,
  18511. ConerTel: admin.Mobile,
  18512. HiType: order.Insutype,
  18513. Insuplc: miConfig.InsuplcAdmdvs,
  18514. MaindiagFlag: "1",
  18515. BillCode: order.SetlId,
  18516. BillNo: order.SetlId,
  18517. BizSn: order.Number,
  18518. PsnSelfPay: order.PsnPartAmt,
  18519. PsnOwnPay: order.PsnPartAmt,
  18520. AcctPay: order.AcctPay,
  18521. PsnCashpay: order.PsnCashPay,
  18522. HiPaymtd: "1",
  18523. Hsorg: miConfig.InsuplcAdmdvs,
  18524. HsorgOpter: miConfig.InsuplcAdmdvs,
  18525. MedinsFillPsn: curRoles.UserName,
  18526. MedinsFillDept: miConfig.OrgName,
  18527. IptMedType: "2",
  18528. }
  18529. struct4101.SetlBegnDate = order.SetlTime
  18530. struct4101.SetlEndDate = order.SetlTime
  18531. time_arr := strings.Split(order.SetlTime, " ")
  18532. struct4101.AdmTime = time_arr[0]
  18533. struct4101.AdmEndTime = time_arr[0]
  18534. //var rf []CustomFundPay
  18535. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18536. //
  18537. //var tempFunPays []service.CustomStruct
  18538. //for _, item := range rf {
  18539. // var tempFunPay service.CustomStruct
  18540. // tempFunPay.FundPayamt = item.FundPayamt
  18541. // tempFunPay.FundPayType = item.FundPayType
  18542. // tempFunPays = append(tempFunPays, tempFunPay)
  18543. //}
  18544. //struct4101.CustomStruct = tempFunPays
  18545. var tempDiaginfos []service.DiaginfoStructTwo
  18546. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18547. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18548. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18549. var config []*models.HisXtDiagnoseConfig
  18550. for _, item := range diagnosis_ids {
  18551. id, _ := strconv.ParseInt(item, 10, 64)
  18552. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18553. config = append(config, &diagnosisConfig)
  18554. }
  18555. for index, item := range config {
  18556. if index == 0 {
  18557. var tempDiaginfo service.DiaginfoStructTwo
  18558. tempDiaginfo.DiagCode = item.CountryCode
  18559. tempDiaginfo.DiagName = item.CountryContentName
  18560. tempDiaginfo.DiagType = "1"
  18561. tempDiaginfo.MaindiagFlag = "1"
  18562. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18563. } else {
  18564. var tempDiaginfo service.DiaginfoStructTwo
  18565. tempDiaginfo.DiagCode = item.CountryCode
  18566. tempDiaginfo.DiagName = item.CountryContentName
  18567. tempDiaginfo.DiagType = "1"
  18568. tempDiaginfo.MaindiagFlag = "0"
  18569. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18570. }
  18571. }
  18572. struct4101.Diseinfo = tempDiaginfos
  18573. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18574. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18575. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18576. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18577. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18578. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18579. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18580. var iteminfo service.IteminfoStruct
  18581. var bedCostTotal float64 = 0 //床位总费
  18582. var bedCostSelfTotal float64 = 0 //床位自费
  18583. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18584. var operationCostTotal float64 = 0 //手术费
  18585. var operationCostSelfTotal float64 = 0 //手术费
  18586. var operationCostPartSelfTotal float64 = 0 //手术费
  18587. var otherCostTotal float64 = 0 //其他费用
  18588. var otherCostSelfTotal float64 = 0 //其他费用
  18589. var otherCostPartSelfTotal float64 = 0 //其他费用
  18590. var materialCostTotal float64 = 0 //材料费
  18591. var materialCostSelfTotal float64 = 0 //材料费
  18592. var materialCostPartSelfTotal float64 = 0 //材料费
  18593. var westernMedicineCostTotal float64 = 0 //西药费
  18594. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18595. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18596. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18597. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18598. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18599. var checkCostTotal float64 = 0 //检查费
  18600. var checkCostSelfTotal float64 = 0 //检查费
  18601. var checkCostPartSelfTotal float64 = 0 //检查费
  18602. var laboratoryCostTotal float64 = 0 //化验费
  18603. var laboratoryCostSelfTotal float64 = 0 //化验费
  18604. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18605. var treatCostTotal float64 = 0 //治疗费用
  18606. var treatCostSelfTotal float64 = 0 //治疗费用
  18607. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18608. decimal.DivisionPrecision = 2
  18609. var bed_fulamt_ownpay_amt float64 = 0
  18610. var operation_fulamt_ownpay_amt float64 = 0
  18611. var other_fulamt_ownpay_amt float64 = 0
  18612. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18613. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18614. var check_fulamt_ownpay_amt float64 = 0
  18615. var material_fulamt_ownpay_amt float64 = 0
  18616. var laboratory_fulamt_ownpay_amt float64 = 0
  18617. var treat_fulamt_ownpay_amt float64 = 0
  18618. var bed_claa_sunmfee float64 = 0
  18619. var bed_clab_amt float64 = 0
  18620. var bed_other_amt float64 = 0
  18621. var operation_claa_sunmfee float64 = 0
  18622. var operation_clab_amt float64 = 0
  18623. var operation_other_amt float64 = 0
  18624. var other_claa_sunmfee float64 = 0
  18625. var other_clab_amt float64 = 0
  18626. var other_other_amt float64 = 0
  18627. var westernMedicine_claa_sunmfee float64 = 0
  18628. var westernMedicine_clab_amt float64 = 0
  18629. var westernMedicine_other_amt float64 = 0
  18630. var chineseTraditional_claa_sunmfee float64 = 0
  18631. var chineseTraditional_clab_amt float64 = 0
  18632. var chineseTraditional_other_amt float64 = 0
  18633. var check_claa_sunmfee float64 = 0
  18634. var check_clab_amt float64 = 0
  18635. var check_other_amt float64 = 0
  18636. var material_claa_sunmfee float64 = 0
  18637. var material_clab_amt float64 = 0
  18638. var material_other_amt float64 = 0
  18639. var laboratory_claa_sunmfee float64 = 0
  18640. var laboratory_clab_amt float64 = 0
  18641. var laboratory_other_amt float64 = 0
  18642. var treat_claa_sunmfee float64 = 0
  18643. var treat_clab_amt float64 = 0
  18644. var treat_other_amt float64 = 0
  18645. for _, item := range order.HisOrderInfo {
  18646. if item.MedChrgitmType == "01" { //床位费
  18647. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18648. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18649. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18650. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18651. if item.ChrgitmLv == "1" {
  18652. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18653. }
  18654. if item.ChrgitmLv == "2" {
  18655. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18656. }
  18657. if item.ChrgitmLv == "3" {
  18658. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18659. }
  18660. }
  18661. if item.MedChrgitmType == "03" { //检查费
  18662. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18663. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18664. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18665. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18666. if item.ChrgitmLv == "1" {
  18667. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18668. }
  18669. if item.ChrgitmLv == "2" {
  18670. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18671. }
  18672. if item.ChrgitmLv == "3" {
  18673. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18674. }
  18675. }
  18676. if item.MedChrgitmType == "04" { //化验费
  18677. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18678. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18679. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18680. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18681. if item.ChrgitmLv == "1" {
  18682. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18683. }
  18684. if item.ChrgitmLv == "2" {
  18685. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18686. }
  18687. if item.ChrgitmLv == "3" {
  18688. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18689. }
  18690. }
  18691. if item.MedChrgitmType == "05" { //治疗费
  18692. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18693. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18694. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18695. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18696. if item.ChrgitmLv == "1" {
  18697. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18698. }
  18699. if item.ChrgitmLv == "2" {
  18700. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18701. }
  18702. if item.ChrgitmLv == "3" {
  18703. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18704. }
  18705. }
  18706. if item.MedChrgitmType == "06" { //手术费
  18707. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18708. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18709. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18710. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18711. if item.ChrgitmLv == "1" {
  18712. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18713. }
  18714. if item.ChrgitmLv == "2" {
  18715. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18716. }
  18717. if item.ChrgitmLv == "3" {
  18718. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18719. }
  18720. }
  18721. if item.MedChrgitmType == "08" { //材料费
  18722. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18723. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18724. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18725. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18726. if item.ChrgitmLv == "1" {
  18727. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18728. }
  18729. if item.ChrgitmLv == "2" {
  18730. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18731. }
  18732. if item.ChrgitmLv == "3" {
  18733. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18734. }
  18735. }
  18736. if item.MedChrgitmType == "09" { //西药费
  18737. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18738. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18739. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18740. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18741. if item.ChrgitmLv == "1" {
  18742. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18743. }
  18744. if item.ChrgitmLv == "2" {
  18745. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18746. }
  18747. if item.ChrgitmLv == "3" {
  18748. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18749. }
  18750. }
  18751. if item.MedChrgitmType == "11" { //中成费
  18752. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18753. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18754. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18755. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18756. if item.ChrgitmLv == "1" {
  18757. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18758. }
  18759. if item.ChrgitmLv == "2" {
  18760. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18761. }
  18762. if item.ChrgitmLv == "3" {
  18763. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18764. }
  18765. }
  18766. if item.MedChrgitmType == "14" { //其他费
  18767. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18768. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18769. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18770. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18771. if item.ChrgitmLv == "1" {
  18772. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18773. }
  18774. if item.ChrgitmLv == "2" {
  18775. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18776. }
  18777. if item.ChrgitmLv == "3" {
  18778. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18779. }
  18780. }
  18781. }
  18782. var iteminfoStructs []service.IteminfoStruct
  18783. if bedCostTotal != 0 {
  18784. iteminfo.MedChrgitm = "01"
  18785. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18786. iteminfo.Amt = bedCostTotal
  18787. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18788. iteminfo.ClabAmt = bed_clab_amt
  18789. iteminfo.OthAmt = bed_other_amt
  18790. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18791. }
  18792. if checkCostTotal != 0 {
  18793. iteminfo.MedChrgitm = "03"
  18794. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18795. iteminfo.Amt = checkCostTotal
  18796. iteminfo.ClaaSumfee = check_claa_sunmfee
  18797. iteminfo.ClabAmt = check_clab_amt
  18798. iteminfo.OthAmt = check_other_amt
  18799. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18800. }
  18801. if laboratoryCostTotal != 0 {
  18802. iteminfo.MedChrgitm = "04"
  18803. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18804. iteminfo.Amt = laboratoryCostTotal
  18805. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18806. iteminfo.ClabAmt = laboratory_clab_amt
  18807. iteminfo.OthAmt = laboratory_other_amt
  18808. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18809. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18810. }
  18811. if treatCostTotal != 0 {
  18812. iteminfo.MedChrgitm = "05"
  18813. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18814. iteminfo.Amt = treatCostTotal
  18815. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18816. iteminfo.ClabAmt = treat_clab_amt
  18817. iteminfo.OthAmt = treat_other_amt
  18818. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18819. //(struct4101.IteminfoStruct, iteminfo)
  18820. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18821. }
  18822. if operationCostTotal != 0 {
  18823. iteminfo.MedChrgitm = "06"
  18824. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18825. iteminfo.Amt = operationCostTotal
  18826. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18827. iteminfo.ClabAmt = operation_clab_amt
  18828. iteminfo.OthAmt = operation_other_amt
  18829. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18830. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18831. }
  18832. if materialCostTotal != 0 {
  18833. iteminfo.MedChrgitm = "08"
  18834. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18835. iteminfo.Amt = materialCostTotal
  18836. iteminfo.ClaaSumfee = material_claa_sunmfee
  18837. iteminfo.ClabAmt = material_clab_amt
  18838. iteminfo.OthAmt = material_other_amt
  18839. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18840. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18841. }
  18842. if westernMedicineCostTotal != 0 {
  18843. iteminfo.MedChrgitm = "09"
  18844. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18845. iteminfo.Amt = westernMedicineCostTotal
  18846. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18847. iteminfo.ClabAmt = westernMedicine_clab_amt
  18848. iteminfo.OthAmt = westernMedicine_other_amt
  18849. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18850. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18851. }
  18852. if chineseTraditionalMedicineCostTotal != 0 {
  18853. iteminfo.MedChrgitm = "11"
  18854. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18855. iteminfo.Amt = westernMedicineCostTotal
  18856. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18857. iteminfo.ClabAmt = westernMedicine_clab_amt
  18858. iteminfo.OthAmt = westernMedicine_other_amt
  18859. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18860. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18861. }
  18862. if otherCostTotal != 0 {
  18863. iteminfo.MedChrgitm = "14"
  18864. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18865. iteminfo.Amt = otherCostTotal
  18866. iteminfo.ClaaSumfee = other_claa_sunmfee
  18867. iteminfo.ClabAmt = other_clab_amt
  18868. iteminfo.OthAmt = other_other_amt
  18869. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18870. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18871. }
  18872. struct4101.IteminfoStruct = iteminfoStructs
  18873. struct4101.Ntly = "中国"
  18874. struct4101.AdmCaty = "A03.06"
  18875. struct4101.DoctorName = doctor.UserName
  18876. struct4101.DoctorCode = doctor.DoctorNumber
  18877. var res ResultSeventeen
  18878. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18879. struct4101.BillCode = order.Number
  18880. struct4101.BillNo = order.SetlId
  18881. var resOther ResultSeventeenOther
  18882. var pp models.PublicParams
  18883. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18884. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18885. pp.FixmedinsName = miConfig.OrgName
  18886. pp.FixmedinsCode = miConfig.Code
  18887. pp.RequestUrl = miConfig.Url
  18888. pp.Cainfo = miConfig.Cainfo
  18889. pp.SecretKey = miConfig.SecretKey
  18890. pp.AccessKey = miConfig.AccessKey
  18891. pp.OpterName = curRoles.UserName
  18892. client := &http.Client{}
  18893. var req *http.Request
  18894. data := make(map[string]interface{})
  18895. data["struct4101"] = struct4101
  18896. data["pp"] = pp
  18897. bytesData, _ := json.Marshal(data)
  18898. if miConfig.MdtrtareaAdmvs == "320921" {
  18899. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18900. } else {
  18901. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18902. }
  18903. resp, _ := client.Do(req)
  18904. defer resp.Body.Close()
  18905. body, ioErr := ioutil.ReadAll(resp.Body)
  18906. if ioErr != nil {
  18907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18909. return
  18910. }
  18911. var respJSON map[string]interface{}
  18912. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18915. return
  18916. }
  18917. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18918. userJSONBytes, _ := json.Marshal(respJSON)
  18919. fmt.Println("log")
  18920. fmt.Println(string(userJSONBytes))
  18921. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18922. utils.ErrorLog("解析失败:%v", err)
  18923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18924. return
  18925. }
  18926. res.InfRefmsgid = resOther.InfRefmsgid
  18927. res.Output = resOther.Output
  18928. res.ErrMsg = resOther.ErrMsg
  18929. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18930. res.Infcode = infocode
  18931. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18932. var pp models.PublicParams
  18933. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18934. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18935. pp.FixmedinsName = miConfig.OrgName
  18936. pp.FixmedinsCode = miConfig.Code
  18937. pp.RequestUrl = miConfig.Url
  18938. pp.Cainfo = miConfig.Cainfo
  18939. pp.SecretKey = miConfig.SecretKey
  18940. pp.AccessKey = miConfig.AccessKey
  18941. pp.OpterName = curRoles.UserName
  18942. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18943. result, _ := service.Jxyb4101(struct4101, pp)
  18944. var dat map[string]interface{}
  18945. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18946. fmt.Println(dat)
  18947. } else {
  18948. fmt.Println(err)
  18949. }
  18950. userJSONBytes, _ := json.Marshal(dat)
  18951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18952. utils.ErrorLog("解析失败:%v", err)
  18953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18954. return
  18955. }
  18956. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18957. var pp models.PublicParams
  18958. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18959. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18960. pp.FixmedinsName = miConfig.OrgName
  18961. pp.FixmedinsCode = miConfig.Code
  18962. pp.RequestUrl = miConfig.Url
  18963. pp.Cainfo = miConfig.Cainfo
  18964. pp.SecretKey = miConfig.SecretKey
  18965. pp.AccessKey = miConfig.AccessKey
  18966. pp.OpterName = curRoles.UserName
  18967. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18968. result, _ := service.Jxyb4101(struct4101, pp)
  18969. var dat map[string]interface{}
  18970. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18971. fmt.Println(dat)
  18972. } else {
  18973. fmt.Println(err)
  18974. }
  18975. userJSONBytes, _ := json.Marshal(dat)
  18976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18977. utils.ErrorLog("解析失败:%v", err)
  18978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18979. return
  18980. }
  18981. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18982. var pp models.PublicParams
  18983. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18984. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18985. pp.FixmedinsName = miConfig.OrgName
  18986. pp.FixmedinsCode = miConfig.Code
  18987. pp.RequestUrl = miConfig.Url
  18988. pp.Cainfo = miConfig.Cainfo
  18989. pp.SecretKey = miConfig.SecretKey
  18990. pp.AccessKey = miConfig.AccessKey
  18991. pp.OpterName = curRoles.UserName
  18992. result, _ := service.Hnyb4101(struct4101, pp)
  18993. var dat map[string]interface{}
  18994. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18995. fmt.Println(dat)
  18996. } else {
  18997. fmt.Println(err)
  18998. }
  18999. userJSONBytes, _ := json.Marshal(dat)
  19000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19001. utils.ErrorLog("解析失败:%v", err)
  19002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19003. return
  19004. }
  19005. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19006. var resOther ResultSeventeenOther
  19007. var pp models.PublicParams
  19008. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19009. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19010. pp.FixmedinsName = miConfig.OrgName
  19011. pp.FixmedinsCode = miConfig.Code
  19012. pp.RequestUrl = miConfig.Url
  19013. pp.Cainfo = miConfig.Cainfo
  19014. pp.SecretKey = miConfig.SecretKey
  19015. pp.AccessKey = miConfig.AccessKey
  19016. pp.OpterName = curRoles.UserName
  19017. client := &http.Client{}
  19018. var req *http.Request
  19019. data := make(map[string]interface{})
  19020. data["struct4101"] = struct4101
  19021. data["pp"] = pp
  19022. bytesData, _ := json.Marshal(data)
  19023. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19024. resp, _ := client.Do(req)
  19025. defer resp.Body.Close()
  19026. body, ioErr := ioutil.ReadAll(resp.Body)
  19027. if ioErr != nil {
  19028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19030. return
  19031. }
  19032. var respJSON map[string]interface{}
  19033. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19036. return
  19037. }
  19038. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19039. userJSONBytes, _ := json.Marshal(respJSON)
  19040. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19041. utils.ErrorLog("解析失败:%v", err)
  19042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19043. return
  19044. }
  19045. res.InfRefmsgid = resOther.InfRefmsgid
  19046. res.Output = resOther.Output
  19047. res.ErrMsg = resOther.ErrMsg
  19048. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19049. res.Infcode = infocode
  19050. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19051. var pp models.PublicParams
  19052. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19053. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19054. pp.FixmedinsName = miConfig.OrgName
  19055. pp.FixmedinsCode = miConfig.Code
  19056. pp.RequestUrl = miConfig.Url
  19057. pp.Cainfo = miConfig.Cainfo
  19058. pp.SecretKey = miConfig.SecretKey
  19059. pp.AccessKey = miConfig.AccessKey
  19060. pp.OpterName = curRoles.UserName
  19061. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19062. fmt.Println(requestLog)
  19063. fmt.Println(errMsgLog)
  19064. saveLog(result, requestLog, "4101a", "上传清单")
  19065. var dat map[string]interface{}
  19066. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19067. fmt.Println(dat)
  19068. } else {
  19069. fmt.Println(err)
  19070. }
  19071. userJSONBytes, _ := json.Marshal(dat)
  19072. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19073. utils.ErrorLog("解析失败:%v", err)
  19074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19075. return
  19076. }
  19077. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19078. var pp models.PublicParams
  19079. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19080. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19081. pp.FixmedinsName = miConfig.OrgName
  19082. pp.FixmedinsCode = miConfig.Code
  19083. pp.RequestUrl = miConfig.Url
  19084. pp.Cainfo = miConfig.Cainfo
  19085. pp.SecretKey = miConfig.SecretKey
  19086. pp.AccessKey = miConfig.AccessKey
  19087. pp.OpterName = curRoles.UserName
  19088. client := &http.Client{}
  19089. var req *http.Request
  19090. data := make(map[string]interface{})
  19091. data["struct4101"] = struct4101
  19092. data["pp"] = pp
  19093. bytesData, _ := json.Marshal(data)
  19094. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19095. resp, _ := client.Do(req)
  19096. defer resp.Body.Close()
  19097. body, ioErr := ioutil.ReadAll(resp.Body)
  19098. if ioErr != nil {
  19099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19101. return
  19102. }
  19103. var respJSON map[string]interface{}
  19104. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19107. return
  19108. }
  19109. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19110. userJSONBytes, _ := json.Marshal(respJSON)
  19111. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19112. utils.ErrorLog("解析失败:%v", err)
  19113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19114. return
  19115. }
  19116. } else {
  19117. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19118. var dat map[string]interface{}
  19119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19120. fmt.Println(dat)
  19121. } else {
  19122. fmt.Println(err)
  19123. }
  19124. userJSONBytes, _ := json.Marshal(dat)
  19125. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19126. utils.ErrorLog("解析失败:%v", err)
  19127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19128. return
  19129. }
  19130. }
  19131. if res.Infcode != 0 {
  19132. errlog := &models.HisOrderError{
  19133. UserOrgId: order.UserOrgId,
  19134. Ctime: time.Now().Unix(),
  19135. Mtime: time.Now().Unix(),
  19136. ErrMsg: res.ErrMsg + "解析失败",
  19137. Status: 1,
  19138. PatientId: order.ID,
  19139. Stage: 10485,
  19140. }
  19141. service.CreateErrMsgLog(errlog)
  19142. continue
  19143. //c.ServeSuccessJSON(map[string]interface{}{
  19144. // "failed_code": -10,
  19145. // "msg": res.ErrMsg,
  19146. //})
  19147. } else {
  19148. //order.FaPiaoNumber = zero
  19149. //order.FaPiaoCode = last_order.FaPiaoCode
  19150. //service.UpdateOrder(order)
  19151. hisFundSettleListResult := &models.HisFundSettleListResult{
  19152. Number: res.Output.SetlListId,
  19153. Status: 1,
  19154. Ctime: time.Now().Unix(),
  19155. Mtime: time.Now().Unix(),
  19156. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19157. IsUpload: 1,
  19158. OrderId: order.ID,
  19159. }
  19160. service.CreateUploadRecord(hisFundSettleListResult)
  19161. continue
  19162. }
  19163. }
  19164. }
  19165. func (c *HisApiController) GetSettleList() {
  19166. order_id, _ := c.GetInt64("order_id")
  19167. admin_user_id, _ := c.GetInt64("admin_user_id")
  19168. order, _ := service.GetHisOrderByIDTwo(order_id)
  19169. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19170. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19171. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19172. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19173. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19174. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19175. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19176. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19177. if order.ID == 0 {
  19178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19179. return
  19180. }
  19181. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19182. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19183. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19184. //fmt.Println(count)
  19185. //var zero string
  19186. //number := count + 1
  19187. //if number >= 1000 {
  19188. // zero = "0000" + strconv.FormatInt(number, 10)
  19189. //} else if number >= 10000 {
  19190. // zero = "000" + strconv.FormatInt(number, 10)
  19191. //} else if number >= 100000 {
  19192. // zero = "00" + strconv.FormatInt(number, 10)
  19193. //} else if number >= 1000000 {
  19194. // zero = "0" + strconv.FormatInt(number, 10)
  19195. //} else {
  19196. // zero = strconv.FormatInt(number, 10)
  19197. //}
  19198. //fmt.Println(zero)
  19199. struct4101 := service.Struct4101{
  19200. PsnNo: order.PsnNo,
  19201. MdtrtId: order.MdtrtId,
  19202. SetlId: order.SetlId,
  19203. PsnName: order.PsnName,
  19204. Gend: order.Gend,
  19205. Brdy: his.Brdy,
  19206. Age: his.Age,
  19207. Naty: order.Naty,
  19208. PatnCertType: "01",
  19209. Certno: order.Certno,
  19210. Prfs: "90",
  19211. ConerName: roles[0].UserName,
  19212. PatnRlts: "99",
  19213. ConerAddr: miConfig.OrgName,
  19214. ConerTel: admin.Mobile,
  19215. HiType: order.Insutype,
  19216. Insuplc: miConfig.InsuplcAdmdvs,
  19217. MaindiagFlag: "1",
  19218. BillCode: order.SetlId,
  19219. BillNo: order.SetlId,
  19220. BizSn: order.Number,
  19221. PsnSelfPay: order.PsnPartAmt,
  19222. PsnOwnPay: order.PsnPartAmt,
  19223. AcctPay: order.AcctPay,
  19224. PsnCashpay: order.PsnCashPay,
  19225. HiPaymtd: "1",
  19226. Hsorg: miConfig.InsuplcAdmdvs,
  19227. HsorgOpter: miConfig.InsuplcAdmdvs,
  19228. MedinsFillPsn: curRoles.UserName,
  19229. MedinsFillDept: miConfig.OrgName,
  19230. IptMedType: "2",
  19231. }
  19232. struct4101.SetlBegnDate = order.SetlTime
  19233. struct4101.SetlEndDate = order.SetlTime
  19234. time_arr := strings.Split(order.SetlTime, " ")
  19235. struct4101.AdmTime = time_arr[0]
  19236. struct4101.AdmEndTime = time_arr[0]
  19237. //
  19238. //var rf []CustomFundPay
  19239. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19240. //
  19241. //var tempFunPays []service.CustomStruct
  19242. //for _, item := range rf {
  19243. // var tempFunPay service.CustomStruct
  19244. // tempFunPay.FundPayamt = item.FundPayamt
  19245. // tempFunPay.FundPayType = item.FundPayType
  19246. // tempFunPays = append(tempFunPays, tempFunPay)
  19247. //}
  19248. //struct4101.CustomStruct = tempFunPays
  19249. var tempDiaginfos []service.DiaginfoStructTwo
  19250. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19251. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19252. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19253. var config []*models.HisXtDiagnoseConfig
  19254. for _, item := range diagnosis_ids {
  19255. id, _ := strconv.ParseInt(item, 10, 64)
  19256. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19257. config = append(config, &diagnosisConfig)
  19258. }
  19259. if miConfig.Code == "H15049901371" {
  19260. //for _, item := range config {
  19261. // if item.ID == 138 {
  19262. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19263. var tempDiaginfo service.DiaginfoStructTwo
  19264. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19265. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19266. tempDiaginfo.DiagType = "1"
  19267. tempDiaginfo.MaindiagFlag = "1"
  19268. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19269. //}
  19270. //}
  19271. for _, item := range config {
  19272. if item.ID != 138 {
  19273. var tempDiaginfo service.DiaginfoStructTwo
  19274. tempDiaginfo.DiagCode = item.CountryCode
  19275. tempDiaginfo.DiagName = item.CountryContentName
  19276. tempDiaginfo.DiagType = "1"
  19277. tempDiaginfo.MaindiagFlag = "0"
  19278. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19279. }
  19280. }
  19281. } else {
  19282. for index, item := range config {
  19283. if index == 0 {
  19284. var tempDiaginfo service.DiaginfoStructTwo
  19285. tempDiaginfo.DiagCode = item.CountryCode
  19286. tempDiaginfo.DiagName = item.CountryContentName
  19287. tempDiaginfo.DiagType = "1"
  19288. tempDiaginfo.MaindiagFlag = "1"
  19289. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19290. } else {
  19291. var tempDiaginfo service.DiaginfoStructTwo
  19292. tempDiaginfo.DiagCode = item.CountryCode
  19293. tempDiaginfo.DiagName = item.CountryContentName
  19294. tempDiaginfo.DiagType = "1"
  19295. tempDiaginfo.MaindiagFlag = "0"
  19296. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19297. }
  19298. }
  19299. }
  19300. struct4101.Diseinfo = tempDiaginfos
  19301. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19302. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19303. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19304. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19305. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19306. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19307. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19308. var iteminfo service.IteminfoStruct
  19309. var bedCostTotal float64 = 0 //床位总费
  19310. var bedCostSelfTotal float64 = 0 //床位自费
  19311. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19312. var operationCostTotal float64 = 0 //手术费
  19313. var operationCostSelfTotal float64 = 0 //手术费
  19314. var operationCostPartSelfTotal float64 = 0 //手术费
  19315. var otherCostTotal float64 = 0 //其他费用
  19316. var otherCostSelfTotal float64 = 0 //其他费用
  19317. var otherCostPartSelfTotal float64 = 0 //其他费用
  19318. var materialCostTotal float64 = 0 //材料费
  19319. var materialCostSelfTotal float64 = 0 //材料费
  19320. var materialCostPartSelfTotal float64 = 0 //材料费
  19321. var westernMedicineCostTotal float64 = 0 //西药费
  19322. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19323. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19324. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19325. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19326. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19327. var checkCostTotal float64 = 0 //检查费
  19328. var checkCostSelfTotal float64 = 0 //检查费
  19329. var checkCostPartSelfTotal float64 = 0 //检查费
  19330. var laboratoryCostTotal float64 = 0 //化验费
  19331. var laboratoryCostSelfTotal float64 = 0 //化验费
  19332. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19333. var treatCostTotal float64 = 0 //治疗费用
  19334. var treatCostSelfTotal float64 = 0 //治疗费用
  19335. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19336. decimal.DivisionPrecision = 2
  19337. var bed_fulamt_ownpay_amt float64 = 0
  19338. var operation_fulamt_ownpay_amt float64 = 0
  19339. var other_fulamt_ownpay_amt float64 = 0
  19340. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19341. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19342. var check_fulamt_ownpay_amt float64 = 0
  19343. var material_fulamt_ownpay_amt float64 = 0
  19344. var laboratory_fulamt_ownpay_amt float64 = 0
  19345. var treat_fulamt_ownpay_amt float64 = 0
  19346. var bed_claa_sunmfee float64 = 0
  19347. var bed_clab_amt float64 = 0
  19348. var bed_other_amt float64 = 0
  19349. var operation_claa_sunmfee float64 = 0
  19350. var operation_clab_amt float64 = 0
  19351. var operation_other_amt float64 = 0
  19352. var other_claa_sunmfee float64 = 0
  19353. var other_clab_amt float64 = 0
  19354. var other_other_amt float64 = 0
  19355. var westernMedicine_claa_sunmfee float64 = 0
  19356. var westernMedicine_clab_amt float64 = 0
  19357. var westernMedicine_other_amt float64 = 0
  19358. var chineseTraditional_claa_sunmfee float64 = 0
  19359. var chineseTraditional_clab_amt float64 = 0
  19360. var chineseTraditional_other_amt float64 = 0
  19361. var check_claa_sunmfee float64 = 0
  19362. var check_clab_amt float64 = 0
  19363. var check_other_amt float64 = 0
  19364. var material_claa_sunmfee float64 = 0
  19365. var material_clab_amt float64 = 0
  19366. var material_other_amt float64 = 0
  19367. var laboratory_claa_sunmfee float64 = 0
  19368. var laboratory_clab_amt float64 = 0
  19369. var laboratory_other_amt float64 = 0
  19370. var treat_claa_sunmfee float64 = 0
  19371. var treat_clab_amt float64 = 0
  19372. var treat_other_amt float64 = 0
  19373. for _, item := range order.HisOrderInfo {
  19374. if item.MedChrgitmType == "01" { //床位费
  19375. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19376. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19377. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19378. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19379. if item.ChrgitmLv == "1" {
  19380. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19381. }
  19382. if item.ChrgitmLv == "2" {
  19383. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19384. }
  19385. if item.ChrgitmLv == "3" {
  19386. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19387. }
  19388. }
  19389. if item.MedChrgitmType == "03" { //检查费
  19390. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19391. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19392. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19393. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19394. if item.ChrgitmLv == "1" {
  19395. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19396. }
  19397. if item.ChrgitmLv == "2" {
  19398. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19399. }
  19400. if item.ChrgitmLv == "3" {
  19401. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19402. }
  19403. }
  19404. if item.MedChrgitmType == "04" { //化验费
  19405. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19406. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19407. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19408. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19409. if item.ChrgitmLv == "1" {
  19410. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19411. }
  19412. if item.ChrgitmLv == "2" {
  19413. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19414. }
  19415. if item.ChrgitmLv == "3" {
  19416. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19417. }
  19418. }
  19419. if item.MedChrgitmType == "05" { //治疗费
  19420. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19421. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19422. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19423. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19424. if item.ChrgitmLv == "1" {
  19425. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19426. }
  19427. if item.ChrgitmLv == "2" {
  19428. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19429. }
  19430. if item.ChrgitmLv == "3" {
  19431. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19432. }
  19433. }
  19434. if item.MedChrgitmType == "06" { //手术费
  19435. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19436. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19437. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19438. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19439. if item.ChrgitmLv == "1" {
  19440. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19441. }
  19442. if item.ChrgitmLv == "2" {
  19443. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19444. }
  19445. if item.ChrgitmLv == "3" {
  19446. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19447. }
  19448. }
  19449. if item.MedChrgitmType == "08" { //材料费
  19450. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19451. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19452. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19453. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19454. if item.ChrgitmLv == "1" {
  19455. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19456. }
  19457. if item.ChrgitmLv == "2" {
  19458. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19459. }
  19460. if item.ChrgitmLv == "3" {
  19461. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19462. }
  19463. }
  19464. if item.MedChrgitmType == "09" { //西药费
  19465. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19466. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19467. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19468. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19469. if item.ChrgitmLv == "1" {
  19470. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19471. }
  19472. if item.ChrgitmLv == "2" {
  19473. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19474. }
  19475. if item.ChrgitmLv == "3" {
  19476. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19477. }
  19478. }
  19479. if item.MedChrgitmType == "11" { //中成费
  19480. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19481. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19482. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19483. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19484. if item.ChrgitmLv == "1" {
  19485. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19486. }
  19487. if item.ChrgitmLv == "2" {
  19488. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19489. }
  19490. if item.ChrgitmLv == "3" {
  19491. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19492. }
  19493. }
  19494. if item.MedChrgitmType == "14" { //其他费
  19495. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19496. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19497. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19498. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19499. if item.ChrgitmLv == "1" {
  19500. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19501. }
  19502. if item.ChrgitmLv == "2" {
  19503. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19504. }
  19505. if item.ChrgitmLv == "3" {
  19506. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19507. }
  19508. }
  19509. }
  19510. var iteminfoStructs []service.IteminfoStruct
  19511. if bedCostTotal != 0 {
  19512. iteminfo.MedChrgitm = "01"
  19513. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19514. iteminfo.Amt = bedCostTotal
  19515. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19516. iteminfo.ClabAmt = bed_clab_amt
  19517. iteminfo.OthAmt = bed_other_amt
  19518. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19519. }
  19520. if checkCostTotal != 0 {
  19521. iteminfo.MedChrgitm = "03"
  19522. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19523. iteminfo.Amt = checkCostTotal
  19524. iteminfo.ClaaSumfee = check_claa_sunmfee
  19525. iteminfo.ClabAmt = check_clab_amt
  19526. iteminfo.OthAmt = check_other_amt
  19527. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19528. }
  19529. if laboratoryCostTotal != 0 {
  19530. iteminfo.MedChrgitm = "04"
  19531. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19532. iteminfo.Amt = laboratoryCostTotal
  19533. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19534. iteminfo.ClabAmt = laboratory_clab_amt
  19535. iteminfo.OthAmt = laboratory_other_amt
  19536. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19537. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19538. }
  19539. if treatCostTotal != 0 {
  19540. iteminfo.MedChrgitm = "05"
  19541. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19542. iteminfo.Amt = treatCostTotal
  19543. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19544. iteminfo.ClabAmt = treat_clab_amt
  19545. iteminfo.OthAmt = treat_other_amt
  19546. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19547. //(struct4101.IteminfoStruct, iteminfo)
  19548. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19549. }
  19550. if operationCostTotal != 0 {
  19551. iteminfo.MedChrgitm = "06"
  19552. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19553. iteminfo.Amt = operationCostTotal
  19554. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19555. iteminfo.ClabAmt = operation_clab_amt
  19556. iteminfo.OthAmt = operation_other_amt
  19557. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19558. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19559. }
  19560. if materialCostTotal != 0 {
  19561. iteminfo.MedChrgitm = "08"
  19562. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19563. iteminfo.Amt = materialCostTotal
  19564. iteminfo.ClaaSumfee = material_claa_sunmfee
  19565. iteminfo.ClabAmt = material_clab_amt
  19566. iteminfo.OthAmt = material_other_amt
  19567. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19568. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19569. }
  19570. if westernMedicineCostTotal != 0 {
  19571. iteminfo.MedChrgitm = "09"
  19572. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19573. iteminfo.Amt = westernMedicineCostTotal
  19574. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19575. iteminfo.ClabAmt = westernMedicine_clab_amt
  19576. iteminfo.OthAmt = westernMedicine_other_amt
  19577. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19578. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19579. }
  19580. if chineseTraditionalMedicineCostTotal != 0 {
  19581. iteminfo.MedChrgitm = "11"
  19582. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19583. iteminfo.Amt = westernMedicineCostTotal
  19584. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19585. iteminfo.ClabAmt = westernMedicine_clab_amt
  19586. iteminfo.OthAmt = westernMedicine_other_amt
  19587. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19588. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19589. }
  19590. if otherCostTotal != 0 {
  19591. iteminfo.MedChrgitm = "14"
  19592. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19593. iteminfo.Amt = otherCostTotal
  19594. iteminfo.ClaaSumfee = other_claa_sunmfee
  19595. iteminfo.ClabAmt = other_clab_amt
  19596. iteminfo.OthAmt = other_other_amt
  19597. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19598. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19599. }
  19600. struct4101.IteminfoStruct = iteminfoStructs
  19601. struct4101.Ntly = "中国"
  19602. struct4101.AdmCaty = "A03.06"
  19603. struct4101.DoctorName = doctor.UserName
  19604. struct4101.DoctorCode = doctor.DoctorNumber
  19605. var res ResultSeventeen
  19606. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19607. struct4101.BillCode = order.Number
  19608. struct4101.BillNo = order.SetlId
  19609. var resOther ResultSeventeenOther
  19610. var pp models.PublicParams
  19611. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19612. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19613. pp.FixmedinsName = miConfig.OrgName
  19614. pp.FixmedinsCode = miConfig.Code
  19615. pp.RequestUrl = miConfig.Url
  19616. pp.Cainfo = miConfig.Cainfo
  19617. pp.SecretKey = miConfig.SecretKey
  19618. pp.AccessKey = miConfig.AccessKey
  19619. pp.OpterName = curRoles.UserName
  19620. client := &http.Client{}
  19621. var req *http.Request
  19622. data := make(map[string]interface{})
  19623. data["struct4101"] = struct4101
  19624. data["pp"] = pp
  19625. bytesData, _ := json.Marshal(data)
  19626. if miConfig.MdtrtareaAdmvs == "320921" {
  19627. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19628. } else {
  19629. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19630. }
  19631. resp, _ := client.Do(req)
  19632. defer resp.Body.Close()
  19633. body, ioErr := ioutil.ReadAll(resp.Body)
  19634. if ioErr != nil {
  19635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19637. return
  19638. }
  19639. var respJSON map[string]interface{}
  19640. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19643. return
  19644. }
  19645. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19646. userJSONBytes, _ := json.Marshal(respJSON)
  19647. fmt.Println("log")
  19648. fmt.Println(string(userJSONBytes))
  19649. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19650. utils.ErrorLog("解析失败:%v", err)
  19651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19652. return
  19653. }
  19654. res.InfRefmsgid = resOther.InfRefmsgid
  19655. res.Output = resOther.Output
  19656. res.ErrMsg = resOther.ErrMsg
  19657. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19658. res.Infcode = infocode
  19659. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19660. var pp models.PublicParams
  19661. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19662. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19663. pp.FixmedinsName = miConfig.OrgName
  19664. pp.FixmedinsCode = miConfig.Code
  19665. pp.RequestUrl = miConfig.Url
  19666. pp.Cainfo = miConfig.Cainfo
  19667. pp.SecretKey = miConfig.SecretKey
  19668. pp.AccessKey = miConfig.AccessKey
  19669. pp.OpterName = curRoles.UserName
  19670. result, _ := service.Jxyb4101(struct4101, pp)
  19671. var dat map[string]interface{}
  19672. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19673. fmt.Println(dat)
  19674. } else {
  19675. fmt.Println(err)
  19676. }
  19677. userJSONBytes, _ := json.Marshal(dat)
  19678. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19679. utils.ErrorLog("解析失败:%v", err)
  19680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19681. return
  19682. }
  19683. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19684. var pp models.PublicParams
  19685. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19686. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19687. pp.FixmedinsName = miConfig.OrgName
  19688. pp.FixmedinsCode = miConfig.Code
  19689. pp.RequestUrl = miConfig.Url
  19690. pp.Cainfo = miConfig.Cainfo
  19691. pp.SecretKey = miConfig.SecretKey
  19692. pp.AccessKey = miConfig.AccessKey
  19693. pp.OpterName = curRoles.UserName
  19694. result, _ := service.Jxyb4101(struct4101, pp)
  19695. var dat map[string]interface{}
  19696. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19697. fmt.Println(dat)
  19698. } else {
  19699. fmt.Println(err)
  19700. }
  19701. userJSONBytes, _ := json.Marshal(dat)
  19702. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19703. utils.ErrorLog("解析失败:%v", err)
  19704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19705. return
  19706. }
  19707. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19708. var pp models.PublicParams
  19709. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19710. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19711. pp.FixmedinsName = miConfig.OrgName
  19712. pp.FixmedinsCode = miConfig.Code
  19713. pp.RequestUrl = miConfig.Url
  19714. pp.Cainfo = miConfig.Cainfo
  19715. pp.SecretKey = miConfig.SecretKey
  19716. pp.AccessKey = miConfig.AccessKey
  19717. pp.OpterName = curRoles.UserName
  19718. result, _ := service.Hnyb4101(struct4101, pp)
  19719. var dat map[string]interface{}
  19720. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19721. fmt.Println(dat)
  19722. } else {
  19723. fmt.Println(err)
  19724. }
  19725. userJSONBytes, _ := json.Marshal(dat)
  19726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19727. utils.ErrorLog("解析失败:%v", err)
  19728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19729. return
  19730. }
  19731. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19732. var resOther ResultSeventeenOther
  19733. var pp models.PublicParams
  19734. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19735. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19736. pp.FixmedinsName = miConfig.OrgName
  19737. pp.FixmedinsCode = miConfig.Code
  19738. pp.RequestUrl = miConfig.Url
  19739. pp.Cainfo = miConfig.Cainfo
  19740. pp.SecretKey = miConfig.SecretKey
  19741. pp.AccessKey = miConfig.AccessKey
  19742. pp.OpterName = curRoles.UserName
  19743. client := &http.Client{}
  19744. var req *http.Request
  19745. data := make(map[string]interface{})
  19746. data["struct4101"] = struct4101
  19747. data["pp"] = pp
  19748. bytesData, _ := json.Marshal(data)
  19749. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19750. resp, _ := client.Do(req)
  19751. defer resp.Body.Close()
  19752. body, ioErr := ioutil.ReadAll(resp.Body)
  19753. if ioErr != nil {
  19754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19756. return
  19757. }
  19758. var respJSON map[string]interface{}
  19759. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19762. return
  19763. }
  19764. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19765. userJSONBytes, _ := json.Marshal(respJSON)
  19766. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19767. utils.ErrorLog("解析失败:%v", err)
  19768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19769. return
  19770. }
  19771. res.InfRefmsgid = resOther.InfRefmsgid
  19772. res.Output = resOther.Output
  19773. res.ErrMsg = resOther.ErrMsg
  19774. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19775. res.Infcode = infocode
  19776. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19777. var pp models.PublicParams
  19778. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19779. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19780. pp.FixmedinsName = miConfig.OrgName
  19781. pp.FixmedinsCode = miConfig.Code
  19782. pp.RequestUrl = miConfig.Url
  19783. pp.Cainfo = miConfig.Cainfo
  19784. pp.SecretKey = miConfig.SecretKey
  19785. pp.AccessKey = miConfig.AccessKey
  19786. pp.OpterName = curRoles.UserName
  19787. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19788. fmt.Println(requestLog)
  19789. fmt.Println(errMsgLog)
  19790. saveLog(result, requestLog, "4101a", "上传清单")
  19791. var dat map[string]interface{}
  19792. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19793. fmt.Println(dat)
  19794. } else {
  19795. fmt.Println(err)
  19796. }
  19797. userJSONBytes, _ := json.Marshal(dat)
  19798. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19799. utils.ErrorLog("解析失败:%v", err)
  19800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19801. return
  19802. }
  19803. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19804. var pp models.PublicParams
  19805. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19806. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19807. pp.FixmedinsName = miConfig.OrgName
  19808. pp.FixmedinsCode = miConfig.Code
  19809. pp.RequestUrl = miConfig.Url
  19810. pp.Cainfo = miConfig.Cainfo
  19811. pp.SecretKey = miConfig.SecretKey
  19812. pp.AccessKey = miConfig.AccessKey
  19813. pp.OpterName = curRoles.UserName
  19814. client := &http.Client{}
  19815. var req *http.Request
  19816. data := make(map[string]interface{})
  19817. data["struct4101"] = struct4101
  19818. data["pp"] = pp
  19819. bytesData, _ := json.Marshal(data)
  19820. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19821. resp, _ := client.Do(req)
  19822. defer resp.Body.Close()
  19823. body, ioErr := ioutil.ReadAll(resp.Body)
  19824. if ioErr != nil {
  19825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19827. return
  19828. }
  19829. var respJSON map[string]interface{}
  19830. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19833. return
  19834. }
  19835. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19836. userJSONBytes, _ := json.Marshal(respJSON)
  19837. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19838. utils.ErrorLog("解析失败:%v", err)
  19839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19840. return
  19841. }
  19842. } else {
  19843. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19844. var dat map[string]interface{}
  19845. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19846. fmt.Println(dat)
  19847. } else {
  19848. fmt.Println(err)
  19849. }
  19850. userJSONBytes, _ := json.Marshal(dat)
  19851. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19852. utils.ErrorLog("解析失败:%v", err)
  19853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19854. return
  19855. }
  19856. }
  19857. if res.Infcode != 0 {
  19858. c.ServeSuccessJSON(map[string]interface{}{
  19859. "failed_code": -10,
  19860. "msg": res.ErrMsg,
  19861. })
  19862. return
  19863. } else {
  19864. //order.FaPiaoNumber = zero
  19865. //order.FaPiaoCode = last_order.FaPiaoCode
  19866. //service.UpdateOrder(order)
  19867. hisFundSettleListResult := &models.HisFundSettleListResult{
  19868. Number: res.Output.SetlListId,
  19869. Status: 1,
  19870. Ctime: time.Now().Unix(),
  19871. Mtime: time.Now().Unix(),
  19872. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19873. IsUpload: 1,
  19874. OrderId: order_id,
  19875. }
  19876. service.CreateUploadRecord(hisFundSettleListResult)
  19877. c.ServeSuccessJSON(map[string]interface{}{
  19878. "msg": "上传成功",
  19879. "result": hisFundSettleListResult,
  19880. })
  19881. return
  19882. }
  19883. }
  19884. func (c *HisApiController) GetSettleListHospital() {
  19885. order_id, _ := c.GetInt64("order_id")
  19886. admin_user_id, _ := c.GetInt64("admin_user_id")
  19887. order, _ := service.GetHisOrderByIDTwo(order_id)
  19888. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19889. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19890. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19891. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19892. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19893. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19894. if order.ID == 0 {
  19895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19896. return
  19897. }
  19898. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19899. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19900. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19901. fmt.Println(count)
  19902. var zero string
  19903. number := count + 1
  19904. if number >= 1000 {
  19905. zero = "0000" + strconv.FormatInt(number, 10)
  19906. } else if number >= 10000 {
  19907. zero = "000" + strconv.FormatInt(number, 10)
  19908. } else if number >= 100000 {
  19909. zero = "00" + strconv.FormatInt(number, 10)
  19910. } else if number >= 1000000 {
  19911. zero = "0" + strconv.FormatInt(number, 10)
  19912. } else {
  19913. zero = strconv.FormatInt(number, 10)
  19914. }
  19915. fmt.Println(zero)
  19916. struct4101 := service.Struct4101{
  19917. PsnNo: order.PsnNo,
  19918. MdtrtId: order.MdtrtId,
  19919. SetlId: order.SetlId,
  19920. PsnName: order.PsnName,
  19921. Gend: order.Gend,
  19922. Brdy: his.Brdy,
  19923. Age: int64(order.Age),
  19924. Naty: order.Naty,
  19925. PatnCertType: "01",
  19926. Certno: order.Certno,
  19927. Prfs: "90",
  19928. ConerName: roles[0].UserName,
  19929. PatnRlts: "99",
  19930. ConerAddr: miConfig.OrgName,
  19931. ConerTel: admin.Mobile,
  19932. HiType: order.Insutype,
  19933. Insuplc: miConfig.InsuplcAdmdvs,
  19934. MaindiagFlag: "1",
  19935. BillCode: order.SetlId,
  19936. BillNo: order.SetlId,
  19937. BizSn: order.Number,
  19938. PsnSelfPay: order.PsnPartAmt,
  19939. PsnOwnPay: order.PsnPartAmt,
  19940. AcctPay: order.AcctPay,
  19941. PsnCashpay: order.PsnCashPay,
  19942. HiPaymtd: "1",
  19943. Hsorg: miConfig.InsuplcAdmdvs,
  19944. HsorgOpter: miConfig.InsuplcAdmdvs,
  19945. MedinsFillPsn: curRoles.UserName,
  19946. MedinsFillDept: depart.Name,
  19947. IptMedType: "2",
  19948. AdmTime: his.InHosptialTime,
  19949. AdmEndTime: his.OutHosptialTime,
  19950. }
  19951. struct4101.SetlBegnDate = order.SetlTime
  19952. struct4101.SetlEndDate = order.SetlTime
  19953. //var rf []CustomFundPay
  19954. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19955. //
  19956. //var tempFunPays []service.CustomStruct
  19957. //for _, item := range rf {
  19958. // var tempFunPay service.CustomStruct
  19959. // tempFunPay.FundPayamt = item.FundPayamt
  19960. // tempFunPay.FundPayType = item.FundPayType
  19961. // tempFunPays = append(tempFunPays, tempFunPay)
  19962. //}
  19963. //struct4101.CustomStruct = tempFunPays
  19964. var tempDiaginfos []service.DiaginfoStructTwo
  19965. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19966. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19967. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19968. //for _, item := range infos {
  19969. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19970. //}
  19971. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19972. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19973. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19974. fmt.Println(diagnosis_ids_arr)
  19975. if order.UserOrgId == 10210 {
  19976. var diagnosis_ids_arr_two []int64
  19977. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19978. var config []*models.HisXtDiagnoseConfig
  19979. for _, id := range diagnosis_ids_arr_two {
  19980. //id, _ := strconv.ParseInt(item, 10, 64)
  19981. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19982. if diagnosisConfig.ID > 0 {
  19983. config = append(config, &diagnosisConfig)
  19984. }
  19985. }
  19986. for index, item := range config {
  19987. if item.ID > 0 {
  19988. if index == 0 {
  19989. var tempDiaginfo service.DiaginfoStructTwo
  19990. tempDiaginfo.DiagCode = item.CountryCode
  19991. tempDiaginfo.DiagName = item.CountryContentName
  19992. tempDiaginfo.DiagType = "1"
  19993. tempDiaginfo.MaindiagFlag = "1"
  19994. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19995. } else {
  19996. var tempDiaginfo service.DiaginfoStructTwo
  19997. tempDiaginfo.DiagCode = item.CountryCode
  19998. tempDiaginfo.DiagName = item.CountryContentName
  19999. tempDiaginfo.DiagType = "1"
  20000. tempDiaginfo.MaindiagFlag = "0"
  20001. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20002. }
  20003. }
  20004. }
  20005. struct4101.Diseinfo = tempDiaginfos
  20006. } else {
  20007. var config []*models.HisXtDiagnoseConfig
  20008. for _, item := range diagnosis_ids_arr {
  20009. id, _ := strconv.ParseInt(item, 10, 64)
  20010. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20011. if diagnosisConfig.ID > 0 {
  20012. config = append(config, &diagnosisConfig)
  20013. }
  20014. }
  20015. for index, item := range config {
  20016. if item.ID > 0 {
  20017. if index == 0 {
  20018. var tempDiaginfo service.DiaginfoStructTwo
  20019. tempDiaginfo.DiagCode = item.CountryCode
  20020. tempDiaginfo.DiagName = item.CountryContentName
  20021. tempDiaginfo.DiagType = "1"
  20022. tempDiaginfo.MaindiagFlag = "1"
  20023. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20024. } else {
  20025. var tempDiaginfo service.DiaginfoStructTwo
  20026. tempDiaginfo.DiagCode = item.CountryCode
  20027. tempDiaginfo.DiagName = item.CountryContentName
  20028. tempDiaginfo.DiagType = "1"
  20029. tempDiaginfo.MaindiagFlag = "0"
  20030. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20031. }
  20032. }
  20033. }
  20034. struct4101.Diseinfo = tempDiaginfos
  20035. }
  20036. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20037. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20038. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20039. tempOpspdiseinfo2.OprnOprtCode = ""
  20040. tempOpspdiseinfo2.OprnOprtName = ""
  20041. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20042. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20043. var iteminfo service.IteminfoStruct
  20044. var bedCostTotal float64 = 0 //床位总费
  20045. var bedCostSelfTotal float64 = 0 //床位自费
  20046. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20047. var operationCostTotal float64 = 0 //手术费
  20048. var operationCostSelfTotal float64 = 0 //手术费
  20049. var operationCostPartSelfTotal float64 = 0 //手术费
  20050. var otherCostTotal float64 = 0 //其他费用
  20051. var otherCostSelfTotal float64 = 0 //其他费用
  20052. var otherCostPartSelfTotal float64 = 0 //其他费用
  20053. var materialCostTotal float64 = 0 //材料费
  20054. var materialCostSelfTotal float64 = 0 //材料费
  20055. var materialCostPartSelfTotal float64 = 0 //材料费
  20056. var westernMedicineCostTotal float64 = 0 //西药费
  20057. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20058. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20059. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20060. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20061. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20062. var checkCostTotal float64 = 0 //检查费
  20063. var checkCostSelfTotal float64 = 0 //检查费
  20064. var checkCostPartSelfTotal float64 = 0 //检查费
  20065. var laboratoryCostTotal float64 = 0 //化验费
  20066. var laboratoryCostSelfTotal float64 = 0 //化验费
  20067. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20068. var treatCostTotal float64 = 0 //治疗费用
  20069. var treatCostSelfTotal float64 = 0 //治疗费用
  20070. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20071. decimal.DivisionPrecision = 2
  20072. var bed_fulamt_ownpay_amt float64 = 0
  20073. var operation_fulamt_ownpay_amt float64 = 0
  20074. var other_fulamt_ownpay_amt float64 = 0
  20075. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20076. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20077. var check_fulamt_ownpay_amt float64 = 0
  20078. var material_fulamt_ownpay_amt float64 = 0
  20079. var laboratory_fulamt_ownpay_amt float64 = 0
  20080. var treat_fulamt_ownpay_amt float64 = 0
  20081. var bed_claa_sunmfee float64 = 0
  20082. var bed_clab_amt float64 = 0
  20083. var bed_other_amt float64 = 0
  20084. var operation_claa_sunmfee float64 = 0
  20085. var operation_clab_amt float64 = 0
  20086. var operation_other_amt float64 = 0
  20087. var other_claa_sunmfee float64 = 0
  20088. var other_clab_amt float64 = 0
  20089. var other_other_amt float64 = 0
  20090. var westernMedicine_claa_sunmfee float64 = 0
  20091. var westernMedicine_clab_amt float64 = 0
  20092. var westernMedicine_other_amt float64 = 0
  20093. var chineseTraditional_claa_sunmfee float64 = 0
  20094. var chineseTraditional_clab_amt float64 = 0
  20095. var chineseTraditional_other_amt float64 = 0
  20096. var check_claa_sunmfee float64 = 0
  20097. var check_clab_amt float64 = 0
  20098. var check_other_amt float64 = 0
  20099. var material_claa_sunmfee float64 = 0
  20100. var material_clab_amt float64 = 0
  20101. var material_other_amt float64 = 0
  20102. var laboratory_claa_sunmfee float64 = 0
  20103. var laboratory_clab_amt float64 = 0
  20104. var laboratory_other_amt float64 = 0
  20105. var treat_claa_sunmfee float64 = 0
  20106. var treat_clab_amt float64 = 0
  20107. var treat_other_amt float64 = 0
  20108. for _, item := range order.HisOrderInfo {
  20109. if item.MedChrgitmType == "01" { //床位费
  20110. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20111. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20112. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20113. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20114. if item.ChrgitmLv == "1" {
  20115. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20116. }
  20117. if item.ChrgitmLv == "2" {
  20118. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20119. }
  20120. if item.ChrgitmLv == "3" {
  20121. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20122. }
  20123. }
  20124. if item.MedChrgitmType == "03" { //检查费
  20125. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20126. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20127. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20128. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20129. if item.ChrgitmLv == "1" {
  20130. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20131. }
  20132. if item.ChrgitmLv == "2" {
  20133. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20134. }
  20135. if item.ChrgitmLv == "3" {
  20136. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20137. }
  20138. }
  20139. if item.MedChrgitmType == "04" { //化验费
  20140. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20141. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20142. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20143. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20144. if item.ChrgitmLv == "1" {
  20145. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20146. }
  20147. if item.ChrgitmLv == "2" {
  20148. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20149. }
  20150. if item.ChrgitmLv == "3" {
  20151. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20152. }
  20153. }
  20154. if item.MedChrgitmType == "05" { //治疗费
  20155. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20156. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20157. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20158. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20159. if item.ChrgitmLv == "1" {
  20160. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20161. }
  20162. if item.ChrgitmLv == "2" {
  20163. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20164. }
  20165. if item.ChrgitmLv == "3" {
  20166. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20167. }
  20168. }
  20169. if item.MedChrgitmType == "06" { //手术费
  20170. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20171. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20172. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20173. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20174. if item.ChrgitmLv == "1" {
  20175. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20176. }
  20177. if item.ChrgitmLv == "2" {
  20178. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20179. }
  20180. if item.ChrgitmLv == "3" {
  20181. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20182. }
  20183. }
  20184. if item.MedChrgitmType == "08" { //材料费
  20185. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20186. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20187. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20188. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20189. if item.ChrgitmLv == "1" {
  20190. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20191. }
  20192. if item.ChrgitmLv == "2" {
  20193. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20194. }
  20195. if item.ChrgitmLv == "3" {
  20196. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20197. }
  20198. }
  20199. if item.MedChrgitmType == "09" { //西药费
  20200. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20201. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20202. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20203. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20204. if item.ChrgitmLv == "1" {
  20205. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20206. }
  20207. if item.ChrgitmLv == "2" {
  20208. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20209. }
  20210. if item.ChrgitmLv == "3" {
  20211. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20212. }
  20213. }
  20214. if item.MedChrgitmType == "11" { //中成费
  20215. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20216. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20217. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20218. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20219. if item.ChrgitmLv == "1" {
  20220. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20221. }
  20222. if item.ChrgitmLv == "2" {
  20223. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20224. }
  20225. if item.ChrgitmLv == "3" {
  20226. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20227. }
  20228. }
  20229. if item.MedChrgitmType == "14" { //其他费
  20230. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20231. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20232. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20233. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20234. if item.ChrgitmLv == "1" {
  20235. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20236. }
  20237. if item.ChrgitmLv == "2" {
  20238. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20239. }
  20240. if item.ChrgitmLv == "3" {
  20241. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20242. }
  20243. }
  20244. }
  20245. var iteminfoStructs []service.IteminfoStruct
  20246. if bedCostTotal != 0 {
  20247. iteminfo.MedChrgitm = "01"
  20248. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20249. iteminfo.Amt = bedCostTotal
  20250. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20251. iteminfo.ClabAmt = bed_clab_amt
  20252. iteminfo.OthAmt = bed_other_amt
  20253. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20254. }
  20255. if checkCostTotal != 0 {
  20256. iteminfo.MedChrgitm = "03"
  20257. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20258. iteminfo.Amt = checkCostTotal
  20259. iteminfo.ClaaSumfee = check_claa_sunmfee
  20260. iteminfo.ClabAmt = check_clab_amt
  20261. iteminfo.OthAmt = check_other_amt
  20262. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20263. }
  20264. if laboratoryCostTotal != 0 {
  20265. iteminfo.MedChrgitm = "04"
  20266. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20267. iteminfo.Amt = laboratoryCostTotal
  20268. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20269. iteminfo.ClabAmt = laboratory_clab_amt
  20270. iteminfo.OthAmt = laboratory_other_amt
  20271. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20272. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20273. }
  20274. if treatCostTotal != 0 {
  20275. iteminfo.MedChrgitm = "05"
  20276. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20277. iteminfo.Amt = treatCostTotal
  20278. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20279. iteminfo.ClabAmt = treat_clab_amt
  20280. iteminfo.OthAmt = treat_other_amt
  20281. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20282. //(struct4101.IteminfoStruct, iteminfo)
  20283. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20284. }
  20285. if operationCostTotal != 0 {
  20286. iteminfo.MedChrgitm = "06"
  20287. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20288. iteminfo.Amt = operationCostTotal
  20289. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20290. iteminfo.ClabAmt = operation_clab_amt
  20291. iteminfo.OthAmt = operation_other_amt
  20292. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20293. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20294. }
  20295. if materialCostTotal != 0 {
  20296. iteminfo.MedChrgitm = "08"
  20297. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20298. iteminfo.Amt = materialCostTotal
  20299. iteminfo.ClaaSumfee = material_claa_sunmfee
  20300. iteminfo.ClabAmt = material_clab_amt
  20301. iteminfo.OthAmt = material_other_amt
  20302. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20303. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20304. }
  20305. if westernMedicineCostTotal != 0 {
  20306. iteminfo.MedChrgitm = "09"
  20307. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20308. iteminfo.Amt = westernMedicineCostTotal
  20309. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20310. iteminfo.ClabAmt = westernMedicine_clab_amt
  20311. iteminfo.OthAmt = westernMedicine_other_amt
  20312. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20313. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20314. }
  20315. if chineseTraditionalMedicineCostTotal != 0 {
  20316. iteminfo.MedChrgitm = "11"
  20317. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20318. iteminfo.Amt = westernMedicineCostTotal
  20319. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20320. iteminfo.ClabAmt = westernMedicine_clab_amt
  20321. iteminfo.OthAmt = westernMedicine_other_amt
  20322. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20323. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20324. }
  20325. if otherCostTotal != 0 {
  20326. iteminfo.MedChrgitm = "14"
  20327. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20328. iteminfo.Amt = otherCostTotal
  20329. iteminfo.ClaaSumfee = other_claa_sunmfee
  20330. iteminfo.ClabAmt = other_clab_amt
  20331. iteminfo.OthAmt = other_other_amt
  20332. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20333. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20334. }
  20335. struct4101.IteminfoStruct = iteminfoStructs
  20336. struct4101.Ntly = "中国"
  20337. struct4101.AdmCaty = "A03.06"
  20338. var resOther ResultSeventeenOther
  20339. var res ResultSeventeen
  20340. if miConfig.MdtrtareaAdmvs == "150499" {
  20341. var pp models.PublicParams
  20342. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20343. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20344. pp.FixmedinsName = miConfig.OrgName
  20345. pp.FixmedinsCode = miConfig.Code
  20346. pp.RequestUrl = miConfig.Url
  20347. pp.Cainfo = miConfig.Cainfo
  20348. pp.SecretKey = miConfig.SecretKey
  20349. pp.AccessKey = miConfig.AccessKey
  20350. pp.OpterName = curRoles.UserName
  20351. client := &http.Client{}
  20352. var req *http.Request
  20353. data := make(map[string]interface{})
  20354. data["struct4101"] = struct4101
  20355. data["pp"] = pp
  20356. bytesData, _ := json.Marshal(data)
  20357. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20358. resp, _ := client.Do(req)
  20359. defer resp.Body.Close()
  20360. body, ioErr := ioutil.ReadAll(resp.Body)
  20361. if ioErr != nil {
  20362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20364. return
  20365. }
  20366. var respJSON map[string]interface{}
  20367. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20370. return
  20371. }
  20372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20373. userJSONBytes, _ := json.Marshal(respJSON)
  20374. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20375. utils.ErrorLog("解析失败:%v", err)
  20376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20377. return
  20378. }
  20379. res.InfRefmsgid = resOther.InfRefmsgid
  20380. res.Output = resOther.Output
  20381. res.ErrMsg = resOther.ErrMsg
  20382. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20383. res.Infcode = infocode
  20384. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20385. var pp models.PublicParams
  20386. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20387. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20388. pp.FixmedinsName = miConfig.OrgName
  20389. pp.FixmedinsCode = miConfig.Code
  20390. pp.RequestUrl = miConfig.Url
  20391. pp.Cainfo = miConfig.Cainfo
  20392. pp.SecretKey = miConfig.SecretKey
  20393. pp.AccessKey = miConfig.AccessKey
  20394. pp.OpterName = curRoles.UserName
  20395. result, _ := service.Jxyb4101(struct4101, pp)
  20396. var dat map[string]interface{}
  20397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20398. fmt.Println(dat)
  20399. } else {
  20400. fmt.Println(err)
  20401. }
  20402. userJSONBytes, _ := json.Marshal(dat)
  20403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20404. utils.ErrorLog("解析失败:%v", err)
  20405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20406. return
  20407. }
  20408. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20409. var pp models.PublicParams
  20410. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20411. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20412. pp.FixmedinsName = miConfig.OrgName
  20413. pp.FixmedinsCode = miConfig.Code
  20414. pp.RequestUrl = miConfig.Url
  20415. pp.Cainfo = miConfig.Cainfo
  20416. pp.SecretKey = miConfig.SecretKey
  20417. pp.AccessKey = miConfig.AccessKey
  20418. pp.OpterName = curRoles.UserName
  20419. result, _ := service.Jxyb4101(struct4101, pp)
  20420. var dat map[string]interface{}
  20421. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20422. fmt.Println(dat)
  20423. } else {
  20424. fmt.Println(err)
  20425. }
  20426. userJSONBytes, _ := json.Marshal(dat)
  20427. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20428. utils.ErrorLog("解析失败:%v", err)
  20429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20430. return
  20431. }
  20432. } else {
  20433. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20434. var dat map[string]interface{}
  20435. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20436. fmt.Println(dat)
  20437. } else {
  20438. fmt.Println(err)
  20439. }
  20440. userJSONBytes, _ := json.Marshal(dat)
  20441. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20442. utils.ErrorLog("解析失败:%v", err)
  20443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20444. return
  20445. }
  20446. }
  20447. if res.Infcode != 0 {
  20448. c.ServeSuccessJSON(map[string]interface{}{
  20449. "failed_code": -10,
  20450. "msg": res.ErrMsg,
  20451. })
  20452. return
  20453. } else {
  20454. if miConfig.MdtrtareaAdmvs != "150499" {
  20455. order.FaPiaoNumber = zero
  20456. order.FaPiaoCode = last_order.FaPiaoCode
  20457. service.UpdateOrder(order)
  20458. }
  20459. hisFundSettleListResult := &models.HisFundSettleListResult{
  20460. Number: res.Output.SetlListId,
  20461. Status: 1,
  20462. Ctime: time.Now().Unix(),
  20463. Mtime: time.Now().Unix(),
  20464. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20465. IsUpload: 1,
  20466. OrderId: order_id,
  20467. }
  20468. service.CreateUploadRecord(hisFundSettleListResult)
  20469. c.ServeSuccessJSON(map[string]interface{}{
  20470. "msg": "上传成功",
  20471. "result": hisFundSettleListResult,
  20472. })
  20473. return
  20474. }
  20475. }
  20476. //func (c *HisApiController) GetBatchSettleList() {
  20477. // orders, _ := service.GetAllHisOrder(10106)
  20478. // for _, item := range orders {
  20479. // order_id := item.ID
  20480. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20481. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20482. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20483. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20484. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20485. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20486. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20487. //
  20488. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20489. //
  20490. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20491. //
  20492. // if order.ID == 0 {
  20493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20494. // return
  20495. // }
  20496. // if his.BalanceAccountsType == 2 {
  20497. // continue
  20498. // }
  20499. // struct4101 := service.Struct4101{
  20500. // PsnNo: order.PsnNo,
  20501. // MdtrtId: order.MdtrtId,
  20502. // SetlId: order.SetlId,
  20503. // PsnName: order.PsnName,
  20504. // Gend: order.Gend,
  20505. // Brdy: his.Brdy,
  20506. // Age: his.Age,
  20507. // Naty: order.Naty,
  20508. // PatnCertType: "01",
  20509. // Certno: order.Certno,
  20510. // Prfs: "90",
  20511. // ConerName: roles[0].UserName,
  20512. // PatnRlts: "99",
  20513. // ConerAddr: miConfig.OrgName,
  20514. // ConerTel: admin.Mobile,
  20515. // HiType: order.Insutype,
  20516. // Insuplc: his.InsuplcAdmdvs,
  20517. // MaindiagFlag: "1",
  20518. // BillCode: order.SetlId,
  20519. // BillNo: order.SetlId,
  20520. // BizSn: order.Number,
  20521. // PsnSelfPay: order.PsnPartAmt,
  20522. // PsnOwnPay: order.PsnPartAmt,
  20523. // AcctPay: order.AcctPay,
  20524. // PsnCashpay: order.PsnCashPay,
  20525. // HiPaymtd: "1",
  20526. // Hsorg: his.InsuplcAdmdvs,
  20527. // HsorgOpter: his.InsuplcAdmdvs,
  20528. // MedinsFillPsn: curRoles.UserName,
  20529. // MedinsFillDept: depart.Name,
  20530. // IptMedType: "2",
  20531. // }
  20532. // struct4101.SetlBegnDate = order.SetlTime
  20533. // struct4101.SetlEndDate = order.SetlTime
  20534. // //if order.SettleType == 1 {
  20535. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20536. // // dateStr := t.Format("2006-01-02")
  20537. // // struct4101.SetlBegnDate = dateStr
  20538. // // struct4101.SetlEndDate = dateStr
  20539. // //} else {
  20540. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20541. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20542. // // dateStartStr := t.Format("2006-01-02")
  20543. // // dateEndStr := t2.Format("2006-01-02")
  20544. // // struct4101.SetlBegnDate = dateStartStr
  20545. // // struct4101.SetlEndDate = dateEndStr
  20546. // //}
  20547. //
  20548. // var rf []CustomFundPay
  20549. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20550. //
  20551. // var tempFunPays []service.CustomStruct
  20552. // var tempFunPay610100 service.CustomStruct
  20553. //
  20554. // for _, item := range rf {
  20555. // if item.FundPayType == "610100" {
  20556. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20557. // tempFunPay610100.FundPayType = item.FundPayType
  20558. // } else {
  20559. // var tempFunPay service.CustomStruct
  20560. // tempFunPay.FundPayamt = item.FundPayamt
  20561. // tempFunPay.FundPayType = item.FundPayType
  20562. // tempFunPays = append(tempFunPays, tempFunPay)
  20563. // }
  20564. // }
  20565. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20566. // struct4101.CustomStruct = tempFunPays
  20567. //
  20568. // var tempDiaginfos []service.DiaginfoStructTwo
  20569. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20570. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20571. //
  20572. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20573. // var config []*models.HisXtDiagnoseConfig
  20574. // for _, item := range diagnosis_ids {
  20575. // id, _ := strconv.ParseInt(item, 10, 64)
  20576. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20577. // config = append(config, &diagnosisConfig)
  20578. // }
  20579. //
  20580. // for index, item := range config {
  20581. // if index == 0 {
  20582. // var tempDiaginfo service.DiaginfoStructTwo
  20583. // tempDiaginfo.DiagCode = item.CountryCode
  20584. // tempDiaginfo.DiagName = item.CountryContentName
  20585. // tempDiaginfo.DiagType = "1"
  20586. // tempDiaginfo.MaindiagFlag = "1"
  20587. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20588. // } else {
  20589. //
  20590. // var tempDiaginfo service.DiaginfoStructTwo
  20591. // tempDiaginfo.DiagCode = item.CountryCode
  20592. // tempDiaginfo.DiagName = item.CountryContentName
  20593. // tempDiaginfo.DiagType = "2"
  20594. // tempDiaginfo.MaindiagFlag = "0"
  20595. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20596. // }
  20597. // }
  20598. // struct4101.Diseinfo = tempDiaginfos
  20599. //
  20600. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20601. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20602. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20603. // tempOpspdiseinfo2.OprnOprtCode = ""
  20604. // tempOpspdiseinfo2.OprnOprtName = ""
  20605. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20606. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20607. //
  20608. // var iteminfo service.IteminfoStruct
  20609. //
  20610. // var bedCostTotal float64 = 0 //床位总费
  20611. // var bedCostSelfTotal float64 = 0 //床位自费
  20612. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20613. //
  20614. // var examineCostTotal float64 = 0 //诊查总费
  20615. // var examineCostSelfTotal float64 = 0 //诊查自费
  20616. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20617. //
  20618. // var nursingCostTotal float64 = 0 //护理总费
  20619. // var nursingCostSelfTotal float64 = 0 //护理自费
  20620. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20621. //
  20622. // var chineseMedicineCostTotal float64 = 0 //中成药
  20623. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20624. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20625. //
  20626. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20627. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20628. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20629. //
  20630. // var registerCostTotal float64 = 0 //一般诊疗费
  20631. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20632. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20633. //
  20634. // var operationCostTotal float64 = 0 //手术费
  20635. // var operationCostSelfTotal float64 = 0 //手术费
  20636. // var operationCostPartSelfTotal float64 = 0 //手术费
  20637. //
  20638. // var otherCostTotal float64 = 0 //其他费用
  20639. // var otherCostSelfTotal float64 = 0 //其他费用
  20640. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20641. //
  20642. // var materialCostTotal float64 = 0 //材料费
  20643. // var materialCostSelfTotal float64 = 0 //材料费
  20644. // var materialCostPartSelfTotal float64 = 0 //材料费
  20645. //
  20646. // var westernMedicineCostTotal float64 = 0 //西药费
  20647. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20648. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20649. //
  20650. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20651. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20652. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20653. //
  20654. // var checkCostTotal float64 = 0 //检查费
  20655. // var checkCostSelfTotal float64 = 0 //检查费
  20656. // var checkCostPartSelfTotal float64 = 0 //检查费
  20657. //
  20658. // var laboratoryCostTotal float64 = 0 //化验费
  20659. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20660. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20661. //
  20662. // var treatCostTotal float64 = 0 //治疗费用
  20663. // var treatCostSelfTotal float64 = 0 //治疗费用
  20664. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20665. //
  20666. // decimal.DivisionPrecision = 2
  20667. //
  20668. // var bed_fulamt_ownpay_amt float64 = 0
  20669. //
  20670. // var examine_fulamt_ownpay_amt float64 = 0
  20671. //
  20672. // var nursing_fulamt_ownpay_amt float64 = 0
  20673. //
  20674. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20675. //
  20676. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20677. //
  20678. // var register_fulamt_ownpay_amt float64 = 0
  20679. //
  20680. // var operation_fulamt_ownpay_amt float64 = 0
  20681. // var other_fulamt_ownpay_amt float64 = 0
  20682. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20683. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20684. // var check_fulamt_ownpay_amt float64 = 0
  20685. // var material_fulamt_ownpay_amt float64 = 0
  20686. // var laboratory_fulamt_ownpay_amt float64 = 0
  20687. // var treat_fulamt_ownpay_amt float64 = 0
  20688. //
  20689. // var bed_claa_sunmfee float64 = 0
  20690. // var bed_clab_amt float64 = 0
  20691. // var bed_other_amt float64 = 0
  20692. //
  20693. // var examine_claa_sunmfee float64 = 0
  20694. // var examine_clab_amt float64 = 0
  20695. // var examine_other_amt float64 = 0
  20696. //
  20697. // var nursing_claa_sunmfee float64 = 0
  20698. // var nursing_clab_amt float64 = 0
  20699. // var nursing_other_amt float64 = 0
  20700. //
  20701. // var chinese_medicine_claa_sunmfee float64 = 0
  20702. // var chinese_medicine_clab_amt float64 = 0
  20703. // var chinese_medicine_other_amt float64 = 0
  20704. //
  20705. // var commonly_treatment_claa_sunmfee float64 = 0
  20706. // var commonly_treatment_clab_amt float64 = 0
  20707. // var commonly_treatment_other_amt float64 = 0
  20708. //
  20709. // var operation_claa_sunmfee float64 = 0
  20710. // var operation_clab_amt float64 = 0
  20711. // var operation_other_amt float64 = 0
  20712. //
  20713. // var other_claa_sunmfee float64 = 0
  20714. // var other_clab_amt float64 = 0
  20715. // var other_other_amt float64 = 0
  20716. //
  20717. // var westernMedicine_claa_sunmfee float64 = 0
  20718. // var westernMedicine_clab_amt float64 = 0
  20719. // var westernMedicine_other_amt float64 = 0
  20720. //
  20721. // var chineseTraditional_claa_sunmfee float64 = 0
  20722. // var chineseTraditional_clab_amt float64 = 0
  20723. // var chineseTraditional_other_amt float64 = 0
  20724. //
  20725. // var check_claa_sunmfee float64 = 0
  20726. // var check_clab_amt float64 = 0
  20727. // var check_other_amt float64 = 0
  20728. //
  20729. // var material_claa_sunmfee float64 = 0
  20730. // var material_clab_amt float64 = 0
  20731. // var material_other_amt float64 = 0
  20732. //
  20733. // var laboratory_claa_sunmfee float64 = 0
  20734. // var laboratory_clab_amt float64 = 0
  20735. // var laboratory_other_amt float64 = 0
  20736. //
  20737. // var treat_claa_sunmfee float64 = 0
  20738. // var treat_clab_amt float64 = 0
  20739. // var treat_other_amt float64 = 0
  20740. //
  20741. // var register_claa_sunmfee float64 = 0
  20742. // var register_clab_amt float64 = 0
  20743. // var register_other_amt float64 = 0
  20744. //
  20745. // for _, item := range order.HisOrderInfo {
  20746. // if item.MedChrgitmType == "01" { //床位费
  20747. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20748. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20749. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20750. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20751. // if item.ChrgitmLv == "1" {
  20752. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20753. // }
  20754. // if item.ChrgitmLv == "2" {
  20755. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20756. //
  20757. // }
  20758. // if item.ChrgitmLv == "3" {
  20759. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20760. // }
  20761. //
  20762. // }
  20763. //
  20764. // if item.MedChrgitmType == "02" { //诊查
  20765. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20766. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20767. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20768. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20769. // if item.ChrgitmLv == "1" {
  20770. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20771. // }
  20772. // if item.ChrgitmLv == "2" {
  20773. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20774. //
  20775. // }
  20776. // if item.ChrgitmLv == "3" {
  20777. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20778. // }
  20779. //
  20780. // }
  20781. //
  20782. // if item.MedChrgitmType == "03" { //检查费
  20783. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20784. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20785. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20786. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20787. // if item.ChrgitmLv == "1" {
  20788. //
  20789. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20790. //
  20791. // }
  20792. // if item.ChrgitmLv == "2" {
  20793. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20794. //
  20795. // }
  20796. // if item.ChrgitmLv == "3" {
  20797. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20798. // }
  20799. // }
  20800. //
  20801. // if item.MedChrgitmType == "04" { //化验费
  20802. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20803. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20804. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20805. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20806. // if item.ChrgitmLv == "1" {
  20807. //
  20808. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20809. //
  20810. // }
  20811. // if item.ChrgitmLv == "2" {
  20812. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20813. //
  20814. // }
  20815. // if item.ChrgitmLv == "3" {
  20816. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20817. // }
  20818. // }
  20819. //
  20820. // if item.MedChrgitmType == "05" { //治疗费
  20821. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20822. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20823. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20824. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20825. // if item.ChrgitmLv == "1" {
  20826. //
  20827. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20828. //
  20829. // }
  20830. // if item.ChrgitmLv == "2" {
  20831. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20832. //
  20833. // }
  20834. // if item.ChrgitmLv == "3" {
  20835. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20836. // }
  20837. // }
  20838. //
  20839. // if item.MedChrgitmType == "06" { //手术费
  20840. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20841. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20842. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20843. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20844. //
  20845. // if item.ChrgitmLv == "1" {
  20846. //
  20847. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20848. //
  20849. // }
  20850. // if item.ChrgitmLv == "2" {
  20851. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20852. //
  20853. // }
  20854. // if item.ChrgitmLv == "3" {
  20855. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20856. // }
  20857. // }
  20858. //
  20859. // if item.MedChrgitmType == "07" { //手术费
  20860. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20861. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20862. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20863. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20864. //
  20865. // if item.ChrgitmLv == "1" {
  20866. //
  20867. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20868. //
  20869. // }
  20870. // if item.ChrgitmLv == "2" {
  20871. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20872. //
  20873. // }
  20874. // if item.ChrgitmLv == "3" {
  20875. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20876. // }
  20877. // }
  20878. //
  20879. // if item.MedChrgitmType == "08" { //材料费
  20880. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20881. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20882. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20883. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20884. // if item.ChrgitmLv == "1" {
  20885. //
  20886. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20887. //
  20888. // }
  20889. // if item.ChrgitmLv == "2" {
  20890. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20891. //
  20892. // }
  20893. // if item.ChrgitmLv == "3" {
  20894. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20895. // }
  20896. // }
  20897. // if item.MedChrgitmType == "09" { //西药费
  20898. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20899. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20900. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20901. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20902. // if item.ChrgitmLv == "1" {
  20903. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20904. // }
  20905. // if item.ChrgitmLv == "2" {
  20906. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20907. // }
  20908. // if item.ChrgitmLv == "3" {
  20909. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20910. // }
  20911. // }
  20912. // if item.MedChrgitmType == "10" { //中药饮片
  20913. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20914. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20915. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20916. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20917. // if item.ChrgitmLv == "1" {
  20918. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20919. // }
  20920. // if item.ChrgitmLv == "2" {
  20921. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20922. // }
  20923. // if item.ChrgitmLv == "3" {
  20924. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20925. // }
  20926. // }
  20927. //
  20928. // if item.MedChrgitmType == "11" { //中成费
  20929. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20930. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20931. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20932. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20933. // if item.ChrgitmLv == "1" {
  20934. //
  20935. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20936. //
  20937. // }
  20938. // if item.ChrgitmLv == "2" {
  20939. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20940. //
  20941. // }
  20942. // if item.ChrgitmLv == "3" {
  20943. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20944. // }
  20945. // }
  20946. //
  20947. // if item.MedChrgitmType == "12" { //中成费
  20948. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20949. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20950. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20951. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20952. // if item.ChrgitmLv == "1" {
  20953. //
  20954. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20955. //
  20956. // }
  20957. // if item.ChrgitmLv == "2" {
  20958. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20959. //
  20960. // }
  20961. // if item.ChrgitmLv == "3" {
  20962. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20963. // }
  20964. // }
  20965. //
  20966. // if item.MedChrgitmType == "13" { //中成费
  20967. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20968. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20969. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20970. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20971. // if item.ChrgitmLv == "1" {
  20972. //
  20973. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20974. //
  20975. // }
  20976. // if item.ChrgitmLv == "2" {
  20977. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20978. //
  20979. // }
  20980. // if item.ChrgitmLv == "3" {
  20981. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20982. // }
  20983. // }
  20984. //
  20985. // if item.MedChrgitmType == "14" { //其他费
  20986. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20987. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20988. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20989. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20990. // if item.ChrgitmLv == "1" {
  20991. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20992. //
  20993. // }
  20994. // if item.ChrgitmLv == "2" {
  20995. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20996. //
  20997. // }
  20998. // if item.ChrgitmLv == "3" {
  20999. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21000. // }
  21001. // }
  21002. //
  21003. // }
  21004. //
  21005. // var iteminfoStructs []service.IteminfoStruct
  21006. //
  21007. // if bedCostTotal != 0 {
  21008. // iteminfo.MedChrgitm = "01"
  21009. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21010. // iteminfo.Amt = bedCostTotal
  21011. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  21012. // iteminfo.ClabAmt = bed_clab_amt
  21013. // iteminfo.OthAmt = bed_other_amt
  21014. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21015. // }
  21016. //
  21017. // if examineCostTotal != 0 {
  21018. // iteminfo.MedChrgitm = "02"
  21019. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  21020. // iteminfo.Amt = examineCostTotal
  21021. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  21022. // iteminfo.ClabAmt = examine_clab_amt
  21023. // iteminfo.OthAmt = examine_other_amt
  21024. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21025. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21026. // }
  21027. //
  21028. // if checkCostTotal != 0 {
  21029. // iteminfo.MedChrgitm = "03"
  21030. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21031. // iteminfo.Amt = checkCostTotal
  21032. // iteminfo.ClaaSumfee = check_claa_sunmfee
  21033. // iteminfo.ClabAmt = check_clab_amt
  21034. // iteminfo.OthAmt = check_other_amt
  21035. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21036. //
  21037. // }
  21038. //
  21039. // if laboratoryCostTotal != 0 {
  21040. // iteminfo.MedChrgitm = "04"
  21041. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21042. // iteminfo.Amt = laboratoryCostTotal
  21043. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21044. // iteminfo.ClabAmt = laboratory_clab_amt
  21045. // iteminfo.OthAmt = laboratory_other_amt
  21046. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21047. //
  21048. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21049. //
  21050. // }
  21051. //
  21052. // if treatCostTotal != 0 {
  21053. // iteminfo.MedChrgitm = "05"
  21054. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21055. // iteminfo.Amt = treatCostTotal
  21056. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  21057. // iteminfo.ClabAmt = treat_clab_amt
  21058. // iteminfo.OthAmt = treat_other_amt
  21059. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21060. // //(struct4101.IteminfoStruct, iteminfo)
  21061. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21062. // }
  21063. //
  21064. // if operationCostTotal != 0 {
  21065. // iteminfo.MedChrgitm = "06"
  21066. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21067. // iteminfo.Amt = operationCostTotal
  21068. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  21069. // iteminfo.ClabAmt = operation_clab_amt
  21070. // iteminfo.OthAmt = operation_other_amt
  21071. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21072. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21073. // }
  21074. //
  21075. // if nursingCostTotal != 0 {
  21076. // iteminfo.MedChrgitm = "07"
  21077. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  21078. // iteminfo.Amt = nursingCostTotal
  21079. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  21080. // iteminfo.ClabAmt = nursing_clab_amt
  21081. // iteminfo.OthAmt = nursing_other_amt
  21082. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21083. // }
  21084. //
  21085. // if materialCostTotal != 0 {
  21086. // iteminfo.MedChrgitm = "08"
  21087. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21088. // iteminfo.Amt = materialCostTotal
  21089. // iteminfo.ClaaSumfee = material_claa_sunmfee
  21090. // iteminfo.ClabAmt = material_clab_amt
  21091. // iteminfo.OthAmt = material_other_amt
  21092. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21093. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21094. // }
  21095. //
  21096. // if westernMedicineCostTotal != 0 {
  21097. // iteminfo.MedChrgitm = "09"
  21098. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21099. // iteminfo.Amt = westernMedicineCostTotal
  21100. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21101. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21102. // iteminfo.OthAmt = westernMedicine_other_amt
  21103. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21104. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21105. //
  21106. // }
  21107. //
  21108. // if chineseMedicineCostTotal != 0 {
  21109. // iteminfo.MedChrgitm = "10"
  21110. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  21111. // iteminfo.Amt = chineseMedicineCostTotal
  21112. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  21113. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  21114. // iteminfo.OthAmt = chinese_medicine_other_amt
  21115. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21116. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21117. //
  21118. // }
  21119. //
  21120. // if chineseTraditionalMedicineCostTotal != 0 {
  21121. // iteminfo.MedChrgitm = "11"
  21122. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21123. // iteminfo.Amt = westernMedicineCostTotal
  21124. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21125. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21126. // iteminfo.OthAmt = westernMedicine_other_amt
  21127. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21128. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21129. //
  21130. // }
  21131. //
  21132. // if commonlyTreatmentCostTotal != 0 {
  21133. // iteminfo.MedChrgitm = "12"
  21134. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21135. // iteminfo.Amt = commonlyTreatmentCostTotal
  21136. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21137. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21138. // iteminfo.OthAmt = commonly_treatment_other_amt
  21139. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21140. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21141. //
  21142. // }
  21143. //
  21144. // if registerCostTotal != 0 {
  21145. // iteminfo.MedChrgitm = "13"
  21146. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21147. // iteminfo.Amt = registerCostTotal
  21148. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21149. // iteminfo.ClabAmt = register_clab_amt
  21150. // iteminfo.OthAmt = register_other_amt
  21151. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21152. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21153. //
  21154. // }
  21155. //
  21156. // if otherCostTotal != 0 {
  21157. // iteminfo.MedChrgitm = "14"
  21158. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21159. // iteminfo.Amt = otherCostTotal
  21160. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21161. // iteminfo.ClabAmt = other_clab_amt
  21162. // iteminfo.OthAmt = other_other_amt
  21163. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21164. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21165. //
  21166. // }
  21167. // struct4101.IteminfoStruct = iteminfoStructs
  21168. // time_arr := strings.Split(order.SetlTime, " ")
  21169. // struct4101.AdmTime = time_arr[0]
  21170. // struct4101.AdmEndTime = time_arr[0]
  21171. //
  21172. // struct4101.DoctorName = doctor.UserName
  21173. // struct4101.DoctorCode = doctor.DoctorNumber
  21174. //
  21175. // struct4101.Ntly = "中国"
  21176. // struct4101.AdmCaty = "A03.06"
  21177. // var res ResultSeventeen
  21178. // if miConfig.MdtrtareaAdmvs == "421300" {
  21179. // data := make(map[string]interface{})
  21180. // data["struct4101"] = struct4101
  21181. // data["secret_key"] = miConfig.SecretKey
  21182. // data["org_name"] = miConfig.OrgName
  21183. // data["opera"] = curRoles.UserName
  21184. // data["code"] = miConfig.Code
  21185. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21186. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21187. //
  21188. // client := &http.Client{}
  21189. // bytesData, _ := json.Marshal(data)
  21190. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21191. // resp, _ := client.Do(req)
  21192. // defer resp.Body.Close()
  21193. // body, ioErr := ioutil.ReadAll(resp.Body)
  21194. // if ioErr != nil {
  21195. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21196. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21197. // return
  21198. // }
  21199. // var respJSON map[string]interface{}
  21200. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21201. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21203. // return
  21204. // }
  21205. //
  21206. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21207. // userJSONBytes, _ := json.Marshal(respJSON)
  21208. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21209. // utils.ErrorLog("解析失败:%v", err)
  21210. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21211. // adminUser := c.GetAdminUserInfo()
  21212. // errlog := &models.HisOrderError{
  21213. // UserOrgId: adminUser.CurrentOrgId,
  21214. // Ctime: time.Now().Unix(),
  21215. // Mtime: time.Now().Unix(),
  21216. // ErrMsg: res.ErrMsg + "解析失败",
  21217. // Status: 1,
  21218. // PatientId: order_id,
  21219. // Stage: 10088,
  21220. // }
  21221. // service.CreateErrMsgLog(errlog)
  21222. // continue
  21223. // }
  21224. //
  21225. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21226. // data := make(map[string]interface{})
  21227. // data["struct4101"] = struct4101
  21228. // data["secret_key"] = miConfig.SecretKey
  21229. // data["org_name"] = miConfig.OrgName
  21230. // data["opera"] = curRoles.UserName
  21231. // data["code"] = miConfig.Code
  21232. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21233. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21234. //
  21235. // client := &http.Client{}
  21236. // bytesData, _ := json.Marshal(data)
  21237. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21238. // resp, _ := client.Do(req)
  21239. // defer resp.Body.Close()
  21240. // body, ioErr := ioutil.ReadAll(resp.Body)
  21241. // if ioErr != nil {
  21242. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21243. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21244. // return
  21245. // }
  21246. // var respJSON map[string]interface{}
  21247. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21248. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21250. // return
  21251. // }
  21252. //
  21253. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21254. // userJSONBytes, _ := json.Marshal(respJSON)
  21255. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21256. // utils.ErrorLog("解析失败:%v", err)
  21257. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21258. // adminUser := c.GetAdminUserInfo()
  21259. // errlog := &models.HisOrderError{
  21260. // UserOrgId: adminUser.CurrentOrgId,
  21261. // Ctime: time.Now().Unix(),
  21262. // Mtime: time.Now().Unix(),
  21263. // ErrMsg: res.ErrMsg + "解析失败",
  21264. // Status: 1,
  21265. // PatientId: order_id,
  21266. // Stage: 10088,
  21267. // }
  21268. // service.CreateErrMsgLog(errlog)
  21269. // continue
  21270. // }
  21271. //
  21272. // } else {
  21273. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21274. // fmt.Println(result)
  21275. //
  21276. // var dat map[string]interface{}
  21277. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21278. // fmt.Println(dat)
  21279. // } else {
  21280. // fmt.Println(err)
  21281. // }
  21282. // userJSONBytes, _ := json.Marshal(dat)
  21283. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21284. // utils.ErrorLog("解析失败:%v", err)
  21285. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21286. // adminUser := c.GetAdminUserInfo()
  21287. // errlog := &models.HisOrderError{
  21288. // UserOrgId: adminUser.CurrentOrgId,
  21289. // Ctime: time.Now().Unix(),
  21290. // Mtime: time.Now().Unix(),
  21291. // ErrMsg: res.ErrMsg + "解析失败",
  21292. // Status: 1,
  21293. // PatientId: order_id,
  21294. // Stage: 10106,
  21295. // }
  21296. // service.CreateErrMsgLog(errlog)
  21297. // continue
  21298. // }
  21299. // }
  21300. //
  21301. // if res.Infcode != 0 {
  21302. // adminUser := c.GetAdminUserInfo()
  21303. // errlog := &models.HisOrderError{
  21304. // UserOrgId: adminUser.CurrentOrgId,
  21305. // Ctime: time.Now().Unix(),
  21306. // Mtime: time.Now().Unix(),
  21307. // ErrMsg: res.ErrMsg,
  21308. // Status: 1,
  21309. // PatientId: order_id,
  21310. // Stage: 10106,
  21311. // }
  21312. // service.CreateErrMsgLog(errlog)
  21313. // continue
  21314. // } else {
  21315. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21316. // Number: res.Output.SetlListId,
  21317. // Status: 1,
  21318. // Ctime: time.Now().Unix(),
  21319. // Mtime: time.Now().Unix(),
  21320. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21321. // IsUpload: 1,
  21322. // OrderId: order_id,
  21323. // }
  21324. // service.CreateUploadRecord(hisFundSettleListResult)
  21325. // continue
  21326. // }
  21327. // }
  21328. //}
  21329. func (c *HisApiController) GetOrgInfo() {
  21330. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21331. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21332. }
  21333. func (c *HisApiController) GetHisPatientInfo() {
  21334. medical_insurance_card := c.GetString("medical_insurance_card")
  21335. id_card_type, _ := c.GetInt64("id_card_type")
  21336. id_card := c.GetString("id_card")
  21337. adminInfo := c.GetAdminUserInfo()
  21338. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21339. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21340. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21341. IdCardNo := ""
  21342. if id_card_type == 1 {
  21343. IdCardNo = medical_insurance_card
  21344. } else if id_card_type == 2 {
  21345. IdCardNo = id_card
  21346. }
  21347. if config.IsOpen == 1 {
  21348. 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
  21349. resp, requestErr := http.Get(api)
  21350. if requestErr != nil {
  21351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21352. return
  21353. }
  21354. defer resp.Body.Close()
  21355. body, ioErr := ioutil.ReadAll(resp.Body)
  21356. if ioErr != nil {
  21357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21359. return
  21360. }
  21361. var respJSON map[string]interface{}
  21362. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21365. return
  21366. }
  21367. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21368. userJSONBytes, _ := json.Marshal(userJSON)
  21369. var res ResultTwo
  21370. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21371. utils.ErrorLog("解析失败:%v", err)
  21372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21373. return
  21374. }
  21375. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21376. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21377. infoStr := string(Iinfos)
  21378. idetinfoStr := string(Idetinfos)
  21379. if res.Infcode == 0 {
  21380. his := models.VMHisPatient{
  21381. Status: 1,
  21382. Ctime: time.Now().Unix(),
  21383. Mtime: time.Now().Unix(),
  21384. PsnNo: res.Output.Baseinfo.PsnNo,
  21385. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21386. Certno: res.Output.Baseinfo.Certno,
  21387. PsnName: res.Output.Baseinfo.PsnName,
  21388. Gend: res.Output.Baseinfo.Gend,
  21389. Naty: res.Output.Baseinfo.Naty,
  21390. Iinfo: infoStr,
  21391. Idetinfo: idetinfoStr,
  21392. UserOrgId: adminInfo.CurrentOrgId,
  21393. IsReturn: 1,
  21394. IdCardType: id_card_type,
  21395. }
  21396. c.ServeSuccessJSON(map[string]interface{}{
  21397. "info": his,
  21398. })
  21399. } else {
  21400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21401. return
  21402. }
  21403. }
  21404. }
  21405. //func GetBasBaseInfo() (jsonStr string, err error) {
  21406. //
  21407. // handle := syscall.NewLazyDLL("SSCard.dll")
  21408. // add := handle.NewProc("ReadCardBas")
  21409. // str := make([]byte, 1024)
  21410. // str1 := make([]byte, 1024)
  21411. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21412. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21413. //
  21414. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21415. //
  21416. // fmt.Println("> Add(4,5)的结果为:", ret)
  21417. // handle.Release()
  21418. //
  21419. // return "", nil
  21420. //
  21421. //}
  21422. //func GetQRBaseInfo() (jsonStr string, err error) {
  21423. // handle := syscall.LoadDLL("SSCard.dll")
  21424. // ReadCardBas := handle.FindProc("GetQRBase")
  21425. //
  21426. // str := make([]byte, 256)
  21427. // str1 := make([]byte, 256)
  21428. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21429. //
  21430. // fmt.Println(string(str))
  21431. // fmt.Println(r)
  21432. // return string(str), nil
  21433. //}
  21434. //func CardInit() int {
  21435. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21436. // add := DllTestDef.MustFindProc("Init")
  21437. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21438. // if err != nil {
  21439. // fmt.Println("SSCard的运算结果为:", ret)
  21440. // }
  21441. // result := int(ret)
  21442. // return result
  21443. //}
  21444. //func CardInit() int {
  21445. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21446. // if err != nil {
  21447. // fmt.Println("SSCard的运算结果为:", ret)
  21448. // }
  21449. // fmt.Println(err)
  21450. // result := int(ret)
  21451. // return result
  21452. //}
  21453. func IntPtr(n int) uintptr {
  21454. return uintptr(n)
  21455. }
  21456. func StrPtr(s string) uintptr {
  21457. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21458. }
  21459. type Result2001 struct {
  21460. Cainfo interface{} `json:"cainfo"`
  21461. ErrMsg string `json:"err_msg"`
  21462. InfRefmsgid string `json:"inf_refmsgid"`
  21463. Infcode int64 `json:"infcode"`
  21464. Output struct {
  21465. Trtinfo struct {
  21466. PsnNo string `json:"psn_no"`
  21467. TrtChkType string `json:"trt_chk_type"`
  21468. FundPayType string `json:"fund_pay_type"`
  21469. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21470. Begndate string `json:"begndate"`
  21471. Enddate string `json:"enddate"`
  21472. TrtChkRslt string `json:"trt_chk_rslt"`
  21473. } `json:"trtinfo"`
  21474. } `json:"output"`
  21475. RefmsgTime string `json:"refmsg_time"`
  21476. RespondTime string `json:"respond_time"`
  21477. Signtype interface{} `json:"signtype"`
  21478. WarnMsg interface{} `json:"warn_msg"`
  21479. }
  21480. type Result2001Org10265 struct {
  21481. Cainfo interface{} `json:"cainfo"`
  21482. ErrMsg string `json:"err_msg"`
  21483. InfRefmsgid string `json:"inf_refmsgid"`
  21484. Infcode string `json:"infcode"`
  21485. Output struct {
  21486. Trtinfo struct {
  21487. PsnNo string `json:"psn_no"`
  21488. TrtChkType string `json:"trt_chk_type"`
  21489. FundPayType string `json:"fund_pay_type"`
  21490. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21491. Begndate string `json:"begndate"`
  21492. Enddate string `json:"enddate"`
  21493. TrtChkRslt string `json:"trt_chk_rslt"`
  21494. } `json:"trtinfo"`
  21495. } `json:"output"`
  21496. RefmsgTime string `json:"refmsg_time"`
  21497. RespondTime string `json:"respond_time"`
  21498. Signtype interface{} `json:"signtype"`
  21499. WarnMsg interface{} `json:"warn_msg"`
  21500. }
  21501. type ResultTwo struct {
  21502. ErrMsg string `json:"err_msg"`
  21503. InfRefmsgid string `json:"inf_refmsgid"`
  21504. Infcode int64 `json:"infcode"`
  21505. Output struct {
  21506. Baseinfo struct {
  21507. //Brdy string `json:"brdy"`
  21508. Certno string `json:"certno"`
  21509. Gend string `json:"gend"`
  21510. Naty string `json:"naty"`
  21511. PsnCertType string `json:"psn_cert_type"`
  21512. PsnName string `json:"psn_name"`
  21513. PsnNo string `json:"psn_no"`
  21514. } `json:"baseinfo"`
  21515. Idetinfo []interface{} `json:"idetinfo"`
  21516. Iinfo []struct {
  21517. Balc float64 `json:"balc"`
  21518. CvlservFlag string `json:"cvlserv_flag"`
  21519. EmpName string `json:"emp_name"`
  21520. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21521. Insutype string `json:"insutype"`
  21522. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21523. //PausInsuDate string `json:"paus_insu_date"`
  21524. //PsnInsuDate string `json:"psn_insu_date"`
  21525. PsnInsuStas string `json:"psn_insu_stas"`
  21526. PsnType string `json:"psn_type"`
  21527. } `json:"insuinfo"`
  21528. } `json:"output"`
  21529. RefmsgTime string `json:"refmsg_time"`
  21530. RespondTime string `json:"respond_time"`
  21531. Signtype interface{} `json:"signtype"`
  21532. WarnInfo interface{} `json:"warn_info"`
  21533. }
  21534. type ResultTwo10265 struct {
  21535. ErrMsg string `json:"err_msg"`
  21536. InfRefmsgid string `json:"inf_refmsgid"`
  21537. Infcode string `json:"infcode"`
  21538. Output struct {
  21539. Baseinfo struct {
  21540. //Brdy string `json:"brdy"`
  21541. Certno string `json:"certno"`
  21542. Gend string `json:"gend"`
  21543. Naty string `json:"naty"`
  21544. PsnCertType string `json:"psn_cert_type"`
  21545. PsnName string `json:"psn_name"`
  21546. PsnNo string `json:"psn_no"`
  21547. } `json:"baseinfo"`
  21548. Idetinfo []interface{} `json:"idetinfo"`
  21549. Iinfo []struct {
  21550. Balc float64 `json:"balc"`
  21551. CvlservFlag string `json:"cvlserv_flag"`
  21552. EmpName string `json:"emp_name"`
  21553. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21554. Insutype string `json:"insutype"`
  21555. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21556. PsnInsuStas string `json:"psn_insu_stas"`
  21557. PsnType string `json:"psn_type"`
  21558. } `json:"insuinfo"`
  21559. } `json:"output"`
  21560. RefmsgTime string `json:"refmsg_time"`
  21561. RespondTime string `json:"respond_time"`
  21562. Signtype interface{} `json:"signtype"`
  21563. WarnInfo interface{} `json:"warn_info"`
  21564. }
  21565. type ResultThree struct {
  21566. Cainfo interface{} `json:"cainfo"`
  21567. ErrMsg string `json:"err_msg"`
  21568. InfRefmsgid string `json:"inf_refmsgid"`
  21569. Infcode int64 `json:"infcode"`
  21570. Output struct {
  21571. Data struct {
  21572. IptOtpNo string `json:"ipt_otp_no"`
  21573. MdtrtID string `json:"mdtrt_id"`
  21574. PsnNo string `json:"psn_no"`
  21575. } `json:"data"`
  21576. } `json:"output"`
  21577. RefmsgTime string `json:"refmsg_time"`
  21578. RespondTime string `json:"respond_time"`
  21579. Signtype interface{} `json:"signtype"`
  21580. WarnMsg interface{} `json:"warn_msg"`
  21581. }
  21582. type ResultThree10265 struct {
  21583. Cainfo interface{} `json:"cainfo"`
  21584. ErrMsg string `json:"err_msg"`
  21585. InfRefmsgid string `json:"inf_refmsgid"`
  21586. Infcode string `json:"infcode"`
  21587. Output struct {
  21588. Data struct {
  21589. IptOtpNo string `json:"ipt_otp_no"`
  21590. MdtrtID string `json:"mdtrt_id"`
  21591. PsnNo string `json:"psn_no"`
  21592. } `json:"data"`
  21593. } `json:"output"`
  21594. RefmsgTime string `json:"refmsg_time"`
  21595. RespondTime string `json:"respond_time"`
  21596. Signtype interface{} `json:"signtype"`
  21597. WarnMsg interface{} `json:"warn_msg"`
  21598. }
  21599. type ResultFour struct {
  21600. Cainfo string `json:"cainfo"`
  21601. ErrMsg string `json:"err_msg"`
  21602. InfRefmsgid string `json:"inf_refmsgid"`
  21603. Infcode int64 `json:"infcode"`
  21604. Output struct {
  21605. Result []struct {
  21606. BasMednFlag string `json:"bas_medn_flag"`
  21607. ChldMedcFlag string `json:"chld_medc_flag"`
  21608. ChrgitmLv string `json:"chrgitm_lv"`
  21609. Cnt float64 `json:"cnt"`
  21610. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21611. DrtReimFlag string `json:"drt_reim_flag"`
  21612. FeedetlSn string `json:"feedetl_sn"`
  21613. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21614. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21615. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21616. ListSpItemFlag string `json:"list_sp_item_flag"`
  21617. LmtUsedFlag string `json:"lmt_used_flag"`
  21618. MedChrgitmType string `json:"med_chrgitm_type"`
  21619. Memo string `json:"memo"`
  21620. OverlmtAmt float64 `json:"overlmt_amt"`
  21621. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21622. Pric float64 `json:"pric"`
  21623. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21624. SelfpayProp float64 `json:"selfpay_prop"`
  21625. } `json:"result"`
  21626. } `json:"output"`
  21627. RefmsgTime string `json:"refmsg_time"`
  21628. RespondTime string `json:"respond_time"`
  21629. Signtype string `json:"signtype"`
  21630. WarnMsg string `json:"warn_msg"`
  21631. }
  21632. type ResultFour10265 struct {
  21633. Cainfo string `json:"cainfo"`
  21634. ErrMsg string `json:"err_msg"`
  21635. InfRefmsgid string `json:"inf_refmsgid"`
  21636. Infcode string `json:"infcode"`
  21637. Output struct {
  21638. Result []struct {
  21639. BasMednFlag string `json:"bas_medn_flag"`
  21640. ChldMedcFlag string `json:"chld_medc_flag"`
  21641. ChrgitmLv string `json:"chrgitm_lv"`
  21642. Cnt float64 `json:"cnt"`
  21643. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21644. DrtReimFlag string `json:"drt_reim_flag"`
  21645. FeedetlSn string `json:"feedetl_sn"`
  21646. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21647. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21648. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21649. ListSpItemFlag string `json:"list_sp_item_flag"`
  21650. LmtUsedFlag string `json:"lmt_used_flag"`
  21651. MedChrgitmType string `json:"med_chrgitm_type"`
  21652. Memo string `json:"memo"`
  21653. OverlmtAmt float64 `json:"overlmt_amt"`
  21654. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21655. Pric float64 `json:"pric"`
  21656. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21657. SelfpayProp float64 `json:"selfpay_prop"`
  21658. } `json:"result"`
  21659. } `json:"output"`
  21660. RefmsgTime string `json:"refmsg_time"`
  21661. RespondTime string `json:"respond_time"`
  21662. Signtype string `json:"signtype"`
  21663. WarnMsg string `json:"warn_msg"`
  21664. }
  21665. type ResultMemo struct {
  21666. InsuAdmdvs string `json:"insuAdmdvs"`
  21667. }
  21668. // [{"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}]
  21669. type ResultIDInfo struct {
  21670. Begntime string `json:"begntime"`
  21671. Endtime string `json:"endtime"`
  21672. Memo string `json:"memo"`
  21673. }
  21674. type ResultFive struct {
  21675. Balc float64 `json:"balc"`
  21676. CvlservFlag string `json:"cvlserv_flag"`
  21677. EmpName string `json:"emp_name"`
  21678. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21679. Insutype string `json:"insutype"`
  21680. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21681. PausInsuDate string `json:"paus_insu_date"`
  21682. PsnInsuDate string `json:"psn_insu_date"`
  21683. PsnInsuStas string `json:"psn_insu_stas"`
  21684. PsnType string `json:"psn_type"`
  21685. }
  21686. type ResultSix struct {
  21687. Cainfo interface{} `json:"cainfo"`
  21688. ErrMsg string `json:"err_msg"`
  21689. InfRefmsgid string `json:"inf_refmsgid"`
  21690. Infcode int64 `json:"infcode"`
  21691. Output struct {
  21692. } `json:"output"`
  21693. RefmsgTime string `json:"refmsg_time"`
  21694. RespondTime string `json:"respond_time"`
  21695. Signtype interface{} `json:"signtype"`
  21696. WarnMsg interface{} `json:"warn_msg"`
  21697. }
  21698. type FJ3507Result struct {
  21699. Cainfo interface{} `json:"cainfo"`
  21700. ErrMsg string `json:"err_msg"`
  21701. InfRefmsgid string `json:"inf_refmsgid"`
  21702. Infcode int64 `json:"infcode"`
  21703. Output struct {
  21704. retRslt string `json:"retRslt"`
  21705. msgRslt string `json:"msgRslt"`
  21706. } `json:"output"`
  21707. RefmsgTime string `json:"refmsg_time"`
  21708. RespondTime string `json:"respond_time"`
  21709. Signtype interface{} `json:"signtype"`
  21710. WarnMsg interface{} `json:"warn_msg"`
  21711. }
  21712. type FJ3507ResultFor10188 struct {
  21713. Cainfo interface{} `json:"cainfo"`
  21714. ErrMsg string `json:"err_msg"`
  21715. InfRefmsgid string `json:"inf_refmsgid"`
  21716. Infcode string `json:"infcode"`
  21717. RefmsgTime string `json:"refmsg_time"`
  21718. RespondTime string `json:"respond_time"`
  21719. Signtype interface{} `json:"signtype"`
  21720. WarnMsg interface{} `json:"warn_msg"`
  21721. }
  21722. type Result2406 struct {
  21723. Cainfo interface{} `json:"cainfo"`
  21724. ErrMsg string `json:"err_msg"`
  21725. InfRefmsgid string `json:"inf_refmsgid"`
  21726. Infcode int64 `json:"infcode"`
  21727. Output struct {
  21728. Result struct {
  21729. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21730. } `json:"result"`
  21731. } `json:"output"`
  21732. RefmsgTime string `json:"refmsg_time"`
  21733. RespondTime string `json:"respond_time"`
  21734. Signtype interface{} `json:"signtype"`
  21735. WarnMsg interface{} `json:"warn_msg"`
  21736. }
  21737. type GZResultSix struct {
  21738. Cainfo interface{} `json:"cainfo"`
  21739. ErrMsg string `json:"err_msg"`
  21740. InfRefmsgid string `json:"inf_refmsgid"`
  21741. Infcode int64 `json:"infcode"`
  21742. Output string `json:"output"`
  21743. RefmsgTime string `json:"refmsg_time"`
  21744. RespondTime string `json:"respond_time"`
  21745. Signtype interface{} `json:"signtype"`
  21746. WarnMsg interface{} `json:"warn_msg"`
  21747. }
  21748. type ResultSix10265 struct {
  21749. Cainfo interface{} `json:"cainfo"`
  21750. ErrMsg string `json:"err_msg"`
  21751. InfRefmsgid string `json:"inf_refmsgid"`
  21752. Infcode string `json:"infcode"`
  21753. Output struct {
  21754. } `json:"output"`
  21755. RefmsgTime string `json:"refmsg_time"`
  21756. RespondTime string `json:"respond_time"`
  21757. Signtype interface{} `json:"signtype"`
  21758. WarnMsg interface{} `json:"warn_msg"`
  21759. }
  21760. type ResultSeven struct {
  21761. Cainfo string `json:"cainfo"`
  21762. ErrMsg string `json:"err_msg"`
  21763. InfRefmsgid string `json:"inf_refmsgid"`
  21764. Infcode int64 `json:"infcode"`
  21765. Output struct {
  21766. Setlinfo struct {
  21767. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21768. AcctPay float64 `json:"acct_pay"`
  21769. ActPayDedc float64 `json:"act_pay_dedc"`
  21770. Age float64 `json:"age"`
  21771. Balc float64 `json:"balc"`
  21772. Certno string `json:"certno"`
  21773. ClrOptins string `json:"clr_optins"`
  21774. ClrType string `json:"clr_type"`
  21775. ClrWay string `json:"clr_way"`
  21776. CvlservFlag string `json:"cvlserv_flag"`
  21777. CvlservPay float64 `json:"cvlserv_pay"`
  21778. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21779. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21780. Gend string `json:"gend"`
  21781. HifesPay float64 `json:"hifes_pay"`
  21782. HifmiPay float64 `json:"hifmi_pay"`
  21783. HifpPay float64 `json:"hifp_pay"`
  21784. HospPartAmt float64 `json:"hosp_part_amt"`
  21785. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21786. Insutype string `json:"insutype"`
  21787. MafPay float64 `json:"maf_pay"`
  21788. MdtrtCertType string `json:"mdtrt_cert_type"`
  21789. HifobPay float64 `json:"hifob_pay"`
  21790. MdtrtID string `json:"mdtrt_id"`
  21791. MedType string `json:"med_type"`
  21792. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21793. MedinsSetlID string `json:"medins_setl_id"`
  21794. Naty string `json:"naty"`
  21795. OthPay float64 `json:"oth_pay"`
  21796. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21797. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21798. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21799. PsnCashPay float64 `json:"psn_cash_pay"`
  21800. PsnCertType string `json:"psn_cert_type"`
  21801. PsnName string `json:"psn_name"`
  21802. PsnNo string `json:"psn_no"`
  21803. PsnPartAmt float64 `json:"psn_part_amt"`
  21804. PsnType string `json:"psn_type"`
  21805. SetlID string `json:"setl_id"`
  21806. SetlTime string `json:"setl_time"`
  21807. } `json:"setlinfo"`
  21808. Setldetail interface{} `json:"setldetail"`
  21809. } `json:"output"`
  21810. RefmsgTime string `json:"refmsg_time"`
  21811. RespondTime string `json:"respond_time"`
  21812. Signtype interface{} `json:"signtype"`
  21813. WarnMsg interface{} `json:"warn_msg"`
  21814. }
  21815. type ResultSevenAH struct {
  21816. Cainfo string `json:"cainfo"`
  21817. ErrMsg string `json:"err_msg"`
  21818. InfRefmsgid string `json:"inf_refmsgid"`
  21819. Infcode int64 `json:"infcode"`
  21820. Output struct {
  21821. Setlinfo struct {
  21822. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21823. AcctPay float64 `json:"acct_pay"`
  21824. ActPayDedc float64 `json:"act_pay_dedc"`
  21825. Age float64 `json:"age"`
  21826. Balc float64 `json:"balc"`
  21827. Certno string `json:"certno"`
  21828. ClrOptins string `json:"clr_optins"`
  21829. ClrType string `json:"clr_type"`
  21830. ClrWay string `json:"clr_way"`
  21831. CvlservFlag string `json:"cvlserv_flag"`
  21832. CvlservPay float64 `json:"cvlserv_pay"`
  21833. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21834. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21835. Gend string `json:"gend"`
  21836. HifesPay float64 `json:"hifes_pay"`
  21837. HifmiPay float64 `json:"hifmi_pay"`
  21838. HifpPay float64 `json:"hifp_pay"`
  21839. HospPartAmt float64 `json:"hosp_part_amt"`
  21840. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21841. Insutype string `json:"insutype"`
  21842. MafPay float64 `json:"maf_pay"`
  21843. MdtrtCertType string `json:"mdtrt_cert_type"`
  21844. HifobPay float64 `json:"hifob_pay"`
  21845. MdtrtID string `json:"mdtrt_id"`
  21846. MedType string `json:"med_type"`
  21847. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21848. MedinsSetlID string `json:"medins_setl_id"`
  21849. Naty string `json:"naty"`
  21850. OthPay float64 `json:"oth_pay"`
  21851. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21852. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21853. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21854. PsnCashPay float64 `json:"psn_cash_pay"`
  21855. PsnCertType string `json:"psn_cert_type"`
  21856. PsnName string `json:"psn_name"`
  21857. PsnNo string `json:"psn_no"`
  21858. PsnPartAmt float64 `json:"psn_part_amt"`
  21859. PsnType string `json:"psn_type"`
  21860. SetlID string `json:"setl_id"`
  21861. SetlTime int64 `json:"setl_time"`
  21862. } `json:"setlinfo"`
  21863. Setldetail interface{} `json:"setldetail"`
  21864. } `json:"output"`
  21865. RefmsgTime string `json:"refmsg_time"`
  21866. RespondTime string `json:"respond_time"`
  21867. Signtype interface{} `json:"signtype"`
  21868. WarnMsg interface{} `json:"warn_msg"`
  21869. }
  21870. type ResultSeven10265 struct {
  21871. Cainfo string `json:"cainfo"`
  21872. ErrMsg string `json:"err_msg"`
  21873. InfRefmsgid string `json:"inf_refmsgid"`
  21874. Infcode string `json:"infcode"`
  21875. Output struct {
  21876. Setlinfo struct {
  21877. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21878. AcctPay float64 `json:"acct_pay"`
  21879. ActPayDedc float64 `json:"act_pay_dedc"`
  21880. Age float64 `json:"age"`
  21881. Balc float64 `json:"balc"`
  21882. Certno string `json:"certno"`
  21883. ClrOptins string `json:"clr_optins"`
  21884. ClrType string `json:"clr_type"`
  21885. ClrWay string `json:"clr_way"`
  21886. CvlservFlag string `json:"cvlserv_flag"`
  21887. CvlservPay float64 `json:"cvlserv_pay"`
  21888. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21889. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21890. Gend string `json:"gend"`
  21891. HifesPay float64 `json:"hifes_pay"`
  21892. HifmiPay float64 `json:"hifmi_pay"`
  21893. HifpPay float64 `json:"hifp_pay"`
  21894. HospPartAmt float64 `json:"hosp_part_amt"`
  21895. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21896. Insutype string `json:"insutype"`
  21897. MafPay float64 `json:"maf_pay"`
  21898. MdtrtCertType string `json:"mdtrt_cert_type"`
  21899. HifobPay float64 `json:"hifob_pay"`
  21900. MdtrtID string `json:"mdtrt_id"`
  21901. MedType string `json:"med_type"`
  21902. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21903. MedinsSetlID string `json:"medins_setl_id"`
  21904. Naty string `json:"naty"`
  21905. OthPay float64 `json:"oth_pay"`
  21906. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21907. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21908. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21909. PsnCashPay float64 `json:"psn_cash_pay"`
  21910. PsnCertType string `json:"psn_cert_type"`
  21911. PsnName string `json:"psn_name"`
  21912. PsnNo string `json:"psn_no"`
  21913. PsnPartAmt float64 `json:"psn_part_amt"`
  21914. PsnType string `json:"psn_type"`
  21915. SetlID string `json:"setl_id"`
  21916. SetlTime string `json:"setl_time"`
  21917. } `json:"setlinfo"`
  21918. Setldetail interface{} `json:"setldetail"`
  21919. } `json:"output"`
  21920. RefmsgTime string `json:"refmsg_time"`
  21921. RespondTime string `json:"respond_time"`
  21922. Signtype interface{} `json:"signtype"`
  21923. WarnMsg interface{} `json:"warn_msg"`
  21924. }
  21925. type ResultSeven10265Two struct {
  21926. Cainfo string `json:"cainfo"`
  21927. ErrMsg string `json:"err_msg"`
  21928. InfRefmsgid string `json:"inf_refmsgid"`
  21929. Infcode string `json:"infcode"`
  21930. Output struct {
  21931. Setlinfo struct {
  21932. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21933. AcctPay float64 `json:"acct_pay"`
  21934. ActPayDedc float64 `json:"act_pay_dedc"`
  21935. Age float64 `json:"age"`
  21936. Balc float64 `json:"balc"`
  21937. Certno string `json:"certno"`
  21938. ClrOptins string `json:"clr_optins"`
  21939. ClrType string `json:"clr_type"`
  21940. ClrWay string `json:"clr_way"`
  21941. CvlservFlag string `json:"cvlserv_flag"`
  21942. CvlservPay float64 `json:"cvlserv_pay"`
  21943. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21944. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21945. Gend string `json:"gend"`
  21946. HifesPay float64 `json:"hifes_pay"`
  21947. HifmiPay float64 `json:"hifmi_pay"`
  21948. HifpPay float64 `json:"hifp_pay"`
  21949. HospPartAmt string `json:"hosp_part_amt"`
  21950. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21951. Insutype string `json:"insutype"`
  21952. MafPay float64 `json:"maf_pay"`
  21953. MdtrtCertType string `json:"mdtrt_cert_type"`
  21954. HifobPay float64 `json:"hifob_pay"`
  21955. MdtrtID string `json:"mdtrt_id"`
  21956. MedType string `json:"med_type"`
  21957. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21958. MedinsSetlID string `json:"medins_setl_id"`
  21959. Naty string `json:"naty"`
  21960. OthPay float64 `json:"oth_pay"`
  21961. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21962. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21963. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21964. PsnCashPay float64 `json:"psn_cash_pay"`
  21965. PsnCertType string `json:"psn_cert_type"`
  21966. PsnName string `json:"psn_name"`
  21967. PsnNo string `json:"psn_no"`
  21968. PsnPartAmt float64 `json:"psn_part_amt"`
  21969. PsnType string `json:"psn_type"`
  21970. SetlID string `json:"setl_id"`
  21971. SetlTime string `json:"setl_time"`
  21972. } `json:"setlinfo"`
  21973. Setldetail interface{} `json:"setldetail"`
  21974. } `json:"output"`
  21975. RefmsgTime string `json:"refmsg_time"`
  21976. RespondTime string `json:"respond_time"`
  21977. Signtype interface{} `json:"signtype"`
  21978. WarnMsg interface{} `json:"warn_msg"`
  21979. }
  21980. type GZResultSeven10265Two struct {
  21981. Cainfo string `json:"cainfo"`
  21982. ErrMsg string `json:"err_msg"`
  21983. InfRefmsgid string `json:"inf_refmsgid"`
  21984. Infcode int64 `json:"infcode"`
  21985. Output struct {
  21986. Setlinfo struct {
  21987. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21988. AcctPay float64 `json:"acct_pay"`
  21989. ActPayDedc float64 `json:"act_pay_dedc"`
  21990. Age float64 `json:"age"`
  21991. Balc float64 `json:"balc"`
  21992. Certno string `json:"certno"`
  21993. ClrOptins string `json:"clr_optins"`
  21994. ClrType string `json:"clr_type"`
  21995. ClrWay string `json:"clr_way"`
  21996. CvlservFlag string `json:"cvlserv_flag"`
  21997. CvlservPay float64 `json:"cvlserv_pay"`
  21998. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21999. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22000. Gend string `json:"gend"`
  22001. HifesPay float64 `json:"hifes_pay"`
  22002. HifmiPay float64 `json:"hifmi_pay"`
  22003. HifpPay float64 `json:"hifp_pay"`
  22004. HospPartAmt float64 `json:"hosp_part_amt"`
  22005. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22006. Insutype string `json:"insutype"`
  22007. MafPay float64 `json:"maf_pay"`
  22008. MdtrtCertType string `json:"mdtrt_cert_type"`
  22009. HifobPay float64 `json:"hifob_pay"`
  22010. MdtrtID string `json:"mdtrt_id"`
  22011. MedType string `json:"med_type"`
  22012. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22013. MedinsSetlID string `json:"medins_setl_id"`
  22014. Naty string `json:"naty"`
  22015. OthPay float64 `json:"oth_pay"`
  22016. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22017. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22018. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22019. PsnCashPay float64 `json:"psn_cash_pay"`
  22020. PsnCertType string `json:"psn_cert_type"`
  22021. PsnName string `json:"psn_name"`
  22022. PsnNo string `json:"psn_no"`
  22023. PsnPartAmt float64 `json:"psn_part_amt"`
  22024. PsnType string `json:"psn_type"`
  22025. SetlID string `json:"setl_id"`
  22026. SetlTime string `json:"setl_time"`
  22027. } `json:"setlinfo"`
  22028. Setldetail interface{} `json:"setldetail"`
  22029. } `json:"output"`
  22030. RefmsgTime string `json:"refmsg_time"`
  22031. RespondTime string `json:"respond_time"`
  22032. Signtype interface{} `json:"signtype"`
  22033. WarnMsg interface{} `json:"warn_msg"`
  22034. }
  22035. type ResultEight struct {
  22036. Cainfo string `json:"cainfo"`
  22037. ErrMsg string `json:"err_msg"`
  22038. InfRefmsgid string `json:"inf_refmsgid"`
  22039. Infcode int64 `json:"infcode"`
  22040. Output struct {
  22041. Stmtinfo struct {
  22042. SetlOptins string `json:"setl_optins"`
  22043. StmtRslt string `json:"stmt_rslt"`
  22044. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22045. } `json:"stmtinfo"`
  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 ResultEightFor10188 struct {
  22053. Cainfo string `json:"cainfo"`
  22054. ErrMsg string `json:"err_msg"`
  22055. InfRefmsgid string `json:"inf_refmsgid"`
  22056. Infcode string `json:"infcode"`
  22057. Output struct {
  22058. Stmtinfo struct {
  22059. SetlOptins string `json:"setl_optins"`
  22060. StmtRslt string `json:"stmt_rslt"`
  22061. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22062. } `json:"stmtinfo"`
  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 ResultNine struct {
  22070. Cainfo string `json:"cainfo"`
  22071. ErrMsg string `json:"err_msg"`
  22072. InfRefmsgid string `json:"inf_refmsgid"`
  22073. Infcode int64 `json:"infcode"`
  22074. Output struct {
  22075. FileQuryNo string `json:"file_qury_no"`
  22076. } `json:"output"`
  22077. RefmsgTime string `json:"refmsg_time"`
  22078. RespondTime string `json:"respond_time"`
  22079. Signtype interface{} `json:"signtype"`
  22080. WarnMsg interface{} `json:"warn_msg"`
  22081. }
  22082. type ResultTen struct {
  22083. Cainfo string `json:"cainfo"`
  22084. ErrMsg string `json:"err_msg"`
  22085. InfRefmsgid string `json:"inf_refmsgid"`
  22086. Infcode int64 `json:"infcode"`
  22087. Output struct {
  22088. Fileinfo struct {
  22089. DldEndtime string `json:"dld_endtime"`
  22090. FileQuryNo string `json:"file_qury_no"`
  22091. Filename string `json:"filename"`
  22092. } `json:"fileinfo"`
  22093. } `json:"output"`
  22094. RefmsgTime string `json:"refmsg_time"`
  22095. RespondTime string `json:"respond_time"`
  22096. Signtype interface{} `json:"signtype"`
  22097. WarnMsg interface{} `json:"warn_msg"`
  22098. }
  22099. type Result5262 struct {
  22100. ErrMsg string `json:"err_msg"`
  22101. InfRefmsgid string `json:"inf_refmsgid"`
  22102. Infcode int64 `json:"infcode"`
  22103. Output struct {
  22104. PageInfo struct {
  22105. Size int `json:"size"`
  22106. RecordCounts int `json:"record_counts"`
  22107. } `json:"page_info"`
  22108. Idetinfo []interface{} `json:"idetinfo"`
  22109. Result []struct {
  22110. SetlID string `json:"setl_id"`
  22111. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22112. MdtrtID string `json:"mdtrt_id"`
  22113. InitSetlID string `json:"init_setl_id,omitempty"`
  22114. PsnNo string `json:"psn_no"`
  22115. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22116. PsnName string `json:"psn_name"`
  22117. PsnCertType string `json:"psn_cert_type"`
  22118. Certno string `json:"certno"`
  22119. Gend string `json:"gend,omitempty"`
  22120. Naty string `json:"naty,omitempty"`
  22121. Brdy string `json:"brdy,omitempty"`
  22122. Age float64 `json:"age,omitempty"`
  22123. Insutype string `json:"insutype,omitempty"`
  22124. PsnType string `json:"psn_type"`
  22125. CvlservFlag string `json:"cvlserv_flag"`
  22126. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22127. SpPsnType string `json:"sp_psn_type,omitempty"`
  22128. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22129. ClctGrde string `json:"clct_grde,omitempty"`
  22130. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22131. NwbFlag string `json:"nwb_flag,omitempty"`
  22132. InsuAdmdvs string `json:"insu_admdvs"`
  22133. EmpNo string `json:"emp_no,omitempty"`
  22134. EmpName string `json:"emp_name,omitempty"`
  22135. EmpType string `json:"emp_type,omitempty"`
  22136. EconType string `json:"econ_type,omitempty"`
  22137. AfilIndu string `json:"afil_indu,omitempty"`
  22138. AfilRlts string `json:"afil_rlts,omitempty"`
  22139. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22140. PayLoc string `json:"pay_loc,omitempty"`
  22141. FixmedinsCode string `json:"fixmedins_code"`
  22142. FixmedinsName string `json:"fixmedins_name"`
  22143. HospLv string `json:"hosp_lv,omitempty"`
  22144. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22145. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22146. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22147. Begndate string `json:"begndate"`
  22148. Enddate string `json:"enddate"`
  22149. SetlTime string `json:"setl_time"`
  22150. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22151. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22152. MedType string `json:"med_type"`
  22153. SetlType string `json:"setl_type,omitempty"`
  22154. ClrType string `json:"clr_type,omitempty"`
  22155. ClrWay string `json:"clr_way,omitempty"`
  22156. PsnSetlway string `json:"psn_setlway,omitempty"`
  22157. ClrOptins string `json:"clr_optins,omitempty"`
  22158. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22159. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22160. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22161. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22162. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22163. DedcStd float64 `json:"dedc_std,omitempty"`
  22164. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22165. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22166. HifpPay float64 `json:"hifp_pay,omitempty"`
  22167. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22168. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22169. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22170. HifesPay float64 `json:"hifes_pay,omitempty"`
  22171. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22172. HifobPay float64 `json:"hifob_pay,omitempty"`
  22173. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22174. MafPay float64 `json:"maf_pay,omitempty"`
  22175. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22176. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22177. PsnPay float64 `json:"psn_pay,omitempty"`
  22178. AcctPay float64 `json:"acct_pay,omitempty"`
  22179. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22180. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22181. Balc float64 `json:"balc,omitempty"`
  22182. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22183. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22184. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22185. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22186. Year string `json:"year,omitempty"`
  22187. DiseNo string `json:"dise_no,omitempty"`
  22188. DiseName string `json:"dise_name,omitempty"`
  22189. Invono string `json:"invono,omitempty"`
  22190. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22191. ValiFlag string `json:"vali_flag,omitempty"`
  22192. Memo string `json:"memo,omitempty"`
  22193. Rid string `json:"rid"`
  22194. UpdtTime string `json:"updt_time,omitempty"`
  22195. CrterID string `json:"crter_id,omitempty"`
  22196. CrterName string `json:"crter_name,omitempty"`
  22197. CrteTime string `json:"crte_time,omitempty"`
  22198. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22199. OpterID string `json:"opter_id,omitempty"`
  22200. OpterName string `json:"opter_name,omitempty"`
  22201. OptTime string `json:"opt_time,omitempty"`
  22202. OptinsNo string `json:"optins_no,omitempty"`
  22203. PoolareaNo string `json:"poolarea_no,omitempty"`
  22204. } `json:"result"`
  22205. } `json:"output"`
  22206. RefmsgTime string `json:"refmsg_time"`
  22207. RespondTime string `json:"respond_time"`
  22208. Signtype interface{} `json:"signtype"`
  22209. WarnInfo interface{} `json:"warn_info"`
  22210. }
  22211. type Result5267 struct {
  22212. ErrMsg string `json:"err_msg"`
  22213. InfRefmsgid string `json:"inf_refmsgid"`
  22214. Infcode int64 `json:"infcode"`
  22215. Output struct {
  22216. PageInfo struct {
  22217. Size int `json:"size"`
  22218. RecordCounts int `json:"record_counts"`
  22219. } `json:"pageinfo"`
  22220. Result []struct {
  22221. SetlID string `json:"setl_id"`
  22222. ClrOptins string `json:"clr_optins"`
  22223. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22224. MdtrtID string `json:"mdtrt_id"`
  22225. InitSetlID string `json:"init_setl_id,omitempty"`
  22226. PsnNo string `json:"psn_no"`
  22227. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22228. PsnName string `json:"psn_name"`
  22229. PsnCertType string `json:"psn_cert_type"`
  22230. Certno string `json:"certno"`
  22231. Gend string `json:"gend,omitempty"`
  22232. Naty string `json:"naty,omitempty"`
  22233. Brdy string `json:"brdy,omitempty"`
  22234. Age float64 `json:"age,omitempty"`
  22235. Insutype string `json:"insutype,omitempty"`
  22236. PsnType string `json:"psn_type"`
  22237. CvlservFlag string `json:"cvlserv_flag"`
  22238. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22239. SpPsnType string `json:"sp_psn_type,omitempty"`
  22240. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22241. ClctGrde string `json:"clct_grde,omitempty"`
  22242. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22243. NwbFlag string `json:"nwb_flag,omitempty"`
  22244. InsuAdmdvs string `json:"insu_admdvs"`
  22245. EmpNo string `json:"emp_no,omitempty"`
  22246. EmpName string `json:"emp_name,omitempty"`
  22247. EmpType string `json:"emp_type,omitempty"`
  22248. EconType string `json:"econ_type,omitempty"`
  22249. AfilIndu string `json:"afil_indu,omitempty"`
  22250. AfilRlts string `json:"afil_rlts,omitempty"`
  22251. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22252. PayLoc string `json:"pay_loc,omitempty"`
  22253. FixmedinsCode string `json:"fixmedins_code"`
  22254. FixmedinsName string `json:"fixmedins_name"`
  22255. HospLv string `json:"hosp_lv,omitempty"`
  22256. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22257. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22258. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22259. Begndate string `json:"begndate,omitempty"`
  22260. Enddate string `json:"enddate,omitempty"`
  22261. SetlTime string `json:"setl_time,omitempty"`
  22262. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22263. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22264. MedType string `json:"med_type"`
  22265. SetlType string `json:"setl_type,omitempty"`
  22266. ClrType string `json:"clr_type,omitempty"`
  22267. ClrWay string `json:"clr_way,omitempty"`
  22268. PsnSetlway string `json:"psn_setlway,omitempty"`
  22269. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22270. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22271. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22272. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22273. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22274. DedcStd float64 `json:"dedc_std,omitempty"`
  22275. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22276. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22277. HifpPay float64 `json:"hifp_pay,omitempty"`
  22278. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22279. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22280. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22281. HifesPay float64 `json:"hifes_pay,omitempty"`
  22282. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22283. HifobPay float64 `json:"hifob_pay,omitempty"`
  22284. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22285. MafPay float64 `json:"maf_pay,omitempty"`
  22286. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22287. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22288. PsnPay float64 `json:"psn_pay,omitempty"`
  22289. AcctPay float64 `json:"acct_pay,omitempty"`
  22290. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22291. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22292. Balc float64 `json:"balc,omitempty"`
  22293. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22294. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22295. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22296. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22297. Year string `json:"year,omitempty"`
  22298. DiseNo string `json:"dise_no,omitempty"`
  22299. DiseName string `json:"dise_name,omitempty"`
  22300. Invono string `json:"invono,omitempty"`
  22301. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22302. Memo string `json:"memo,omitempty"`
  22303. UpdtTime string `json:"updt_time,omitempty"`
  22304. OpterID string `json:"opter_id,omitempty"`
  22305. OpterName string `json:"opter_name,omitempty"`
  22306. OptTime string `json:"opt_time,omitempty"`
  22307. OptinsNo string `json:"optins_no,omitempty"`
  22308. PoolareaNo string `json:"poolarea_no,omitempty"`
  22309. } `json:"result"`
  22310. } `json:"output"`
  22311. RefmsgTime string `json:"refmsg_time"`
  22312. RespondTime string `json:"respond_time"`
  22313. Signtype interface{} `json:"signtype"`
  22314. WarnInfo interface{} `json:"warn_info"`
  22315. }
  22316. // type Autogenerated struct {
  22317. // Output struct {
  22318. // Setlinfo struct {
  22319. // SetlTime string `json:"setl_time"`
  22320. // CvlservPay float64 `json:"cvlserv_pay"`
  22321. // Year string `json:"year"`
  22322. // MedType string `json:"med_type"`
  22323. // PsnPay float64 `json:"psn_pay"`
  22324. // OpterID string `json:"opter_id"`
  22325. // Begndate string `json:"begndate"`
  22326. // FlxempeFlag string `json:"flxempe_flag"`
  22327. // HifmiPay float64 `json:"hifmi_pay"`
  22328. // PsnNo string `json:"psn_no"`
  22329. // ActPayDedc float64 `json:"act_pay_dedc"`
  22330. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22331. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22332. // ClrWay string `json:"clr_way"`
  22333. // OthPay float64 `json:"oth_pay"`
  22334. // Gend string `json:"gend"`
  22335. // MdtrtID string `json:"mdtrt_id"`
  22336. // AcctPay float64 `json:"acct_pay"`
  22337. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22338. // Insutype string `json:"insutype"`
  22339. // Invono interface{} `json:"invono"`
  22340. // Enddate string `json:"enddate"`
  22341. // CashPayamt float64 `json:"cash_payamt"`
  22342. // PsnType string `json:"psn_type"`
  22343. // FixmedinsName string `json:"fixmedins_name"`
  22344. // HifpPay float64 `json:"hifp_pay"`
  22345. // NewFlag interface{} `json:"new_flag"`
  22346. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22347. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22348. // PayLoc string `json:"pay_loc"`
  22349. // ClrType string `json:"clr_type"`
  22350. // RefdSetlFlag string `json:"refd_setl_flag"`
  22351. // CvlservFlag string `json:"cvlserv_flag"`
  22352. // EmpName string `json:"emp_name"`
  22353. // Brdy string `json:"brdy"`
  22354. // Naty string `json:"naty"`
  22355. // Certno string `json:"certno"`
  22356. // DiseCode string `json:"dise_code"`
  22357. // FixmedinsCode string `json:"fixmedins_code"`
  22358. // DedcHospLv string `json:"dedc_hosp_lv"`
  22359. // OpterName string `json:"opter_name"`
  22360. // Balc float64 `json:"balc"`
  22361. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22362. // PsnCertType string `json:"psn_cert_type"`
  22363. // HifobPay float64 `json:"hifob_pay"`
  22364. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22365. // HifesPay float64 `json:"hifes_pay"`
  22366. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22367. // OptTime string `json:"opt_time"`
  22368. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22369. // SetlID string `json:"setl_id"`
  22370. // MafPay float64 `json:"maf_pay"`
  22371. // PsnName string `json:"psn_name"`
  22372. // InsuOptins interface{} `json:"insu_optins"`
  22373. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22374. // ClrOptins string `json:"clr_optins"`
  22375. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22376. // DiseName string `json:"dise_name"`
  22377. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22378. // Age float64 `json:"age"`
  22379. // DtrtCertType string `json:"dtrt_cert_type"`
  22380. // HospLv string `json:"hosp_lv"`
  22381. // } `json:"setlinfo"`
  22382. // Setldetail []struct {
  22383. // FundPayType string `json:"fund_pay_type"`
  22384. // FundPayamt float64 `json:"fund_payamt"`
  22385. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22386. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22387. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22388. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22389. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22390. // } `json:"setldetail"`
  22391. // } `json:"output"`
  22392. // Infcode int `json:"infcode"`
  22393. // WarnMsg interface{} `json:"warn_msg"`
  22394. // Cainfo interface{} `json:"cainfo"`
  22395. // ErrMsg interface{} `json:"err_msg"`
  22396. // RefmsgTime string `json:"refmsg_time"`
  22397. // Signtype interface{} `json:"signtype"`
  22398. // RespondTime string `json:"respond_time"`
  22399. // InfRefmsgid string `json:"inf_refmsgid"`
  22400. // }
  22401. type Result002 struct {
  22402. Cainfo interface{} `json:"cainfo"`
  22403. ErrMsg string `json:"err_msg"`
  22404. InfRefmsgid string `json:"inf_refmsgid"`
  22405. Infcode int64 `json:"infcode"`
  22406. Output struct {
  22407. RxFile string `json:"rx_file"`
  22408. SignDigest string `json:"sign_digest"`
  22409. SignCertSn string `json:"sign_cert_sn"`
  22410. SignCertDn string `json:"sign_cert_dn"`
  22411. } `json:"output"`
  22412. RefmsgTime string `json:"refmsg_time"`
  22413. RespondTime string `json:"respond_time"`
  22414. Signtype interface{} `json:"signtype"`
  22415. WarnMsg interface{} `json:"warn_msg"`
  22416. }
  22417. type Result003 struct {
  22418. Cainfo interface{} `json:"cainfo"`
  22419. ErrMsg string `json:"err_msg"`
  22420. InfRefmsgid string `json:"inf_refmsgid"`
  22421. Infcode int64 `json:"infcode"`
  22422. Output struct {
  22423. HiRxno string `json:"hi_rxno"`
  22424. RxStasCodg string `json:"rx_stas_codg"`
  22425. RxStasName string `json:"rx_stas_name"`
  22426. } `json:"output"`
  22427. RefmsgTime string `json:"refmsg_time"`
  22428. RespondTime string `json:"respond_time"`
  22429. Signtype interface{} `json:"signtype"`
  22430. WarnMsg interface{} `json:"warn_msg"`
  22431. }
  22432. type ResultEleven struct {
  22433. Cainfo string `json:"cainfo"`
  22434. ErrMsg string `json:"err_msg"`
  22435. InfRefmsgid string `json:"inf_refmsgid"`
  22436. Infcode int64 `json:"infcode"`
  22437. Output struct {
  22438. Setlinfo struct {
  22439. SetlTime string `json:"setl_time"`
  22440. CvlservPay float64 `json:"cvlserv_pay"`
  22441. Year string `json:"year"`
  22442. MedType string `json:"med_type"`
  22443. PsnPay float64 `json:"psn_pay"`
  22444. OpterID string `json:"opter_id"`
  22445. Begndate string `json:"begndate"`
  22446. FlxempeFlag string `json:"flxempe_flag"`
  22447. HifmiPay float64 `json:"hifmi_pay"`
  22448. PsnNo string `json:"psn_no"`
  22449. ActPayDedc float64 `json:"act_pay_dedc"`
  22450. MedinsSetlID interface{} `json:"medins_setl_id"`
  22451. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22452. ClrWay string `json:"clr_way"`
  22453. OthPay float64 `json:"oth_pay"`
  22454. Gend string `json:"gend"`
  22455. MdtrtID string `json:"mdtrt_id"`
  22456. AcctPay float64 `json:"acct_pay"`
  22457. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22458. Insutype string `json:"insutype"`
  22459. Invono interface{} `json:"invono"`
  22460. Enddate string `json:"enddate"`
  22461. CashPayamt float64 `json:"cash_payamt"`
  22462. PsnType string `json:"psn_type"`
  22463. FixmedinsName string `json:"fixmedins_name"`
  22464. HifpPay float64 `json:"hifp_pay"`
  22465. NewFlag interface{} `json:"new_flag"`
  22466. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22467. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22468. PayLoc string `json:"pay_loc"`
  22469. ClrType string `json:"clr_type"`
  22470. RefdSetlFlag string `json:"refd_setl_flag"`
  22471. CvlservFlag string `json:"cvlserv_flag"`
  22472. EmpName string `json:"emp_name"`
  22473. Brdy string `json:"brdy"`
  22474. Naty string `json:"naty"`
  22475. Certno string `json:"certno"`
  22476. DiseCode string `json:"dise_code"`
  22477. FixmedinsCode string `json:"fixmedins_code"`
  22478. DedcHospLv string `json:"dedc_hosp_lv"`
  22479. OpterName string `json:"opter_name"`
  22480. Balc float64 `json:"balc"`
  22481. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22482. PsnCertType string `json:"psn_cert_type"`
  22483. HifobPay float64 `json:"hifob_pay"`
  22484. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22485. HifesPay float64 `json:"hifes_pay"`
  22486. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22487. OptTime string `json:"opt_time"`
  22488. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22489. SetlID string `json:"setl_id"`
  22490. MafPay float64 `json:"maf_pay"`
  22491. PsnName string `json:"psn_name"`
  22492. InsuOptins interface{} `json:"insu_optins"`
  22493. PrefFundPay interface{} `json:"pref_fund_pay"`
  22494. ClrOptins string `json:"clr_optins"`
  22495. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22496. DiseName string `json:"dise_name"`
  22497. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22498. Age float64 `json:"age"`
  22499. DtrtCertType string `json:"dtrt_cert_type"`
  22500. HospLv string `json:"hosp_lv"`
  22501. PsnCashPay float64 `json:"psn_cash_pay"`
  22502. } `json:"setlinfo"`
  22503. } `json:"output"`
  22504. RefmsgTime string `json:"refmsg_time"`
  22505. RespondTime string `json:"respond_time"`
  22506. Signtype interface{} `json:"signtype"`
  22507. WarnMsg interface{} `json:"warn_msg"`
  22508. }
  22509. type ResultElevenah struct {
  22510. Cainfo string `json:"cainfo"`
  22511. ErrMsg string `json:"err_msg"`
  22512. InfRefmsgid string `json:"inf_refmsgid"`
  22513. Infcode int64 `json:"infcode"`
  22514. Output struct {
  22515. Setlinfo struct {
  22516. SetlTime int64 `json:"setl_time"`
  22517. CvlservPay float64 `json:"cvlserv_pay"`
  22518. Year string `json:"year"`
  22519. MedType string `json:"med_type"`
  22520. PsnPay float64 `json:"psn_pay"`
  22521. OpterID string `json:"opter_id"`
  22522. Begndate int64 `json:"begndate"`
  22523. FlxempeFlag string `json:"flxempe_flag"`
  22524. HifmiPay float64 `json:"hifmi_pay"`
  22525. PsnNo string `json:"psn_no"`
  22526. ActPayDedc float64 `json:"act_pay_dedc"`
  22527. MedinsSetlID interface{} `json:"medins_setl_id"`
  22528. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22529. ClrWay string `json:"clr_way"`
  22530. OthPay float64 `json:"oth_pay"`
  22531. Gend string `json:"gend"`
  22532. MdtrtID string `json:"mdtrt_id"`
  22533. AcctPay float64 `json:"acct_pay"`
  22534. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22535. Insutype string `json:"insutype"`
  22536. Invono interface{} `json:"invono"`
  22537. Enddate int64 `json:"enddate"`
  22538. CashPayamt float64 `json:"cash_payamt"`
  22539. PsnType string `json:"psn_type"`
  22540. FixmedinsName string `json:"fixmedins_name"`
  22541. HifpPay float64 `json:"hifp_pay"`
  22542. NewFlag interface{} `json:"new_flag"`
  22543. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22544. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22545. PayLoc string `json:"pay_loc"`
  22546. ClrType string `json:"clr_type"`
  22547. RefdSetlFlag string `json:"refd_setl_flag"`
  22548. CvlservFlag string `json:"cvlserv_flag"`
  22549. EmpName string `json:"emp_name"`
  22550. Brdy int64 `json:"brdy"`
  22551. Naty string `json:"naty"`
  22552. Certno string `json:"certno"`
  22553. DiseCode string `json:"dise_code"`
  22554. FixmedinsCode string `json:"fixmedins_code"`
  22555. DedcHospLv string `json:"dedc_hosp_lv"`
  22556. OpterName string `json:"opter_name"`
  22557. Balc float64 `json:"balc"`
  22558. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22559. PsnCertType string `json:"psn_cert_type"`
  22560. HifobPay float64 `json:"hifob_pay"`
  22561. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22562. HifesPay float64 `json:"hifes_pay"`
  22563. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22564. OptTime int64 `json:"opt_time"`
  22565. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22566. SetlID string `json:"setl_id"`
  22567. MafPay float64 `json:"maf_pay"`
  22568. PsnName string `json:"psn_name"`
  22569. InsuOptins interface{} `json:"insu_optins"`
  22570. PrefFundPay interface{} `json:"pref_fund_pay"`
  22571. ClrOptins string `json:"clr_optins"`
  22572. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22573. DiseName string `json:"dise_name"`
  22574. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22575. Age float64 `json:"age"`
  22576. DtrtCertType string `json:"dtrt_cert_type"`
  22577. HospLv string `json:"hosp_lv"`
  22578. PsnCashPay float64 `json:"psn_cash_pay"`
  22579. } `json:"setlinfo"`
  22580. } `json:"output"`
  22581. RefmsgTime string `json:"refmsg_time"`
  22582. RespondTime string `json:"respond_time"`
  22583. Signtype interface{} `json:"signtype"`
  22584. WarnMsg interface{} `json:"warn_msg"`
  22585. }
  22586. type ResultEleven10265 struct {
  22587. Cainfo string `json:"cainfo"`
  22588. ErrMsg string `json:"err_msg"`
  22589. InfRefmsgid string `json:"inf_refmsgid"`
  22590. Infcode string `json:"infcode"`
  22591. Output struct {
  22592. Setlinfo struct {
  22593. SetlTime string `json:"setl_time"`
  22594. CvlservPay float64 `json:"cvlserv_pay"`
  22595. Year string `json:"year"`
  22596. MedType string `json:"med_type"`
  22597. PsnPay float64 `json:"psn_pay"`
  22598. OpterID string `json:"opter_id"`
  22599. Begndate string `json:"begndate"`
  22600. FlxempeFlag string `json:"flxempe_flag"`
  22601. HifmiPay float64 `json:"hifmi_pay"`
  22602. PsnNo string `json:"psn_no"`
  22603. ActPayDedc float64 `json:"act_pay_dedc"`
  22604. MedinsSetlID interface{} `json:"medins_setl_id"`
  22605. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22606. ClrWay string `json:"clr_way"`
  22607. OthPay float64 `json:"oth_pay"`
  22608. Gend string `json:"gend"`
  22609. MdtrtID string `json:"mdtrt_id"`
  22610. AcctPay float64 `json:"acct_pay"`
  22611. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22612. Insutype string `json:"insutype"`
  22613. Invono interface{} `json:"invono"`
  22614. Enddate string `json:"enddate"`
  22615. CashPayamt float64 `json:"cash_payamt"`
  22616. PsnType string `json:"psn_type"`
  22617. FixmedinsName string `json:"fixmedins_name"`
  22618. HifpPay float64 `json:"hifp_pay"`
  22619. NewFlag interface{} `json:"new_flag"`
  22620. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22621. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22622. PayLoc string `json:"pay_loc"`
  22623. ClrType string `json:"clr_type"`
  22624. RefdSetlFlag string `json:"refd_setl_flag"`
  22625. CvlservFlag string `json:"cvlserv_flag"`
  22626. EmpName string `json:"emp_name"`
  22627. Brdy string `json:"brdy"`
  22628. Naty string `json:"naty"`
  22629. Certno string `json:"certno"`
  22630. DiseCode string `json:"dise_code"`
  22631. FixmedinsCode string `json:"fixmedins_code"`
  22632. DedcHospLv string `json:"dedc_hosp_lv"`
  22633. OpterName string `json:"opter_name"`
  22634. Balc float64 `json:"balc"`
  22635. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22636. PsnCertType string `json:"psn_cert_type"`
  22637. HifobPay float64 `json:"hifob_pay"`
  22638. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22639. HifesPay float64 `json:"hifes_pay"`
  22640. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22641. OptTime string `json:"opt_time"`
  22642. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22643. SetlID string `json:"setl_id"`
  22644. MafPay float64 `json:"maf_pay"`
  22645. PsnName string `json:"psn_name"`
  22646. InsuOptins interface{} `json:"insu_optins"`
  22647. PrefFundPay interface{} `json:"pref_fund_pay"`
  22648. ClrOptins string `json:"clr_optins"`
  22649. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22650. DiseName string `json:"dise_name"`
  22651. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22652. Age float64 `json:"age"`
  22653. DtrtCertType string `json:"dtrt_cert_type"`
  22654. HospLv string `json:"hosp_lv"`
  22655. PsnCashPay float64 `json:"psn_cash_pay"`
  22656. } `json:"setlinfo"`
  22657. } `json:"output"`
  22658. RefmsgTime string `json:"refmsg_time"`
  22659. RespondTime string `json:"respond_time"`
  22660. Signtype interface{} `json:"signtype"`
  22661. WarnMsg interface{} `json:"warn_msg"`
  22662. }
  22663. type ResultTwelve struct {
  22664. Cainfo string `json:"cainfo"`
  22665. ErrMsg string `json:"err_msg"`
  22666. InfRefmsgid string `json:"inf_refmsgid"`
  22667. Infcode int64 `json:"infcode"`
  22668. Output struct {
  22669. MdtrtId string `json:"mdtrt_id"`
  22670. ChrgBchno string `json:"chrg_bchno"`
  22671. PsnNo string `json:"psn_no"`
  22672. } `json:"output"`
  22673. RefmsgTime string `json:"refmsg_time"`
  22674. RespondTime string `json:"respond_time"`
  22675. Signtype interface{} `json:"signtype"`
  22676. WarnMsg interface{} `json:"warn_msg"`
  22677. }
  22678. type ResultThirteen struct {
  22679. ErrMsg string `json:"err_msg"`
  22680. InfRefmsgid string `json:"inf_refmsgid"`
  22681. Infcode int64 `json:"infcode"`
  22682. Output struct {
  22683. Result struct {
  22684. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22685. } `json:"result"`
  22686. } `json:"output"`
  22687. RefmsgTime string `json:"refmsg_time"`
  22688. RespondTime string `json:"respond_time"`
  22689. Signtype interface{} `json:"signtype"`
  22690. WarnInfo interface{} `json:"warn_info"`
  22691. }
  22692. type ResultThirteen10265 struct {
  22693. ErrMsg string `json:"err_msg"`
  22694. InfRefmsgid string `json:"inf_refmsgid"`
  22695. Infcode string `json:"infcode"`
  22696. Output struct {
  22697. Result struct {
  22698. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22699. } `json:"result"`
  22700. } `json:"output"`
  22701. RefmsgTime string `json:"refmsg_time"`
  22702. RespondTime string `json:"respond_time"`
  22703. Signtype interface{} `json:"signtype"`
  22704. WarnInfo interface{} `json:"warn_info"`
  22705. }
  22706. type ResultFourteen struct {
  22707. ErrMsg string `json:"err_msg"`
  22708. InfRefmsgid string `json:"inf_refmsgid"`
  22709. Infcode int64 `json:"infcode"`
  22710. Output struct {
  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 ResultCFYLJG001 struct {
  22718. ErrMsg string `json:"err_msg"`
  22719. InfRefmsgid string `json:"inf_refmsgid"`
  22720. Infcode int64 `json:"infcode"`
  22721. Output struct {
  22722. RxTraceCode string `json:"rx_trace_code"`
  22723. HiRxno string `json:"hi_rxno"`
  22724. } `json:"output"`
  22725. RefmsgTime string `json:"refmsg_time"`
  22726. RespondTime string `json:"respond_time"`
  22727. Signtype interface{} `json:"signtype"`
  22728. WarnInfo interface{} `json:"warn_info"`
  22729. }
  22730. type ResultCFYLJG007 struct {
  22731. ErrMsg string `json:"err_msg"`
  22732. InfRefmsgid string `json:"inf_refmsgid"`
  22733. Infcode int64 `json:"infcode"`
  22734. Output struct {
  22735. HiRxno string `json:"hi_rxno"`
  22736. RxStasName string `json:"rx_stas_name"`
  22737. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22738. Seltdelts []interface{} `json:"seltdelts"`
  22739. RxUsedStasName string `json:"rx_used_stas_name"`
  22740. RxStasCodg string `json:"rx_stas_codg"`
  22741. } `json:"output"`
  22742. RefmsgTime string `json:"refmsg_time"`
  22743. RespondTime string `json:"respond_time"`
  22744. Signtype interface{} `json:"signtype"`
  22745. WarnInfo interface{} `json:"warn_info"`
  22746. }
  22747. type ResultCFYLJG002 struct {
  22748. ErrMsg string `json:"err_msg"`
  22749. InfRefmsgid string `json:"inf_refmsgid"`
  22750. Infcode int64 `json:"infcode"`
  22751. Output struct {
  22752. RxFile string `json:"rx_file"`
  22753. SignDigest string `json:"sign_digest"`
  22754. SignCertSn string `json:"sign_cert_sn"`
  22755. SignCertDn string `json:"sign_cert_dn"`
  22756. } `json:"output"`
  22757. RefmsgTime string `json:"refmsg_time"`
  22758. RespondTime string `json:"respond_time"`
  22759. Signtype interface{} `json:"signtype"`
  22760. WarnInfo interface{} `json:"warn_info"`
  22761. }
  22762. type ResultCFYLJG003 struct {
  22763. ErrMsg string `json:"err_msg"`
  22764. InfRefmsgid string `json:"inf_refmsgid"`
  22765. Infcode int64 `json:"infcode"`
  22766. Output struct {
  22767. HiRxno string `json:"hi_rxno"`
  22768. RxStasCodg string `json:"rx_stas_codg"`
  22769. RxStasName string `json:"rx_stas_name"`
  22770. } `json:"output"`
  22771. RefmsgTime string `json:"refmsg_time"`
  22772. RespondTime string `json:"respond_time"`
  22773. Signtype interface{} `json:"signtype"`
  22774. WarnInfo interface{} `json:"warn_info"`
  22775. }
  22776. type ResultCFYLJG004 struct {
  22777. ErrMsg string `json:"err_msg"`
  22778. InfRefmsgid string `json:"inf_refmsgid"`
  22779. Infcode int64 `json:"infcode"`
  22780. Output struct {
  22781. HiRxno string `json:"hi_rxno"`
  22782. RxStasCodg string `json:"rx_stas_codg"`
  22783. RxStasName string `json:"rx_stas_name"`
  22784. } `json:"output"`
  22785. RefmsgTime string `json:"refmsg_time"`
  22786. RespondTime string `json:"respond_time"`
  22787. Signtype interface{} `json:"signtype"`
  22788. WarnInfo interface{} `json:"warn_info"`
  22789. }
  22790. type ResultCFYLJG008 struct {
  22791. ErrMsg string `json:"err_msg"`
  22792. InfRefmsgid string `json:"inf_refmsgid"`
  22793. Infcode int64 `json:"infcode"`
  22794. Output struct {
  22795. PoolareaNo string `json:"poolareaNo"`
  22796. AdmdvsName string `json:"admdvsName"`
  22797. Count string `json:"count"`
  22798. } `json:"output"`
  22799. RefmsgTime string `json:"refmsg_time"`
  22800. RespondTime string `json:"respond_time"`
  22801. Signtype interface{} `json:"signtype"`
  22802. WarnInfo interface{} `json:"warn_info"`
  22803. }
  22804. type ResultCFYLJG005 struct {
  22805. ErrMsg string `json:"err_msg"`
  22806. InfRefmsgid string `json:"inf_refmsgid"`
  22807. Infcode int64 `json:"infcode"`
  22808. Output struct {
  22809. HiRxNo string `json:"hi_rxno"`
  22810. FixMedinsCode string `json:"fixmedins_code"`
  22811. FixMedinsName string `json:"fixmedins_name"`
  22812. RxStasCodg string `json:"rx_stas_codg"`
  22813. RxStasName string `json:"rx_stas_name"`
  22814. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22815. RxUserdStasName string `json:"rx_userd_stas_name"`
  22816. PrscTime string `json:"prsc_time"`
  22817. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22818. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22819. RxUsedWayName string `json:"rx_used_way_name"`
  22820. RxFrquCodg string `json:"rx_frqu_codg"`
  22821. RxFrquName string `json:"rx_frqu_name"`
  22822. RxDosunt string `json:"rx_dosunt"`
  22823. RxDoscnt float64 `json:"rx_doscnt"`
  22824. RxDrordDscr string `json:"rx_drord_dscr"`
  22825. ValiDays int64 `json:"vali_days"`
  22826. ValiEndTime string `json:"vali_end_time"`
  22827. ReptFlag string `json:"rept_flag"`
  22828. MaxReptCnt int64 `json:"max_rept_cnt"`
  22829. ReptdCnt int64 `json:"reptd_cnt"`
  22830. MinInrvDays int64 `json:"min_inrv_days"`
  22831. RxTypeCode string `json:"rx_type_code"`
  22832. RxTypeName string `json:"rx_type_name"`
  22833. LongRxFlag string `json:"long_rx_flag"`
  22834. RxDetlList []struct {
  22835. MedListCodg string `json:"med_list_codg"`
  22836. MedinsListCodg string `json:"medins_list_codg"`
  22837. HospPrepFlag string `json:"hosp_prep_flag"`
  22838. RxItemTypeCode string `json:"rx_item_type_code"`
  22839. RxItemTypeName string `json:"rx_item_type_name"`
  22840. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22841. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22842. TcmHerbFoote string `json:"tcmherb_foote"`
  22843. MednTypeCode string `json:"medn_type_code"`
  22844. MednTypeName string `json:"medn_type_name"`
  22845. MainMedcFlag string `json:"main_medc_flag"`
  22846. UrgtFlag string `json:"urgt_flag"`
  22847. BasMednFlag string `json:"bas_medn_flag"`
  22848. ImpDrugFlag string `json:"imp_drug_flag"`
  22849. ProdBarc string `json:"prod_barc"`
  22850. DrugProdname string `json:"drug_prodname"`
  22851. GennameCodg string `json:"genname_codg"`
  22852. DrugGenname string `json:"drug_genname"`
  22853. DrugDosform string `json:"drug_dosform"`
  22854. DrugSpec string `json:"drug_spec"`
  22855. PrdrName string `json:"prdr_name"`
  22856. MedcWayCodg string `json:"medc_way_codg"`
  22857. MedcWayDscr string `json:"medc_way_dscr"`
  22858. MedcBegntime string `json:"medc_begntime"`
  22859. MedcEndtime string `json:"medc_endtime"`
  22860. MedcDays float64 `json:"medc_days"`
  22861. DrugPric float64 `json:"drug_pric"`
  22862. DrugSumamt float64 `json:"drug_sumamt"`
  22863. DrugCnt float64 `json:"drug_cnt"`
  22864. DrugDosunt string `json:"drug_dosunt"`
  22865. SinDoscnt float64 `json:"sin_doscnt"`
  22866. SinDosunt string `json:"sin_dosunt"`
  22867. UsedFrquCodg string `json:"used_frqu_codg"`
  22868. UsedFrquName string `json:"used_frqu_name"`
  22869. DrugTotlcnt string `json:"drug_totlcnt"`
  22870. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22871. DiseCodg string `json:"dise_codg"`
  22872. HospApprFlag string `json:"hosp_appr_flag"`
  22873. } `json:"rx_detl_list"`
  22874. RxOtpinfo struct {
  22875. MedType string `json:"med_type"`
  22876. IptOtpNo string `json:"ipt_otp_no"`
  22877. OtpIptFlag string `json:"otp_ipt_flag"`
  22878. PatnName string `json:"patn_name"`
  22879. PatnAge float64 `json:"patn_age"`
  22880. PatnHgt float64 `json:"patn_hgt"`
  22881. PatnWt float64 `json:"patn_wt"`
  22882. Gend string `json:"gend"`
  22883. GesoVal float64 `json:"geso_val"`
  22884. NwbFlag string `json:"nwb_flag"`
  22885. NwbAge string `json:"nwb_age"`
  22886. SuckPrdFlag string `json:"suck_prd_flag"`
  22887. AlgsHis string `json:"algs_his"`
  22888. Insutype string `json:"insutype"`
  22889. PrscDeptName string `json:"prsc_dept_name"`
  22890. PrscDrName string `json:"prsc_dr_name"`
  22891. PharName string `json:"phar_name"`
  22892. PharChkTime string `json:"phar_chk_time"`
  22893. MdtrtTime string `json:"mdtrt_time"`
  22894. DiseCodg string `json:"dise_codg"`
  22895. DiseName string `json:"dise_name"`
  22896. SpDiseFlag string `json:"sp_dise_flag"`
  22897. MaindiagCode string `json:"maindiag_code"`
  22898. MaindiagName string `json:"maindiag_name"`
  22899. DiseCondDscr string `json:"dise_cond_dscr"`
  22900. FstdiagFlag string `json:"fstdiag_flag"`
  22901. } `json:"rx_otpinfo"`
  22902. RxDiseList []struct {
  22903. DiagType string `json:"diag_type"`
  22904. MaindiagFlag string `json:"maindiag_flag"`
  22905. DiagSrtNo string `json:"diag_srt_no"`
  22906. DiagCode string `json:"diag_code"`
  22907. DiagName string `json:"diag_name"`
  22908. DiagDept string `json:"diag_dept"`
  22909. DiagDrNo string `json:"diag_dr_no"`
  22910. DiagDrName string `json:"diag_dr_name"`
  22911. DiagTime string `json:"diag_time"`
  22912. TcmDiseCode string `json:"tcm_dise_code"`
  22913. TcmDiseName string `json:"tcm_dise_name"`
  22914. TcmSympCode string `json:"tcmsymp_code"`
  22915. TcmSymp string `json:"tcmsymp"`
  22916. } `json:"rx_dise_list"`
  22917. } `json:"output"`
  22918. RefmsgTime string `json:"refmsg_time"`
  22919. RespondTime string `json:"respond_time"`
  22920. Signtype interface{} `json:"signtype"`
  22921. WarnInfo interface{} `json:"warn_info"`
  22922. }
  22923. type ResultCFYLJG006 struct {
  22924. ErrMsg string `json:"err_msg"`
  22925. InfRefmsgid string `json:"inf_refmsgid"`
  22926. Infcode int64 `json:"infcode"`
  22927. Output struct {
  22928. HiRxNo string `json:"hi_rxno"`
  22929. PharCode string `json:"phar_code"`
  22930. PharName string `json:"phar_name"`
  22931. RxChkOpnn string `json:"rx_chk_opnn"`
  22932. RxChkTime string `json:"rx_chk_time"`
  22933. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22934. RxChkStasName string `json:"rx_chk_stas_name"`
  22935. RxStasCodg string `json:"rx_stas_codg"`
  22936. RxStasName string `json:"rx_stas_name"`
  22937. } `json:"output"`
  22938. RefmsgTime string `json:"refmsg_time"`
  22939. RespondTime string `json:"respond_time"`
  22940. Signtype interface{} `json:"signtype"`
  22941. WarnInfo interface{} `json:"warn_info"`
  22942. }
  22943. type ResultFourteen10265 struct {
  22944. ErrMsg string `json:"err_msg"`
  22945. InfRefmsgid string `json:"inf_refmsgid"`
  22946. Infcode string `json:"infcode"`
  22947. Output struct {
  22948. } `json:"output"`
  22949. RefmsgTime string `json:"refmsg_time"`
  22950. RespondTime string `json:"respond_time"`
  22951. Signtype interface{} `json:"signtype"`
  22952. WarnInfo interface{} `json:"warn_info"`
  22953. }
  22954. type ResultSixteen struct {
  22955. Cainfo string `json:"cainfo"`
  22956. ErrMsg string `json:"err_msg"`
  22957. InfRefmsgid string `json:"inf_refmsgid"`
  22958. Infcode int64 `json:"infcode"`
  22959. Output struct {
  22960. Setlinfo struct {
  22961. MdtrtID string `json:"mdtrt_id"`
  22962. SetlID string `json:"setl_id"`
  22963. ClrOptins string `json:"clr_optins"`
  22964. SetlTime string `json:"setl_time"`
  22965. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22966. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22967. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22968. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22969. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22970. ActPayDedc float64 `json:"act_pay_dedc"`
  22971. HifpPay float64 `json:"hifp_pay"`
  22972. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22973. Lfpay float64 `json:"selfpay"`
  22974. CvlservPay float64 `json:"cvlserv_pay"`
  22975. HifesPay float64 `json:"hifes_pay"`
  22976. HifmiPay float64 `json:"hifmi_pay"`
  22977. HifobPay float64 `json:"hifob_pay"`
  22978. MafPay float64 `json:"maf_pay"`
  22979. OthPay float64 `json:"oth_pay"`
  22980. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22981. PsnPartAmt float64 `json:"psn_part_amt"`
  22982. AcctPay float64 `json:"acct_pay"`
  22983. Balc float64 `json:"balc"`
  22984. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22985. HospPartAmt float64 `json:"hosp_part_amt"`
  22986. MedinsSetlID string `json:"medins_setl_id"`
  22987. PdnCashPay string `json:"pdn_cash_pay"`
  22988. } `json:"setlinfo"`
  22989. } `json:"output"`
  22990. RefmsgTime string `json:"refmsg_time"`
  22991. RespondTime string `json:"respond_time"`
  22992. Signtype interface{} `json:"signtype"`
  22993. WarnMsg interface{} `json:"warn_msg"`
  22994. }
  22995. type ResultSixteen10265 struct {
  22996. Cainfo string `json:"cainfo"`
  22997. ErrMsg string `json:"err_msg"`
  22998. InfRefmsgid string `json:"inf_refmsgid"`
  22999. Infcode string `json:"infcode"`
  23000. Output struct {
  23001. Setlinfo struct {
  23002. MdtrtID string `json:"mdtrt_id"`
  23003. SetlID string `json:"setl_id"`
  23004. ClrOptins string `json:"clr_optins"`
  23005. SetlTime string `json:"setl_time"`
  23006. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23007. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23008. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23009. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23010. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23011. ActPayDedc float64 `json:"act_pay_dedc"`
  23012. HifpPay float64 `json:"hifp_pay"`
  23013. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23014. Lfpay float64 `json:"selfpay"`
  23015. CvlservPay float64 `json:"cvlserv_pay"`
  23016. HifesPay float64 `json:"hifes_pay"`
  23017. HifmiPay float64 `json:"hifmi_pay"`
  23018. HifobPay float64 `json:"hifob_pay"`
  23019. MafPay float64 `json:"maf_pay"`
  23020. OthPay float64 `json:"oth_pay"`
  23021. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23022. PsnPartAmt float64 `json:"psn_part_amt"`
  23023. AcctPay float64 `json:"acct_pay"`
  23024. Balc float64 `json:"balc"`
  23025. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23026. HospPartAmt float64 `json:"hosp_part_amt"`
  23027. MedinsSetlID string `json:"medins_setl_id"`
  23028. PdnCashPay string `json:"pdn_cash_pay"`
  23029. } `json:"setlinfo"`
  23030. } `json:"output"`
  23031. RefmsgTime string `json:"refmsg_time"`
  23032. RespondTime string `json:"respond_time"`
  23033. Signtype interface{} `json:"signtype"`
  23034. WarnMsg interface{} `json:"warn_msg"`
  23035. }
  23036. type ResultSixteen10265Two struct {
  23037. Cainfo string `json:"cainfo"`
  23038. ErrMsg string `json:"err_msg"`
  23039. InfRefmsgid string `json:"inf_refmsgid"`
  23040. Infcode string `json:"infcode"`
  23041. Output struct {
  23042. Setlinfo interface{} `json:"setlinfo"`
  23043. } `json:"output"`
  23044. RefmsgTime string `json:"refmsg_time"`
  23045. RespondTime string `json:"respond_time"`
  23046. Signtype interface{} `json:"signtype"`
  23047. WarnMsg interface{} `json:"warn_msg"`
  23048. }
  23049. type ResultgzSixteen10265Two struct {
  23050. Cainfo string `json:"cainfo"`
  23051. ErrMsg string `json:"err_msg"`
  23052. InfRefmsgid string `json:"inf_refmsgid"`
  23053. Infcode int64 `json:"infcode"`
  23054. Output struct {
  23055. Setlinfo interface{} `json:"setlinfo"`
  23056. } `json:"output"`
  23057. RefmsgTime string `json:"refmsg_time"`
  23058. RespondTime string `json:"respond_time"`
  23059. Signtype interface{} `json:"signtype"`
  23060. WarnMsg interface{} `json:"warn_msg"`
  23061. }
  23062. type ResultSeventeen struct {
  23063. ErrMsg string `json:"err_msg"`
  23064. InfRefmsgid string `json:"inf_refmsgid"`
  23065. Infcode int64 `json:"infcode"`
  23066. Output struct {
  23067. SetlListId string `json:"setl_list_id"`
  23068. } `json:"output"`
  23069. RefmsgTime string `json:"refmsg_time"`
  23070. RespondTime string `json:"respond_time"`
  23071. Signtype string `json:"signtype"`
  23072. WarnInfo string `json:"warn_info"`
  23073. }
  23074. type ResultSeventeenOther struct {
  23075. ErrMsg string `json:"err_msg"`
  23076. InfRefmsgid string `json:"inf_refmsgid"`
  23077. Infcode string `json:"infcode"`
  23078. Output struct {
  23079. SetlListId string `json:"setl_list_id"`
  23080. } `json:"output"`
  23081. RefmsgTime string `json:"refmsg_time"`
  23082. RespondTime string `json:"respond_time"`
  23083. Signtype string `json:"signtype"`
  23084. WarnInfo string `json:"warn_info"`
  23085. }
  23086. type Result90991 struct {
  23087. ErrMsg string `json:"err_msg"`
  23088. InfRefmsgid string `json:"inf_refmsgid"`
  23089. Infcode int64 `json:"infcode"`
  23090. Output struct {
  23091. Result struct {
  23092. PsnNo string `json:"psn_no"`
  23093. CardStat string `json:"card_stat"`
  23094. Certno string `json:"certno"`
  23095. PsnName string `json:"psn_name"`
  23096. CheckStat string `json:"check_stat"`
  23097. SscnoCheckStat string `json:"sscno_check_stat"`
  23098. } `json:"result"`
  23099. } `json:"output"`
  23100. RefmsgTime string `json:"refmsg_time"`
  23101. RespondTime string `json:"respond_time"`
  23102. Signtype interface{} `json:"signtype"`
  23103. WarnInfo interface{} `json:"warn_info"`
  23104. }
  23105. type Result90100 struct {
  23106. ErrMsg string `json:"err_msg"`
  23107. InfRefmsgid string `json:"inf_refmsgid"`
  23108. Infcode int64 `json:"infcode"`
  23109. Output struct {
  23110. PoolareaNo string `json:"poolarea_no"`
  23111. PoolareaNoName string `json:"poolarea_no_name"`
  23112. Insutype string `json:"insutype"`
  23113. InsutypeName string `json:"insutype_name"`
  23114. ClctType string `json:"clct_type"`
  23115. ClctTypeName string `json:"clct_type_name"`
  23116. ClctFlag string `json:"clct_flag"`
  23117. ClctFlagName string `json:"clct_flag_name"`
  23118. AccrymBegn string `json:"accrym_begn"`
  23119. AccrymEnd string `json:"accrym_end"`
  23120. ClctTime string `json:"clct_time"`
  23121. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23122. } `json:"output"`
  23123. RefmsgTime string `json:"refmsg_time"`
  23124. RespondTime string `json:"respond_time"`
  23125. Signtype interface{} `json:"signtype"`
  23126. WarnInfo interface{} `json:"warn_info"`
  23127. }
  23128. type Custom struct {
  23129. DetItemFeeSumamt string
  23130. Cut string
  23131. FeedetlSn string
  23132. Price string
  23133. MedListCodg string
  23134. Type int64
  23135. AdviceId int64
  23136. ProjectId int64
  23137. ItemId int64
  23138. }
  23139. type Result5301 struct {
  23140. ErrMsg string `json:"err_msg"`
  23141. InfRefmsgid string `json:"inf_refmsgid"`
  23142. Infcode int64 `json:"infcode"`
  23143. Output struct {
  23144. Result []struct {
  23145. OpspDiseCode string `json:"opsp_dise_code"`
  23146. OpspDiseName string `json:"opsp_dise_name"`
  23147. Begndate string `json:"begndate"`
  23148. Enddate string `json:"enddate"`
  23149. } `json:"feedetail"`
  23150. } `json:"output"`
  23151. RefmsgTime string `json:"refmsg_time"`
  23152. RespondTime string `json:"respond_time"`
  23153. Signtype interface{} `json:"signtype"`
  23154. WarnInfo interface{} `json:"warn_info"`
  23155. }
  23156. type Result5301For10265 struct {
  23157. ErrMsg string `json:"err_msg"`
  23158. InfRefmsgid string `json:"inf_refmsgid"`
  23159. Infcode string `json:"infcode"`
  23160. Output struct {
  23161. Result []struct {
  23162. OpspDiseCode string `json:"opsp_dise_code"`
  23163. OpspDiseName string `json:"opsp_dise_name"`
  23164. Begndate string `json:"begndate"`
  23165. Enddate string `json:"enddate"`
  23166. } `json:"feedetail"`
  23167. } `json:"output"`
  23168. RefmsgTime string `json:"refmsg_time"`
  23169. RespondTime string `json:"respond_time"`
  23170. Signtype interface{} `json:"signtype"`
  23171. WarnInfo interface{} `json:"warn_info"`
  23172. }
  23173. //获取个人信息----挂号-----上传就诊信息
  23174. func (c *HisApiController) GetRegisterInfo() {
  23175. id, _ := c.GetInt64("id")
  23176. record_time := c.GetString("record_time")
  23177. settlementValue, _ := c.GetInt64("settlement_value")
  23178. medical_insurance_card := c.GetString("medical_insurance_card")
  23179. name := c.GetString("name")
  23180. id_card_type, _ := c.GetInt64("id_card_type")
  23181. certificates, _ := c.GetInt64("certificates")
  23182. medical_care, _ := c.GetInt64("medical_care")
  23183. birthday := c.GetString("birthday")
  23184. id_card := c.GetString("id_card")
  23185. register_type, _ := c.GetInt64("register")
  23186. doctor, _ := c.GetInt64("doctor")
  23187. department, _ := c.GetInt64("department")
  23188. gender, _ := c.GetInt64("sex")
  23189. registration_fee, _ := c.GetFloat("registration_fee")
  23190. medical_expenses, _ := c.GetFloat("medical_expenses")
  23191. social_type, _ := c.GetInt64("social_type")
  23192. admin_user_id, _ := c.GetInt64("admin_user_id")
  23193. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23194. mdtrt_type := c.GetString("mdtrt_type")
  23195. if id_card_type == 5 {
  23196. id_card_type = 4
  23197. }
  23198. timeLayout := "2006-01-02"
  23199. loc, _ := time.LoadLocation("Local")
  23200. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23201. birthUnix := birthdays.Unix()
  23202. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23203. if err != nil {
  23204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23205. return
  23206. }
  23207. recordDateTime := theTime.Unix()
  23208. adminInfo := c.GetAdminUserInfo()
  23209. var patient service.Patients
  23210. if id == 0 {
  23211. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23212. } else {
  23213. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23214. }
  23215. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23216. if patientPrescription.ID == 0 {
  23217. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23218. }
  23219. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23220. if patient.ID == 0 {
  23221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23222. return
  23223. }
  23224. if len(patient.IdCardNo) == 0 {
  23225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23226. return
  23227. }
  23228. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23229. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23230. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23231. //就诊结算未完成,不能进行二次挂号
  23232. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23233. if len(his) >= 1 {
  23234. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23235. if len(his) >= 1 && order.ID == 0 {
  23236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23237. return
  23238. }
  23239. }
  23240. //var register_log string
  23241. if config.IsOpen == 1 {
  23242. var res ResultTwo
  23243. var res10265 ResultTwo10265
  23244. var PsnNo string
  23245. var PsnCertType string
  23246. var Certno string
  23247. var PsnName string
  23248. var Gend string
  23249. var Naty string
  23250. var Brdy string
  23251. var Age float64
  23252. var infoStr string
  23253. var idetinfoStr string
  23254. var infocode int64
  23255. var verify_number string
  23256. fmt.Println(verify_number)
  23257. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23258. psn_info, _ := service.GetPsnByPatientId(id)
  23259. PsnNo = psn_info.PsnNo
  23260. PsnCertType = psn_info.PsnCertType
  23261. Certno = psn_info.Certno
  23262. PsnName = psn_info.PsnName
  23263. Gend = psn_info.Gend
  23264. Naty = psn_info.Naty
  23265. Brdy = psn_info.Brdy
  23266. Age = psn_info.Age
  23267. infoStr = psn_info.Insuinfo
  23268. idetinfoStr = psn_info.Idetinfo
  23269. infocode = 0
  23270. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23271. psn_info, _ := service.GetPsnByPatientId(id)
  23272. PsnNo = psn_info.PsnNo
  23273. PsnCertType = psn_info.PsnCertType
  23274. Certno = psn_info.Certno
  23275. PsnName = psn_info.PsnName
  23276. Gend = psn_info.Gend
  23277. Naty = psn_info.Naty
  23278. Brdy = psn_info.Brdy
  23279. Age = psn_info.Age
  23280. infoStr = psn_info.Insuinfo
  23281. idetinfoStr = psn_info.Idetinfo
  23282. infocode = 0
  23283. verify_number = psn_info.VerifyNumber
  23284. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23285. if id_card_type == 2 {
  23286. //请求内网数据
  23287. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23288. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23289. "&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
  23290. resp, requestErr := http.Get(api)
  23291. if requestErr != nil {
  23292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23293. return
  23294. }
  23295. body, ioErr := ioutil.ReadAll(resp.Body)
  23296. if ioErr != nil {
  23297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23299. return
  23300. }
  23301. var respJSON map[string]interface{}
  23302. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23305. return
  23306. }
  23307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23308. result_byte, _ := json.Marshal(respJSON)
  23309. result := string(result_byte)
  23310. var dat map[string]interface{}
  23311. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23312. fmt.Println(dat)
  23313. } else {
  23314. fmt.Println(err)
  23315. }
  23316. userJSONBytes, _ := json.Marshal(dat)
  23317. var res ResultTwo
  23318. var resTwo10265 ResultTwo10265
  23319. if miConfig.Code == "H15049901371" {
  23320. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23321. utils.ErrorLog("解析失败:%v", err)
  23322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23323. return
  23324. }
  23325. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23326. res.Infcode = Infcode
  23327. res.ErrMsg = resTwo10265.ErrMsg
  23328. res.Output = resTwo10265.Output
  23329. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23330. res.RespondTime = resTwo10265.RespondTime
  23331. res.WarnInfo = resTwo10265.WarnInfo
  23332. } else {
  23333. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23334. utils.ErrorLog("解析失败:%v", err)
  23335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23336. return
  23337. }
  23338. }
  23339. //var insutypes []string
  23340. //var insutype string
  23341. //var is390 int = 0
  23342. //var is310 int = 0
  23343. //for _, item := range res.Output.Iinfo {
  23344. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23345. // insutypes = append(insutypes, item.Insutype)
  23346. // }
  23347. //}
  23348. //if len(insutypes) == 1 {
  23349. // insutype = insutypes[0]
  23350. //} else {
  23351. // for _, i := range insutypes {
  23352. // if i == "390" {
  23353. // is390 = 1
  23354. // }
  23355. //
  23356. // if i == "310" {
  23357. // is310 = 1
  23358. // }
  23359. // }
  23360. //}
  23361. //if is390 == 1 {
  23362. // insutype = "390"
  23363. //}
  23364. //if is310 == 1 {
  23365. // insutype = "310"
  23366. //}
  23367. //if len(insutypes) == 0 {
  23368. // insutype = "310"
  23369. //}
  23370. PsnNo = res.Output.Baseinfo.PsnNo
  23371. PsnCertType = res.Output.Baseinfo.PsnCertType
  23372. Certno = res.Output.Baseinfo.Certno
  23373. PsnName = res.Output.Baseinfo.PsnName
  23374. Gend = res.Output.Baseinfo.Gend
  23375. Naty = res.Output.Baseinfo.Naty
  23376. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23377. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23378. infoStr = string(Iinfos)
  23379. idetinfoStr = string(Idetinfos)
  23380. infocode = res.Infcode
  23381. //infocode = 0
  23382. //verify_number = psn_info.VerifyNumber
  23383. } else {
  23384. psn_info, _ := service.GetPsnByPatientId(id)
  23385. PsnNo = psn_info.PsnNo
  23386. PsnCertType = psn_info.PsnCertType
  23387. Certno = psn_info.Certno
  23388. PsnName = psn_info.PsnName
  23389. Gend = psn_info.Gend
  23390. Naty = psn_info.Naty
  23391. Brdy = psn_info.Brdy
  23392. Age = psn_info.Age
  23393. infoStr = psn_info.Insuinfo
  23394. idetinfoStr = psn_info.Idetinfo
  23395. infocode = 0
  23396. verify_number = psn_info.VerifyNumber
  23397. }
  23398. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23399. if id_card_type == 1 {
  23400. psn_info, _ := service.GetPsnByPatientId(id)
  23401. PsnNo = psn_info.PsnNo
  23402. PsnCertType = psn_info.PsnCertType
  23403. Certno = psn_info.Certno
  23404. PsnName = psn_info.PsnName
  23405. Gend = psn_info.Gend
  23406. Naty = psn_info.Naty
  23407. Brdy = psn_info.Brdy
  23408. Age = psn_info.Age
  23409. infoStr = psn_info.Insuinfo
  23410. idetinfoStr = psn_info.Idetinfo
  23411. infocode = 0
  23412. verify_number = psn_info.VerifyNumber
  23413. } else if id_card_type == 2 {
  23414. 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)
  23415. fmt.Println(errMsgLog)
  23416. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23417. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23418. utils.ErrorLog("解析失败:%v", err)
  23419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23420. return
  23421. }
  23422. PsnNo = res.Output.Baseinfo.PsnNo
  23423. PsnCertType = res.Output.Baseinfo.PsnCertType
  23424. Certno = res.Output.Baseinfo.Certno
  23425. PsnName = res.Output.Baseinfo.PsnName
  23426. Gend = res.Output.Baseinfo.Gend
  23427. Naty = res.Output.Baseinfo.Naty
  23428. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23429. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23430. infoStr = string(Iinfos)
  23431. idetinfoStr = string(Idetinfos)
  23432. infocode = res.Infcode
  23433. }
  23434. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23435. if id_card_type == 1 {
  23436. psn_info, _ := service.GetPsnByPatientId(id)
  23437. PsnNo = psn_info.PsnNo
  23438. PsnCertType = psn_info.PsnCertType
  23439. Certno = psn_info.Certno
  23440. PsnName = psn_info.PsnName
  23441. Gend = psn_info.Gend
  23442. Naty = psn_info.Naty
  23443. Brdy = psn_info.Brdy
  23444. Age = psn_info.Age
  23445. infoStr = psn_info.Insuinfo
  23446. idetinfoStr = psn_info.Idetinfo
  23447. infocode = 0
  23448. verify_number = psn_info.VerifyNumber
  23449. } else if id_card_type == 2 {
  23450. 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, "")
  23451. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23452. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23453. utils.ErrorLog("解析失败:%v", err)
  23454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23455. return
  23456. }
  23457. PsnNo = res.Output.Baseinfo.PsnNo
  23458. PsnCertType = res.Output.Baseinfo.PsnCertType
  23459. Certno = res.Output.Baseinfo.Certno
  23460. PsnName = res.Output.Baseinfo.PsnName
  23461. Gend = res.Output.Baseinfo.Gend
  23462. Naty = res.Output.Baseinfo.Naty
  23463. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23464. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23465. infoStr = string(Iinfos)
  23466. idetinfoStr = string(Idetinfos)
  23467. infocode = res.Infcode
  23468. } else {
  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. }
  23483. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23484. if id_card_type == 1 {
  23485. psn_info, _ := service.GetPsnByPatientId(id)
  23486. PsnNo = psn_info.PsnNo
  23487. PsnCertType = psn_info.PsnCertType
  23488. Certno = psn_info.Certno
  23489. PsnName = psn_info.PsnName
  23490. Gend = psn_info.Gend
  23491. Naty = psn_info.Naty
  23492. Brdy = psn_info.Brdy
  23493. Age = psn_info.Age
  23494. infoStr = psn_info.Insuinfo
  23495. idetinfoStr = psn_info.Idetinfo
  23496. infocode = 0
  23497. verify_number = psn_info.VerifyNumber
  23498. } else if id_card_type == 2 {
  23499. psn_info, _ := service.GetPsnByPatientId(id)
  23500. PsnNo = psn_info.PsnNo
  23501. PsnCertType = psn_info.PsnCertType
  23502. Certno = psn_info.Certno
  23503. PsnName = psn_info.PsnName
  23504. Gend = psn_info.Gend
  23505. Naty = psn_info.Naty
  23506. Brdy = psn_info.Brdy
  23507. Age = psn_info.Age
  23508. infoStr = psn_info.Insuinfo
  23509. idetinfoStr = psn_info.Idetinfo
  23510. infocode = 0
  23511. verify_number = psn_info.VerifyNumber
  23512. } else {
  23513. psn_info, _ := service.GetPsnByPatientId(id)
  23514. PsnNo = psn_info.PsnNo
  23515. PsnCertType = psn_info.PsnCertType
  23516. Certno = psn_info.Certno
  23517. PsnName = psn_info.PsnName
  23518. Gend = psn_info.Gend
  23519. Naty = psn_info.Naty
  23520. Brdy = psn_info.Brdy
  23521. Age = psn_info.Age
  23522. infoStr = psn_info.Insuinfo
  23523. idetinfoStr = psn_info.Idetinfo
  23524. infocode = 0
  23525. verify_number = psn_info.VerifyNumber
  23526. }
  23527. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23528. psn_info, _ := service.GetPsnByPatientId(id)
  23529. PsnNo = psn_info.PsnNo
  23530. PsnCertType = psn_info.PsnCertType
  23531. Certno = psn_info.Certno
  23532. PsnName = psn_info.PsnName
  23533. Gend = psn_info.Gend
  23534. Naty = psn_info.Naty
  23535. Brdy = psn_info.Brdy
  23536. Age = psn_info.Age
  23537. infoStr = psn_info.Insuinfo
  23538. idetinfoStr = psn_info.Idetinfo
  23539. infocode = 0
  23540. verify_number = psn_info.VerifyNumber
  23541. idetinfoStr = psn_info.Idetinfo
  23542. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23543. if id_card_type == 1 {
  23544. psn_info, _ := service.GetPsnByPatientId(id)
  23545. PsnNo = psn_info.PsnNo
  23546. PsnCertType = psn_info.PsnCertType
  23547. Certno = psn_info.Certno
  23548. PsnName = psn_info.PsnName
  23549. Gend = psn_info.Gend
  23550. Naty = psn_info.Naty
  23551. Brdy = psn_info.Brdy
  23552. Age = psn_info.Age
  23553. infoStr = psn_info.Insuinfo
  23554. idetinfoStr = psn_info.Idetinfo
  23555. infocode = 0
  23556. verify_number = psn_info.VerifyNumber
  23557. } else if id_card_type == 2 {
  23558. 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)
  23559. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23560. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23561. utils.ErrorLog("解析失败:%v", err)
  23562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23563. return
  23564. }
  23565. PsnNo = res.Output.Baseinfo.PsnNo
  23566. PsnCertType = res.Output.Baseinfo.PsnCertType
  23567. Certno = res.Output.Baseinfo.Certno
  23568. PsnName = res.Output.Baseinfo.PsnName
  23569. Gend = res.Output.Baseinfo.Gend
  23570. Naty = res.Output.Baseinfo.Naty
  23571. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23572. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23573. infoStr = string(Iinfos)
  23574. idetinfoStr = string(Idetinfos)
  23575. infocode = res.Infcode
  23576. } else if id_card_type == 4 {
  23577. psn_info, _ := service.GetPsnByPatientId(id)
  23578. PsnNo = psn_info.PsnNo
  23579. PsnCertType = psn_info.PsnCertType
  23580. Certno = psn_info.Certno
  23581. PsnName = psn_info.PsnName
  23582. Gend = psn_info.Gend
  23583. Naty = psn_info.Naty
  23584. Brdy = psn_info.Brdy
  23585. Age = psn_info.Age
  23586. infoStr = psn_info.Insuinfo
  23587. idetinfoStr = psn_info.Idetinfo
  23588. infocode = 0
  23589. verify_number = psn_info.VerifyNumber
  23590. }
  23591. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23592. var result string
  23593. var requestLog string
  23594. 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), "")
  23595. if id_card_type == 4 {
  23596. psn_info, _ := service.GetPsnByPatientId(id)
  23597. PsnNo = psn_info.PsnNo
  23598. PsnCertType = psn_info.PsnCertType
  23599. Certno = psn_info.Certno
  23600. PsnName = psn_info.PsnName
  23601. Gend = psn_info.Gend
  23602. Naty = psn_info.Naty
  23603. Brdy = psn_info.Brdy
  23604. Age = psn_info.Age
  23605. infoStr = psn_info.Insuinfo
  23606. idetinfoStr = psn_info.Idetinfo
  23607. infocode = 0
  23608. verify_number = psn_info.VerifyNumber
  23609. } else {
  23610. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23611. if miConfig.Code == "H15049901371" {
  23612. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23613. utils.ErrorLog("解析失败:%v", err)
  23614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23615. return
  23616. }
  23617. res.ErrMsg = res10265.ErrMsg
  23618. res.Output = res10265.Output
  23619. res.InfRefmsgid = res10265.InfRefmsgid
  23620. } else {
  23621. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23622. utils.ErrorLog("解析失败:%v", err)
  23623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23624. return
  23625. }
  23626. }
  23627. PsnNo = res.Output.Baseinfo.PsnNo
  23628. PsnCertType = res.Output.Baseinfo.PsnCertType
  23629. Certno = res.Output.Baseinfo.Certno
  23630. PsnName = res.Output.Baseinfo.PsnName
  23631. Gend = res.Output.Baseinfo.Gend
  23632. Naty = res.Output.Baseinfo.Naty
  23633. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23634. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23635. infoStr = string(Iinfos)
  23636. idetinfoStr = string(Idetinfos)
  23637. if miConfig.Code == "H15049901371" {
  23638. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23639. } else {
  23640. infocode = res.Infcode
  23641. }
  23642. }
  23643. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23644. psn_info, _ := service.GetPsnByPatientId(id)
  23645. PsnNo = psn_info.PsnNo
  23646. PsnCertType = psn_info.PsnCertType
  23647. Certno = psn_info.Certno
  23648. PsnName = psn_info.PsnName
  23649. Gend = psn_info.Gend
  23650. Naty = psn_info.Naty
  23651. Brdy = psn_info.Brdy
  23652. Age = psn_info.Age
  23653. infoStr = psn_info.Insuinfo
  23654. idetinfoStr = psn_info.Idetinfo
  23655. infocode = 0
  23656. verify_number = psn_info.VerifyNumber
  23657. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23658. psn_info, _ := service.GetPsnByPatientId(id)
  23659. PsnNo = psn_info.PsnNo
  23660. PsnCertType = psn_info.PsnCertType
  23661. Certno = psn_info.Certno
  23662. PsnName = psn_info.PsnName
  23663. Gend = psn_info.Gend
  23664. Naty = psn_info.Naty
  23665. Brdy = psn_info.Brdy
  23666. Age = psn_info.Age
  23667. infoStr = psn_info.Insuinfo
  23668. idetinfoStr = psn_info.Idetinfo
  23669. infocode = 0
  23670. verify_number = psn_info.VerifyNumber
  23671. } else {
  23672. var result string
  23673. var requestLog string
  23674. //if miConfig.UserOrgId == 10138 {
  23675. if id_card_type != 4 || id_card_type != 1 {
  23676. var insa string
  23677. if len(patient.InsuplcAdmdvs) > 0 {
  23678. insa = patient.InsuplcAdmdvs
  23679. } else {
  23680. insa = miConfig.InsuplcAdmdvs
  23681. }
  23682. //psn_info, _ := service.GetPsnByPatientId(id)
  23683. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23684. 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)
  23685. }
  23686. //}
  23687. //else {
  23688. // var insa string
  23689. // if len(patient.InsuplcAdmdvs) > 0 {
  23690. // insa = patient.InsuplcAdmdvs
  23691. // } else {
  23692. // insa = miConfig.InsuplcAdmdvs
  23693. // }
  23694. // 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)
  23695. //}
  23696. if id_card_type == 4 || id_card_type == 1 {
  23697. psn_info, _ := service.GetPsnByPatientId(id)
  23698. PsnNo = psn_info.PsnNo
  23699. PsnCertType = psn_info.PsnCertType
  23700. Certno = psn_info.Certno
  23701. PsnName = psn_info.PsnName
  23702. Gend = psn_info.Gend
  23703. Naty = psn_info.Naty
  23704. Brdy = psn_info.Brdy
  23705. Age = psn_info.Age
  23706. infoStr = psn_info.Insuinfo
  23707. idetinfoStr = psn_info.Idetinfo
  23708. infocode = 0
  23709. verify_number = psn_info.VerifyNumber
  23710. } else {
  23711. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23712. if miConfig.Code == "H15049901371" {
  23713. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23714. utils.ErrorLog("解析失败:%v", err)
  23715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23716. return
  23717. }
  23718. res.ErrMsg = res10265.ErrMsg
  23719. res.Output = res10265.Output
  23720. res.InfRefmsgid = res10265.InfRefmsgid
  23721. } else {
  23722. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23723. utils.ErrorLog("解析失败:%v", err)
  23724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23725. return
  23726. }
  23727. }
  23728. PsnNo = res.Output.Baseinfo.PsnNo
  23729. PsnCertType = res.Output.Baseinfo.PsnCertType
  23730. Certno = res.Output.Baseinfo.Certno
  23731. PsnName = res.Output.Baseinfo.PsnName
  23732. Gend = res.Output.Baseinfo.Gend
  23733. Naty = res.Output.Baseinfo.Naty
  23734. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23735. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23736. infoStr = string(Iinfos)
  23737. idetinfoStr = string(Idetinfos)
  23738. if miConfig.Code == "H15049901371" {
  23739. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23740. } else {
  23741. infocode = res.Infcode
  23742. }
  23743. }
  23744. }
  23745. if infocode == 0 {
  23746. his := models.VMHisPatient{
  23747. Name: name,
  23748. Gender: gender,
  23749. Birthday: birthUnix,
  23750. MedicalTreatmentType: medical_care,
  23751. IdType: certificates,
  23752. IdCardNo: id_card,
  23753. BalanceAccountsType: settlementValue,
  23754. SocialType: social_type,
  23755. MedicalInsuranceNumber: medical_insurance_card,
  23756. RegisterType: register_type,
  23757. RegisterCost: registration_fee,
  23758. TreatmentCost: medical_expenses,
  23759. Status: 1,
  23760. Ctime: time.Now().Unix(),
  23761. Mtime: time.Now().Unix(),
  23762. PsnNo: PsnNo,
  23763. PsnCertType: PsnCertType,
  23764. Certno: Certno,
  23765. PsnName: PsnName,
  23766. Gend: Gend,
  23767. Naty: Naty,
  23768. Brdy: Brdy,
  23769. Age: Age,
  23770. Iinfo: infoStr,
  23771. Idetinfo: idetinfoStr,
  23772. PatientId: patient.ID,
  23773. RecordDate: theTime.Unix(),
  23774. UserOrgId: adminInfo.CurrentOrgId,
  23775. AdminUserId: admin_user_id,
  23776. IsReturn: 1,
  23777. IdCardType: id_card_type,
  23778. Doctor: doctor,
  23779. Departments: department,
  23780. MdtrtGrpType: mdtrt_type,
  23781. }
  23782. timestamp := time.Now().Unix()
  23783. tempTime := time.Unix(timestamp, 0)
  23784. timeFormat := tempTime.Format("20060102150405")
  23785. chrgBchno := rand.Intn(100000) + 10000
  23786. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23787. his.Number = ipt_otp_no
  23788. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23789. department, _ := service.GetDepartMentDetail(department)
  23790. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23791. IdCardNo := ""
  23792. if id_card_type == 1 {
  23793. // IdCardNo = medical_insurance_card
  23794. IdCardNo = patient.IdCardNo
  23795. } else {
  23796. IdCardNo = patient.IdCardNo
  23797. }
  23798. var rf []*ResultFive
  23799. json.Unmarshal([]byte(his.Iinfo), &rf)
  23800. var insutypes []*ResultFive
  23801. var insutype string
  23802. var insuplc_admdvs_temp string
  23803. var is390 int = 0
  23804. var is310 int = 0
  23805. for _, item := range rf {
  23806. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23807. insutypes = append(insutypes, item)
  23808. }
  23809. }
  23810. if len(insutypes) == 1 {
  23811. insutype = insutypes[0].Insutype
  23812. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23813. if insutype == "390" {
  23814. is390 = 1
  23815. }
  23816. if insutype == "310" {
  23817. is310 = 1
  23818. }
  23819. } else {
  23820. for _, i := range insutypes {
  23821. if i.Insutype == "390" {
  23822. is390 = 1
  23823. }
  23824. if i.Insutype == "310" {
  23825. is310 = 1
  23826. }
  23827. }
  23828. }
  23829. if is390 == 1 {
  23830. insutype = "390"
  23831. }
  23832. if is310 == 1 {
  23833. insutype = "310"
  23834. }
  23835. fmt.Println(social_type)
  23836. if social_type > 0 {
  23837. insutype = strconv.FormatInt(social_type, 10)
  23838. }
  23839. var infocode int64
  23840. var resThree ResultThree
  23841. var resThree10265 ResultThree10265
  23842. if len(insuplc_admdvs) == 0 {
  23843. psn_info, _ := service.GetPsnByPatientId(id)
  23844. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23845. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23846. //}
  23847. } else {
  23848. insuplc_admdvs_temp = insuplc_admdvs
  23849. }
  23850. if miConfig.MdtrtareaAdmvs == "421300" {
  23851. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23852. psn_info, _ := service.GetPsnByPatientId(id)
  23853. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23854. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23855. "&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
  23856. resp, requestErr := http.Get(api)
  23857. if requestErr != nil {
  23858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23859. return
  23860. }
  23861. body, ioErr := ioutil.ReadAll(resp.Body)
  23862. if ioErr != nil {
  23863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23865. return
  23866. }
  23867. var respJSON map[string]interface{}
  23868. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23871. return
  23872. }
  23873. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23874. result, _ := json.Marshal(respJSON)
  23875. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23876. utils.ErrorLog("解析失败:%v", err)
  23877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23878. return
  23879. }
  23880. infocode = resThree.Infcode
  23881. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23882. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23883. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23884. // insuplc_admdvs_temp =
  23885. //}
  23886. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23887. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23888. //}
  23889. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23890. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23891. "&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
  23892. resp, requestErr := http.Get(api)
  23893. if requestErr != nil {
  23894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23895. return
  23896. }
  23897. body, ioErr := ioutil.ReadAll(resp.Body)
  23898. if ioErr != nil {
  23899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23901. return
  23902. }
  23903. var respJSON map[string]interface{}
  23904. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23907. return
  23908. }
  23909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23910. result, _ := json.Marshal(respJSON)
  23911. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23912. utils.ErrorLog("解析失败:%v", err)
  23913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23914. return
  23915. }
  23916. infocode = resThree.Infcode
  23917. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23918. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23919. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23920. // insuplc_admdvs_temp =
  23921. //}
  23922. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23923. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23924. //}
  23925. utils.ErrorLog("解析失败:%v", insutype)
  23926. utils.ErrorLog("解析失败:%v", PsnNo)
  23927. utils.ErrorLog("解析失败:%v", Certno)
  23928. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23929. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23930. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23931. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23932. utils.ErrorLog("解析失败:%v", PsnNo)
  23933. utils.ErrorLog("解析失败:%v", department.Number)
  23934. utils.ErrorLog("解析失败:%v", department.Name)
  23935. utils.ErrorLog("解析失败:%v", roles.UserName)
  23936. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23937. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23938. "&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
  23939. resp, requestErr := http.Get(api)
  23940. if requestErr != nil {
  23941. utils.ErrorLog("解析失败:%v", requestErr)
  23942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23943. return
  23944. }
  23945. body, ioErr := ioutil.ReadAll(resp.Body)
  23946. if ioErr != nil {
  23947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23949. return
  23950. }
  23951. var respJSON map[string]interface{}
  23952. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23955. return
  23956. }
  23957. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23958. result, _ := json.Marshal(respJSON)
  23959. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23960. utils.ErrorLog("解析失败:%v", err)
  23961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23962. return
  23963. }
  23964. infocode = resThree.Infcode
  23965. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23966. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23967. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23968. // insuplc_admdvs_temp =
  23969. //}
  23970. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23971. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23972. //}
  23973. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23974. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23975. "&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
  23976. resp, requestErr := http.Get(api)
  23977. if requestErr != nil {
  23978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23979. return
  23980. }
  23981. body, ioErr := ioutil.ReadAll(resp.Body)
  23982. if ioErr != nil {
  23983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23985. return
  23986. }
  23987. var respJSON map[string]interface{}
  23988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23991. return
  23992. }
  23993. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23994. result, _ := json.Marshal(respJSON)
  23995. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23996. utils.ErrorLog("解析失败:%v", err)
  23997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23998. return
  23999. }
  24000. infocode = resThree.Infcode
  24001. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24002. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24003. psn_info, _ := service.GetPsnByPatientId(id)
  24004. var verify_number string
  24005. if id_card_type == 4 {
  24006. verify_number = psn_info.VerifyNumber
  24007. } else if id_card_type == 1 {
  24008. bas := strings.Split(psn_info.CardInfo, "|")
  24009. cardNumber := bas[2]
  24010. verify_number = cardNumber
  24011. }
  24012. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24013. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24014. "&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
  24015. resp, requestErr := http.Get(api)
  24016. if requestErr != nil {
  24017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24018. return
  24019. }
  24020. body, ioErr := ioutil.ReadAll(resp.Body)
  24021. if ioErr != nil {
  24022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24024. return
  24025. }
  24026. var respJSON map[string]interface{}
  24027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24030. return
  24031. }
  24032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24033. result, _ := json.Marshal(respJSON)
  24034. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24035. // utils.ErrorLog("解析失败:%v", err)
  24036. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24037. // return
  24038. //}
  24039. //infocode = resThree.Infcode
  24040. //result, _ := json.Marshal(respJSON)
  24041. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24042. utils.ErrorLog("解析失败:%v", err)
  24043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24044. return
  24045. }
  24046. resThree.ErrMsg = resThree10265.ErrMsg
  24047. resThree.Output = resThree10265.Output
  24048. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24049. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24050. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24051. psn_info, _ := service.GetPsnByPatientId(id)
  24052. his.PsnNo = psn_info.PsnNo
  24053. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24054. var cert_no string
  24055. if id_card_type == 3 {
  24056. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  24057. cert_no = IdCardNo
  24058. } else if id_card_type == 4 {
  24059. cert_no = IdCardNo
  24060. psn_info.VerifyNumber = psn_info.VerifyNumber
  24061. } else {
  24062. bas := strings.Split(psn_info.CardInfo, "|")
  24063. cert_no = bas[2]
  24064. }
  24065. var hisPrescription []*models.HisPrescription
  24066. for _, item := range rf {
  24067. if item.Insutype == insutype {
  24068. //insuplc_admdvs = item.InsuplcAdmdvs
  24069. his.InsuplcAdmdvs = insuplc_admdvs
  24070. }
  24071. }
  24072. his.Insutype = insutype
  24073. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24074. fmt.Println(res3101)
  24075. fmt.Println(res3101.Infcode)
  24076. if res3101.Infcode == "0" {
  24077. fmt.Println("33333333")
  24078. if len(res3101.Output.Result) > 0 {
  24079. fmt.Println("222222")
  24080. for _, item := range res3101.Output.Result {
  24081. if len(res3101.ErrMsg) == 0 {
  24082. res3101.ErrMsg = item.VolaCont
  24083. } else {
  24084. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24085. }
  24086. }
  24087. c.ServeSuccessJSON(map[string]interface{}{
  24088. "failed_code": -10,
  24089. "msg": res3101.ErrMsg,
  24090. })
  24091. return
  24092. } else {
  24093. fmt.Println("11111")
  24094. var api string
  24095. if miConfig.MdtrtareaAdmvs == "320921" {
  24096. ipt_otp_no = timeFormat
  24097. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24098. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24099. "&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
  24100. } else {
  24101. ipt_otp_no = timeFormat
  24102. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24103. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24104. "&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
  24105. }
  24106. resp, requestErr := http.Get(api)
  24107. if requestErr != nil {
  24108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24109. return
  24110. }
  24111. body, ioErr := ioutil.ReadAll(resp.Body)
  24112. if ioErr != nil {
  24113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24115. return
  24116. }
  24117. var respJSON map[string]interface{}
  24118. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24121. return
  24122. }
  24123. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24124. result, _ := json.Marshal(respJSON)
  24125. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24126. utils.ErrorLog("解析失败:%v", err)
  24127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24128. return
  24129. }
  24130. resThree.ErrMsg = resThree10265.ErrMsg
  24131. resThree.Output = resThree10265.Output
  24132. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24133. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24134. }
  24135. } else if res3101.Infcode != "0" {
  24136. c.ServeSuccessJSON(map[string]interface{}{
  24137. "failed_code": -10,
  24138. "msg": res3101.ErrMsg,
  24139. })
  24140. return
  24141. }
  24142. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24143. psn_info, _ := service.GetPsnByPatientId(id)
  24144. var cert_no string
  24145. if id_card_type == 1 {
  24146. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24147. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24148. } else if id_card_type == 4 {
  24149. cert_no = psn_info.VerifyNumber
  24150. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24151. } else {
  24152. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24153. cert_no = psn_info.VerifyNumber
  24154. }
  24155. 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)
  24156. saveLog(result, requestLog, "2201", "挂号")
  24157. if miConfig.Code == "H15049901371" {
  24158. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24159. utils.ErrorLog("解析失败:%v", err)
  24160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24161. return
  24162. }
  24163. resThree.ErrMsg = resThree10265.ErrMsg
  24164. resThree.Output = resThree10265.Output
  24165. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24166. } else {
  24167. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24168. utils.ErrorLog("解析失败:%v", err)
  24169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24170. return
  24171. }
  24172. }
  24173. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24174. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24175. psn_info, _ := service.GetPsnByPatientId(id)
  24176. var result string
  24177. var requestLog string
  24178. if id_card_type == 1 {
  24179. bas := strings.Split(psn_info.CardInfo, "|")
  24180. basNumber := bas[2]
  24181. card_sn := bas[3]
  24182. 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)
  24183. saveLog(result, requestLog, "2201A", "挂号")
  24184. } else if id_card_type == 2 {
  24185. 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, "", "", "", "", "", "")
  24186. saveLog(result, requestLog, "2201A", "挂号")
  24187. } else {
  24188. 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)
  24189. saveLog(result, requestLog, "2201A", "挂号")
  24190. }
  24191. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24192. utils.ErrorLog("解析失败:%v", err)
  24193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24194. return
  24195. }
  24196. infocode = resThree.Infcode
  24197. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24198. psn_info, _ := service.GetPsnByPatientId(id)
  24199. var result string
  24200. var requestLog string
  24201. if id_card_type == 1 {
  24202. bas := strings.Split(psn_info.CardInfo, "|")
  24203. basNumber := bas[2]
  24204. card_sn := ""
  24205. 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)
  24206. saveLog(result, requestLog, "2201A", "挂号")
  24207. } else if id_card_type == 2 {
  24208. 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, "", "", "", "", "", "")
  24209. saveLog(result, requestLog, "2201A", "挂号")
  24210. } else {
  24211. 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)
  24212. saveLog(result, requestLog, "2201A", "挂号")
  24213. }
  24214. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24215. utils.ErrorLog("解析失败:%v", err)
  24216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24217. return
  24218. }
  24219. infocode = resThree.Infcode
  24220. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24221. psn_info, _ := service.GetPsnByPatientId(id)
  24222. his.PsnNo = psn_info.PsnNo
  24223. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24224. var cert_no string
  24225. if id_card_type == 1 {
  24226. bas := strings.Split(psn_info.CardInfo, "|")
  24227. cert_no = bas[2]
  24228. } else if id_card_type == 4 {
  24229. cert_no = psn_info.VerifyNumber
  24230. psn_info.VerifyNumber = psn_info.VerifyNumber
  24231. IdCardNo = psn_info.VerifyNumber
  24232. } else {
  24233. cert_no = IdCardNo
  24234. psn_info.VerifyNumber = cert_no
  24235. }
  24236. for _, item := range rf {
  24237. if item.Insutype == insutype {
  24238. his.InsuplcAdmdvs = insuplc_admdvs
  24239. }
  24240. }
  24241. his.Insutype = insutype
  24242. var api string
  24243. ipt_otp_no = timeFormat
  24244. 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 +
  24245. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24246. "&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
  24247. resp, requestErr := http.Get(api)
  24248. if requestErr != nil {
  24249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24250. return
  24251. }
  24252. body, ioErr := ioutil.ReadAll(resp.Body)
  24253. if ioErr != nil {
  24254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24256. return
  24257. }
  24258. var respJSON map[string]interface{}
  24259. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24262. return
  24263. }
  24264. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24265. if status == "0" {
  24266. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24267. c.ServeSuccessJSON(map[string]interface{}{
  24268. "failed_code": -10,
  24269. "msg": err_msg,
  24270. })
  24271. return
  24272. }
  24273. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24274. result, _ := json.Marshal(respJSON)
  24275. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24276. utils.ErrorLog("解析失败:%v", err)
  24277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24278. return
  24279. }
  24280. infocode = resThree.Infcode
  24281. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24282. psn_info, _ := service.GetPsnByPatientId(id)
  24283. his.PsnNo = psn_info.PsnNo
  24284. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24285. var cert_no string
  24286. if id_card_type == 1 {
  24287. bas := strings.Split(psn_info.CardInfo, "|")
  24288. cert_no = bas[2]
  24289. } else if id_card_type == 4 {
  24290. cert_no = psn_info.VerifyNumber
  24291. psn_info.VerifyNumber = psn_info.VerifyNumber
  24292. IdCardNo = psn_info.VerifyNumber
  24293. } else {
  24294. cert_no = IdCardNo
  24295. psn_info.VerifyNumber = cert_no
  24296. }
  24297. for _, item := range rf {
  24298. if item.Insutype == insutype {
  24299. his.InsuplcAdmdvs = insuplc_admdvs
  24300. patient.InsuplcAdmdvs = insuplc_admdvs
  24301. }
  24302. }
  24303. his.Insutype = insutype
  24304. var api string
  24305. ipt_otp_no = timeFormat
  24306. 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 +
  24307. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24308. "&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
  24309. resp, requestErr := http.Get(api)
  24310. if requestErr != nil {
  24311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24312. return
  24313. }
  24314. body, ioErr := ioutil.ReadAll(resp.Body)
  24315. if ioErr != nil {
  24316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24318. return
  24319. }
  24320. var respJSON map[string]interface{}
  24321. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24324. return
  24325. }
  24326. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24327. if status == "0" {
  24328. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24329. c.ServeSuccessJSON(map[string]interface{}{
  24330. "failed_code": -10,
  24331. "msg": err_msg,
  24332. })
  24333. return
  24334. }
  24335. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24336. result, _ := json.Marshal(respJSON)
  24337. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24338. utils.ErrorLog("解析失败:%v", err)
  24339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24340. return
  24341. }
  24342. infocode = resThree.Infcode
  24343. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24344. psn_info, _ := service.GetPsnByPatientId(id)
  24345. var result string
  24346. var requestLog string
  24347. if id_card_type == 1 {
  24348. bas := strings.Split(psn_info.CardInfo, "|")
  24349. basNumber := bas[2]
  24350. card_sn := bas[3]
  24351. 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)
  24352. saveLog(result, requestLog, "2201A", "挂号")
  24353. } else if id_card_type == 2 {
  24354. 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, "", "")
  24355. saveLog(result, requestLog, "2201A", "挂号")
  24356. } else {
  24357. 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, "", "")
  24358. saveLog(result, requestLog, "2201A", "挂号")
  24359. }
  24360. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24361. utils.ErrorLog("解析失败:%v", err)
  24362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24363. return
  24364. }
  24365. infocode = resThree.Infcode
  24366. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24367. psn_info, _ := service.GetPsnByPatientId(id)
  24368. 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)
  24369. saveLog(result, requestLog, "2201A", "挂号")
  24370. if miConfig.Code == "H15049901371" {
  24371. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24372. utils.ErrorLog("解析失败:%v", err)
  24373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24374. return
  24375. }
  24376. resThree.ErrMsg = resThree10265.ErrMsg
  24377. resThree.Output = resThree10265.Output
  24378. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24379. } else {
  24380. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24381. utils.ErrorLog("解析失败:%v", err)
  24382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24383. return
  24384. }
  24385. }
  24386. if miConfig.Code == "H15049901371" {
  24387. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24388. } else {
  24389. infocode = resThree.Infcode
  24390. }
  24391. } else {
  24392. psn_info, _ := service.GetPsnByPatientId(id)
  24393. if id_card_type == 4 || id_card_type == 1 {
  24394. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24395. }
  24396. var rf []*ResultFive
  24397. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24398. var insutypes []*ResultFive
  24399. var insutype string
  24400. var is390 int = 0
  24401. var is310 int = 0
  24402. for _, item := range rf {
  24403. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24404. insutypes = append(insutypes, item)
  24405. }
  24406. }
  24407. if len(insutypes) == 1 {
  24408. insutype = insutypes[0].Insutype
  24409. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24410. } else {
  24411. for _, i := range insutypes {
  24412. if i.Insutype == "390" {
  24413. is390 = 1
  24414. }
  24415. if i.Insutype == "310" {
  24416. is310 = 1
  24417. }
  24418. }
  24419. }
  24420. if is390 == 1 {
  24421. insutype = "390"
  24422. }
  24423. if is310 == 1 {
  24424. insutype = "310"
  24425. }
  24426. fmt.Println(len(insutypes))
  24427. if len(insutypes) == 0 {
  24428. for index, item := range rf {
  24429. if index == 0 {
  24430. insutype = item.Insutype
  24431. insuplc_admdvs = item.InsuplcAdmdvs
  24432. }
  24433. }
  24434. fmt.Println(insutype)
  24435. fmt.Println(insuplc_admdvs)
  24436. }
  24437. if social_type > 0 {
  24438. insutype = strconv.FormatInt(social_type, 10)
  24439. }
  24440. fmt.Println("--------")
  24441. fmt.Println(psn_info)
  24442. fmt.Println(psn_info.PsnNo)
  24443. if miConfig.MdtrtareaAdmvs == "441202" {
  24444. var hisPrescription []*models.HisPrescription
  24445. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24446. if res3101.Infcode == 0 {
  24447. fmt.Println("33333333")
  24448. if len(res3101.Output.Result) > 0 {
  24449. fmt.Println("222222")
  24450. for _, item := range res3101.Output.Result {
  24451. if len(res3101.ErrMsg) == 0 {
  24452. res3101.ErrMsg = item.VolaCont
  24453. } else {
  24454. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24455. }
  24456. }
  24457. c.ServeSuccessJSON(map[string]interface{}{
  24458. "failed_code": -10,
  24459. "msg": res3101.ErrMsg,
  24460. })
  24461. return
  24462. } else {
  24463. hour := time.Now().Format("15")
  24464. min := time.Now().Format("04")
  24465. sec := time.Now().Format("05")
  24466. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24467. fmt.Println(record_time_two)
  24468. 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)
  24469. saveLog(result, requestLog, "2201A", "挂号")
  24470. if miConfig.Code == "H15049901371" {
  24471. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24472. utils.ErrorLog("解析失败:%v", err)
  24473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24474. return
  24475. }
  24476. resThree.ErrMsg = resThree10265.ErrMsg
  24477. resThree.Output = resThree10265.Output
  24478. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24479. } else {
  24480. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24481. utils.ErrorLog("解析失败:%v", err)
  24482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24483. return
  24484. }
  24485. }
  24486. if miConfig.Code == "H15049901371" {
  24487. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24488. } else {
  24489. infocode = resThree.Infcode
  24490. }
  24491. }
  24492. } else if res3101.Infcode != 0 {
  24493. c.ServeSuccessJSON(map[string]interface{}{
  24494. "failed_code": -10,
  24495. "msg": res3101.ErrMsg,
  24496. })
  24497. return
  24498. }
  24499. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24500. var hisPrescription []*models.HisPrescription
  24501. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24502. if res3101.Infcode == 0 {
  24503. fmt.Println("33333333")
  24504. if len(res3101.Output.Result) > 0 {
  24505. fmt.Println("222222")
  24506. for _, item := range res3101.Output.Result {
  24507. if len(res3101.ErrMsg) == 0 {
  24508. res3101.ErrMsg = item.VolaCont
  24509. } else {
  24510. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24511. }
  24512. }
  24513. c.ServeSuccessJSON(map[string]interface{}{
  24514. "failed_code": -10,
  24515. "msg": res3101.ErrMsg,
  24516. })
  24517. return
  24518. } else {
  24519. hour := time.Now().Format("15")
  24520. min := time.Now().Format("04")
  24521. sec := time.Now().Format("05")
  24522. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24523. fmt.Println(record_time_two)
  24524. 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)
  24525. saveLog(result, requestLog, "2201A", "挂号")
  24526. if miConfig.Code == "H15049901371" {
  24527. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24528. utils.ErrorLog("解析失败:%v", err)
  24529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24530. return
  24531. }
  24532. resThree.ErrMsg = resThree10265.ErrMsg
  24533. resThree.Output = resThree10265.Output
  24534. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24535. } else {
  24536. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24537. utils.ErrorLog("解析失败:%v", err)
  24538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24539. return
  24540. }
  24541. }
  24542. if miConfig.Code == "H15049901371" {
  24543. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24544. } else {
  24545. infocode = resThree.Infcode
  24546. }
  24547. }
  24548. } else if res3101.Infcode != 0 {
  24549. c.ServeSuccessJSON(map[string]interface{}{
  24550. "failed_code": -10,
  24551. "msg": res3101.ErrMsg,
  24552. })
  24553. return
  24554. }
  24555. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24556. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24557. psn_info, _ := service.GetPsnByPatientId(id)
  24558. var verify_number string
  24559. if id_card_type == 4 {
  24560. verify_number = psn_info.VerifyNumber
  24561. } else if id_card_type == 1 {
  24562. bas := strings.Split(psn_info.CardInfo, "|")
  24563. cardNumber := bas[2]
  24564. verify_number = cardNumber
  24565. } else {
  24566. verify_number = psn_info.Certno
  24567. }
  24568. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24569. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24570. "&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
  24571. resp, requestErr := http.Get(api)
  24572. if requestErr != nil {
  24573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24574. return
  24575. }
  24576. body, ioErr := ioutil.ReadAll(resp.Body)
  24577. if ioErr != nil {
  24578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24580. return
  24581. }
  24582. var respJSON map[string]interface{}
  24583. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24586. return
  24587. }
  24588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24589. result, _ := json.Marshal(respJSON)
  24590. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24591. utils.ErrorLog("解析失败:%v", err)
  24592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24593. return
  24594. }
  24595. infocode = resThree.Infcode
  24596. } else {
  24597. hour := time.Now().Format("15")
  24598. min := time.Now().Format("04")
  24599. sec := time.Now().Format("05")
  24600. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24601. if id_card_type == 1 {
  24602. for _, item := range rf {
  24603. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24604. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24605. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24606. } else if strconv.FormatInt(social_type, 10) == "390" {
  24607. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24608. } else {
  24609. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24610. }
  24611. }
  24612. }
  24613. }
  24614. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24615. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24616. }
  24617. if id_card_type == 1 {
  24618. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24619. bas := strings.Split(psn_info.CardInfo, "|")
  24620. basNumber := bas[1]
  24621. IdCardNo = basNumber
  24622. }
  24623. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24624. IdCardNo = psn_info.VerifyNumber
  24625. }
  24626. if len(insuplc_admdvs_temp) == 0 {
  24627. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24628. }
  24629. var result string
  24630. var requestLog string
  24631. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" {
  24632. var hisPrescription []*models.HisPrescription
  24633. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24634. if res3101.Infcode == 0 {
  24635. if len(res3101.Output.Result) > 0 {
  24636. if len(res3101.Output.Result) > 0 {
  24637. c.ServeSuccessJSON(map[string]interface{}{
  24638. "failed_code": -10,
  24639. "failed_type": 100,
  24640. "warm_type": 1,
  24641. "msg": res3101.Output.Result,
  24642. })
  24643. return
  24644. } else {
  24645. c.ServeSuccessJSON(map[string]interface{}{
  24646. "failed_code": -10,
  24647. "msg": res3101.ErrMsg,
  24648. })
  24649. return
  24650. }
  24651. } else {
  24652. hour := time.Now().Format("15")
  24653. min := time.Now().Format("04")
  24654. sec := time.Now().Format("05")
  24655. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24656. fmt.Println(record_time_two)
  24657. if his.IdCardType == 2 {
  24658. IdCardNo = psn_info.Certno
  24659. psn_info.VerifyNumber = psn_info.Certno
  24660. } else if his.IdCardType == 4 {
  24661. IdCardNo = psn_info.Certno
  24662. } else {
  24663. bas := strings.Split(psn_info.CardInfo, "|")
  24664. IdCardNo = bas[2]
  24665. }
  24666. 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)
  24667. saveLog(result, requestLog, "2201A", "挂号")
  24668. if miConfig.Code == "H15049901371" {
  24669. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24670. utils.ErrorLog("解析失败:%v", err)
  24671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24672. return
  24673. }
  24674. resThree.ErrMsg = resThree10265.ErrMsg
  24675. resThree.Output = resThree10265.Output
  24676. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24677. } else {
  24678. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24679. utils.ErrorLog("解析失败:%v", err)
  24680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24681. return
  24682. }
  24683. }
  24684. if miConfig.Code == "H15049901371" {
  24685. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24686. } else {
  24687. infocode = resThree.Infcode
  24688. }
  24689. }
  24690. } else if res3101.Infcode != 0 {
  24691. c.ServeSuccessJSON(map[string]interface{}{
  24692. "failed_code": -10,
  24693. "msg": res3101.ErrMsg,
  24694. })
  24695. return
  24696. }
  24697. } else {
  24698. psn_info, _ := service.GetPsnByPatientId(id)
  24699. var rf []*ResultFive
  24700. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24701. //var insutypes []*ResultFive
  24702. var insutype string
  24703. var insutypes []*ResultFive
  24704. var is390 int = 0
  24705. var is310 int = 0
  24706. for _, item := range rf {
  24707. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24708. insutypes = append(insutypes, item)
  24709. }
  24710. }
  24711. if len(insutypes) == 1 {
  24712. insutype = insutypes[0].Insutype
  24713. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24714. } else {
  24715. for _, i := range insutypes {
  24716. if i.Insutype == "390" {
  24717. is390 = 1
  24718. }
  24719. if i.Insutype == "310" {
  24720. is310 = 1
  24721. }
  24722. }
  24723. }
  24724. if is390 == 1 {
  24725. insutype = "390"
  24726. }
  24727. if is310 == 1 {
  24728. insutype = "310"
  24729. }
  24730. if len(insutypes) == 0 {
  24731. insutype = "310"
  24732. }
  24733. if social_type > 0 {
  24734. insutype = strconv.FormatInt(social_type, 10)
  24735. }
  24736. for _, item := range rf {
  24737. utils.ErrorLog("解析失败:%v", item.Insutype)
  24738. utils.ErrorLog("解析失败:%v", insutype)
  24739. if item.Insutype == insutype {
  24740. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24741. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  24742. }
  24743. }
  24744. 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)
  24745. saveLog(result, requestLog, "2201A", "挂号")
  24746. }
  24747. if miConfig.Code == "H15049901371" {
  24748. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24749. utils.ErrorLog("解析失败:%v", err)
  24750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24751. return
  24752. }
  24753. resThree.ErrMsg = resThree10265.ErrMsg
  24754. resThree.Output = resThree10265.Output
  24755. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24756. } else {
  24757. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24758. utils.ErrorLog("解析失败:%v", err)
  24759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24760. return
  24761. }
  24762. }
  24763. if miConfig.Code == "H15049901371" {
  24764. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24765. } else {
  24766. infocode = resThree.Infcode
  24767. }
  24768. }
  24769. }
  24770. if infocode == -1 {
  24771. adminUser := c.GetAdminUserInfo()
  24772. errlog := &models.HisOrderError{
  24773. UserOrgId: adminUser.CurrentOrgId,
  24774. Ctime: time.Now().Unix(),
  24775. Mtime: time.Now().Unix(),
  24776. ErrMsg: resThree.ErrMsg,
  24777. Status: 1,
  24778. PatientId: id,
  24779. RecordTime: recordDateTime,
  24780. Stage: 2,
  24781. }
  24782. service.CreateErrMsgLog(errlog)
  24783. c.ServeSuccessJSON(map[string]interface{}{
  24784. "failed_code": -10,
  24785. "msg": resThree.ErrMsg,
  24786. })
  24787. return
  24788. }
  24789. his.Number = resThree.Output.Data.MdtrtID
  24790. his.PsnNo = resThree.Output.Data.PsnNo
  24791. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24792. his.IdCardNo = patient.IdCardNo
  24793. his.PhoneNumber = patient.Phone
  24794. his.UserOrgId = adminInfo.CurrentOrgId
  24795. his.Insutype = insutype
  24796. his.Ctime = time.Now().Unix()
  24797. his.Mtime = time.Now().Unix()
  24798. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24799. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24800. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24801. }
  24802. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24803. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24804. }
  24805. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24806. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24807. }
  24808. his.Status = 1
  24809. his.MdtrtGrpType = mdtrt_type
  24810. service.UpdateHisPatientStatus(&his)
  24811. service.UpdateHisPatient123(&patient)
  24812. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24813. c.ServeSuccessJSON(map[string]interface{}{
  24814. "his_info": his,
  24815. })
  24816. } else {
  24817. adminUser := c.GetAdminUserInfo()
  24818. errlog := &models.HisOrderError{
  24819. UserOrgId: adminUser.CurrentOrgId,
  24820. Ctime: time.Now().Unix(),
  24821. Mtime: time.Now().Unix(),
  24822. ErrMsg: res.ErrMsg,
  24823. Status: 1,
  24824. PatientId: id,
  24825. RecordTime: recordDateTime,
  24826. Stage: 1,
  24827. }
  24828. service.CreateErrMsgLog(errlog)
  24829. c.ServeSuccessJSON(map[string]interface{}{
  24830. "failed_code": -10,
  24831. "msg": res.ErrMsg,
  24832. })
  24833. return
  24834. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24835. }
  24836. }
  24837. }
  24838. func (c *HisApiController) GetUploadInfo() {
  24839. id, _ := c.GetInt64("id")
  24840. record_time := c.GetString("record_time")
  24841. his_patient_id, _ := c.GetInt64("his_patient_id")
  24842. order_id, _ := c.GetInt64("order_id")
  24843. pay_way, _ := c.GetInt64("pay_way")
  24844. pay_ways := c.GetString("pay_ways")
  24845. oth_desc := c.GetString("oth_desc")
  24846. pay_price, _ := c.GetFloat("pay_price")
  24847. pay_card_no := c.GetString("pay_card_no")
  24848. discount_price, _ := c.GetFloat("discount_price")
  24849. preferential_price, _ := c.GetFloat("preferential_price")
  24850. reality_price, _ := c.GetFloat("reality_price")
  24851. found_price, _ := c.GetFloat("found_price")
  24852. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24853. private_price, _ := c.GetFloat("private_price")
  24854. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24855. admin_user_id, _ := c.GetInt64("admin_user_id")
  24856. fapiao_code := c.GetString("fapiao_code")
  24857. fapiao_number := c.GetString("fapiao_number")
  24858. diagnosis_id := c.GetString("diagnosis")
  24859. sick_type, _ := c.GetInt64("sick_type")
  24860. reg_type, _ := c.GetInt64("p_type")
  24861. begin_time := c.GetString("begin_time")
  24862. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24863. cash_pay := c.GetString("cash_pay")
  24864. band_card_pay := c.GetString("band_card_pay")
  24865. wechat_pay := c.GetString("wechat_pay")
  24866. ali_pay := c.GetString("ali_pay")
  24867. jifen_pay := c.GetString("jifen_pay")
  24868. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24869. fmt.Println(acct_used_flag)
  24870. id_str := c.GetString("ids")
  24871. ids_arr := strings.Split(id_str, ",")
  24872. timeLayout := "2006-01-02"
  24873. loc, _ := time.LoadLocation("Local")
  24874. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24875. if err != nil {
  24876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24877. return
  24878. }
  24879. recordDateTime := theTime.Unix()
  24880. adminUser := c.GetAdminUserInfo()
  24881. var tempOrder models.HisOrder
  24882. tempOrder, _ = service.GetHisOrderByID(order_id)
  24883. var prescriptions []*models.HisPrescription
  24884. var start_time int64
  24885. var end_time int64
  24886. //押金模块
  24887. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24888. tmp_decimal := c.GetString("tmp_decimal")
  24889. var decimal float64 //本次使用的押金
  24890. var errmsg error
  24891. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24892. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24893. return
  24894. }
  24895. if len(tmp_decimal) > 0 {
  24896. if tmp_decimal[0] == 45 {
  24897. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24898. return
  24899. }
  24900. }
  24901. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24902. fmt.Println(errs)
  24903. decimal = tt
  24904. //if adminUser.CurrentOrgId == 10106{
  24905. // if len(fapiao_code) == 0{
  24906. // fapiao_code = "144072080589"
  24907. // }
  24908. // if len(fapiao_number) == 0{
  24909. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24910. // if order.ID == 0{
  24911. // fapiao_number = "00001520"
  24912. // }else{
  24913. // //fapiao_code = "00001520"
  24914. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24915. // var zero string
  24916. // if fpNumber >= 1000{
  24917. // zero = "0000" + strconv.Itoa(fpNumber)
  24918. // }else if fpNumber >= 10000{
  24919. // zero = "000" + strconv.Itoa(fpNumber)
  24920. // } else if fpNumber >= 100000{
  24921. // zero = "00" + strconv.Itoa(fpNumber)
  24922. // } else if fpNumber >= 1000000{
  24923. // zero = "0" + strconv.Itoa(fpNumber)
  24924. // }else {
  24925. // zero = strconv.Itoa(fpNumber)
  24926. // }
  24927. // fapiao_number = zero
  24928. // }
  24929. // }
  24930. //}
  24931. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24932. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24933. var patientPrescription models.HisPrescriptionInfo
  24934. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24935. if patientPrescription.ID == 0 {
  24936. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24937. }
  24938. //if patientPrescription.Do
  24939. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24940. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24941. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24942. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24943. var config []*models.HisXtDiagnoseConfig
  24944. for _, item := range diagnosis_ids {
  24945. id, _ := strconv.ParseInt(item, 10, 64)
  24946. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24947. config = append(config, &diagnosisConfig)
  24948. }
  24949. sickConfig, _ := service.FindSickById(sick_type)
  24950. //if tempOrder.ID == 0 {
  24951. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24952. //}
  24953. if tempOrder.ID == 0 {
  24954. var result string
  24955. var requestLog string
  24956. var res2 ResultSix
  24957. var res3 GZResultSix
  24958. var ressix10265 ResultSix10265
  24959. if miConfig.MdtrtareaAdmvs == "421300" {
  24960. data := make(map[string]interface{})
  24961. client := &http.Client{}
  24962. data["psn_no"] = his.PsnNo
  24963. data["mdtrt_id"] = his.Number
  24964. data["opter"] = roles.UserName
  24965. data["org_name"] = miConfig.OrgName
  24966. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24967. data["doctor_id"] = doctor_info.DoctorNumber
  24968. data["doctor_name"] = doctor_info.UserName
  24969. data["department"] = department.Name
  24970. data["fixmedins_code"] = miConfig.Code
  24971. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24972. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24973. data["secret_key"] = miConfig.SecretKey
  24974. data["sick_code"] = sickConfig.CountryCode
  24975. data["sick_name"] = sickConfig.ClassName
  24976. data["dept"] = strconv.FormatInt(department.ID, 10)
  24977. data["config"] = config
  24978. data["begin_time"] = begin_time
  24979. bytesData, _ := json.Marshal(data)
  24980. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24981. resp, _ := client.Do(req)
  24982. defer resp.Body.Close()
  24983. body, ioErr := ioutil.ReadAll(resp.Body)
  24984. if ioErr != nil {
  24985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24987. return
  24988. }
  24989. var respJSON map[string]interface{}
  24990. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24993. return
  24994. }
  24995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24996. userJSONBytes, _ := json.Marshal(respJSON)
  24997. fmt.Println("log")
  24998. fmt.Println(string(userJSONBytes))
  24999. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25000. utils.ErrorLog("解析失败:%v", err)
  25001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25002. return
  25003. }
  25004. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25005. data := make(map[string]interface{})
  25006. client := &http.Client{}
  25007. data["psn_no"] = his.PsnNo
  25008. data["mdtrt_id"] = his.Number
  25009. data["opter"] = roles.UserName
  25010. data["org_name"] = miConfig.OrgName
  25011. if reg_type == 11 && his.Insutype == "390" {
  25012. data["med_type"] = "110104"
  25013. } else {
  25014. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25015. }
  25016. data["doctor_id"] = doctor_info.DoctorNumber
  25017. data["doctor_name"] = doctor_info.UserName
  25018. data["department"] = department.Name
  25019. data["fixmedins_code"] = miConfig.Code
  25020. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25021. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25022. data["secret_key"] = miConfig.SecretKey
  25023. data["sick_code"] = sickConfig.CountryCode
  25024. data["sick_name"] = sickConfig.ClassName
  25025. data["dept"] = strconv.FormatInt(department.ID, 10)
  25026. data["config"] = config
  25027. data["begin_time"] = begin_time
  25028. bytesData, _ := json.Marshal(data)
  25029. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25030. resp, _ := client.Do(req)
  25031. defer resp.Body.Close()
  25032. body, ioErr := ioutil.ReadAll(resp.Body)
  25033. if ioErr != nil {
  25034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25036. return
  25037. }
  25038. var respJSON map[string]interface{}
  25039. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25042. return
  25043. }
  25044. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25045. userJSONBytes, _ := json.Marshal(respJSON)
  25046. fmt.Println("log")
  25047. fmt.Println(string(userJSONBytes))
  25048. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25049. utils.ErrorLog("解析失败:%v", err)
  25050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25051. return
  25052. }
  25053. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25054. data := make(map[string]interface{})
  25055. client := &http.Client{}
  25056. data["psn_no"] = his.PsnNo
  25057. data["mdtrt_id"] = his.Number
  25058. data["opter"] = roles.UserName
  25059. data["org_name"] = miConfig.OrgName
  25060. if reg_type == 11 && his.Insutype == "390" {
  25061. data["med_type"] = "110104"
  25062. } else {
  25063. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25064. }
  25065. data["doctor_id"] = doctor_info.DoctorNumber
  25066. data["doctor_name"] = doctor_info.UserName
  25067. data["department"] = department.Name
  25068. data["fixmedins_code"] = miConfig.Code
  25069. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25070. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25071. data["secret_key"] = miConfig.SecretKey
  25072. data["sick_code"] = sickConfig.CountryCode
  25073. data["sick_name"] = sickConfig.ClassName
  25074. data["dept"] = strconv.FormatInt(department.ID, 10)
  25075. data["config"] = config
  25076. data["begin_time"] = begin_time
  25077. bytesData, _ := json.Marshal(data)
  25078. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25079. resp, _ := client.Do(req)
  25080. defer resp.Body.Close()
  25081. body, ioErr := ioutil.ReadAll(resp.Body)
  25082. if ioErr != nil {
  25083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25085. return
  25086. }
  25087. var respJSON map[string]interface{}
  25088. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25091. return
  25092. }
  25093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25094. userJSONBytes, _ := json.Marshal(respJSON)
  25095. fmt.Println("log")
  25096. fmt.Println(string(userJSONBytes))
  25097. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25098. utils.ErrorLog("解析失败:%v", err)
  25099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25100. return
  25101. }
  25102. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25103. data := make(map[string]interface{})
  25104. client := &http.Client{}
  25105. data["psn_no"] = his.PsnNo
  25106. data["mdtrt_id"] = his.Number
  25107. data["opter"] = roles.UserName
  25108. data["org_name"] = miConfig.OrgName
  25109. if reg_type == 11 && his.Insutype == "390" {
  25110. data["med_type"] = "110104"
  25111. } else {
  25112. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25113. }
  25114. data["doctor_id"] = doctor_info.DoctorNumber
  25115. data["doctor_name"] = doctor_info.UserName
  25116. data["department"] = department.Name
  25117. data["fixmedins_code"] = miConfig.Code
  25118. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25119. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25120. data["secret_key"] = miConfig.SecretKey
  25121. data["sick_code"] = sickConfig.CountryCode
  25122. data["sick_name"] = sickConfig.ClassName
  25123. data["dept"] = strconv.FormatInt(department.ID, 10)
  25124. data["config"] = config
  25125. data["begin_time"] = begin_time
  25126. bytesData, _ := json.Marshal(data)
  25127. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25128. resp, _ := client.Do(req)
  25129. defer resp.Body.Close()
  25130. body, ioErr := ioutil.ReadAll(resp.Body)
  25131. if ioErr != nil {
  25132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25134. return
  25135. }
  25136. var respJSON map[string]interface{}
  25137. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25140. return
  25141. }
  25142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25143. userJSONBytes, _ := json.Marshal(respJSON)
  25144. fmt.Println("log")
  25145. fmt.Println(string(userJSONBytes))
  25146. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25147. utils.ErrorLog("解析失败:%v", err)
  25148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25149. return
  25150. }
  25151. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25152. data := make(map[string]interface{})
  25153. client := &http.Client{}
  25154. data["psn_no"] = his.PsnNo
  25155. data["mdtrt_id"] = his.Number
  25156. data["doctor"] = roles.UserName
  25157. data["department"] = department.Name
  25158. data["org_name"] = miConfig.OrgName
  25159. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25160. data["doctor_id"] = doctor_info.DoctorNumber
  25161. data["new_doctor_name"] = doctor_info.UserName
  25162. data["fixmedins_code"] = miConfig.Code
  25163. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25164. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25165. data["secret_key"] = miConfig.SecretKey
  25166. data["sick_code"] = sickConfig.CountryCode
  25167. data["sick_name"] = sickConfig.ClassName
  25168. data["url"] = miConfig.Url
  25169. data["ak"] = miConfig.AccessKey
  25170. data["begin_time"] = begin_time
  25171. data["cainfo"] = miConfig.Cainfo
  25172. data["dept"] = strconv.FormatInt(department.ID, 10)
  25173. data["config"] = config
  25174. bytesData, _ := json.Marshal(data)
  25175. var req *http.Request
  25176. if miConfig.MdtrtareaAdmvs == "320921" {
  25177. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25178. //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 +
  25179. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25180. } else {
  25181. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25182. }
  25183. resp, _ := client.Do(req)
  25184. defer resp.Body.Close()
  25185. body, ioErr := ioutil.ReadAll(resp.Body)
  25186. if ioErr != nil {
  25187. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25189. return
  25190. }
  25191. var respJSON map[string]interface{}
  25192. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25195. return
  25196. }
  25197. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25198. userJSONBytes, _ := json.Marshal(respJSON)
  25199. fmt.Println("log")
  25200. fmt.Println(string(userJSONBytes))
  25201. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25202. utils.ErrorLog("解析失败:%v", err)
  25203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25204. return
  25205. }
  25206. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25207. res2.Output = ressix10265.Output
  25208. res2.ErrMsg = ressix10265.ErrMsg
  25209. res2.Cainfo = ressix10265.Cainfo
  25210. res2.WarnMsg = ressix10265.WarnMsg
  25211. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25212. res2.Infcode = infocode
  25213. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25214. data := make(map[string]interface{})
  25215. client := &http.Client{}
  25216. data["psn_no"] = his.PsnNo
  25217. data["mdtrt_id"] = his.Number
  25218. data["doctor"] = roles.UserName
  25219. data["department"] = department.Name
  25220. data["org_name"] = miConfig.OrgName
  25221. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25222. data["doctor_id"] = doctor_info.DoctorNumber
  25223. data["new_doctor_name"] = doctor_info.UserName
  25224. data["fixmedins_code"] = miConfig.Code
  25225. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25226. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25227. data["secret_key"] = miConfig.SecretKey
  25228. data["sick_code"] = sickConfig.CountryCode
  25229. data["sick_name"] = sickConfig.ClassName
  25230. data["url"] = miConfig.Url
  25231. data["ak"] = miConfig.AccessKey
  25232. data["begin_time"] = begin_time
  25233. data["cainfo"] = miConfig.Cainfo
  25234. data["dept"] = strconv.FormatInt(department.ID, 10)
  25235. data["config"] = config
  25236. bytesData, _ := json.Marshal(data)
  25237. var req *http.Request
  25238. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25239. resp, _ := client.Do(req)
  25240. defer resp.Body.Close()
  25241. body, ioErr := ioutil.ReadAll(resp.Body)
  25242. if ioErr != nil {
  25243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25245. return
  25246. }
  25247. var respJSON map[string]interface{}
  25248. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25251. return
  25252. }
  25253. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25254. userJSONBytes, _ := json.Marshal(respJSON)
  25255. fmt.Println("log")
  25256. fmt.Println(string(userJSONBytes))
  25257. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25258. utils.ErrorLog("解析失败:%v", err)
  25259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25260. return
  25261. }
  25262. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25263. res2.Output = ressix10265.Output
  25264. res2.ErrMsg = ressix10265.ErrMsg
  25265. res2.Cainfo = ressix10265.Cainfo
  25266. res2.WarnMsg = ressix10265.WarnMsg
  25267. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25268. res2.Infcode = infocode
  25269. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25270. 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)
  25271. saveLog(result, requestLog, "2203", "上传就诊信息")
  25272. var respJSON2 map[string]interface{}
  25273. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25276. return
  25277. }
  25278. userJSONBytes2, _ := json.Marshal(respJSON2)
  25279. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25280. utils.ErrorLog("解析失败:%v", err)
  25281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25282. return
  25283. }
  25284. 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)
  25285. fmt.Println(result2)
  25286. fmt.Println(src_request)
  25287. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25288. data := make(map[string]interface{})
  25289. client := &http.Client{}
  25290. data["psn_no"] = his.PsnNo
  25291. data["mdtrt_id"] = his.Number
  25292. data["doctor"] = roles.UserName
  25293. data["department"] = department.Name
  25294. data["org_name"] = miConfig.OrgName
  25295. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25296. data["doctor_id"] = doctor_info.DoctorNumber
  25297. data["new_doctor_name"] = doctor_info.UserName
  25298. data["fixmedins_code"] = miConfig.Code
  25299. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25300. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25301. data["secret_key"] = miConfig.SecretKey
  25302. data["sick_code"] = sickConfig.CountryCode
  25303. data["sick_name"] = sickConfig.ClassName
  25304. data["url"] = miConfig.Url
  25305. data["ak"] = miConfig.AccessKey
  25306. data["begin_time"] = begin_time
  25307. data["cainfo"] = miConfig.Cainfo
  25308. data["dept"] = strconv.FormatInt(department.ID, 10)
  25309. data["config"] = config
  25310. bytesData, _ := json.Marshal(data)
  25311. var req *http.Request
  25312. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25313. resp, _ := client.Do(req)
  25314. defer resp.Body.Close()
  25315. body, ioErr := ioutil.ReadAll(resp.Body)
  25316. if ioErr != nil {
  25317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25319. return
  25320. }
  25321. var respJSON map[string]interface{}
  25322. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25325. return
  25326. }
  25327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25328. userJSONBytes, _ := json.Marshal(respJSON)
  25329. fmt.Println("log")
  25330. fmt.Println(string(userJSONBytes))
  25331. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25332. utils.ErrorLog("解析失败:%v", err)
  25333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25334. return
  25335. }
  25336. } else {
  25337. if miConfig.MdtrtareaAdmvs == "440781" { //
  25338. 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)
  25339. } else {
  25340. if miConfig.Code == "H15049901371" {
  25341. //赤峰地区国家医保医疗类别
  25342. //职工透析:医疗类别选特殊情况门诊990502
  25343. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25344. var med_type string
  25345. if his.Insutype == "390" {
  25346. if reg_type == 14 {
  25347. med_type = "9933"
  25348. } else if reg_type == 11 {
  25349. med_type = "11"
  25350. }
  25351. } else if his.Insutype == "310" {
  25352. if reg_type == 14 {
  25353. med_type = "990502"
  25354. } else if reg_type == 11 {
  25355. med_type = "11"
  25356. }
  25357. }
  25358. 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)
  25359. } else {
  25360. 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)
  25361. }
  25362. }
  25363. saveLog(result, requestLog, "2203", "上传就诊信息")
  25364. var respJSON2 map[string]interface{}
  25365. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25368. return
  25369. }
  25370. userJSONBytes2, _ := json.Marshal(respJSON2)
  25371. if miConfig.Code == "H15049901371" {
  25372. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25373. utils.ErrorLog("解析失败:%v", err)
  25374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25375. return
  25376. }
  25377. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25378. res2.Output = ressix10265.Output
  25379. res2.ErrMsg = ressix10265.ErrMsg
  25380. res2.Cainfo = ressix10265.Cainfo
  25381. res2.WarnMsg = ressix10265.WarnMsg
  25382. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25383. res2.Infcode = infocode
  25384. } else {
  25385. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25386. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25387. utils.ErrorLog("解析失败:%v", err)
  25388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25389. return
  25390. }
  25391. res2.Infcode = res3.Infcode
  25392. } else {
  25393. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25394. utils.ErrorLog("解析失败:%v", err)
  25395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25396. return
  25397. }
  25398. }
  25399. }
  25400. }
  25401. if res2.Infcode == -1 {
  25402. adminUser := c.GetAdminUserInfo()
  25403. errlog := &models.HisOrderError{
  25404. UserOrgId: adminUser.CurrentOrgId,
  25405. Ctime: time.Now().Unix(),
  25406. Mtime: time.Now().Unix(),
  25407. ErrMsg: res2.ErrMsg,
  25408. Status: 1,
  25409. PatientId: id,
  25410. RecordTime: recordDateTime,
  25411. Stage: 3,
  25412. }
  25413. service.CreateErrMsgLog(errlog)
  25414. c.ServeSuccessJSON(map[string]interface{}{
  25415. "failed_code": -10,
  25416. "msg": res2.ErrMsg,
  25417. })
  25418. return
  25419. } else {
  25420. his.Diagnosis = diagnosis_id
  25421. his.SickType = sickConfig.ID
  25422. //var p_type int64
  25423. //if reg_type == 1111 || reg_type == 1112 {
  25424. // p_type = 11
  25425. //
  25426. //}
  25427. his.PType = fmt.Sprintf("%d", reg_type)
  25428. service.UpdateHisPatientThree(&his)
  25429. data := make(map[string]interface{})
  25430. if settle_accounts_type == 1 { //日结
  25431. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25432. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25433. } else {
  25434. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25435. }
  25436. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25437. data["pre"] = prescriptions
  25438. } else { //月结
  25439. start_time_str := c.GetString("start_time")
  25440. end_time_str := c.GetString("end_time")
  25441. timeLayout := "2006-01-02"
  25442. loc, _ := time.LoadLocation("Local")
  25443. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25444. if err != nil {
  25445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25446. return
  25447. }
  25448. recordStartTime := theStartTime.Unix()
  25449. start_time = recordStartTime
  25450. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25451. if err != nil {
  25452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25453. return
  25454. }
  25455. recordEndTime := theEndTime.Unix()
  25456. end_time = recordEndTime
  25457. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25458. data["pre"] = prescriptions
  25459. }
  25460. timestamp := time.Now().Unix()
  25461. tempTime := time.Unix(timestamp, 0)
  25462. timeFormat := tempTime.Format("20060102150405")
  25463. chrgBchno := rand.Intn(100000) + 10000
  25464. new_chrg_bchno := ""
  25465. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25466. new_chrg_bchno = chrg_bchno
  25467. strconv.FormatInt(his.PatientId, 10)
  25468. client := &http.Client{}
  25469. if adminUser.CurrentOrgId == 10265 {
  25470. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25471. new_chrg_bchno = "0000"
  25472. }
  25473. }
  25474. data["psn_no"] = his.PsnNo
  25475. data["mdtrt_id"] = his.Number
  25476. data["chrg_bchno"] = new_chrg_bchno
  25477. data["org_name"] = miConfig.OrgName
  25478. data["doctor"] = doctor_info.UserName
  25479. data["doctor_id"] = doctor_info.DoctorNumber
  25480. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25481. data["fixmedins_code"] = miConfig.Code
  25482. data["dept_code"] = department.Number
  25483. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25484. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25485. data["secret_key"] = miConfig.SecretKey
  25486. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25487. data["url"] = miConfig.Url
  25488. data["ak"] = miConfig.AccessKey
  25489. data["new_doctor_name"] = patientPrescription.Doctor
  25490. data["diag_code"] = sickConfig.CountryCode
  25491. data["cainfo"] = miConfig.Cainfo
  25492. data["opter"] = roles.UserName
  25493. var ids []int64
  25494. for _, item := range prescriptions {
  25495. ids = append(ids, item.ID)
  25496. }
  25497. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25498. if config.IsOpen == 1 { //对接了医保,走医保流程
  25499. var res ResultFour
  25500. var resFour10265 ResultFour10265
  25501. if miConfig.MdtrtareaAdmvs == "421300" {
  25502. bytesData, _ := json.Marshal(data)
  25503. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25504. resp, _ := client.Do(req)
  25505. defer resp.Body.Close()
  25506. body, ioErr := ioutil.ReadAll(resp.Body)
  25507. if ioErr != nil {
  25508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25510. return
  25511. }
  25512. var respJSON map[string]interface{}
  25513. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25516. return
  25517. }
  25518. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25519. userJSONBytes, _ := json.Marshal(respJSON)
  25520. fmt.Println("log")
  25521. fmt.Println(string(userJSONBytes))
  25522. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25523. utils.ErrorLog("解析失败:%v", err)
  25524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25525. return
  25526. }
  25527. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25528. bytesData, _ := json.Marshal(data)
  25529. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25530. resp, _ := client.Do(req)
  25531. defer resp.Body.Close()
  25532. body, ioErr := ioutil.ReadAll(resp.Body)
  25533. if ioErr != nil {
  25534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25536. return
  25537. }
  25538. var respJSON map[string]interface{}
  25539. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25542. return
  25543. }
  25544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25545. userJSONBytes, _ := json.Marshal(respJSON)
  25546. fmt.Println("log")
  25547. fmt.Println(string(userJSONBytes))
  25548. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25549. utils.ErrorLog("解析失败:%v", err)
  25550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25551. return
  25552. }
  25553. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25554. bytesData, _ := json.Marshal(data)
  25555. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25556. resp, _ := client.Do(req)
  25557. defer resp.Body.Close()
  25558. body, ioErr := ioutil.ReadAll(resp.Body)
  25559. if ioErr != nil {
  25560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25562. return
  25563. }
  25564. var respJSON map[string]interface{}
  25565. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25568. return
  25569. }
  25570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25571. userJSONBytes, _ := json.Marshal(respJSON)
  25572. fmt.Println("log")
  25573. fmt.Println(string(userJSONBytes))
  25574. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25575. utils.ErrorLog("解析失败:%v", err)
  25576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25577. return
  25578. }
  25579. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25580. bytesData, _ := json.Marshal(data)
  25581. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25582. resp, _ := client.Do(req)
  25583. defer resp.Body.Close()
  25584. body, ioErr := ioutil.ReadAll(resp.Body)
  25585. if ioErr != nil {
  25586. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25588. return
  25589. }
  25590. var respJSON map[string]interface{}
  25591. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25594. return
  25595. }
  25596. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25597. userJSONBytes, _ := json.Marshal(respJSON)
  25598. fmt.Println("log")
  25599. fmt.Println(string(userJSONBytes))
  25600. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25601. utils.ErrorLog("解析失败:%v", err)
  25602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25603. return
  25604. }
  25605. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25606. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25607. if result3101.Infcode == "0" {
  25608. if len(result3101.Output.Result) > 0 {
  25609. var errMsgs []string
  25610. for _, item := range result3101.Output.Result {
  25611. errMsgs = append(errMsgs, item.VolaCont)
  25612. }
  25613. c.ServeSuccessJSON(map[string]interface{}{
  25614. "failed_code": -10,
  25615. "msg": errMsgs,
  25616. })
  25617. return
  25618. }
  25619. }
  25620. bytesData, _ := json.Marshal(data)
  25621. var req *http.Request
  25622. if miConfig.MdtrtareaAdmvs == "320921" {
  25623. data["diag_code"] = sickConfig.CountryCode
  25624. fmt.Println(data)
  25625. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25626. } else {
  25627. data["diag_code"] = sickConfig.CountryCode
  25628. fmt.Println(data)
  25629. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25630. }
  25631. resp, _ := client.Do(req)
  25632. defer resp.Body.Close()
  25633. body, ioErr := ioutil.ReadAll(resp.Body)
  25634. if ioErr != nil {
  25635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25637. return
  25638. }
  25639. var respJSON map[string]interface{}
  25640. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25643. return
  25644. }
  25645. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25646. userJSONBytes, _ := json.Marshal(respJSON)
  25647. fmt.Println("log")
  25648. fmt.Println(string(userJSONBytes))
  25649. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25650. utils.ErrorLog("解析失败:%v", err)
  25651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25652. return
  25653. }
  25654. res.InfRefmsgid = resFour10265.InfRefmsgid
  25655. res.Output = resFour10265.Output
  25656. res.ErrMsg = resFour10265.ErrMsg
  25657. res.Cainfo = resFour10265.Cainfo
  25658. res.WarnMsg = resFour10265.WarnMsg
  25659. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25660. res.Infcode = infocode
  25661. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25662. var pagesize int = 2
  25663. var start int = 1
  25664. var stop int
  25665. var pagecount int
  25666. var curpage int
  25667. var isSuccess bool = true
  25668. data["doctor_id"] = doctor_info.DoctorNumber
  25669. //总页数,向上取整,注意除之前要先转换类型为float64
  25670. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25671. for curpage = 1; curpage <= pagecount; curpage++ {
  25672. if curpage == 1 {
  25673. start = 1
  25674. } else {
  25675. start = (curpage-1)*pagesize + 1
  25676. }
  25677. stop = curpage * pagesize
  25678. if stop > len(prescriptions) {
  25679. stop = len(prescriptions)
  25680. }
  25681. //var requestLog string
  25682. data["pre"] = prescriptions[start-1 : stop]
  25683. fmt.Println(data["pre"])
  25684. bytesData, _ := json.Marshal(data)
  25685. var req *http.Request
  25686. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25687. resp, _ := client.Do(req)
  25688. defer resp.Body.Close()
  25689. body, ioErr := ioutil.ReadAll(resp.Body)
  25690. if ioErr != nil {
  25691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25693. return
  25694. }
  25695. var respJSON map[string]interface{}
  25696. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25699. return
  25700. }
  25701. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25702. userJSONBytes, _ := json.Marshal(respJSON)
  25703. fmt.Println("log")
  25704. fmt.Println(string(userJSONBytes))
  25705. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25706. utils.ErrorLog("解析失败:%v", err)
  25707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25708. return
  25709. }
  25710. res.InfRefmsgid = resFour10265.InfRefmsgid
  25711. res.Output = resFour10265.Output
  25712. res.ErrMsg = resFour10265.ErrMsg
  25713. res.Cainfo = resFour10265.Cainfo
  25714. res.WarnMsg = resFour10265.WarnMsg
  25715. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25716. res.Infcode = infocode
  25717. if infocode == 0 {
  25718. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25719. } else {
  25720. isSuccess = false
  25721. errlog := &models.HisOrderError{
  25722. UserOrgId: adminUser.CurrentOrgId,
  25723. Ctime: time.Now().Unix(),
  25724. Mtime: time.Now().Unix(),
  25725. Number: chrg_bchno,
  25726. ErrMsg: "",
  25727. Status: 1,
  25728. PatientId: id,
  25729. RecordTime: recordDateTime,
  25730. Stage: 4,
  25731. }
  25732. service.CreateErrMsgLog(errlog)
  25733. c.ServeSuccessJSON(map[string]interface{}{
  25734. "failed_code": -10,
  25735. "msg": res.ErrMsg,
  25736. })
  25737. return
  25738. }
  25739. }
  25740. if isSuccess {
  25741. res.Infcode = 0
  25742. }
  25743. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25744. 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)
  25745. var dat map[string]interface{}
  25746. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25747. fmt.Println(dat)
  25748. } else {
  25749. fmt.Println(err)
  25750. }
  25751. saveLog(result, request_log, "2204", "上传费用明细")
  25752. userJSONBytes, _ := json.Marshal(dat)
  25753. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25754. utils.ErrorLog("解析失败:%v", err)
  25755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25756. return
  25757. }
  25758. res.InfRefmsgid = resFour10265.InfRefmsgid
  25759. res.Output = resFour10265.Output
  25760. res.ErrMsg = resFour10265.ErrMsg
  25761. res.Cainfo = resFour10265.Cainfo
  25762. res.WarnMsg = resFour10265.WarnMsg
  25763. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25764. res.Infcode = infocode
  25765. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25766. bytesData, _ := json.Marshal(data)
  25767. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25768. resp, _ := client.Do(req)
  25769. defer resp.Body.Close()
  25770. body, ioErr := ioutil.ReadAll(resp.Body)
  25771. if ioErr != nil {
  25772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25774. return
  25775. }
  25776. var respJSON map[string]interface{}
  25777. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25780. return
  25781. }
  25782. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25783. userJSONBytes, _ := json.Marshal(respJSON)
  25784. fmt.Println("log")
  25785. fmt.Println(string(userJSONBytes))
  25786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25787. utils.ErrorLog("解析失败:%v", err)
  25788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25789. return
  25790. }
  25791. } else {
  25792. if miConfig.Code == "H15049901371" {
  25793. 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)
  25794. var dat map[string]interface{}
  25795. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25796. fmt.Println(dat)
  25797. } else {
  25798. fmt.Println(err)
  25799. }
  25800. saveLog(result, request_log, "2204", "上传费用明细")
  25801. userJSONBytes, _ := json.Marshal(dat)
  25802. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25803. utils.ErrorLog("解析失败:%v", err)
  25804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25805. return
  25806. }
  25807. res.InfRefmsgid = resFour10265.InfRefmsgid
  25808. res.Output = resFour10265.Output
  25809. res.ErrMsg = resFour10265.ErrMsg
  25810. res.Cainfo = resFour10265.Cainfo
  25811. res.WarnMsg = resFour10265.WarnMsg
  25812. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25813. res.Infcode = infocode
  25814. } else {
  25815. 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)
  25816. var dat map[string]interface{}
  25817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25818. fmt.Println(dat)
  25819. } else {
  25820. fmt.Println(err)
  25821. }
  25822. saveLog(result, request_log, "2204", "上传费用明细")
  25823. userJSONBytes, _ := json.Marshal(dat)
  25824. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25825. utils.ErrorLog("解析失败:%v", err)
  25826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25827. return
  25828. }
  25829. }
  25830. }
  25831. if res.Infcode == 0 {
  25832. order := &models.HisOrder{
  25833. UserOrgId: adminUser.CurrentOrgId,
  25834. HisPatientId: his.ID,
  25835. PatientId: his.PatientId,
  25836. SettleAccountsDate: recordDateTime,
  25837. MdtrtId: his.Number,
  25838. PsnNo: his.PsnNo,
  25839. MedType: strconv.FormatInt(reg_type, 10),
  25840. Ctime: time.Now().Unix(),
  25841. Mtime: time.Now().Unix(),
  25842. Status: 1,
  25843. Number: chrg_bchno,
  25844. Infcode: res.Infcode,
  25845. WarnMsg: res.WarnMsg,
  25846. Cainfo: res.Cainfo,
  25847. ErrMsg: res.ErrMsg,
  25848. RespondTime: res.RefmsgTime,
  25849. InfRefmsgid: res.InfRefmsgid,
  25850. OrderStatus: 1,
  25851. PayWay: pay_way,
  25852. PayWays: pay_ways,
  25853. OthDesc: oth_desc,
  25854. PayPrice: pay_price,
  25855. PayCardNo: pay_card_no,
  25856. DiscountPrice: discount_price,
  25857. PreferentialPrice: preferential_price,
  25858. RealityPrice: reality_price,
  25859. FoundPrice: found_price,
  25860. MedicalInsurancePrice: medical_insurance_price,
  25861. PrivatePrice: private_price,
  25862. IsMedicineInsurance: 1,
  25863. SettleType: settle_accounts_type,
  25864. SettleStartTime: start_time,
  25865. SettleEndTime: end_time,
  25866. Creator: roles.AdminUserId,
  25867. Modify: roles.AdminUserId,
  25868. FaPiaoNumber: fapiao_number,
  25869. FaPiaoCode: fapiao_code,
  25870. PType: 2,
  25871. Diagnosis: diagnosis_id,
  25872. CashPay: cash_pay,
  25873. WechatPay: wechat_pay,
  25874. AliPay: ali_pay,
  25875. JifenPay: jifen_pay,
  25876. BandCardPay: band_card_pay,
  25877. }
  25878. err = service.CreateOrder(order)
  25879. if err != nil {
  25880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25881. return
  25882. }
  25883. for _, item := range res.Output.Result {
  25884. temp := strings.Split(item.FeedetlSn, "-")
  25885. var advice_id int64 = 0
  25886. var project_id int64 = 0
  25887. var types int64 = 0
  25888. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25889. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25890. if temp[1] == "1" {
  25891. advice_id = id
  25892. project_id = 0
  25893. } else if temp[1] == "2" {
  25894. advice_id = 0
  25895. project_id = id
  25896. }
  25897. if item.MedChrgitmType == "9" {
  25898. item.MedChrgitmType = "09"
  25899. }
  25900. info := &models.HisOrderInfo{
  25901. OrderNumber: order.Number,
  25902. FeedetlSn: item.FeedetlSn,
  25903. UploadDate: time.Now().Unix(),
  25904. AdviceId: advice_id,
  25905. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25906. Cnt: item.Cnt,
  25907. Pric: float64(item.Pric),
  25908. PatientId: his.PatientId,
  25909. PricUplmtAmt: item.PricUplmtAmt,
  25910. SelfpayProp: item.SelfpayProp,
  25911. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25912. OverlmtAmt: item.OverlmtAmt,
  25913. PreselfpayAmt: item.PreselfpayAmt,
  25914. BasMednFlag: item.BasMednFlag,
  25915. MedChrgitmType: item.MedChrgitmType,
  25916. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25917. Status: 1,
  25918. Memo: item.Memo,
  25919. Mtime: time.Now().Unix(),
  25920. InscpScpAmt: item.InscpScpAmt,
  25921. DrtReimFlag: item.DrtReimFlag,
  25922. Ctime: time.Now().Unix(),
  25923. ListSpItemFlag: item.ListSpItemFlag,
  25924. ChldMedcFlag: item.ChldMedcFlag,
  25925. LmtUsedFlag: item.LmtUsedFlag,
  25926. ChrgitmLv: item.ChrgitmLv,
  25927. UserOrgId: adminUser.CurrentOrgId,
  25928. HisPatientId: his.ID,
  25929. OrderId: order.ID,
  25930. ProjectId: project_id,
  25931. Type: types,
  25932. }
  25933. service.CreateOrderInfo(info)
  25934. }
  25935. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25936. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25937. var total float64
  25938. for _, item := range prescriptions {
  25939. if item.Type == 1 { //药品
  25940. for _, subItem := range item.HisDoctorAdviceInfo {
  25941. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25942. total_one := price * subItem.PrescribingNumber
  25943. total = total + total_one
  25944. }
  25945. }
  25946. if item.Type == 2 { //项目
  25947. for _, subItem := range item.HisPrescriptionProject {
  25948. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25949. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25950. total_one := price * cnt
  25951. total = total + total_one
  25952. }
  25953. }
  25954. }
  25955. allTotal := fmt.Sprintf("%.2f", total)
  25956. //if adminUser.CurrentOrgId == 9919 {
  25957. //
  25958. // allTotal = fmt.Sprintf("%.2f", total)
  25959. //
  25960. //} else {
  25961. //
  25962. // allTotal = fmt.Sprintf("%.2f", total)
  25963. //
  25964. //}
  25965. if res.Infcode == 0 {
  25966. var rf []*ResultFive
  25967. json.Unmarshal([]byte(his.Iinfo), &rf)
  25968. chrg_bchno := chrg_bchno
  25969. cert_no := his.Certno
  25970. var insutypes []string
  25971. var insutype string
  25972. var is390 int = 0
  25973. var is310 int = 0
  25974. for _, item := range rf {
  25975. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25976. insutypes = append(insutypes, item.Insutype)
  25977. }
  25978. }
  25979. if len(insutypes) == 1 {
  25980. insutype = insutypes[0]
  25981. } else {
  25982. for _, i := range insutypes {
  25983. if i == "390" {
  25984. is390 = 1
  25985. }
  25986. if i == "310" {
  25987. is310 = 1
  25988. }
  25989. }
  25990. }
  25991. if is390 == 1 {
  25992. insutype = "390"
  25993. }
  25994. if is310 == 1 {
  25995. insutype = "310"
  25996. }
  25997. if len(insutypes) == 0 {
  25998. insutype = "310"
  25999. }
  26000. if len(insutypes) == 2 {
  26001. insutype = strconv.FormatInt(his.SocialType, 10)
  26002. }
  26003. insutype = strconv.FormatInt(his.SocialType, 10)
  26004. //insutype = "390"
  26005. if his.IdCardType == 1 {
  26006. // cert_no = his.MedicalInsuranceNumber
  26007. cert_no = his.Certno
  26008. } else {
  26009. cert_no = his.Certno
  26010. }
  26011. var res ResultSeven
  26012. var resSeven10265 ResultSeven10265
  26013. var gzresSeven10265Two GZResultSeven10265Two
  26014. var src_resquest string
  26015. var result2 string
  26016. if miConfig.MdtrtareaAdmvs == "421300" {
  26017. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26018. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26019. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26020. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26021. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26022. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26023. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26024. resp, requestErr := http.Get(api)
  26025. if requestErr != nil {
  26026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26027. return
  26028. }
  26029. body, ioErr := ioutil.ReadAll(resp.Body)
  26030. if ioErr != nil {
  26031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26033. return
  26034. }
  26035. var respJSON map[string]interface{}
  26036. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26039. return
  26040. }
  26041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26042. result, _ := json.Marshal(respJSON)
  26043. if miConfig.Code == "H15049901371" {
  26044. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26045. utils.ErrorLog("解析失败:%v", err)
  26046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26047. return
  26048. }
  26049. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26050. res.Output = resSeven10265.Output
  26051. res.ErrMsg = resSeven10265.ErrMsg
  26052. res.Cainfo = resSeven10265.Cainfo
  26053. res.WarnMsg = resSeven10265.WarnMsg
  26054. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26055. res.Infcode = infocode
  26056. } else {
  26057. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26058. utils.ErrorLog("解析失败:%v", err)
  26059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26060. return
  26061. }
  26062. }
  26063. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26064. if reg_type == 11 && his.Insutype == "390" {
  26065. reg_type = 110104
  26066. }
  26067. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26068. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26069. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26070. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26071. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26072. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26073. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26074. resp, requestErr := http.Get(api)
  26075. if requestErr != nil {
  26076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26077. return
  26078. }
  26079. body, ioErr := ioutil.ReadAll(resp.Body)
  26080. if ioErr != nil {
  26081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26083. return
  26084. }
  26085. var respJSON map[string]interface{}
  26086. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26089. return
  26090. }
  26091. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26092. result, _ := json.Marshal(respJSON)
  26093. if miConfig.Code == "H15049901371" {
  26094. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26095. utils.ErrorLog("解析失败:%v", err)
  26096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26097. return
  26098. }
  26099. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26100. res.Output = resSeven10265.Output
  26101. res.ErrMsg = resSeven10265.ErrMsg
  26102. res.Cainfo = resSeven10265.Cainfo
  26103. res.WarnMsg = resSeven10265.WarnMsg
  26104. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26105. res.Infcode = infocode
  26106. } else {
  26107. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26108. utils.ErrorLog("解析失败:%v", err)
  26109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26110. return
  26111. }
  26112. }
  26113. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26114. if reg_type == 11 && his.Insutype == "390" {
  26115. reg_type = 110104
  26116. }
  26117. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26118. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26119. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26120. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26121. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26122. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26123. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26124. resp, requestErr := http.Get(api)
  26125. if requestErr != nil {
  26126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26127. return
  26128. }
  26129. body, ioErr := ioutil.ReadAll(resp.Body)
  26130. if ioErr != nil {
  26131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26133. return
  26134. }
  26135. var respJSON map[string]interface{}
  26136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26139. return
  26140. }
  26141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26142. result, _ := json.Marshal(respJSON)
  26143. if miConfig.Code == "H15049901371" {
  26144. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26145. utils.ErrorLog("解析失败:%v", err)
  26146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26147. return
  26148. }
  26149. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26150. res.Output = resSeven10265.Output
  26151. res.ErrMsg = resSeven10265.ErrMsg
  26152. res.Cainfo = resSeven10265.Cainfo
  26153. res.WarnMsg = resSeven10265.WarnMsg
  26154. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26155. res.Infcode = infocode
  26156. } else {
  26157. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26158. utils.ErrorLog("解析失败:%v", err)
  26159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26160. return
  26161. }
  26162. }
  26163. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26164. if reg_type == 11 && his.Insutype == "390" {
  26165. reg_type = 110104
  26166. }
  26167. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26168. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26169. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26170. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26171. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26172. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26173. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26174. resp, requestErr := http.Get(api)
  26175. if requestErr != nil {
  26176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26177. return
  26178. }
  26179. body, ioErr := ioutil.ReadAll(resp.Body)
  26180. if ioErr != nil {
  26181. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26183. return
  26184. }
  26185. var respJSON map[string]interface{}
  26186. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26189. return
  26190. }
  26191. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26192. result, _ := json.Marshal(respJSON)
  26193. if miConfig.Code == "H15049901371" {
  26194. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26195. utils.ErrorLog("解析失败:%v", err)
  26196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26197. return
  26198. }
  26199. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26200. res.Output = resSeven10265.Output
  26201. res.ErrMsg = resSeven10265.ErrMsg
  26202. res.Cainfo = resSeven10265.Cainfo
  26203. res.WarnMsg = resSeven10265.WarnMsg
  26204. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26205. res.Infcode = infocode
  26206. } else {
  26207. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26208. utils.ErrorLog("解析失败:%v", err)
  26209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26210. return
  26211. }
  26212. }
  26213. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26214. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26215. if result3101.Infcode == "0" {
  26216. if len(result3101.Output.Result) > 0 {
  26217. var errMsgs []string
  26218. for _, item := range result3101.Output.Result {
  26219. errMsgs = append(errMsgs, item.VolaCont)
  26220. }
  26221. c.ServeSuccessJSON(map[string]interface{}{
  26222. "failed_code": -10,
  26223. "msg": errMsgs,
  26224. })
  26225. return
  26226. } else {
  26227. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26228. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26229. bas := strings.Split(psn_info.CardInfo, "|")
  26230. if his.IdCardType == 1 {
  26231. cert_no = bas[2]
  26232. } else if his.IdCardType == 3 {
  26233. cert_no = his.Certno
  26234. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26235. } else if his.IdCardType == 4 {
  26236. cert_no = his.Certno
  26237. psn_info.VerifyNumber = psn_info.VerifyNumber
  26238. }
  26239. var api string
  26240. if miConfig.MdtrtareaAdmvs == "320921" {
  26241. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26242. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26243. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26244. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26245. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26246. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26247. "&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
  26248. } else {
  26249. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26250. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26251. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26252. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26253. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26254. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26255. "&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
  26256. }
  26257. resp, requestErr := http.Get(api)
  26258. if requestErr != nil {
  26259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26260. return
  26261. }
  26262. body, ioErr := ioutil.ReadAll(resp.Body)
  26263. if ioErr != nil {
  26264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26266. return
  26267. }
  26268. var respJSON map[string]interface{}
  26269. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26272. return
  26273. }
  26274. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26275. result, _ := json.Marshal(respJSON)
  26276. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26277. utils.ErrorLog("解析失败:%v", err)
  26278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26279. return
  26280. }
  26281. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26282. res.Output = resSeven10265.Output
  26283. res.ErrMsg = resSeven10265.ErrMsg
  26284. res.Cainfo = resSeven10265.Cainfo
  26285. res.WarnMsg = resSeven10265.WarnMsg
  26286. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26287. res.Infcode = infocode
  26288. }
  26289. }
  26290. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26291. psn_info, _ := service.GetPsnByPatientId(id)
  26292. var verify_number string
  26293. if psn_info.IdCardType == 4 {
  26294. verify_number = psn_info.VerifyNumber
  26295. } else if psn_info.IdCardType == 1 {
  26296. bas := strings.Split(psn_info.CardInfo, "|")
  26297. cardNumber := bas[2]
  26298. verify_number = cardNumber
  26299. } else {
  26300. psn_info.IdCardType = 2
  26301. verify_number = psn_info.Certno
  26302. }
  26303. var api string
  26304. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26305. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26306. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26307. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26308. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26309. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26310. "&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
  26311. resp, requestErr := http.Get(api)
  26312. if requestErr != nil {
  26313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26314. return
  26315. }
  26316. body, ioErr := ioutil.ReadAll(resp.Body)
  26317. if ioErr != nil {
  26318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26320. return
  26321. }
  26322. var respJSON map[string]interface{}
  26323. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26326. return
  26327. }
  26328. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26329. result, _ := json.Marshal(respJSON)
  26330. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26331. utils.ErrorLog("解析失败:%v", err)
  26332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26333. return
  26334. }
  26335. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26336. res.Output = resSeven10265.Output
  26337. res.ErrMsg = resSeven10265.ErrMsg
  26338. res.Cainfo = resSeven10265.Cainfo
  26339. res.WarnMsg = resSeven10265.WarnMsg
  26340. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26341. res.Infcode = infocode
  26342. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26343. var cert_no string
  26344. if his.IdCardType == 4 {
  26345. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26346. cert_no = psn_info.VerifyNumber
  26347. 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)
  26348. } else if his.IdCardType == 1 {
  26349. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26350. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26351. 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)
  26352. }
  26353. //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)
  26354. var dat map[string]interface{}
  26355. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26356. fmt.Println(dat)
  26357. } else {
  26358. fmt.Println(err)
  26359. }
  26360. saveLog(result2, src_resquest, "2207", "结算")
  26361. userJSONBytes, _ := json.Marshal(dat)
  26362. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26363. utils.ErrorLog("解析失败:%v", err)
  26364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26365. return
  26366. }
  26367. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26368. res.Output = resSeven10265.Output
  26369. res.ErrMsg = resSeven10265.ErrMsg
  26370. res.Cainfo = resSeven10265.Cainfo
  26371. res.WarnMsg = resSeven10265.WarnMsg
  26372. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26373. res.Infcode = infocode
  26374. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26375. res2 := c.GetoleInfo()
  26376. if res2.Infcode == 0 {
  26377. var result string
  26378. var request_log string
  26379. var result_log string
  26380. if res2.Output.MdtrtCertType == "02" {
  26381. 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)
  26382. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26383. } else if res2.Output.MdtrtCertType == "01" {
  26384. 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)
  26385. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26386. } else {
  26387. 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)
  26388. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26389. }
  26390. var dat map[string]interface{}
  26391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26392. fmt.Println(dat)
  26393. } else {
  26394. fmt.Println(err)
  26395. }
  26396. userJSONBytes, _ := json.Marshal(dat)
  26397. var res5 ResultTwo
  26398. //var resTwo10265 ResultTwo10265
  26399. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26400. utils.ErrorLog("解析失败:%v", err)
  26401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26402. return
  26403. }
  26404. if res5.Infcode == -1 {
  26405. c.ServeSuccessJSON(map[string]interface{}{
  26406. "failed_code": -10,
  26407. "msg": res5.ErrMsg,
  26408. })
  26409. return
  26410. }
  26411. var insutypes []string
  26412. var insutype string
  26413. var is390 int = 0
  26414. var is310 int = 0
  26415. for _, item := range res5.Output.Iinfo {
  26416. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26417. insutypes = append(insutypes, item.Insutype)
  26418. }
  26419. }
  26420. if len(insutypes) == 1 {
  26421. insutype = insutypes[0]
  26422. } else {
  26423. for _, i := range insutypes {
  26424. if i == "390" {
  26425. is390 = 1
  26426. }
  26427. if i == "310" {
  26428. is310 = 1
  26429. }
  26430. }
  26431. }
  26432. if is390 == 1 {
  26433. insutype = "390"
  26434. }
  26435. if is310 == 1 {
  26436. insutype = "310"
  26437. }
  26438. if len(insutypes) == 0 {
  26439. insutype = "310"
  26440. }
  26441. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26442. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26443. infoStr := string(Iinfos)
  26444. idetinfoStr := string(Idetinfos)
  26445. psn := &models.HisPsn{
  26446. PsnNo: res5.Output.Baseinfo.PsnNo,
  26447. PatientId: id,
  26448. Certno: res5.Output.Baseinfo.Certno,
  26449. Gend: res5.Output.Baseinfo.Gend,
  26450. Naty: res5.Output.Baseinfo.Naty,
  26451. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26452. PsnName: res5.Output.Baseinfo.PsnName,
  26453. Idetinfo: idetinfoStr,
  26454. Insuinfo: infoStr,
  26455. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26456. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26457. VerifyNumber: res2.Output.EcToken,
  26458. }
  26459. if res2.Output.MdtrtCertType == "01" {
  26460. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26461. psn.VerifyNumber = res2.Output.EcToken
  26462. } else if res2.Output.MdtrtCertType == "02" {
  26463. psn.VerifyNumber = res2.Output.CardNo
  26464. } else {
  26465. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26466. }
  26467. service.CreateHisPsn(psn)
  26468. if res2.Output.MdtrtCertType == "01" {
  26469. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26470. token := res2.Output.EcToken
  26471. 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)
  26472. } else if res2.Output.MdtrtCertType == "02" {
  26473. 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)
  26474. } else {
  26475. 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)
  26476. }
  26477. var dat2 map[string]interface{}
  26478. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26479. fmt.Println(dat2)
  26480. } else {
  26481. fmt.Println(err)
  26482. }
  26483. userJSONBytes3, _ := json.Marshal(dat2)
  26484. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26485. utils.ErrorLog("解析失败:%v", err)
  26486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26487. return
  26488. }
  26489. saveLog(result2, src_resquest, "2207", "结算")
  26490. } else {
  26491. c.ServeSuccessJSON(map[string]interface{}{
  26492. "failed_code": -10,
  26493. "msg": res2.ErrMsg,
  26494. })
  26495. return
  26496. }
  26497. } else {
  26498. if miConfig.Code == "H15049901371" {
  26499. //赤峰地区国家医保医疗类别
  26500. //职工透析:医疗类别选特殊情况门诊990502
  26501. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26502. var med_type string
  26503. if his.Insutype == "390" {
  26504. if reg_type == 14 {
  26505. med_type = "9933"
  26506. } else if reg_type == 11 {
  26507. med_type = "11"
  26508. }
  26509. } else if his.Insutype == "310" {
  26510. if reg_type == 14 {
  26511. med_type = "990502"
  26512. } else if reg_type == 11 {
  26513. med_type = "11"
  26514. }
  26515. }
  26516. 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)
  26517. } else {
  26518. if his.IdCardType == 4 {
  26519. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26520. var token string
  26521. token = psn_info.VerifyNumber
  26522. 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)
  26523. } else {
  26524. if his.IdCardType == 1 {
  26525. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26526. bas := strings.Split(psn_info.CardInfo, "|")
  26527. basNumber := bas[2]
  26528. cert_no = basNumber
  26529. }
  26530. 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)
  26531. }
  26532. }
  26533. //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)
  26534. var dat map[string]interface{}
  26535. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26536. fmt.Println(dat)
  26537. } else {
  26538. fmt.Println(err)
  26539. }
  26540. saveLog(result2, src_resquest, "2207", "结算")
  26541. userJSONBytes, _ := json.Marshal(dat)
  26542. if miConfig.Code == "H15049901371" {
  26543. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26544. utils.ErrorLog("解析失败:%v", err)
  26545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26546. return
  26547. }
  26548. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26549. res.Output = resSeven10265.Output
  26550. res.ErrMsg = resSeven10265.ErrMsg
  26551. res.Cainfo = resSeven10265.Cainfo
  26552. res.WarnMsg = resSeven10265.WarnMsg
  26553. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26554. res.Infcode = infocode
  26555. } else {
  26556. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26557. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26558. utils.ErrorLog("解析失败:%v", err)
  26559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26560. return
  26561. }
  26562. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26563. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26564. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26565. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26566. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26567. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26568. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26569. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26570. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26571. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26572. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26573. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26574. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26575. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26576. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26577. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26578. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26579. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26580. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26581. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26582. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26583. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26584. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26585. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26586. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26587. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26588. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26589. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26590. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26591. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26592. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26593. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26594. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26595. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26596. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26597. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26598. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26599. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26600. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26601. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26602. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26603. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26604. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26605. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26606. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26607. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26608. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26609. res.Cainfo = gzresSeven10265Two.Cainfo
  26610. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26611. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26612. //res.Infcode = infocode
  26613. } else {
  26614. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26615. utils.ErrorLog("解析失败:%v", err)
  26616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26617. return
  26618. }
  26619. }
  26620. }
  26621. }
  26622. if res.Infcode == -1 {
  26623. errlog := &models.HisOrderError{
  26624. UserOrgId: adminUser.CurrentOrgId,
  26625. Ctime: time.Now().Unix(),
  26626. Mtime: time.Now().Unix(),
  26627. Number: chrg_bchno,
  26628. ErrMsg: res.ErrMsg,
  26629. Status: 1,
  26630. PatientId: id,
  26631. RecordTime: recordDateTime,
  26632. Stage: 6,
  26633. }
  26634. service.CreateErrMsgLog(errlog)
  26635. c.ServeSuccessJSON(map[string]interface{}{
  26636. "failed_code": -10,
  26637. "msg": res.ErrMsg,
  26638. })
  26639. return
  26640. } else {
  26641. sickConfig, _ := service.FindSickById(his.SickType)
  26642. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26643. order.OrderStatus = 2
  26644. order.Status = 1
  26645. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26646. order.SetlId = res.Output.Setlinfo.SetlID
  26647. order.PsnNo = res.Output.Setlinfo.PsnNo
  26648. order.PsnName = res.Output.Setlinfo.PsnName
  26649. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26650. order.Certno = res.Output.Setlinfo.Certno
  26651. order.Gend = res.Output.Setlinfo.Gend
  26652. order.Naty = res.Output.Setlinfo.Naty
  26653. order.Age = res.Output.Setlinfo.Age
  26654. order.Insutype = res.Output.Setlinfo.Insutype
  26655. order.PsnType = res.Output.Setlinfo.PsnType
  26656. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26657. order.SetlTime = res.Output.Setlinfo.SetlTime
  26658. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26659. if res.Output.Setlinfo.MedType == "140101" {
  26660. order.MedType = "14"
  26661. } else {
  26662. if res.Output.Setlinfo.MedType == "110104" {
  26663. order.MedType = "11"
  26664. } else {
  26665. order.MedType = res.Output.Setlinfo.MedType
  26666. }
  26667. }
  26668. if reg_type == 1112 {
  26669. order.MedType = "1112"
  26670. }
  26671. if reg_type == 1111 {
  26672. order.MedType = "1111"
  26673. }
  26674. order.ClrType = res.Output.Setlinfo.ClrType
  26675. if adminUser.CurrentOrgId == 10480 {
  26676. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26677. order.ClrType = "11"
  26678. } else {
  26679. order.ClrType = "9903"
  26680. }
  26681. }
  26682. if adminUser.CurrentOrgId == 10721 {
  26683. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26684. order.ClrType = "11"
  26685. } else {
  26686. order.ClrType = "9903"
  26687. }
  26688. }
  26689. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26690. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26691. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26692. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26693. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26694. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26695. order.HifpPay = res.Output.Setlinfo.HifpPay
  26696. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26697. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26698. order.HifesPay = res.Output.Setlinfo.HifesPay
  26699. order.HifobPay = res.Output.Setlinfo.HifobPay
  26700. order.MafPay = res.Output.Setlinfo.MafPay
  26701. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26702. order.OthPay = res.Output.Setlinfo.OthPay
  26703. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26704. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26705. order.AcctPay = res.Output.Setlinfo.AcctPay
  26706. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26707. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26708. order.Balc = res.Output.Setlinfo.Balc
  26709. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26710. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26711. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26712. //order.ClrType = res.Output.Setlinfo.ClrType
  26713. order.ClrWay = res.Output.Setlinfo.ClrWay
  26714. order.Creator = order.Creator
  26715. order.Modify = roles.AdminUserId
  26716. order.RequestLog = src_resquest
  26717. order.FaPiaoNumber = fapiao_number
  26718. order.FaPiaoCode = fapiao_code
  26719. order.SickName = sickConfig.ClassName
  26720. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26721. //detailStr := string(setlDetail)
  26722. //order.SetlDetail = detailStr
  26723. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26724. err = service.UpDateOrder(order)
  26725. if err == nil {
  26726. //判断是否使用了押金
  26727. if dec_way == "true" {
  26728. tmpstring := strconv.FormatInt(order.ID, 10)
  26729. order.Decimal = decimal
  26730. service.UpDateOrder(order)
  26731. //扣押金
  26732. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26733. if errmsg != nil {
  26734. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26735. return
  26736. }
  26737. }
  26738. c.ServeSuccessJSON(map[string]interface{}{
  26739. "msg": "结算成功",
  26740. })
  26741. } else {
  26742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26743. return
  26744. }
  26745. }
  26746. } else {
  26747. adminUser := c.GetAdminUserInfo()
  26748. errlog := &models.HisOrderError{
  26749. UserOrgId: adminUser.CurrentOrgId,
  26750. Ctime: time.Now().Unix(),
  26751. Mtime: time.Now().Unix(),
  26752. ErrMsg: res.ErrMsg,
  26753. Status: 1,
  26754. PatientId: id,
  26755. RecordTime: recordDateTime,
  26756. Stage: 4,
  26757. }
  26758. service.CreateErrMsgLog(errlog)
  26759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26760. return
  26761. }
  26762. } else {
  26763. adminUser := c.GetAdminUserInfo()
  26764. errlog := &models.HisOrderError{
  26765. UserOrgId: adminUser.CurrentOrgId,
  26766. Ctime: time.Now().Unix(),
  26767. Mtime: time.Now().Unix(),
  26768. ErrMsg: res.ErrMsg,
  26769. Status: 1,
  26770. PatientId: id,
  26771. RecordTime: recordDateTime,
  26772. Stage: 4,
  26773. }
  26774. service.CreateErrMsgLog(errlog)
  26775. c.ServeSuccessJSON(map[string]interface{}{
  26776. "failed_code": -10,
  26777. "msg": res.ErrMsg,
  26778. })
  26779. return
  26780. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26781. //return
  26782. }
  26783. }
  26784. }
  26785. } else if tempOrder.ID > 0 {
  26786. if tempOrder.IsPre == 1 {
  26787. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26788. var rf []*ResultFive
  26789. json.Unmarshal([]byte(his.Iinfo), &rf)
  26790. chrg_bchno := tempOrder.Number
  26791. cert_no := his.Certno
  26792. var insutypes []string
  26793. var insutype string
  26794. var is390 int = 0
  26795. var is310 int = 0
  26796. for _, item := range rf {
  26797. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26798. insutypes = append(insutypes, item.Insutype)
  26799. }
  26800. }
  26801. if len(insutypes) == 1 {
  26802. insutype = insutypes[0]
  26803. } else {
  26804. for _, i := range insutypes {
  26805. if i == "390" {
  26806. is390 = 1
  26807. }
  26808. if i == "310" {
  26809. is310 = 1
  26810. }
  26811. }
  26812. }
  26813. if is390 == 1 {
  26814. insutype = "390"
  26815. }
  26816. if is310 == 1 {
  26817. insutype = "310"
  26818. }
  26819. if len(insutypes) == 0 {
  26820. insutype = "310"
  26821. }
  26822. if len(insutypes) == 2 {
  26823. insutype = strconv.FormatInt(his.SocialType, 10)
  26824. }
  26825. //insutype = "390"
  26826. if his.IdCardType == 1 {
  26827. // cert_no = his.MedicalInsuranceNumber
  26828. cert_no = his.Certno
  26829. } else {
  26830. cert_no = his.Certno
  26831. }
  26832. var res ResultSeven
  26833. var ahres ResultSevenAH
  26834. var resSeven10265 ResultSeven10265
  26835. var gzresSeven10265Two GZResultSeven10265Two
  26836. var src_resquest string
  26837. var result2 string
  26838. if miConfig.MdtrtareaAdmvs == "450721" {
  26839. res2 := c.GetoleInfo()
  26840. if res2.Infcode == 0 {
  26841. var result string
  26842. var request_log string
  26843. var result_log string
  26844. if res2.Output.MdtrtCertType == "02" {
  26845. 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)
  26846. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26847. } else if res2.Output.MdtrtCertType == "01" {
  26848. 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)
  26849. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26850. } else {
  26851. 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)
  26852. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26853. }
  26854. var dat map[string]interface{}
  26855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26856. fmt.Println(dat)
  26857. } else {
  26858. fmt.Println(err)
  26859. }
  26860. userJSONBytes, _ := json.Marshal(dat)
  26861. var res5 ResultTwo
  26862. //var resTwo10265 ResultTwo10265
  26863. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26864. utils.ErrorLog("解析失败:%v", err)
  26865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26866. return
  26867. }
  26868. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26869. if res5.Infcode == -1 {
  26870. c.ServeSuccessJSON(map[string]interface{}{
  26871. "failed_code": -10,
  26872. "msg": res5.ErrMsg,
  26873. })
  26874. return
  26875. }
  26876. var insutypes []string
  26877. var insutype string
  26878. var is390 int = 0
  26879. var is310 int = 0
  26880. for _, item := range res5.Output.Iinfo {
  26881. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26882. insutypes = append(insutypes, item.Insutype)
  26883. }
  26884. }
  26885. if len(insutypes) == 1 {
  26886. insutype = insutypes[0]
  26887. } else {
  26888. for _, i := range insutypes {
  26889. if i == "390" {
  26890. is390 = 1
  26891. }
  26892. if i == "310" {
  26893. is310 = 1
  26894. }
  26895. }
  26896. }
  26897. if is390 == 1 {
  26898. insutype = "390"
  26899. }
  26900. if is310 == 1 {
  26901. insutype = "310"
  26902. }
  26903. if len(insutypes) == 0 {
  26904. insutype = "310"
  26905. }
  26906. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26907. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26908. infoStr := string(Iinfos)
  26909. idetinfoStr := string(Idetinfos)
  26910. psn := &models.HisPsn{
  26911. PsnNo: res5.Output.Baseinfo.PsnNo,
  26912. PatientId: id,
  26913. Certno: res5.Output.Baseinfo.Certno,
  26914. Gend: res5.Output.Baseinfo.Gend,
  26915. Naty: res5.Output.Baseinfo.Naty,
  26916. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26917. PsnName: res5.Output.Baseinfo.PsnName,
  26918. Idetinfo: idetinfoStr,
  26919. Insuinfo: infoStr,
  26920. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26921. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26922. VerifyNumber: res2.Output.EcToken,
  26923. }
  26924. service.CreateHisPsn(psn)
  26925. if res2.Output.MdtrtCertType == "01" {
  26926. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26927. token := res2.Output.EcToken
  26928. 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)
  26929. } else if res2.Output.MdtrtCertType == "02" {
  26930. 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)
  26931. } else {
  26932. 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)
  26933. }
  26934. var dat2 map[string]interface{}
  26935. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26936. fmt.Println(dat2)
  26937. } else {
  26938. fmt.Println(err)
  26939. }
  26940. userJSONBytes3, _ := json.Marshal(dat2)
  26941. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26942. utils.ErrorLog("解析失败:%v", err)
  26943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26944. return
  26945. }
  26946. saveLog(result2, src_resquest, "2207", "结算")
  26947. } else {
  26948. c.ServeSuccessJSON(map[string]interface{}{
  26949. "failed_code": -10,
  26950. "msg": res2.ErrMsg,
  26951. })
  26952. return
  26953. }
  26954. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26955. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26956. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26957. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26958. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26959. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26960. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26961. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26962. resp, requestErr := http.Get(api)
  26963. if requestErr != nil {
  26964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26965. return
  26966. }
  26967. body, ioErr := ioutil.ReadAll(resp.Body)
  26968. if ioErr != nil {
  26969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26971. return
  26972. }
  26973. var respJSON map[string]interface{}
  26974. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26977. return
  26978. }
  26979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26980. result, _ := json.Marshal(respJSON)
  26981. fmt.Println("log")
  26982. fmt.Println(string(result))
  26983. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26984. utils.ErrorLog("解析失败:%v", err)
  26985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26986. return
  26987. }
  26988. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26989. if reg_type == 11 && his.Insutype == "390" {
  26990. reg_type = 110104
  26991. }
  26992. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26993. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26994. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26995. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26996. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26997. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26998. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26999. resp, requestErr := http.Get(api)
  27000. if requestErr != nil {
  27001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27002. return
  27003. }
  27004. body, ioErr := ioutil.ReadAll(resp.Body)
  27005. if ioErr != nil {
  27006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27008. return
  27009. }
  27010. var respJSON map[string]interface{}
  27011. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27014. return
  27015. }
  27016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27017. result, _ := json.Marshal(respJSON)
  27018. fmt.Println("log")
  27019. fmt.Println(string(result))
  27020. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27021. utils.ErrorLog("解析失败:%v", err)
  27022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27023. return
  27024. }
  27025. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27026. if reg_type == 11 && his.Insutype == "390" {
  27027. reg_type = 110104
  27028. }
  27029. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27030. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27031. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27032. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27033. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27034. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27035. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27036. resp, requestErr := http.Get(api)
  27037. if requestErr != nil {
  27038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27039. return
  27040. }
  27041. body, ioErr := ioutil.ReadAll(resp.Body)
  27042. if ioErr != nil {
  27043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27045. return
  27046. }
  27047. var respJSON map[string]interface{}
  27048. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27051. return
  27052. }
  27053. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27054. result, _ := json.Marshal(respJSON)
  27055. fmt.Println("log")
  27056. fmt.Println(string(result))
  27057. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27058. utils.ErrorLog("解析失败:%v", err)
  27059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27060. return
  27061. }
  27062. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27063. if reg_type == 11 && his.Insutype == "390" {
  27064. reg_type = 110104
  27065. }
  27066. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27067. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27068. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27069. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27070. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27071. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27072. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27073. resp, requestErr := http.Get(api)
  27074. if requestErr != nil {
  27075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27076. return
  27077. }
  27078. body, ioErr := ioutil.ReadAll(resp.Body)
  27079. if ioErr != nil {
  27080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27082. return
  27083. }
  27084. var respJSON map[string]interface{}
  27085. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27088. return
  27089. }
  27090. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27091. result, _ := json.Marshal(respJSON)
  27092. fmt.Println("log")
  27093. fmt.Println(string(result))
  27094. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27095. utils.ErrorLog("解析失败:%v", err)
  27096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27097. return
  27098. }
  27099. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27100. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27101. if result3101.Infcode == "0" {
  27102. if len(result3101.Output.Result) > 0 {
  27103. var errMsgs []string
  27104. for _, item := range result3101.Output.Result {
  27105. errMsgs = append(errMsgs, item.VolaCont)
  27106. }
  27107. c.ServeSuccessJSON(map[string]interface{}{
  27108. "failed_code": -10,
  27109. "msg": errMsgs,
  27110. })
  27111. return
  27112. } else {
  27113. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27114. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27115. bas := strings.Split(psn_info.CardInfo, "|")
  27116. if his.IdCardType == 1 {
  27117. cert_no = bas[2]
  27118. } else if his.IdCardType == 3 {
  27119. cert_no = his.Certno
  27120. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27121. } else if his.IdCardType == 4 {
  27122. cert_no = his.Certno
  27123. psn_info.VerifyNumber = psn_info.VerifyNumber
  27124. }
  27125. //江苏地区国家医保医疗类别
  27126. //职工透析:医疗类别选特殊情况门诊9933
  27127. //居民血透门慢: 医疗类别选门诊慢病1402
  27128. //var med_type string
  27129. //if his.Insutype == "310" {
  27130. // if reg_type == 14 {
  27131. // med_type = "9933"
  27132. // } else if reg_type == 11 {
  27133. // med_type = "11"
  27134. //
  27135. // }
  27136. //} else if his.Insutype == "390" {
  27137. // if reg_type == 14 {
  27138. // med_type = "1402"
  27139. // } else if reg_type == 11 {
  27140. // med_type = "11"
  27141. // }
  27142. //}
  27143. var api string
  27144. if miConfig.MdtrtareaAdmvs == "320921" {
  27145. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27146. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27147. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27148. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27149. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27150. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27151. "&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
  27152. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27153. } else {
  27154. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27155. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27156. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27157. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27158. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27159. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27160. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27161. "&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
  27162. }
  27163. resp, requestErr := http.Get(api)
  27164. if requestErr != nil {
  27165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27166. return
  27167. }
  27168. body, ioErr := ioutil.ReadAll(resp.Body)
  27169. if ioErr != nil {
  27170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27172. return
  27173. }
  27174. var respJSON map[string]interface{}
  27175. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27178. return
  27179. }
  27180. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27181. result, _ := json.Marshal(respJSON)
  27182. fmt.Println("log")
  27183. fmt.Println(string(result))
  27184. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27185. utils.ErrorLog("解析失败:%v", err)
  27186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27187. return
  27188. }
  27189. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27190. res.Output = resSeven10265.Output
  27191. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27192. res.ErrMsg = resSeven10265.ErrMsg
  27193. res.Cainfo = resSeven10265.Cainfo
  27194. res.WarnMsg = resSeven10265.WarnMsg
  27195. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27196. res.Infcode = infocode
  27197. }
  27198. }
  27199. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27200. psn_info, _ := service.GetPsnByPatientId(id)
  27201. var verify_number string
  27202. if psn_info.IdCardType == 4 {
  27203. verify_number = psn_info.VerifyNumber
  27204. } else if psn_info.IdCardType == 1 {
  27205. bas := strings.Split(psn_info.CardInfo, "|")
  27206. cardNumber := bas[2]
  27207. verify_number = cardNumber
  27208. } else {
  27209. verify_number = psn_info.Certno
  27210. psn_info.IdCardType = 2
  27211. }
  27212. var api string
  27213. new_chrg_bchno := chrg_bchno
  27214. if adminUser.CurrentOrgId == 10265 {
  27215. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27216. new_chrg_bchno = "0000"
  27217. }
  27218. }
  27219. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27220. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27221. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27222. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27223. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27224. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27225. "&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
  27226. resp, requestErr := http.Get(api)
  27227. if requestErr != nil {
  27228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27229. return
  27230. }
  27231. body, ioErr := ioutil.ReadAll(resp.Body)
  27232. if ioErr != nil {
  27233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27235. return
  27236. }
  27237. var respJSON map[string]interface{}
  27238. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27241. return
  27242. }
  27243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27244. result, _ := json.Marshal(respJSON)
  27245. fmt.Println("log")
  27246. fmt.Println(string(result))
  27247. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27248. utils.ErrorLog("解析失败:%v", err)
  27249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27250. return
  27251. }
  27252. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27253. res.Output = resSeven10265.Output
  27254. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27255. res.ErrMsg = resSeven10265.ErrMsg
  27256. res.Cainfo = resSeven10265.Cainfo
  27257. res.WarnMsg = resSeven10265.WarnMsg
  27258. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27259. res.Infcode = infocode
  27260. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27261. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27262. var cert_no string
  27263. if his.IdCardType == 1 {
  27264. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27265. } else {
  27266. cert_no = psn_info.VerifyNumber
  27267. }
  27268. 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)
  27269. var dat map[string]interface{}
  27270. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27271. fmt.Println(dat)
  27272. } else {
  27273. fmt.Println(err)
  27274. }
  27275. saveLog(result2, src_resquest, "2207", "结算")
  27276. userJSONBytes, _ := json.Marshal(dat)
  27277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27278. utils.ErrorLog("解析失败:%v", err)
  27279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27280. return
  27281. }
  27282. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27283. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27284. var cert_no string
  27285. var card_sn string
  27286. if his.IdCardType == 1 {
  27287. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27288. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27289. bas := strings.Split(psn_info.CardInfo, "|")
  27290. card_sn = bas[3]
  27291. } else if his.IdCardType == 2 {
  27292. cert_no = his.IdCardNo
  27293. } else {
  27294. cert_no = psn_info.VerifyNumber
  27295. }
  27296. var rf []*ResultFive
  27297. json.Unmarshal([]byte(his.Iinfo), &rf)
  27298. var psn_type string
  27299. for _, item := range rf {
  27300. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27301. psn_type = item.PsnType
  27302. }
  27303. }
  27304. 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)
  27305. var dat map[string]interface{}
  27306. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27307. fmt.Println(dat)
  27308. } else {
  27309. fmt.Println(err)
  27310. }
  27311. saveLog(result2, src_resquest, "2207", "结算")
  27312. userJSONBytes, _ := json.Marshal(dat)
  27313. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27314. utils.ErrorLog("解析失败:%v", err)
  27315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27316. return
  27317. }
  27318. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27319. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27320. var cert_no string
  27321. var card_sn string
  27322. if his.IdCardType == 1 {
  27323. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27324. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27325. //bas := strings.Split(psn_info.CardInfo, "|")
  27326. card_sn = ""
  27327. } else if his.IdCardType == 2 {
  27328. cert_no = his.IdCardNo
  27329. } else {
  27330. cert_no = psn_info.VerifyNumber
  27331. }
  27332. var rf []*ResultFive
  27333. json.Unmarshal([]byte(his.Iinfo), &rf)
  27334. var psn_type string
  27335. for _, item := range rf {
  27336. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27337. psn_type = item.PsnType
  27338. }
  27339. }
  27340. 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)
  27341. var dat map[string]interface{}
  27342. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27343. fmt.Println(dat)
  27344. } else {
  27345. fmt.Println(err)
  27346. }
  27347. saveLog(result2, src_resquest, "2207", "结算")
  27348. userJSONBytes, _ := json.Marshal(dat)
  27349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27350. utils.ErrorLog("解析失败:%v", err)
  27351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27352. return
  27353. }
  27354. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27355. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27356. if his.IdCardType == 1 {
  27357. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27358. bas := strings.Split(psn_info.CardInfo, "|")
  27359. cert_no = bas[2]
  27360. } else if his.IdCardType == 3 {
  27361. cert_no = his.Certno
  27362. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27363. } else if his.IdCardType == 4 {
  27364. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27365. cert_no = psn_info.VerifyNumber
  27366. psn_info.VerifyNumber = psn_info.VerifyNumber
  27367. } else {
  27368. cert_no = his.Certno
  27369. psn_info.VerifyNumber = his.Certno
  27370. }
  27371. var api string
  27372. var med_type string
  27373. if his.Insutype == "390" {
  27374. if reg_type == 992102 {
  27375. med_type = "992102"
  27376. }
  27377. if reg_type == 140104 {
  27378. med_type = "140104"
  27379. }
  27380. if reg_type == 140201 {
  27381. med_type = "140201"
  27382. }
  27383. if reg_type == 14 {
  27384. med_type = "14"
  27385. }
  27386. } else if his.Insutype == "310" {
  27387. if reg_type == 992102 {
  27388. med_type = "992102"
  27389. }
  27390. if reg_type == 140104 {
  27391. med_type = "140104"
  27392. }
  27393. if reg_type == 140201 {
  27394. med_type = "140201"
  27395. }
  27396. if reg_type == 14 {
  27397. med_type = "14"
  27398. }
  27399. }
  27400. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27401. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27402. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27403. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27404. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27405. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27406. "&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
  27407. resp, requestErr := http.Get(api)
  27408. if requestErr != nil {
  27409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27410. return
  27411. }
  27412. body, ioErr := ioutil.ReadAll(resp.Body)
  27413. if ioErr != nil {
  27414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27416. return
  27417. }
  27418. var respJSON map[string]interface{}
  27419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27422. return
  27423. }
  27424. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27425. if status == "0" {
  27426. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27427. c.ServeSuccessJSON(map[string]interface{}{
  27428. "failed_code": -10,
  27429. "msg": err_msg,
  27430. })
  27431. return
  27432. }
  27433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27434. result, _ := json.Marshal(respJSON)
  27435. fmt.Println("log")
  27436. fmt.Println(string(result))
  27437. if err := json.Unmarshal(result, &ahres); err != nil {
  27438. utils.ErrorLog("解析失败:%v", err)
  27439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27440. return
  27441. }
  27442. res.InfRefmsgid = ahres.InfRefmsgid
  27443. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27444. // 创建对应的Time类型
  27445. t := time.UnixMilli(timestamp)
  27446. // 格式化成指定的日期字符串
  27447. str := t.Format("2006-01-02 15:04:05")
  27448. res.Output.Setlinfo.SetlTime = str
  27449. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27450. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27451. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27452. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27453. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27454. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27455. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27456. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27457. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27458. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27459. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27460. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27461. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27462. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27463. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27464. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27465. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27466. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27467. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27468. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27469. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27470. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27471. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27472. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27473. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27474. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27475. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27476. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27477. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27478. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27479. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27480. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27481. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27482. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27483. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27484. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27485. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27486. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27487. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27488. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27489. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27490. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27491. res.Output.Setldetail = ahres.Output.Setldetail
  27492. res.ErrMsg = ahres.ErrMsg
  27493. res.Cainfo = ahres.Cainfo
  27494. res.WarnMsg = ahres.WarnMsg
  27495. res.Infcode = ahres.Infcode
  27496. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27497. res.Output.Setlinfo.ClrType = "11"
  27498. } else {
  27499. res.Output.Setlinfo.ClrType = "9903"
  27500. }
  27501. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27502. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27503. if his.IdCardType == 1 {
  27504. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27505. bas := strings.Split(psn_info.CardInfo, "|")
  27506. cert_no = bas[2]
  27507. } else if his.IdCardType == 3 {
  27508. cert_no = his.Certno
  27509. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27510. } else if his.IdCardType == 4 {
  27511. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27512. cert_no = his.Certno
  27513. psn_info.VerifyNumber = psn_info.VerifyNumber
  27514. } else {
  27515. cert_no = his.Certno
  27516. psn_info.VerifyNumber = his.Certno
  27517. }
  27518. var api string
  27519. var med_type string
  27520. if his.Insutype == "390" {
  27521. if reg_type == 992102 {
  27522. med_type = "992102"
  27523. }
  27524. if reg_type == 140104 {
  27525. med_type = "140104"
  27526. }
  27527. if reg_type == 14 {
  27528. med_type = "14"
  27529. }
  27530. if reg_type == 140201 {
  27531. med_type = "140201"
  27532. }
  27533. } else if his.Insutype == "310" {
  27534. if reg_type == 992102 {
  27535. med_type = "992102"
  27536. }
  27537. if reg_type == 14 {
  27538. med_type = "14"
  27539. }
  27540. if reg_type == 140104 {
  27541. med_type = "140104"
  27542. }
  27543. if reg_type == 140201 {
  27544. med_type = "140201"
  27545. }
  27546. }
  27547. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27548. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27549. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27550. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27551. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27552. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27553. "&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
  27554. resp, requestErr := http.Get(api)
  27555. if requestErr != nil {
  27556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27557. return
  27558. }
  27559. body, ioErr := ioutil.ReadAll(resp.Body)
  27560. if ioErr != nil {
  27561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27563. return
  27564. }
  27565. var respJSON map[string]interface{}
  27566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27569. return
  27570. }
  27571. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27572. if status == "0" {
  27573. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27574. c.ServeSuccessJSON(map[string]interface{}{
  27575. "failed_code": -10,
  27576. "msg": err_msg,
  27577. })
  27578. return
  27579. }
  27580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27581. result, _ := json.Marshal(respJSON)
  27582. fmt.Println("log")
  27583. fmt.Println(string(result))
  27584. if err := json.Unmarshal(result, &ahres); err != nil {
  27585. utils.ErrorLog("解析失败:%v", err)
  27586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27587. return
  27588. }
  27589. res.InfRefmsgid = ahres.InfRefmsgid
  27590. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27591. // 创建对应的Time类型
  27592. t := time.UnixMilli(timestamp)
  27593. // 格式化成指定的日期字符串
  27594. str := t.Format("2006-01-02 15:04:05")
  27595. res.Output.Setlinfo.SetlTime = str
  27596. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27597. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27598. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27599. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27600. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27601. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27602. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27603. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27604. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27605. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27606. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27607. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27608. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27609. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27610. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27611. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27612. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27613. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27614. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27615. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27616. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27617. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27618. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27619. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27620. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27621. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27622. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27623. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27624. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27625. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27626. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27627. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27628. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27629. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27630. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27631. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27632. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27633. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27634. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27635. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27636. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27637. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27638. res.Output.Setldetail = ahres.Output.Setldetail
  27639. res.ErrMsg = ahres.ErrMsg
  27640. res.Cainfo = ahres.Cainfo
  27641. res.WarnMsg = ahres.WarnMsg
  27642. res.Infcode = ahres.Infcode
  27643. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27644. res.Output.Setlinfo.ClrType = "11"
  27645. } else {
  27646. res.Output.Setlinfo.ClrType = "9903"
  27647. }
  27648. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27649. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27650. var cert_no string
  27651. if his.IdCardType == 1 {
  27652. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27653. } else if his.IdCardType == 2 {
  27654. cert_no = his.IdCardNo
  27655. } else {
  27656. cert_no = psn_info.VerifyNumber
  27657. }
  27658. 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, "")
  27659. var dat map[string]interface{}
  27660. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27661. fmt.Println(dat)
  27662. } else {
  27663. fmt.Println(err)
  27664. }
  27665. saveLog(result2, src_resquest, "2207", "结算")
  27666. userJSONBytes, _ := json.Marshal(dat)
  27667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27668. utils.ErrorLog("解析失败:%v", err)
  27669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27670. return
  27671. }
  27672. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27673. psn_info, _ := service.GetPsnByPatientId(id)
  27674. var verify_number string
  27675. if psn_info.IdCardType == 4 {
  27676. verify_number = psn_info.VerifyNumber
  27677. } else if psn_info.IdCardType == 1 {
  27678. bas := strings.Split(psn_info.CardInfo, "|")
  27679. cardNumber := bas[2]
  27680. verify_number = cardNumber
  27681. } else {
  27682. verify_number = psn_info.Certno
  27683. psn_info.IdCardType = 2
  27684. }
  27685. var api string
  27686. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27687. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27688. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27689. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27690. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27691. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27692. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27693. resp, requestErr := http.Get(api)
  27694. if requestErr != nil {
  27695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27696. return
  27697. }
  27698. body, ioErr := ioutil.ReadAll(resp.Body)
  27699. if ioErr != nil {
  27700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27702. return
  27703. }
  27704. var respJSON map[string]interface{}
  27705. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27708. return
  27709. }
  27710. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27711. result, _ := json.Marshal(respJSON)
  27712. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27713. utils.ErrorLog("解析失败:%v", err)
  27714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27715. return
  27716. }
  27717. } else {
  27718. var src_resquest string
  27719. if miConfig.Code == "H15049901371" {
  27720. //赤峰地区国家医保医疗类别
  27721. //职工透析:医疗类别选特殊情况门诊990502
  27722. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27723. var med_type string
  27724. if his.Insutype == "390" {
  27725. if reg_type == 14 {
  27726. med_type = "9933"
  27727. } else if reg_type == 11 {
  27728. med_type = "11"
  27729. }
  27730. } else if his.Insutype == "310" {
  27731. if reg_type == 14 {
  27732. med_type = "990502"
  27733. } else if reg_type == 11 {
  27734. med_type = "11"
  27735. }
  27736. }
  27737. 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)
  27738. } else {
  27739. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" {
  27740. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27741. if result3101.Infcode == 0 {
  27742. if len(result3101.Output.Result) > 0 {
  27743. c.ServeSuccessJSON(map[string]interface{}{
  27744. "failed_code": -10,
  27745. "failed_type": 100,
  27746. "warm_type": 2,
  27747. "msg": result3101.Output.Result,
  27748. })
  27749. return
  27750. }
  27751. } else {
  27752. c.ServeSuccessJSON(map[string]interface{}{
  27753. "failed_code": -10,
  27754. "msg": result3101.ErrMsg,
  27755. })
  27756. return
  27757. }
  27758. }
  27759. if his.IdCardType == 4 {
  27760. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27761. token := psn_info.VerifyNumber
  27762. 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)
  27763. } else {
  27764. 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)
  27765. }
  27766. }
  27767. var dat map[string]interface{}
  27768. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27769. fmt.Println(dat)
  27770. } else {
  27771. fmt.Println(err)
  27772. }
  27773. saveLog(result2, src_resquest, "2207", "结算")
  27774. userJSONBytes, _ := json.Marshal(dat)
  27775. if miConfig.Code == "H15049901371" {
  27776. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27777. utils.ErrorLog("解析失败:%v", err)
  27778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27779. return
  27780. }
  27781. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27782. res.Output = resSeven10265.Output
  27783. res.ErrMsg = resSeven10265.ErrMsg
  27784. res.Cainfo = resSeven10265.Cainfo
  27785. res.WarnMsg = resSeven10265.WarnMsg
  27786. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27787. res.Infcode = infocode
  27788. } else {
  27789. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27790. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27791. utils.ErrorLog("解析失败:%v", err)
  27792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27793. return
  27794. }
  27795. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27796. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27797. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27798. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27799. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27800. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27801. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27802. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27803. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27804. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27805. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27806. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27807. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27808. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27809. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27810. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27811. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27812. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27813. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27814. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27815. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27816. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27817. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27818. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27819. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27820. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27821. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27822. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27823. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27824. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27825. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27826. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27827. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27828. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27829. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27830. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27831. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27832. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27833. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27834. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27835. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27836. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27837. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27838. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27839. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27840. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27841. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27842. res.Cainfo = gzresSeven10265Two.Cainfo
  27843. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27844. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27845. //res.Infcode = infocode
  27846. } else {
  27847. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27848. utils.ErrorLog("解析失败:%v", err)
  27849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27850. return
  27851. }
  27852. }
  27853. }
  27854. }
  27855. if res.Infcode == -1 {
  27856. errlog := &models.HisOrderError{
  27857. UserOrgId: adminUser.CurrentOrgId,
  27858. Ctime: time.Now().Unix(),
  27859. Mtime: time.Now().Unix(),
  27860. Number: chrg_bchno,
  27861. ErrMsg: res.ErrMsg,
  27862. Status: 1,
  27863. PatientId: id,
  27864. RecordTime: recordDateTime,
  27865. Stage: 6,
  27866. }
  27867. service.CreateErrMsgLog(errlog)
  27868. c.ServeSuccessJSON(map[string]interface{}{
  27869. "failed_code": -10,
  27870. "msg": res.ErrMsg,
  27871. })
  27872. return
  27873. } else {
  27874. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27875. order.OrderStatus = 2
  27876. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27877. order.SetlId = res.Output.Setlinfo.SetlID
  27878. order.PsnNo = res.Output.Setlinfo.PsnNo
  27879. order.PsnName = res.Output.Setlinfo.PsnName
  27880. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27881. order.Certno = res.Output.Setlinfo.Certno
  27882. order.Gend = res.Output.Setlinfo.Gend
  27883. order.Naty = res.Output.Setlinfo.Naty
  27884. order.Age = res.Output.Setlinfo.Age
  27885. order.Insutype = res.Output.Setlinfo.Insutype
  27886. order.PsnType = res.Output.Setlinfo.PsnType
  27887. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27888. order.SetlTime = res.Output.Setlinfo.SetlTime
  27889. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27890. order.PayWays = pay_ways
  27891. order.AcctUsedFlag = acct_used_flag
  27892. order.WechatPay = wechat_pay
  27893. order.AliPay = ali_pay
  27894. order.JifenPay = jifen_pay
  27895. order.BandCardPay = band_card_pay
  27896. order.CashPay = cash_pay
  27897. order.OthDesc = oth_desc
  27898. //order.MedType = res.Output.Setlinfo.MedType
  27899. if reg_type == 1112 {
  27900. order.MedType = "1112"
  27901. }
  27902. if reg_type == 1111 {
  27903. order.MedType = "1111"
  27904. }
  27905. order.ClrType = res.Output.Setlinfo.ClrType
  27906. if adminUser.CurrentOrgId == 10480 {
  27907. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27908. order.ClrType = "11"
  27909. } else {
  27910. order.ClrType = "9903"
  27911. }
  27912. }
  27913. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27914. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27915. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27916. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27917. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27918. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27919. order.HifpPay = res.Output.Setlinfo.HifpPay
  27920. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27921. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27922. order.HifesPay = res.Output.Setlinfo.HifesPay
  27923. order.HifobPay = res.Output.Setlinfo.HifobPay
  27924. order.MafPay = res.Output.Setlinfo.MafPay
  27925. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27926. order.OthPay = res.Output.Setlinfo.OthPay
  27927. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27928. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27929. order.AcctPay = res.Output.Setlinfo.AcctPay
  27930. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27931. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27932. order.Balc = res.Output.Setlinfo.Balc
  27933. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27934. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27935. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27936. order.ClrWay = res.Output.Setlinfo.ClrWay
  27937. order.Creator = order.Creator
  27938. order.Modify = roles.AdminUserId
  27939. order.RequestLog = src_resquest
  27940. order.Diagnosis = diagnosis_id
  27941. order.FaPiaoNumber = fapiao_number
  27942. order.FaPiaoCode = fapiao_code
  27943. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27944. detailStr := string(setlDetail)
  27945. order.SetlDetail = detailStr
  27946. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27947. err = service.UpDateOrder(order)
  27948. if err == nil {
  27949. //判断是否使用了押金
  27950. if dec_way == "true" {
  27951. tmpstring := strconv.FormatInt(order.ID, 10)
  27952. //扣押金
  27953. order.Decimal = decimal
  27954. service.UpDateOrder(order)
  27955. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27956. if errmsg != nil {
  27957. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27958. return
  27959. }
  27960. }
  27961. c.ServeSuccessJSON(map[string]interface{}{
  27962. "msg": "结算成功",
  27963. })
  27964. } else {
  27965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27966. return
  27967. }
  27968. }
  27969. }
  27970. }
  27971. }
  27972. // 上传明细-预结算-
  27973. func (c *HisApiController) GetPreUploadInfo() {
  27974. id, _ := c.GetInt64("id")
  27975. record_time := c.GetString("record_time")
  27976. his_patient_id, _ := c.GetInt64("his_patient_id")
  27977. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27978. admin_user_id, _ := c.GetInt64("admin_user_id")
  27979. diagnosis_id := c.GetString("diagnosis")
  27980. sick_type, _ := c.GetInt64("sick_type")
  27981. reg_type, _ := c.GetInt64("p_type")
  27982. begin_time := c.GetString("begin_time")
  27983. acct_used_flag := c.GetString("acct_used_flag")
  27984. id_str := c.GetString("ids")
  27985. ids_arr := strings.Split(id_str, ",")
  27986. timeLayout := "2006-01-02"
  27987. loc, _ := time.LoadLocation("Local")
  27988. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27989. if err != nil {
  27990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27991. return
  27992. }
  27993. recordDateTime := theTime.Unix()
  27994. adminUser := c.GetAdminUserInfo()
  27995. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27996. var config []*models.HisXtDiagnoseConfig
  27997. for _, item := range diagnosis_ids {
  27998. id, _ := strconv.ParseInt(item, 10, 64)
  27999. if id > 0 {
  28000. diagnosisConfig, _ := service.FindDiagnoseById(id)
  28001. config = append(config, &diagnosisConfig)
  28002. }
  28003. }
  28004. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  28005. sickConfig, _ := service.FindSickById(sick_type)
  28006. var prescriptions []*models.HisPrescription
  28007. var start_time int64
  28008. var end_time int64
  28009. var isSuccess bool = true
  28010. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28011. fmt.Println(his_patient_id)
  28012. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28013. timestamp := time.Now().Unix()
  28014. tempTime := time.Unix(timestamp, 0)
  28015. timeFormat := tempTime.Format("20060102150405")
  28016. chrgBchno := rand.Intn(100000) + 10000
  28017. new_chrg_bchno := ""
  28018. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  28019. new_chrg_bchno = chrg_bchno
  28020. if adminUser.CurrentOrgId == 10265 {
  28021. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28022. new_chrg_bchno = "0000"
  28023. }
  28024. }
  28025. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28026. var patientPrescription models.HisPrescriptionInfo
  28027. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28028. if patientPrescription.ID == 0 {
  28029. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  28030. }
  28031. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28032. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28033. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  28034. strconv.FormatInt(his.PatientId, 10)
  28035. var res2406 Result2406
  28036. //安徽单病种处理
  28037. if miConfig.MdtrtareaAdmvs == "341203" && 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. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  28091. data := make(map[string]interface{})
  28092. client := &http.Client{}
  28093. data["psn_no"] = his.PsnNo
  28094. data["mdtrt_id"] = his.Number
  28095. data["operator"] = roles.UserName
  28096. data["cert_no"] = his.IdCardNo
  28097. data["org_name"] = miConfig.OrgName
  28098. data["psn_name"] = his.Name
  28099. data["ipt_otp_no"] = his.IptOtpNo
  28100. data["ipt_psn_sp_flag_type"] = "0901"
  28101. data["ipt_psn_sp_flag"] = "1"
  28102. data["fixmedins_code"] = miConfig.Code
  28103. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28104. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28105. data["url"] = miConfig.Url
  28106. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28107. bytesData, _ := json.Marshal(data)
  28108. var req *http.Request
  28109. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28110. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28111. resp, _ := client.Do(req)
  28112. defer resp.Body.Close()
  28113. body, ioErr := ioutil.ReadAll(resp.Body)
  28114. if ioErr != nil {
  28115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28117. return
  28118. }
  28119. var respJSON map[string]interface{}
  28120. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28123. return
  28124. }
  28125. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28126. if status == "0" {
  28127. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28128. c.ServeSuccessJSON(map[string]interface{}{
  28129. "failed_code": -10,
  28130. "msg": err_msg,
  28131. })
  28132. return
  28133. }
  28134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28135. userJSONBytes, _ := json.Marshal(respJSON)
  28136. fmt.Println("log")
  28137. fmt.Println(string(userJSONBytes))
  28138. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28139. utils.ErrorLog("解析失败:%v", err)
  28140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28141. return
  28142. }
  28143. }
  28144. if res2406.Infcode != 0 {
  28145. adminUser := c.GetAdminUserInfo()
  28146. errlog := &models.HisOrderError{
  28147. UserOrgId: adminUser.CurrentOrgId,
  28148. Ctime: time.Now().Unix(),
  28149. Mtime: time.Now().Unix(),
  28150. ErrMsg: res2406.ErrMsg,
  28151. Status: 1,
  28152. PatientId: id,
  28153. RecordTime: recordDateTime,
  28154. Stage: 3,
  28155. }
  28156. service.CreateErrMsgLog(errlog)
  28157. c.ServeSuccessJSON(map[string]interface{}{
  28158. "failed_code": -10,
  28159. "msg": res2406.ErrMsg,
  28160. })
  28161. return
  28162. }
  28163. var res2 ResultSix
  28164. var res3 GZResultSix
  28165. var resSix10265 ResultSix10265
  28166. //var time_stamp string
  28167. if miConfig.MdtrtareaAdmvs == "421300" {
  28168. data := make(map[string]interface{})
  28169. client := &http.Client{}
  28170. data["psn_no"] = his.PsnNo
  28171. data["mdtrt_id"] = his.Number
  28172. data["department"] = department.Name
  28173. data["org_name"] = miConfig.OrgName
  28174. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28175. data["doctor_id"] = doctor_info.DoctorNumber
  28176. data["doctor_name"] = roles.UserName
  28177. data["fixmedins_code"] = miConfig.Code
  28178. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28179. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28180. data["secret_key"] = miConfig.SecretKey
  28181. data["sick_code"] = sickConfig.CountryCode
  28182. data["sick_name"] = sickConfig.ClassName
  28183. data["begin_time"] = begin_time
  28184. data["dept"] = strconv.FormatInt(department.ID, 10)
  28185. data["config"] = config
  28186. data["opter"] = roles.UserName
  28187. fmt.Println(data)
  28188. bytesData, _ := json.Marshal(data)
  28189. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28190. resp, _ := client.Do(req)
  28191. defer resp.Body.Close()
  28192. body, ioErr := ioutil.ReadAll(resp.Body)
  28193. if ioErr != nil {
  28194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28196. return
  28197. }
  28198. var respJSON map[string]interface{}
  28199. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28202. return
  28203. }
  28204. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28205. userJSONBytes, _ := json.Marshal(respJSON)
  28206. fmt.Println("log")
  28207. fmt.Println(string(userJSONBytes))
  28208. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28209. utils.ErrorLog("解析失败:%v", err)
  28210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28211. return
  28212. }
  28213. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28214. data := make(map[string]interface{})
  28215. client := &http.Client{}
  28216. data["psn_no"] = his.PsnNo
  28217. data["mdtrt_id"] = his.Number
  28218. data["department"] = department.Name
  28219. data["org_name"] = miConfig.OrgName
  28220. if reg_type == 11 && his.Insutype == "390" {
  28221. data["med_type"] = "110104"
  28222. } else {
  28223. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28224. }
  28225. data["doctor_id"] = doctor_info.DoctorNumber
  28226. data["doctor_name"] = roles.UserName
  28227. data["fixmedins_code"] = miConfig.Code
  28228. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28229. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28230. data["secret_key"] = miConfig.SecretKey
  28231. data["sick_code"] = sickConfig.CountryCode
  28232. data["sick_name"] = sickConfig.ClassName
  28233. data["begin_time"] = begin_time
  28234. data["dept"] = strconv.FormatInt(department.ID, 10)
  28235. data["config"] = config
  28236. data["opter"] = roles.UserName
  28237. fmt.Println(data)
  28238. bytesData, _ := json.Marshal(data)
  28239. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28240. resp, _ := client.Do(req)
  28241. defer resp.Body.Close()
  28242. body, ioErr := ioutil.ReadAll(resp.Body)
  28243. if ioErr != nil {
  28244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28246. return
  28247. }
  28248. var respJSON map[string]interface{}
  28249. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28252. return
  28253. }
  28254. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28255. userJSONBytes, _ := json.Marshal(respJSON)
  28256. fmt.Println("log")
  28257. fmt.Println(string(userJSONBytes))
  28258. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28259. utils.ErrorLog("解析失败:%v", err)
  28260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28261. return
  28262. }
  28263. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28264. data := make(map[string]interface{})
  28265. client := &http.Client{}
  28266. data["psn_no"] = his.PsnNo
  28267. data["mdtrt_id"] = his.Number
  28268. data["department"] = department.Name
  28269. data["org_name"] = miConfig.OrgName
  28270. if reg_type == 11 && his.Insutype == "390" {
  28271. data["med_type"] = "110104"
  28272. } else {
  28273. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28274. }
  28275. data["doctor_id"] = doctor_info.DoctorNumber
  28276. data["doctor_name"] = roles.UserName
  28277. data["fixmedins_code"] = miConfig.Code
  28278. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28279. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28280. data["secret_key"] = miConfig.SecretKey
  28281. data["sick_code"] = sickConfig.CountryCode
  28282. data["sick_name"] = sickConfig.ClassName
  28283. data["begin_time"] = begin_time
  28284. data["dept"] = strconv.FormatInt(department.ID, 10)
  28285. data["config"] = config
  28286. data["opter"] = roles.UserName
  28287. fmt.Println(data)
  28288. bytesData, _ := json.Marshal(data)
  28289. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28290. resp, _ := client.Do(req)
  28291. defer resp.Body.Close()
  28292. body, ioErr := ioutil.ReadAll(resp.Body)
  28293. if ioErr != nil {
  28294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28296. return
  28297. }
  28298. var respJSON map[string]interface{}
  28299. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28302. return
  28303. }
  28304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28305. userJSONBytes, _ := json.Marshal(respJSON)
  28306. fmt.Println("log")
  28307. fmt.Println(string(userJSONBytes))
  28308. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28309. utils.ErrorLog("解析失败:%v", err)
  28310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28311. return
  28312. }
  28313. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28314. data := make(map[string]interface{})
  28315. client := &http.Client{}
  28316. data["psn_no"] = his.PsnNo
  28317. data["mdtrt_id"] = his.Number
  28318. data["department"] = department.Name
  28319. data["org_name"] = miConfig.OrgName
  28320. if reg_type == 11 && his.Insutype == "390" {
  28321. data["med_type"] = "110104"
  28322. } else {
  28323. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28324. }
  28325. data["doctor_id"] = doctor_info.DoctorNumber
  28326. data["doctor_name"] = roles.UserName
  28327. data["fixmedins_code"] = miConfig.Code
  28328. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28329. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28330. data["secret_key"] = miConfig.SecretKey
  28331. data["sick_code"] = sickConfig.CountryCode
  28332. data["sick_name"] = sickConfig.ClassName
  28333. data["begin_time"] = begin_time
  28334. data["dept"] = strconv.FormatInt(department.ID, 10)
  28335. data["config"] = config
  28336. data["opter"] = roles.UserName
  28337. fmt.Println(data)
  28338. bytesData, _ := json.Marshal(data)
  28339. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28340. resp, _ := client.Do(req)
  28341. defer resp.Body.Close()
  28342. body, ioErr := ioutil.ReadAll(resp.Body)
  28343. if ioErr != nil {
  28344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28346. return
  28347. }
  28348. var respJSON map[string]interface{}
  28349. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28352. return
  28353. }
  28354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28355. userJSONBytes, _ := json.Marshal(respJSON)
  28356. fmt.Println("log")
  28357. fmt.Println(string(userJSONBytes))
  28358. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28359. utils.ErrorLog("解析失败:%v", err)
  28360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28361. return
  28362. }
  28363. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28364. data := make(map[string]interface{})
  28365. client := &http.Client{}
  28366. data["psn_no"] = his.PsnNo
  28367. data["mdtrt_id"] = his.Number
  28368. data["doctor"] = roles.UserName
  28369. data["department"] = department.Name
  28370. data["org_name"] = miConfig.OrgName
  28371. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28372. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28373. data["fixmedins_code"] = miConfig.Code
  28374. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28375. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28376. data["secret_key"] = miConfig.SecretKey
  28377. data["sick_code"] = sickConfig.CountryCode
  28378. data["sick_name"] = sickConfig.ClassName
  28379. data["begin_time"] = begin_time
  28380. data["dept"] = strconv.FormatInt(department.ID, 10)
  28381. data["config"] = config
  28382. data["url"] = miConfig.Url
  28383. data["ak"] = miConfig.AccessKey
  28384. data["cainfo"] = miConfig.Cainfo
  28385. bytesData, _ := json.Marshal(data)
  28386. var req *http.Request
  28387. if miConfig.MdtrtareaAdmvs == "320921" {
  28388. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28389. } else {
  28390. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28391. }
  28392. resp, _ := client.Do(req)
  28393. defer resp.Body.Close()
  28394. body, ioErr := ioutil.ReadAll(resp.Body)
  28395. if ioErr != nil {
  28396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28398. return
  28399. }
  28400. var respJSON map[string]interface{}
  28401. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28404. return
  28405. }
  28406. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28407. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28408. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28409. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28410. userJSONBytes, _ := json.Marshal(respJSON)
  28411. fmt.Println("log")
  28412. fmt.Println(string(userJSONBytes))
  28413. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28414. utils.ErrorLog("解析失败:%v", err)
  28415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28416. return
  28417. }
  28418. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28419. res2.Output = resSix10265.Output
  28420. res2.ErrMsg = resSix10265.ErrMsg
  28421. res2.Cainfo = resSix10265.Cainfo
  28422. res2.WarnMsg = resSix10265.WarnMsg
  28423. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28424. res2.Infcode = infocode
  28425. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28426. data := make(map[string]interface{})
  28427. client := &http.Client{}
  28428. data["psn_no"] = his.PsnNo
  28429. data["mdtrt_id"] = his.Number
  28430. data["doctor"] = roles.UserName
  28431. data["department"] = department.Name
  28432. data["org_name"] = miConfig.OrgName
  28433. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28434. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28435. data["fixmedins_code"] = miConfig.Code
  28436. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28437. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28438. data["secret_key"] = miConfig.SecretKey
  28439. data["sick_code"] = sickConfig.CountryCode
  28440. data["sick_name"] = sickConfig.ClassName
  28441. data["begin_time"] = begin_time
  28442. data["dept"] = strconv.FormatInt(department.ID, 10)
  28443. data["config"] = config
  28444. //data["url"] = miConfig.Url
  28445. //data["ak"] = miConfig.AccessKey
  28446. data["cainfo"] = miConfig.Cainfo
  28447. fmt.Println(data)
  28448. bytesData, _ := json.Marshal(data)
  28449. var req *http.Request
  28450. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28451. resp, _ := client.Do(req)
  28452. defer resp.Body.Close()
  28453. body, ioErr := ioutil.ReadAll(resp.Body)
  28454. if ioErr != nil {
  28455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28457. return
  28458. }
  28459. var respJSON map[string]interface{}
  28460. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28463. return
  28464. }
  28465. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28466. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28467. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28468. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28469. userJSONBytes, _ := json.Marshal(respJSON)
  28470. fmt.Println("log")
  28471. fmt.Println(string(userJSONBytes))
  28472. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28473. utils.ErrorLog("解析失败:%v", err)
  28474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28475. return
  28476. }
  28477. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28478. res2.Output = resSix10265.Output
  28479. res2.ErrMsg = resSix10265.ErrMsg
  28480. res2.Cainfo = resSix10265.Cainfo
  28481. res2.WarnMsg = resSix10265.WarnMsg
  28482. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28483. res2.Infcode = infocode
  28484. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28485. 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)
  28486. saveLog(result, requestLog, "2203", "上传就诊信息")
  28487. var respJSON2 map[string]interface{}
  28488. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28491. return
  28492. }
  28493. userJSONBytes2, _ := json.Marshal(respJSON2)
  28494. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28495. utils.ErrorLog("解析失败:%v", err)
  28496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28497. return
  28498. }
  28499. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28500. var result string
  28501. var requestLog string
  28502. 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, "")
  28503. saveLog(result, requestLog, "2203", "上传就诊信息")
  28504. var respJSON2 map[string]interface{}
  28505. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28508. return
  28509. }
  28510. userJSONBytes2, _ := json.Marshal(respJSON2)
  28511. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28512. utils.ErrorLog("解析失败:%v", err)
  28513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28514. return
  28515. }
  28516. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28517. var result string
  28518. var requestLog string
  28519. 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, "")
  28520. saveLog(result, requestLog, "2203", "上传就诊信息")
  28521. var respJSON2 map[string]interface{}
  28522. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28525. return
  28526. }
  28527. userJSONBytes2, _ := json.Marshal(respJSON2)
  28528. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28529. utils.ErrorLog("解析失败:%v", err)
  28530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28531. return
  28532. }
  28533. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28534. data := make(map[string]interface{})
  28535. client := &http.Client{}
  28536. data["psn_no"] = his.PsnNo
  28537. data["mdtrt_id"] = his.Number
  28538. data["operator"] = roles.UserName
  28539. data["department"] = department.Name
  28540. data["org_name"] = miConfig.OrgName
  28541. var med_type string
  28542. if his.Insutype == "390" {
  28543. if reg_type == 992102 {
  28544. med_type = "992102"
  28545. data["sick_code"] = "ZDZ940"
  28546. data["sick_name"] = "慢性肾衰竭"
  28547. }
  28548. if reg_type == 140104 {
  28549. med_type = "140104"
  28550. data["sick_code"] = sickConfig.CountryCode
  28551. data["sick_name"] = sickConfig.ClassName
  28552. }
  28553. if reg_type == 14 {
  28554. med_type = "140104"
  28555. data["sick_code"] = sickConfig.CountryCode
  28556. data["sick_name"] = sickConfig.ClassName
  28557. }
  28558. } else if his.Insutype == "310" {
  28559. if reg_type == 992102 {
  28560. med_type = "992102"
  28561. data["sick_code"] = "ZDZ940"
  28562. data["sick_name"] = "慢性肾衰竭"
  28563. }
  28564. if reg_type == 140104 {
  28565. med_type = "140104"
  28566. data["sick_code"] = sickConfig.CountryCode
  28567. data["sick_name"] = sickConfig.ClassName
  28568. }
  28569. if reg_type == 14 {
  28570. med_type = "14"
  28571. data["sick_code"] = sickConfig.CountryCode
  28572. data["sick_name"] = sickConfig.ClassName
  28573. }
  28574. }
  28575. data["med_type"] = med_type
  28576. data["doctor_number"] = doctor_info.DoctorNumber
  28577. data["doctor_name"] = doctor_info.UserName
  28578. data["fixmedins_code"] = miConfig.Code
  28579. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28580. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28581. data["secret_key"] = miConfig.SecretKey
  28582. data["begin_time"] = begin_time
  28583. data["dept"] = strconv.FormatInt(department.ID, 10)
  28584. data["config"] = config
  28585. data["url"] = miConfig.Url
  28586. data["ak"] = miConfig.AccessKey
  28587. data["cainfo"] = miConfig.Cainfo
  28588. bytesData, _ := json.Marshal(data)
  28589. var req *http.Request
  28590. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28591. resp, _ := client.Do(req)
  28592. defer resp.Body.Close()
  28593. body, ioErr := ioutil.ReadAll(resp.Body)
  28594. if ioErr != nil {
  28595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28597. return
  28598. }
  28599. var respJSON map[string]interface{}
  28600. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28603. return
  28604. }
  28605. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28606. if status == "0" {
  28607. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28608. c.ServeSuccessJSON(map[string]interface{}{
  28609. "failed_code": -10,
  28610. "msg": err_msg,
  28611. })
  28612. return
  28613. }
  28614. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28615. userJSONBytes, _ := json.Marshal(respJSON)
  28616. fmt.Println("log")
  28617. fmt.Println(string(userJSONBytes))
  28618. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28619. utils.ErrorLog("解析失败:%v", err)
  28620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28621. return
  28622. }
  28623. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28624. data := make(map[string]interface{})
  28625. client := &http.Client{}
  28626. data["psn_no"] = his.PsnNo
  28627. data["mdtrt_id"] = his.Number
  28628. data["operator"] = roles.UserName
  28629. data["department"] = department.Name
  28630. data["org_name"] = miConfig.OrgName
  28631. var med_type string
  28632. if his.Insutype == "390" {
  28633. if reg_type == 992102 {
  28634. med_type = "992102"
  28635. data["sick_code"] = sickConfig.CountryCode
  28636. data["sick_name"] = sickConfig.ClassName
  28637. }
  28638. if reg_type == 140104 {
  28639. med_type = "140104"
  28640. data["sick_code"] = sickConfig.CountryCode
  28641. data["sick_name"] = sickConfig.ClassName
  28642. }
  28643. if reg_type == 140201 {
  28644. med_type = "140201"
  28645. data["sick_code"] = sickConfig.CountryCode
  28646. data["sick_name"] = sickConfig.ClassName
  28647. }
  28648. if reg_type == 14 {
  28649. med_type = "14"
  28650. data["sick_code"] = sickConfig.CountryCode
  28651. data["sick_name"] = sickConfig.ClassName
  28652. }
  28653. } else if his.Insutype == "310" {
  28654. if reg_type == 992102 {
  28655. med_type = "992102"
  28656. data["sick_code"] = sickConfig.CountryCode
  28657. data["sick_name"] = sickConfig.ClassName
  28658. }
  28659. if reg_type == 140104 {
  28660. med_type = "140104"
  28661. data["sick_code"] = sickConfig.CountryCode
  28662. data["sick_name"] = sickConfig.ClassName
  28663. }
  28664. if reg_type == 140201 {
  28665. med_type = "140201"
  28666. data["sick_code"] = sickConfig.CountryCode
  28667. data["sick_name"] = sickConfig.ClassName
  28668. }
  28669. if reg_type == 14 {
  28670. med_type = "14"
  28671. data["sick_code"] = sickConfig.CountryCode
  28672. data["sick_name"] = sickConfig.ClassName
  28673. }
  28674. }
  28675. data["med_type"] = med_type
  28676. data["doctor_number"] = doctor_info.DoctorNumber
  28677. data["doctor_name"] = doctor_info.UserName
  28678. data["fixmedins_code"] = miConfig.Code
  28679. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28680. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28681. data["secret_key"] = miConfig.SecretKey
  28682. data["begin_time"] = begin_time
  28683. data["dept"] = strconv.FormatInt(department.ID, 10)
  28684. data["config"] = config
  28685. data["url"] = miConfig.Url
  28686. data["ak"] = miConfig.AccessKey
  28687. data["cainfo"] = miConfig.Cainfo
  28688. bytesData, _ := json.Marshal(data)
  28689. var req *http.Request
  28690. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28691. resp, _ := client.Do(req)
  28692. defer resp.Body.Close()
  28693. body, ioErr := ioutil.ReadAll(resp.Body)
  28694. if ioErr != nil {
  28695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28697. return
  28698. }
  28699. var respJSON map[string]interface{}
  28700. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28703. return
  28704. }
  28705. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28706. if status == "0" {
  28707. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28708. c.ServeSuccessJSON(map[string]interface{}{
  28709. "failed_code": -10,
  28710. "msg": err_msg,
  28711. })
  28712. return
  28713. }
  28714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28715. userJSONBytes, _ := json.Marshal(respJSON)
  28716. fmt.Println("log")
  28717. fmt.Println(string(userJSONBytes))
  28718. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28719. utils.ErrorLog("解析失败:%v", err)
  28720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28721. return
  28722. }
  28723. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28724. var result string
  28725. var requestLog string
  28726. 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, "")
  28727. saveLog(result, requestLog, "2203", "上传就诊信息")
  28728. var respJSON2 map[string]interface{}
  28729. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28732. return
  28733. }
  28734. userJSONBytes2, _ := json.Marshal(respJSON2)
  28735. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28736. utils.ErrorLog("解析失败:%v", err)
  28737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28738. return
  28739. }
  28740. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28741. data := make(map[string]interface{})
  28742. client := &http.Client{}
  28743. data["psn_no"] = his.PsnNo
  28744. data["mdtrt_id"] = his.Number
  28745. data["doctor"] = roles.UserName
  28746. data["department"] = department.Name
  28747. data["org_name"] = miConfig.OrgName
  28748. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28749. data["doctor_id"] = doctor_info.DoctorNumber
  28750. data["fixmedins_code"] = miConfig.Code
  28751. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28752. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28753. data["secret_key"] = miConfig.SecretKey
  28754. data["sick_code"] = sickConfig.CountryCode
  28755. data["sick_name"] = sickConfig.ClassName
  28756. data["begin_time"] = begin_time
  28757. data["new_doctor_name"] = doctor_info.UserName
  28758. data["dept"] = strconv.FormatInt(department.ID, 10)
  28759. data["config"] = config
  28760. bytesData, _ := json.Marshal(data)
  28761. var req *http.Request
  28762. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28763. resp, _ := client.Do(req)
  28764. defer resp.Body.Close()
  28765. body, ioErr := ioutil.ReadAll(resp.Body)
  28766. if ioErr != nil {
  28767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28769. return
  28770. }
  28771. var respJSON map[string]interface{}
  28772. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28775. return
  28776. }
  28777. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28778. userJSONBytes, _ := json.Marshal(respJSON)
  28779. fmt.Println("log")
  28780. fmt.Println(string(userJSONBytes))
  28781. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28782. utils.ErrorLog("解析失败:%v", err)
  28783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28784. return
  28785. }
  28786. } else {
  28787. var result string
  28788. var requestLog string
  28789. if miConfig.MdtrtareaAdmvs == "440781" { //
  28790. 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)
  28791. } else {
  28792. if miConfig.Code == "H15049901371" {
  28793. //赤峰地区国家医保医疗类别
  28794. //职工透析:医疗类别选特殊情况门诊990502
  28795. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28796. var med_type string
  28797. if his.Insutype == "390" {
  28798. if reg_type == 14 {
  28799. med_type = "9933"
  28800. } else if reg_type == 11 {
  28801. med_type = "11"
  28802. }
  28803. } else if his.Insutype == "310" {
  28804. if reg_type == 14 {
  28805. med_type = "990502"
  28806. } else if reg_type == 11 {
  28807. med_type = "11"
  28808. }
  28809. }
  28810. 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)
  28811. } else {
  28812. 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)
  28813. }
  28814. saveLog(result, requestLog, "2203", "上传就诊信息")
  28815. var respJSON2 map[string]interface{}
  28816. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28819. return
  28820. }
  28821. userJSONBytes2, _ := json.Marshal(respJSON2)
  28822. if miConfig.Code == "H15049901371" {
  28823. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28824. utils.ErrorLog("解析失败:%v", err)
  28825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28826. return
  28827. }
  28828. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28829. res2.Output = resSix10265.Output
  28830. res2.ErrMsg = resSix10265.ErrMsg
  28831. res2.Cainfo = resSix10265.Cainfo
  28832. res2.WarnMsg = resSix10265.WarnMsg
  28833. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28834. res2.Infcode = infocode
  28835. } else {
  28836. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28837. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28838. utils.ErrorLog("解析失败:%v", err)
  28839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28840. return
  28841. }
  28842. res2.Infcode = res3.Infcode
  28843. } else {
  28844. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28845. utils.ErrorLog("解析失败:%v", err)
  28846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28847. return
  28848. }
  28849. }
  28850. }
  28851. }
  28852. }
  28853. if res2.Infcode == -1 {
  28854. adminUser := c.GetAdminUserInfo()
  28855. errlog := &models.HisOrderError{
  28856. UserOrgId: adminUser.CurrentOrgId,
  28857. Ctime: time.Now().Unix(),
  28858. Mtime: time.Now().Unix(),
  28859. ErrMsg: res2.ErrMsg,
  28860. Status: 1,
  28861. PatientId: id,
  28862. RecordTime: recordDateTime,
  28863. Stage: 3,
  28864. }
  28865. service.CreateErrMsgLog(errlog)
  28866. c.ServeSuccessJSON(map[string]interface{}{
  28867. "failed_code": -10,
  28868. "msg": res2.ErrMsg,
  28869. })
  28870. return
  28871. }
  28872. if res2.Infcode != 0 {
  28873. adminUser := c.GetAdminUserInfo()
  28874. errlog := &models.HisOrderError{
  28875. UserOrgId: adminUser.CurrentOrgId,
  28876. Ctime: time.Now().Unix(),
  28877. Mtime: time.Now().Unix(),
  28878. ErrMsg: res2.ErrMsg,
  28879. Status: 1,
  28880. PatientId: id,
  28881. RecordTime: recordDateTime,
  28882. Stage: 3,
  28883. }
  28884. service.CreateErrMsgLog(errlog)
  28885. c.ServeSuccessJSON(map[string]interface{}{
  28886. "failed_code": -10,
  28887. "msg": res2.ErrMsg,
  28888. })
  28889. return
  28890. } else {
  28891. his.Diagnosis = diagnosis_id
  28892. his.SickType = sickConfig.ID
  28893. his.PType = fmt.Sprintf("%d", reg_type)
  28894. service.UpdateHisPatientThree(&his)
  28895. data := make(map[string]interface{})
  28896. if settle_accounts_type == 1 { //日结
  28897. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28898. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28899. } else {
  28900. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28901. }
  28902. data["pre"] = prescriptions
  28903. } else { //月结
  28904. start_time_str := c.GetString("start_time")
  28905. end_time_str := c.GetString("end_time")
  28906. timeLayout := "2006-01-02"
  28907. loc, _ := time.LoadLocation("Local")
  28908. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28909. if err != nil {
  28910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28911. return
  28912. }
  28913. recordStartTime := theStartTime.Unix()
  28914. start_time = recordStartTime
  28915. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28916. if err != nil {
  28917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28918. return
  28919. }
  28920. recordEndTime := theEndTime.Unix()
  28921. end_time = recordEndTime
  28922. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28923. data["pre"] = prescriptions
  28924. }
  28925. client := &http.Client{}
  28926. data["psn_no"] = his.PsnNo
  28927. data["mdtrt_id"] = his.Number
  28928. data["chrg_bchno"] = new_chrg_bchno
  28929. data["org_name"] = miConfig.OrgName
  28930. data["doctor"] = doctor_info.UserName
  28931. data["doctor_id"] = doctor_info.DoctorNumber
  28932. data["dept"] = department.Name
  28933. data["fixmedins_code"] = miConfig.Code
  28934. data["opter"] = roles.UserName
  28935. data["dept_code"] = department.Number
  28936. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28937. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28938. data["secret_key"] = miConfig.SecretKey
  28939. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28940. data["url"] = miConfig.Url
  28941. data["ak"] = miConfig.AccessKey
  28942. data["new_doctor_name"] = patientPrescription.Doctor
  28943. if his.Insutype == "390" {
  28944. if reg_type == 992102 {
  28945. data["diag_code"] = "ZDZ940"
  28946. }
  28947. if reg_type == 140104 {
  28948. data["diag_code"] = sickConfig.CountryCode
  28949. }
  28950. if reg_type == 140201 {
  28951. data["diag_code"] = sickConfig.CountryCode
  28952. }
  28953. if reg_type == 14 {
  28954. data["diag_code"] = sickConfig.CountryCode
  28955. }
  28956. } else if his.Insutype == "310" {
  28957. if miConfig.MdtrtareaAdmvs == "341203" {
  28958. if reg_type == 992102 {
  28959. data["diag_code"] = "ZDZ940"
  28960. }
  28961. if reg_type != 992102 {
  28962. data["diag_code"] = sickConfig.CountryCode
  28963. }
  28964. } else {
  28965. data["diag_code"] = sickConfig.CountryCode
  28966. }
  28967. }
  28968. data["cainfo"] = miConfig.Cainfo
  28969. data["opter"] = roles.UserName
  28970. var ids []int64
  28971. for _, item := range prescriptions {
  28972. ids = append(ids, item.ID)
  28973. }
  28974. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28975. if config.IsOpen == 1 { //对接了医保,走医保流程
  28976. var res ResultFour
  28977. var resFour10265 ResultFour10265
  28978. if miConfig.MdtrtareaAdmvs == "421300" {
  28979. bytesData, _ := json.Marshal(data)
  28980. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28981. resp, _ := client.Do(req)
  28982. defer resp.Body.Close()
  28983. body, ioErr := ioutil.ReadAll(resp.Body)
  28984. if ioErr != nil {
  28985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28987. return
  28988. }
  28989. var respJSON map[string]interface{}
  28990. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28993. return
  28994. }
  28995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28996. userJSONBytes, _ := json.Marshal(respJSON)
  28997. fmt.Println("log")
  28998. fmt.Println(string(userJSONBytes))
  28999. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29000. utils.ErrorLog("解析失败:%v", err)
  29001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29002. return
  29003. }
  29004. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29005. bytesData, _ := json.Marshal(data)
  29006. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  29007. resp, _ := client.Do(req)
  29008. defer resp.Body.Close()
  29009. body, ioErr := ioutil.ReadAll(resp.Body)
  29010. if ioErr != nil {
  29011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29013. return
  29014. }
  29015. var respJSON map[string]interface{}
  29016. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29019. return
  29020. }
  29021. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29022. userJSONBytes, _ := json.Marshal(respJSON)
  29023. fmt.Println("log")
  29024. fmt.Println(string(userJSONBytes))
  29025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29026. utils.ErrorLog("解析失败:%v", err)
  29027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29028. return
  29029. }
  29030. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29031. bytesData, _ := json.Marshal(data)
  29032. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29033. resp, _ := client.Do(req)
  29034. defer resp.Body.Close()
  29035. body, ioErr := ioutil.ReadAll(resp.Body)
  29036. if ioErr != nil {
  29037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29039. return
  29040. }
  29041. var respJSON map[string]interface{}
  29042. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29045. return
  29046. }
  29047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29048. userJSONBytes, _ := json.Marshal(respJSON)
  29049. fmt.Println("log")
  29050. fmt.Println(string(userJSONBytes))
  29051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29052. utils.ErrorLog("解析失败:%v", err)
  29053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29054. return
  29055. }
  29056. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29057. bytesData, _ := json.Marshal(data)
  29058. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29059. resp, _ := client.Do(req)
  29060. defer resp.Body.Close()
  29061. body, ioErr := ioutil.ReadAll(resp.Body)
  29062. if ioErr != nil {
  29063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29065. return
  29066. }
  29067. var respJSON map[string]interface{}
  29068. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29071. return
  29072. }
  29073. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29074. userJSONBytes, _ := json.Marshal(respJSON)
  29075. fmt.Println("log")
  29076. fmt.Println(string(userJSONBytes))
  29077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29078. utils.ErrorLog("解析失败:%v", err)
  29079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29080. return
  29081. }
  29082. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29083. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29084. if result3101.Infcode == "0" {
  29085. if len(result3101.Output.Result) > 0 {
  29086. var errMsgs []string
  29087. for _, item := range result3101.Output.Result {
  29088. errMsgs = append(errMsgs, item.VolaCont)
  29089. }
  29090. c.ServeSuccessJSON(map[string]interface{}{
  29091. "failed_code": -10,
  29092. "msg": errMsgs,
  29093. })
  29094. return
  29095. } else {
  29096. if miConfig.MdtrtareaAdmvs == "320921" {
  29097. data["doctor_id"] = "D320923012139"
  29098. } else {
  29099. data["doctor_id"] = "D371621008686"
  29100. }
  29101. bytesData, _ := json.Marshal(data)
  29102. var req *http.Request
  29103. if miConfig.MdtrtareaAdmvs == "320921" {
  29104. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29105. } else {
  29106. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29107. }
  29108. resp, _ := client.Do(req)
  29109. defer resp.Body.Close()
  29110. body, ioErr := ioutil.ReadAll(resp.Body)
  29111. if ioErr != nil {
  29112. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29114. return
  29115. }
  29116. var respJSON map[string]interface{}
  29117. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29120. return
  29121. }
  29122. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29123. userJSONBytes, _ := json.Marshal(respJSON)
  29124. fmt.Println("log")
  29125. fmt.Println(string(userJSONBytes))
  29126. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29127. utils.ErrorLog("解析失败:%v", err)
  29128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29129. return
  29130. }
  29131. res.InfRefmsgid = resFour10265.InfRefmsgid
  29132. res.Output = resFour10265.Output
  29133. res.ErrMsg = resFour10265.ErrMsg
  29134. res.Cainfo = resFour10265.Cainfo
  29135. res.WarnMsg = resFour10265.WarnMsg
  29136. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29137. res.Infcode = infocode
  29138. }
  29139. }
  29140. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29141. var pagesize int = 5
  29142. var start int = 1
  29143. var stop int
  29144. var pagecount int
  29145. var curpage int
  29146. data["doctor_id"] = doctor_info.DoctorNumber
  29147. var res2 ResultFour
  29148. //var result res.
  29149. //总页数,向上取整,注意除之前要先转换类型为float64
  29150. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29151. for curpage = 1; curpage <= pagecount; curpage++ {
  29152. if curpage == 1 {
  29153. start = 1
  29154. } else {
  29155. start = (curpage-1)*pagesize + 1
  29156. }
  29157. stop = curpage * pagesize
  29158. if stop > len(prescriptions) {
  29159. stop = len(prescriptions)
  29160. }
  29161. //var requestLog string
  29162. data["pre"] = prescriptions[start-1 : stop]
  29163. fmt.Println(data["pre"])
  29164. bytesData, _ := json.Marshal(data)
  29165. var req *http.Request
  29166. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29167. resp, _ := client.Do(req)
  29168. defer resp.Body.Close()
  29169. body, ioErr := ioutil.ReadAll(resp.Body)
  29170. if ioErr != nil {
  29171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29173. return
  29174. }
  29175. var respJSON map[string]interface{}
  29176. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29179. return
  29180. }
  29181. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29182. userJSONBytes, _ := json.Marshal(respJSON)
  29183. fmt.Println("log")
  29184. fmt.Println(string(userJSONBytes))
  29185. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29186. utils.ErrorLog("解析失败:%v", err)
  29187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29188. return
  29189. }
  29190. res.InfRefmsgid = resFour10265.InfRefmsgid
  29191. res.Output = resFour10265.Output
  29192. res.ErrMsg = resFour10265.ErrMsg
  29193. res.Cainfo = resFour10265.Cainfo
  29194. res.WarnMsg = resFour10265.WarnMsg
  29195. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29196. res.Infcode = infocode
  29197. if infocode == 0 {
  29198. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29199. } else {
  29200. isSuccess = false
  29201. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29202. res.Infcode = -1
  29203. res.ErrMsg = resFour10265.ErrMsg
  29204. errlog := &models.HisOrderError{
  29205. UserOrgId: adminUser.CurrentOrgId,
  29206. Ctime: time.Now().Unix(),
  29207. Mtime: time.Now().Unix(),
  29208. Number: chrg_bchno,
  29209. ErrMsg: "",
  29210. Status: 1,
  29211. PatientId: id,
  29212. RecordTime: recordDateTime,
  29213. Stage: 4,
  29214. }
  29215. service.CreateErrMsgLog(errlog)
  29216. }
  29217. }
  29218. if isSuccess {
  29219. res.Infcode = 0
  29220. res.Output.Result = res2.Output.Result
  29221. } else {
  29222. order := &models.HisOrder{
  29223. UserOrgId: adminUser.CurrentOrgId,
  29224. HisPatientId: his.ID,
  29225. PatientId: his.PatientId,
  29226. SettleAccountsDate: recordDateTime,
  29227. Ctime: time.Now().Unix(),
  29228. Mtime: time.Now().Unix(),
  29229. MdtrtId: his.Number,
  29230. PsnNo: his.PsnNo,
  29231. MedType: strconv.FormatInt(reg_type, 10),
  29232. Status: 1,
  29233. Number: chrg_bchno,
  29234. Infcode: res.Infcode,
  29235. WarnMsg: res.WarnMsg,
  29236. Cainfo: res.Cainfo,
  29237. ErrMsg: res.ErrMsg,
  29238. RespondTime: res.RefmsgTime,
  29239. InfRefmsgid: res.InfRefmsgid,
  29240. OrderStatus: 1,
  29241. IsMedicineInsurance: 1,
  29242. SettleType: settle_accounts_type,
  29243. SettleStartTime: start_time,
  29244. SettleEndTime: end_time,
  29245. Creator: roles.AdminUserId,
  29246. Modify: roles.AdminUserId,
  29247. PType: 2,
  29248. Diagnosis: diagnosis_id,
  29249. }
  29250. err = service.CreateOrder(order)
  29251. if err != nil {
  29252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29253. return
  29254. }
  29255. c.ServeSuccessJSON(map[string]interface{}{
  29256. "failed_code": -10,
  29257. "msg": res2.ErrMsg,
  29258. })
  29259. return
  29260. }
  29261. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29262. 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)
  29263. var dat map[string]interface{}
  29264. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29265. fmt.Println(dat)
  29266. } else {
  29267. fmt.Println(err)
  29268. }
  29269. saveLog(result, request_log, "2204", "上传费用明细")
  29270. userJSONBytes, _ := json.Marshal(dat)
  29271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29272. utils.ErrorLog("解析失败:%v", err)
  29273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29274. return
  29275. }
  29276. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29277. 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, "", "")
  29278. var dat map[string]interface{}
  29279. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29280. fmt.Println(dat)
  29281. } else {
  29282. fmt.Println(err)
  29283. }
  29284. saveLog(result, request_log, "2204", "上传费用明细")
  29285. userJSONBytes, _ := json.Marshal(dat)
  29286. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29287. utils.ErrorLog("解析失败:%v", err)
  29288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29289. return
  29290. }
  29291. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29292. 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, "", "")
  29293. var dat map[string]interface{}
  29294. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29295. fmt.Println(dat)
  29296. } else {
  29297. fmt.Println(err)
  29298. }
  29299. saveLog(result, request_log, "2204", "上传费用明细")
  29300. userJSONBytes, _ := json.Marshal(dat)
  29301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29302. utils.ErrorLog("解析失败:%v", err)
  29303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29304. return
  29305. }
  29306. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29307. bytesData, _ := json.Marshal(data)
  29308. var req *http.Request
  29309. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29310. resp, _ := client.Do(req)
  29311. defer resp.Body.Close()
  29312. body, ioErr := ioutil.ReadAll(resp.Body)
  29313. if ioErr != nil {
  29314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29316. return
  29317. }
  29318. var respJSON map[string]interface{}
  29319. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29322. return
  29323. }
  29324. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29325. if status == "0" {
  29326. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29327. c.ServeSuccessJSON(map[string]interface{}{
  29328. "failed_code": -10,
  29329. "msg": err_msg,
  29330. })
  29331. return
  29332. }
  29333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29334. userJSONBytes, _ := json.Marshal(respJSON)
  29335. fmt.Println("log")
  29336. fmt.Println(string(userJSONBytes))
  29337. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29338. utils.ErrorLog("解析失败:%v", err)
  29339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29340. return
  29341. }
  29342. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29343. bytesData, _ := json.Marshal(data)
  29344. var req *http.Request
  29345. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29346. resp, _ := client.Do(req)
  29347. defer resp.Body.Close()
  29348. body, ioErr := ioutil.ReadAll(resp.Body)
  29349. if ioErr != nil {
  29350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29352. return
  29353. }
  29354. var respJSON map[string]interface{}
  29355. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29358. return
  29359. }
  29360. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29361. if status == "0" {
  29362. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29363. c.ServeSuccessJSON(map[string]interface{}{
  29364. "failed_code": -10,
  29365. "msg": err_msg,
  29366. })
  29367. return
  29368. }
  29369. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29370. userJSONBytes, _ := json.Marshal(respJSON)
  29371. fmt.Println("log")
  29372. fmt.Println(string(userJSONBytes))
  29373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29374. utils.ErrorLog("解析失败:%v", err)
  29375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29376. return
  29377. }
  29378. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29379. 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, "", "")
  29380. var dat map[string]interface{}
  29381. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29382. fmt.Println(dat)
  29383. } else {
  29384. fmt.Println(err)
  29385. }
  29386. saveLog(result, request_log, "2204", "上传费用明细")
  29387. userJSONBytes, _ := json.Marshal(dat)
  29388. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29389. utils.ErrorLog("解析失败:%v", err)
  29390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29391. return
  29392. }
  29393. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29394. bytesData, _ := json.Marshal(data)
  29395. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29396. resp, _ := client.Do(req)
  29397. defer resp.Body.Close()
  29398. body, ioErr := ioutil.ReadAll(resp.Body)
  29399. if ioErr != nil {
  29400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29402. return
  29403. }
  29404. var respJSON map[string]interface{}
  29405. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29408. return
  29409. }
  29410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29411. userJSONBytes, _ := json.Marshal(respJSON)
  29412. fmt.Println("log")
  29413. fmt.Println(string(userJSONBytes))
  29414. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29415. utils.ErrorLog("解析失败:%v", err)
  29416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29417. return
  29418. }
  29419. } else {
  29420. if miConfig.MdtrtareaAdmvs == "441202" {
  29421. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29422. if result3101.Infcode == 0 {
  29423. if len(result3101.Output.Result) > 0 {
  29424. var errMsgs []string
  29425. for _, item := range result3101.Output.Result {
  29426. errMsgs = append(errMsgs, item.VolaCont)
  29427. }
  29428. c.ServeSuccessJSON(map[string]interface{}{
  29429. "failed_code": -10,
  29430. "msg": errMsgs,
  29431. })
  29432. return
  29433. } else {
  29434. 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)
  29435. var dat map[string]interface{}
  29436. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29437. fmt.Println(dat)
  29438. } else {
  29439. fmt.Println(err)
  29440. }
  29441. saveLog(result, request_log, "2204", "上传费用明细")
  29442. userJSONBytes, _ := json.Marshal(dat)
  29443. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29444. utils.ErrorLog("解析失败:%v", err)
  29445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29446. return
  29447. }
  29448. }
  29449. } else {
  29450. c.ServeSuccessJSON(map[string]interface{}{
  29451. "failed_code": -10,
  29452. "msg": result3101.ErrMsg,
  29453. })
  29454. return
  29455. }
  29456. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29457. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29458. if result3101.Infcode == 0 {
  29459. if len(result3101.Output.Result) > 0 {
  29460. var errMsgs []string
  29461. for _, item := range result3101.Output.Result {
  29462. errMsgs = append(errMsgs, item.VolaCont)
  29463. }
  29464. c.ServeSuccessJSON(map[string]interface{}{
  29465. "failed_code": -10,
  29466. "msg": errMsgs,
  29467. })
  29468. return
  29469. } else {
  29470. 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)
  29471. var dat map[string]interface{}
  29472. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29473. fmt.Println(dat)
  29474. } else {
  29475. fmt.Println(err)
  29476. }
  29477. saveLog(result, request_log, "2204", "上传费用明细")
  29478. userJSONBytes, _ := json.Marshal(dat)
  29479. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29480. utils.ErrorLog("解析失败:%v", err)
  29481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29482. return
  29483. }
  29484. }
  29485. } else {
  29486. c.ServeSuccessJSON(map[string]interface{}{
  29487. "failed_code": -10,
  29488. "msg": result3101.ErrMsg,
  29489. })
  29490. return
  29491. }
  29492. } else {
  29493. if miConfig.Code == "H15049901371" {
  29494. 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)
  29495. var dat map[string]interface{}
  29496. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29497. fmt.Println(dat)
  29498. } else {
  29499. fmt.Println(err)
  29500. }
  29501. saveLog(result, request_log, "2204", "上传费用明细")
  29502. userJSONBytes, _ := json.Marshal(dat)
  29503. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29504. utils.ErrorLog("解析失败:%v", err)
  29505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29506. return
  29507. }
  29508. res.InfRefmsgid = resFour10265.InfRefmsgid
  29509. res.Output = resFour10265.Output
  29510. res.ErrMsg = resFour10265.ErrMsg
  29511. res.Cainfo = resFour10265.Cainfo
  29512. res.WarnMsg = resFour10265.WarnMsg
  29513. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29514. res.Infcode = infocode
  29515. } else {
  29516. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" {
  29517. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29518. if result3101.Infcode == 0 {
  29519. if len(result3101.Output.Result) > 0 {
  29520. c.ServeSuccessJSON(map[string]interface{}{
  29521. "failed_code": -10,
  29522. "failed_type": 100,
  29523. "warm_type": 1,
  29524. "msg": result3101.Output.Result,
  29525. })
  29526. return
  29527. } else {
  29528. 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)
  29529. var dat map[string]interface{}
  29530. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29531. fmt.Println(dat)
  29532. } else {
  29533. fmt.Println(err)
  29534. }
  29535. saveLog(result, request_log, "2204", "上传费用明细")
  29536. userJSONBytes, _ := json.Marshal(dat)
  29537. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29538. utils.ErrorLog("解析失败:%v", err)
  29539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29540. return
  29541. }
  29542. }
  29543. } else {
  29544. c.ServeSuccessJSON(map[string]interface{}{
  29545. "failed_code": -10,
  29546. "msg": result3101.ErrMsg,
  29547. })
  29548. return
  29549. }
  29550. } else {
  29551. 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)
  29552. var dat map[string]interface{}
  29553. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29554. fmt.Println(dat)
  29555. } else {
  29556. fmt.Println(err)
  29557. }
  29558. saveLog(result, request_log, "2204", "上传费用明细")
  29559. userJSONBytes, _ := json.Marshal(dat)
  29560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29561. utils.ErrorLog("解析失败:%v", err)
  29562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29563. return
  29564. }
  29565. }
  29566. }
  29567. }
  29568. }
  29569. var total_two float64
  29570. if res.Infcode == -1 {
  29571. errlog := &models.HisOrderError{
  29572. UserOrgId: adminUser.CurrentOrgId,
  29573. Ctime: time.Now().Unix(),
  29574. Mtime: time.Now().Unix(),
  29575. Number: chrg_bchno,
  29576. ErrMsg: res.ErrMsg,
  29577. Status: 1,
  29578. PatientId: id,
  29579. RecordTime: recordDateTime,
  29580. Stage: 4,
  29581. }
  29582. service.CreateErrMsgLog(errlog)
  29583. c.ServeSuccessJSON(map[string]interface{}{
  29584. "failed_code": -10,
  29585. "msg": res.ErrMsg,
  29586. })
  29587. return
  29588. }
  29589. if res.Infcode == 0 {
  29590. order := &models.HisOrder{
  29591. UserOrgId: adminUser.CurrentOrgId,
  29592. HisPatientId: his.ID,
  29593. PatientId: his.PatientId,
  29594. SettleAccountsDate: recordDateTime,
  29595. Ctime: time.Now().Unix(),
  29596. Mtime: time.Now().Unix(),
  29597. MdtrtId: his.Number,
  29598. PsnNo: his.PsnNo,
  29599. MedType: strconv.FormatInt(reg_type, 10),
  29600. Status: 1,
  29601. Number: chrg_bchno,
  29602. Infcode: res.Infcode,
  29603. WarnMsg: res.WarnMsg,
  29604. Cainfo: res.Cainfo,
  29605. ErrMsg: res.ErrMsg,
  29606. RespondTime: res.RefmsgTime,
  29607. InfRefmsgid: res.InfRefmsgid,
  29608. OrderStatus: 1,
  29609. IsMedicineInsurance: 1,
  29610. SettleType: settle_accounts_type,
  29611. SettleStartTime: start_time,
  29612. SettleEndTime: end_time,
  29613. Creator: roles.AdminUserId,
  29614. Modify: roles.AdminUserId,
  29615. PType: 2,
  29616. Diagnosis: diagnosis_id,
  29617. }
  29618. err = service.CreateOrder(order)
  29619. if err != nil {
  29620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29621. return
  29622. }
  29623. for _, item := range res.Output.Result {
  29624. temp := strings.Split(item.FeedetlSn, "-")
  29625. var advice_id int64 = 0
  29626. var project_id int64 = 0
  29627. var types int64 = 0
  29628. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29629. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29630. if temp[1] == "1" {
  29631. advice_id = id
  29632. project_id = 0
  29633. } else if temp[1] == "2" {
  29634. advice_id = 0
  29635. project_id = id
  29636. }
  29637. total_two = total_two + item.DetItemFeeSumamt
  29638. info := &models.HisOrderInfo{
  29639. OrderNumber: order.Number,
  29640. FeedetlSn: item.FeedetlSn,
  29641. UploadDate: time.Now().Unix(),
  29642. AdviceId: advice_id,
  29643. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29644. Cnt: item.Cnt,
  29645. Pric: float64(item.Pric),
  29646. PatientId: his.PatientId,
  29647. PricUplmtAmt: item.PricUplmtAmt,
  29648. SelfpayProp: item.SelfpayProp,
  29649. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29650. OverlmtAmt: item.OverlmtAmt,
  29651. PreselfpayAmt: item.PreselfpayAmt,
  29652. BasMednFlag: item.BasMednFlag,
  29653. MedChrgitmType: item.MedChrgitmType,
  29654. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29655. Status: 1,
  29656. Memo: item.Memo,
  29657. Mtime: time.Now().Unix(),
  29658. InscpScpAmt: item.InscpScpAmt,
  29659. DrtReimFlag: item.DrtReimFlag,
  29660. Ctime: time.Now().Unix(),
  29661. ListSpItemFlag: item.ListSpItemFlag,
  29662. ChldMedcFlag: item.ChldMedcFlag,
  29663. LmtUsedFlag: item.LmtUsedFlag,
  29664. ChrgitmLv: item.ChrgitmLv,
  29665. UserOrgId: adminUser.CurrentOrgId,
  29666. HisPatientId: his.ID,
  29667. OrderId: order.ID,
  29668. ProjectId: project_id,
  29669. Type: types,
  29670. }
  29671. service.CreateOrderInfo(info)
  29672. }
  29673. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29674. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29675. var total float64
  29676. for _, item := range prescriptions {
  29677. if item.Type == 1 { //药品
  29678. for _, subItem := range item.HisDoctorAdviceInfo {
  29679. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29680. total_one := price * subItem.PrescribingNumber
  29681. fmt.Println("subItem")
  29682. fmt.Println(subItem.Price)
  29683. fmt.Println("price")
  29684. fmt.Println(price)
  29685. fmt.Println("total_one")
  29686. fmt.Println(total_one)
  29687. total = total + total_one
  29688. fmt.Println(total)
  29689. }
  29690. }
  29691. if item.Type == 2 { //项目
  29692. for _, subItem := range item.HisPrescriptionProject {
  29693. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29694. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29695. total_one := price * cnt
  29696. total = total + total_one
  29697. }
  29698. }
  29699. }
  29700. allTotal := fmt.Sprintf("%.2f", total)
  29701. if res.Infcode == 0 {
  29702. var rf []*ResultFive
  29703. json.Unmarshal([]byte(his.Iinfo), &rf)
  29704. chrg_bchno := chrg_bchno
  29705. cert_no := his.Certno
  29706. var insutypes []string
  29707. var insutype string
  29708. var is390 int = 0
  29709. var is310 int = 0
  29710. for _, item := range rf {
  29711. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29712. insutypes = append(insutypes, item.Insutype)
  29713. }
  29714. }
  29715. if len(insutypes) == 1 {
  29716. insutype = insutypes[0]
  29717. } else {
  29718. for _, i := range insutypes {
  29719. if i == "390" {
  29720. is390 = 1
  29721. }
  29722. if i == "310" {
  29723. is310 = 1
  29724. }
  29725. }
  29726. }
  29727. if is390 == 1 {
  29728. insutype = "390"
  29729. }
  29730. if is310 == 1 {
  29731. insutype = "310"
  29732. }
  29733. if len(insutypes) == 0 {
  29734. insutype = "390"
  29735. }
  29736. if len(insutypes) == 2 {
  29737. insutype = strconv.FormatInt(his.SocialType, 10)
  29738. }
  29739. //insutype = "390"
  29740. if his.IdCardType == 1 {
  29741. cert_no = his.MedicalInsuranceNumber
  29742. } else {
  29743. cert_no = his.Certno
  29744. }
  29745. var res ResultSeven
  29746. var ahres ResultSevenAH
  29747. var resSeven10265 ResultSeven10265
  29748. var resSeven10265Two ResultSeven10265Two
  29749. var gzresSeven10265Two GZResultSeven10265Two
  29750. if miConfig.MdtrtareaAdmvs == "421300" {
  29751. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29752. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29753. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29754. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29755. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29756. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29757. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29758. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29759. resp, requestErr := http.Get(api)
  29760. if requestErr != nil {
  29761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29762. return
  29763. }
  29764. body, ioErr := ioutil.ReadAll(resp.Body)
  29765. if ioErr != nil {
  29766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29768. return
  29769. }
  29770. var respJSON map[string]interface{}
  29771. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29774. return
  29775. }
  29776. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29777. result, _ := json.Marshal(respJSON)
  29778. fmt.Println("log")
  29779. fmt.Println(string(result))
  29780. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29781. utils.ErrorLog("解析失败:%v", err)
  29782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29783. return
  29784. }
  29785. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29786. if reg_type == 11 && his.Insutype == "390" {
  29787. reg_type = 110104
  29788. }
  29789. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29790. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29791. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29792. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29793. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29794. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29795. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29796. resp, requestErr := http.Get(api)
  29797. if requestErr != nil {
  29798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29799. return
  29800. }
  29801. body, ioErr := ioutil.ReadAll(resp.Body)
  29802. if ioErr != nil {
  29803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29805. return
  29806. }
  29807. var respJSON map[string]interface{}
  29808. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29811. return
  29812. }
  29813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29814. result, _ := json.Marshal(respJSON)
  29815. fmt.Println("log")
  29816. fmt.Println(string(result))
  29817. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29818. utils.ErrorLog("解析失败:%v", err)
  29819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29820. return
  29821. }
  29822. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29823. if reg_type == 11 && his.Insutype == "390" {
  29824. reg_type = 110104
  29825. }
  29826. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29827. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29828. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29829. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29830. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29831. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29832. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29833. resp, requestErr := http.Get(api)
  29834. if requestErr != nil {
  29835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29836. return
  29837. }
  29838. body, ioErr := ioutil.ReadAll(resp.Body)
  29839. if ioErr != nil {
  29840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29842. return
  29843. }
  29844. var respJSON map[string]interface{}
  29845. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29848. return
  29849. }
  29850. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29851. result, _ := json.Marshal(respJSON)
  29852. fmt.Println("log")
  29853. fmt.Println(string(result))
  29854. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29855. utils.ErrorLog("解析失败:%v", err)
  29856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29857. return
  29858. }
  29859. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29860. if reg_type == 11 && his.Insutype == "390" {
  29861. reg_type = 110104
  29862. }
  29863. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29864. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29865. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29866. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29867. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29868. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29869. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29870. resp, requestErr := http.Get(api)
  29871. if requestErr != nil {
  29872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29873. return
  29874. }
  29875. body, ioErr := ioutil.ReadAll(resp.Body)
  29876. if ioErr != nil {
  29877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29879. return
  29880. }
  29881. var respJSON map[string]interface{}
  29882. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29885. return
  29886. }
  29887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29888. result, _ := json.Marshal(respJSON)
  29889. fmt.Println("log")
  29890. fmt.Println(string(result))
  29891. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29892. utils.ErrorLog("解析失败:%v", err)
  29893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29894. return
  29895. }
  29896. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29897. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29898. if result3101.Infcode == "0" {
  29899. if len(result3101.Output.Result) > 0 {
  29900. var errMsgs []string
  29901. for _, item := range result3101.Output.Result {
  29902. errMsgs = append(errMsgs, item.VolaCont)
  29903. }
  29904. c.ServeSuccessJSON(map[string]interface{}{
  29905. "failed_code": -10,
  29906. "msg": errMsgs,
  29907. })
  29908. return
  29909. } else {
  29910. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29911. if his.IdCardType != 4 {
  29912. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29913. bas := strings.Split(psn_info.CardInfo, "|")
  29914. if his.IdCardType == 1 {
  29915. cert_no = bas[2]
  29916. } else {
  29917. cert_no = bas[1]
  29918. }
  29919. } else {
  29920. cert_no = his.Certno
  29921. }
  29922. //江苏地区国家医保医疗类别
  29923. //职工透析:医疗类别选特殊情况门诊9933
  29924. //居民血透门慢: 医疗类别选门诊慢病1402
  29925. //var med_type string
  29926. //if his.Insutype == "310" {
  29927. // if reg_type == 14 {
  29928. // med_type = "9933"
  29929. // } else if reg_type == 11 {
  29930. // med_type = "11"
  29931. //
  29932. // }
  29933. //} else if his.Insutype == "390" {
  29934. // if reg_type == 14 {
  29935. // med_type = "1402"
  29936. // } else if reg_type == 11 {
  29937. // med_type = "11"
  29938. // }
  29939. //}
  29940. var api string
  29941. if miConfig.MdtrtareaAdmvs == "320921" {
  29942. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29943. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29944. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29945. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29946. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29947. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29948. "&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
  29949. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29950. } else {
  29951. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29952. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29953. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29954. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29955. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29956. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29957. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29958. "&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
  29959. }
  29960. resp, requestErr := http.Get(api)
  29961. if requestErr != nil {
  29962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29963. return
  29964. }
  29965. body, ioErr := ioutil.ReadAll(resp.Body)
  29966. if ioErr != nil {
  29967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29969. return
  29970. }
  29971. var respJSON map[string]interface{}
  29972. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29975. return
  29976. }
  29977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29978. result, _ := json.Marshal(respJSON)
  29979. fmt.Println("log")
  29980. fmt.Println(string(result))
  29981. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29982. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29983. utils.ErrorLog("解析失败:%v", err)
  29984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29985. return
  29986. }
  29987. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29988. res.Output = resSeven10265.Output
  29989. res.ErrMsg = resSeven10265.ErrMsg
  29990. res.Cainfo = resSeven10265.Cainfo
  29991. res.WarnMsg = resSeven10265.WarnMsg
  29992. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29993. res.Infcode = infocode
  29994. } else {
  29995. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29996. utils.ErrorLog("解析失败:%v", err)
  29997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29998. return
  29999. }
  30000. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  30001. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  30002. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  30003. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  30004. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30005. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  30006. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  30007. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  30008. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  30009. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  30010. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  30011. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30012. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  30013. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  30014. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30015. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30016. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  30017. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  30018. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  30019. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  30020. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  30021. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30022. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  30023. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  30024. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  30025. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  30026. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  30027. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  30028. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  30029. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  30030. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30031. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  30032. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  30033. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  30034. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30035. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30036. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30037. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30038. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  30039. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30040. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  30041. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  30042. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  30043. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  30044. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  30045. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  30046. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  30047. res.ErrMsg = resSeven10265Two.ErrMsg
  30048. res.Cainfo = resSeven10265Two.Cainfo
  30049. res.WarnMsg = resSeven10265Two.WarnMsg
  30050. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30051. res.Infcode = infocode
  30052. }
  30053. }
  30054. }
  30055. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30056. psn_info, _ := service.GetPsnByPatientId(id)
  30057. var verify_number string
  30058. if psn_info.IdCardType == 4 {
  30059. verify_number = psn_info.VerifyNumber
  30060. } else if psn_info.IdCardType == 1 {
  30061. bas := strings.Split(psn_info.CardInfo, "|")
  30062. cardNumber := bas[2]
  30063. verify_number = cardNumber
  30064. } else {
  30065. psn_info.IdCardType = 2
  30066. verify_number = psn_info.Certno
  30067. }
  30068. var api string
  30069. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30070. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  30071. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30072. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30073. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  30074. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30075. "&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
  30076. resp, requestErr := http.Get(api)
  30077. if requestErr != nil {
  30078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30079. return
  30080. }
  30081. body, ioErr := ioutil.ReadAll(resp.Body)
  30082. if ioErr != nil {
  30083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30085. return
  30086. }
  30087. var respJSON map[string]interface{}
  30088. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30091. return
  30092. }
  30093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30094. result, _ := json.Marshal(respJSON)
  30095. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30096. utils.ErrorLog("解析失败:%v", err)
  30097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30098. return
  30099. }
  30100. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30101. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  30102. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  30103. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30104. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  30105. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  30106. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  30107. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  30108. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  30109. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  30110. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  30111. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  30112. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  30113. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30114. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  30115. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  30116. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  30117. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  30118. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  30119. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  30120. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30121. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  30122. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  30123. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  30124. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  30125. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  30126. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  30127. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  30128. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  30129. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  30130. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  30131. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  30132. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  30133. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  30134. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30135. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  30136. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  30137. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  30138. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  30139. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  30140. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  30141. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30142. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30143. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30144. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30145. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30146. res.ErrMsg = resSeven10265.ErrMsg
  30147. res.Cainfo = resSeven10265.Cainfo
  30148. res.WarnMsg = resSeven10265.WarnMsg
  30149. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30150. res.Infcode = infocode
  30151. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30152. acct_used_flag := "1"
  30153. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30154. var result string
  30155. var request_log string
  30156. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30157. 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)
  30158. } else {
  30159. 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)
  30160. }
  30161. var dat map[string]interface{}
  30162. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30163. fmt.Println(dat)
  30164. } else {
  30165. fmt.Println(err)
  30166. }
  30167. saveLog(result, request_log, "2206", "预结算")
  30168. userJSONBytes, _ := json.Marshal(dat)
  30169. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30170. utils.ErrorLog("解析失败:%v", err)
  30171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30172. return
  30173. }
  30174. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30175. var result string
  30176. var request_log string
  30177. if his.IdCardType == 2 {
  30178. insutype = strconv.FormatInt(his.SocialType, 10)
  30179. 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, "")
  30180. } else if his.IdCardType == 1 {
  30181. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30182. bas := strings.Split(psn_info.CardInfo, "|")
  30183. basNumber := bas[2]
  30184. card_sn := bas[3]
  30185. var rf []*ResultFive
  30186. json.Unmarshal([]byte(his.Iinfo), &rf)
  30187. var psn_type string
  30188. for _, item := range rf {
  30189. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30190. psn_type = item.PsnType
  30191. }
  30192. }
  30193. insutype = strconv.FormatInt(his.SocialType, 10)
  30194. 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)
  30195. } else {
  30196. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30197. //bas := strings.Split(psn_info.CardInfo, "|")
  30198. //basNumber := bas[2]
  30199. //card_sn := bas[3]
  30200. var rf []*ResultFive
  30201. json.Unmarshal([]byte(his.Iinfo), &rf)
  30202. var psn_type string
  30203. for _, item := range rf {
  30204. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30205. psn_type = item.PsnType
  30206. }
  30207. }
  30208. insutype = strconv.FormatInt(his.SocialType, 10)
  30209. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30210. 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)
  30211. }
  30212. var dat map[string]interface{}
  30213. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30214. fmt.Println(dat)
  30215. } else {
  30216. fmt.Println(err)
  30217. }
  30218. saveLog(result, request_log, "2206", "预结算")
  30219. userJSONBytes, _ := json.Marshal(dat)
  30220. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30221. utils.ErrorLog("解析失败:%v", err)
  30222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30223. return
  30224. }
  30225. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30226. var result string
  30227. var request_log string
  30228. if his.IdCardType == 2 {
  30229. insutype = strconv.FormatInt(his.SocialType, 10)
  30230. 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, "")
  30231. } else if his.IdCardType == 1 {
  30232. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30233. bas := strings.Split(psn_info.CardInfo, "|")
  30234. basNumber := bas[0]
  30235. card_sn := ""
  30236. var rf []*ResultFive
  30237. json.Unmarshal([]byte(his.Iinfo), &rf)
  30238. var psn_type string
  30239. for _, item := range rf {
  30240. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30241. psn_type = item.PsnType
  30242. }
  30243. }
  30244. insutype = strconv.FormatInt(his.SocialType, 10)
  30245. 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)
  30246. } else {
  30247. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30248. //bas := strings.Split(psn_info.CardInfo, "|")
  30249. //basNumber := bas[2]
  30250. //card_sn := bas[3]
  30251. var rf []*ResultFive
  30252. json.Unmarshal([]byte(his.Iinfo), &rf)
  30253. var psn_type string
  30254. for _, item := range rf {
  30255. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30256. psn_type = item.PsnType
  30257. }
  30258. }
  30259. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30260. 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)
  30261. }
  30262. var dat map[string]interface{}
  30263. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30264. fmt.Println(dat)
  30265. } else {
  30266. fmt.Println(err)
  30267. }
  30268. saveLog(result, request_log, "2206", "预结算")
  30269. userJSONBytes, _ := json.Marshal(dat)
  30270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30271. utils.ErrorLog("解析失败:%v", err)
  30272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30273. return
  30274. }
  30275. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30276. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30277. if his.IdCardType == 4 {
  30278. psn_info.VerifyNumber = psn_info.VerifyNumber
  30279. cert_no = psn_info.VerifyNumber
  30280. } else if his.IdCardType == 2 {
  30281. cert_no = psn_info.Certno
  30282. psn_info.VerifyNumber = psn_info.Certno
  30283. } else {
  30284. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30285. bas := strings.Split(psn_info.CardInfo, "|")
  30286. if his.IdCardType == 1 {
  30287. cert_no = bas[2]
  30288. } else {
  30289. cert_no = bas[1]
  30290. }
  30291. }
  30292. var api string
  30293. var med_type string
  30294. if his.Insutype == "390" {
  30295. if reg_type == 992102 {
  30296. med_type = "992102"
  30297. }
  30298. if reg_type == 140104 {
  30299. med_type = "140104"
  30300. }
  30301. if reg_type == 140201 {
  30302. med_type = "140201"
  30303. }
  30304. if reg_type == 14 {
  30305. med_type = "140104"
  30306. }
  30307. } else if his.Insutype == "310" {
  30308. if reg_type == 992102 {
  30309. med_type = "992102"
  30310. }
  30311. if reg_type == 140104 {
  30312. med_type = "140104"
  30313. }
  30314. if reg_type == 140201 {
  30315. med_type = "140201"
  30316. }
  30317. if reg_type == 14 {
  30318. med_type = "140104"
  30319. }
  30320. }
  30321. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30322. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30323. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30324. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30325. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30326. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30327. "&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
  30328. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30329. resp, requestErr := http.Get(api)
  30330. if requestErr != nil {
  30331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30332. return
  30333. }
  30334. body, ioErr := ioutil.ReadAll(resp.Body)
  30335. if ioErr != nil {
  30336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30338. return
  30339. }
  30340. var respJSON map[string]interface{}
  30341. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30344. return
  30345. }
  30346. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30347. if status == "0" {
  30348. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30349. c.ServeSuccessJSON(map[string]interface{}{
  30350. "failed_code": -10,
  30351. "msg": err_msg,
  30352. })
  30353. return
  30354. }
  30355. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30356. result, _ := json.Marshal(respJSON)
  30357. fmt.Println("log")
  30358. fmt.Println(string(result))
  30359. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30360. utils.ErrorLog("解析失败:%v", err)
  30361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30362. return
  30363. }
  30364. res.InfRefmsgid = ahres.InfRefmsgid
  30365. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30366. // 创建对应的Time类型
  30367. t := time.UnixMilli(timestamp)
  30368. // 格式化成指定的日期字符串
  30369. str := t.Format("2006-01-02 15:04:05")
  30370. res.Output.Setlinfo.SetlTime = str
  30371. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30372. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30373. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30374. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30375. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30376. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30377. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30378. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30379. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30380. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30381. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30382. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30383. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30384. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30385. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30386. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30387. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30388. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30389. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30390. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30391. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30392. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30393. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30394. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30395. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30396. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30397. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30398. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30399. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30400. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30401. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30402. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30403. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30404. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30405. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30406. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30407. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30408. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30409. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30410. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30411. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30412. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30413. //res.Output.Setldetail = ahres.Output.Setldetail
  30414. res.ErrMsg = ahres.ErrMsg
  30415. res.Cainfo = ahres.Cainfo
  30416. res.WarnMsg = ahres.WarnMsg
  30417. res.Infcode = ahres.Infcode
  30418. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30419. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30420. if his.IdCardType == 4 {
  30421. psn_info.VerifyNumber = psn_info.VerifyNumber
  30422. cert_no = psn_info.Certno
  30423. } else if his.IdCardType == 2 {
  30424. cert_no = psn_info.Certno
  30425. psn_info.VerifyNumber = psn_info.Certno
  30426. } else {
  30427. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30428. bas := strings.Split(psn_info.CardInfo, "|")
  30429. if his.IdCardType == 1 {
  30430. cert_no = bas[2]
  30431. } else {
  30432. cert_no = bas[1]
  30433. }
  30434. }
  30435. var api string
  30436. var med_type string
  30437. if his.Insutype == "390" {
  30438. if reg_type == 992102 {
  30439. med_type = "992102"
  30440. }
  30441. if reg_type == 140104 {
  30442. med_type = "140104"
  30443. }
  30444. if reg_type == 140201 {
  30445. med_type = "140201"
  30446. }
  30447. if reg_type == 14 {
  30448. med_type = "14"
  30449. }
  30450. } else if his.Insutype == "310" {
  30451. if reg_type == 992102 {
  30452. med_type = "992102"
  30453. }
  30454. if reg_type == 140104 {
  30455. med_type = "140104"
  30456. }
  30457. if reg_type == 140201 {
  30458. med_type = "140201"
  30459. }
  30460. if reg_type == 14 {
  30461. med_type = "14"
  30462. }
  30463. }
  30464. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30465. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30466. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30467. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30468. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30469. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30470. "&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
  30471. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30472. resp, requestErr := http.Get(api)
  30473. if requestErr != nil {
  30474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30475. return
  30476. }
  30477. body, ioErr := ioutil.ReadAll(resp.Body)
  30478. if ioErr != nil {
  30479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30481. return
  30482. }
  30483. var respJSON map[string]interface{}
  30484. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30487. return
  30488. }
  30489. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30490. if status == "0" {
  30491. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30492. c.ServeSuccessJSON(map[string]interface{}{
  30493. "failed_code": -10,
  30494. "msg": err_msg,
  30495. })
  30496. return
  30497. }
  30498. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30499. result, _ := json.Marshal(respJSON)
  30500. fmt.Println("log")
  30501. fmt.Println(string(result))
  30502. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30503. utils.ErrorLog("解析失败:%v", err)
  30504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30505. return
  30506. }
  30507. res.InfRefmsgid = ahres.InfRefmsgid
  30508. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30509. // 创建对应的Time类型
  30510. t := time.UnixMilli(timestamp)
  30511. // 格式化成指定的日期字符串
  30512. str := t.Format("2006-01-02 15:04:05")
  30513. res.Output.Setlinfo.SetlTime = str
  30514. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30515. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30516. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30517. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30518. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30519. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30520. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30521. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30522. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30523. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30524. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30525. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30526. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30527. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30528. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30529. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30530. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30531. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30532. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30533. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30534. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30535. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30536. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30537. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30538. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30539. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30540. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30541. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30542. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30543. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30544. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30545. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30546. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30547. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30548. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30549. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30550. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30551. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30552. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30553. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30554. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30555. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30556. //res.Output.Setldetail = ahres.Output.Setldetail
  30557. res.ErrMsg = ahres.ErrMsg
  30558. res.Cainfo = ahres.Cainfo
  30559. res.WarnMsg = ahres.WarnMsg
  30560. res.Infcode = ahres.Infcode
  30561. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30562. var result string
  30563. var request_log string
  30564. if his.IdCardType == 2 {
  30565. 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")
  30566. } else if his.IdCardType == 1 {
  30567. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30568. bas := strings.Split(psn_info.CardInfo, "|")
  30569. basNumber := bas[2]
  30570. card_sn := bas[3]
  30571. 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")
  30572. } else {
  30573. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30574. 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")
  30575. }
  30576. var dat map[string]interface{}
  30577. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30578. fmt.Println(dat)
  30579. } else {
  30580. fmt.Println(err)
  30581. }
  30582. saveLog(result, request_log, "2206", "预结算")
  30583. userJSONBytes, _ := json.Marshal(dat)
  30584. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30585. utils.ErrorLog("解析失败:%v", err)
  30586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30587. return
  30588. }
  30589. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30590. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30591. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30592. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30593. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30594. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30595. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30596. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30597. resp, requestErr := http.Get(api)
  30598. if requestErr != nil {
  30599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30600. return
  30601. }
  30602. body, ioErr := ioutil.ReadAll(resp.Body)
  30603. if ioErr != nil {
  30604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30606. return
  30607. }
  30608. var respJSON map[string]interface{}
  30609. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30612. return
  30613. }
  30614. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30615. result, _ := json.Marshal(respJSON)
  30616. fmt.Println("log")
  30617. fmt.Println(string(result))
  30618. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30619. utils.ErrorLog("解析失败:%v", err)
  30620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30621. return
  30622. }
  30623. } else {
  30624. if miConfig.MdtrtareaAdmvs == "441202" {
  30625. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30626. if result3101.Infcode == 0 {
  30627. if len(result3101.Output.Result) > 0 {
  30628. c.ServeSuccessJSON(map[string]interface{}{
  30629. "failed_code": -10,
  30630. "failed_type": 100,
  30631. "msg": result3101.Output.Result,
  30632. })
  30633. return
  30634. } else {
  30635. var result string
  30636. var request_log string
  30637. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30638. allTotal = fmt.Sprintf("%.2f", total_two)
  30639. if his.IdCardType == 4 {
  30640. 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)
  30641. } else {
  30642. 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)
  30643. }
  30644. var dat map[string]interface{}
  30645. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30646. fmt.Println(dat)
  30647. } else {
  30648. fmt.Println(err)
  30649. }
  30650. saveLog(result, request_log, "2206", "预结算")
  30651. //userJSONBytes, _ := json.Marshal(dat)
  30652. //
  30653. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30654. // utils.ErrorLog("解析失败:%v", err)
  30655. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30656. // return
  30657. //}
  30658. userJSONBytes, _ := json.Marshal(dat)
  30659. if miConfig.Code == "H15049901371" {
  30660. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30661. utils.ErrorLog("解析失败:%v", err)
  30662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30663. return
  30664. }
  30665. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30666. res.Output = resSeven10265.Output
  30667. res.ErrMsg = resSeven10265.ErrMsg
  30668. res.Cainfo = resSeven10265.Cainfo
  30669. res.WarnMsg = resSeven10265.WarnMsg
  30670. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30671. res.Infcode = infocode
  30672. } else {
  30673. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30674. utils.ErrorLog("解析失败:%v", err)
  30675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30676. return
  30677. }
  30678. }
  30679. }
  30680. } else {
  30681. c.ServeSuccessJSON(map[string]interface{}{
  30682. "failed_code": -10,
  30683. "msg": result3101.ErrMsg,
  30684. })
  30685. return
  30686. }
  30687. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30688. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30689. if result3101.Infcode == 0 {
  30690. if len(result3101.Output.Result) > 0 {
  30691. var errMsgs []string
  30692. for _, item := range result3101.Output.Result {
  30693. errMsgs = append(errMsgs, item.VolaCont)
  30694. }
  30695. c.ServeSuccessJSON(map[string]interface{}{
  30696. "failed_code": -10,
  30697. "msg": errMsgs,
  30698. })
  30699. return
  30700. } else {
  30701. var result string
  30702. var request_log string
  30703. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30704. allTotal = fmt.Sprintf("%.2f", total_two)
  30705. if his.IdCardType == 4 {
  30706. 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)
  30707. } else {
  30708. 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)
  30709. }
  30710. var dat map[string]interface{}
  30711. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30712. fmt.Println(dat)
  30713. } else {
  30714. fmt.Println(err)
  30715. }
  30716. saveLog(result, request_log, "2206", "预结算")
  30717. //userJSONBytes, _ := json.Marshal(dat)
  30718. //
  30719. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30720. // utils.ErrorLog("解析失败:%v", err)
  30721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30722. // return
  30723. //}
  30724. userJSONBytes, _ := json.Marshal(dat)
  30725. if miConfig.Code == "H15049901371" {
  30726. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30727. utils.ErrorLog("解析失败:%v", err)
  30728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30729. return
  30730. }
  30731. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30732. res.Output = resSeven10265.Output
  30733. res.ErrMsg = resSeven10265.ErrMsg
  30734. res.Cainfo = resSeven10265.Cainfo
  30735. res.WarnMsg = resSeven10265.WarnMsg
  30736. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30737. res.Infcode = infocode
  30738. } else {
  30739. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30740. utils.ErrorLog("解析失败:%v", err)
  30741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30742. return
  30743. }
  30744. }
  30745. }
  30746. } else {
  30747. c.ServeSuccessJSON(map[string]interface{}{
  30748. "failed_code": -10,
  30749. "msg": result3101.ErrMsg,
  30750. })
  30751. return
  30752. }
  30753. } else {
  30754. var result string
  30755. var request_log string
  30756. var dat map[string]interface{}
  30757. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30758. allTotal = fmt.Sprintf("%.2f", total_two)
  30759. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" {
  30760. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30761. if result3101.Infcode == 0 {
  30762. if len(result3101.Output.Result) > 0 {
  30763. c.ServeSuccessJSON(map[string]interface{}{
  30764. "failed_code": -10,
  30765. "failed_type": 100,
  30766. "warm_type": 2,
  30767. "msg": result3101.Output.Result,
  30768. })
  30769. return
  30770. } else {
  30771. var result string
  30772. var request_log string
  30773. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30774. allTotal = fmt.Sprintf("%.2f", total_two)
  30775. if his.IdCardType == 4 {
  30776. 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)
  30777. } else {
  30778. if his.IdCardType == 2 {
  30779. cert_no = psn_info.Certno
  30780. psn_info.VerifyNumber = psn_info.Certno
  30781. } else {
  30782. bas := strings.Split(psn_info.CardInfo, "|")
  30783. cert_no = bas[2]
  30784. }
  30785. 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)
  30786. }
  30787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30788. fmt.Println(dat)
  30789. } else {
  30790. fmt.Println(err)
  30791. }
  30792. saveLog(result, request_log, "2206", "预结算")
  30793. }
  30794. } else {
  30795. c.ServeSuccessJSON(map[string]interface{}{
  30796. "failed_code": -10,
  30797. "msg": result3101.ErrMsg,
  30798. })
  30799. return
  30800. }
  30801. } else {
  30802. if his.IdCardType == 4 {
  30803. 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)
  30804. } else {
  30805. if his.IdCardType == 2 {
  30806. cert_no = psn_info.Certno
  30807. psn_info.VerifyNumber = psn_info.Certno
  30808. } else {
  30809. bas := strings.Split(psn_info.CardInfo, "|")
  30810. cert_no = bas[2]
  30811. }
  30812. 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)
  30813. }
  30814. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30815. fmt.Println(dat)
  30816. } else {
  30817. fmt.Println(err)
  30818. }
  30819. saveLog(result, request_log, "2206", "预结算")
  30820. }
  30821. //userJSONBytes, _ := json.Marshal(dat)
  30822. //
  30823. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30824. // utils.ErrorLog("解析失败:%v", err)
  30825. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30826. // return
  30827. //}
  30828. userJSONBytes, _ := json.Marshal(dat)
  30829. if miConfig.Code == "H15049901371" {
  30830. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30831. utils.ErrorLog("解析失败:%v", err)
  30832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30833. return
  30834. }
  30835. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30836. res.Output = resSeven10265.Output
  30837. res.ErrMsg = resSeven10265.ErrMsg
  30838. res.Cainfo = resSeven10265.Cainfo
  30839. res.WarnMsg = resSeven10265.WarnMsg
  30840. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30841. res.Infcode = infocode
  30842. } else {
  30843. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30844. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30845. utils.ErrorLog("解析失败:%v", err)
  30846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30847. return
  30848. }
  30849. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30850. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30851. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30852. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30853. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30854. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30855. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30856. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30857. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30858. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30859. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30860. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30861. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30862. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30863. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30864. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30865. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30866. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30867. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30868. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30869. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30870. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30871. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30872. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30873. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30874. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30875. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30876. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30877. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30878. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30879. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30880. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30881. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30882. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30883. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30884. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30885. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30886. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30887. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30888. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30889. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30890. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30891. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30892. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30893. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30894. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30895. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30896. res.Cainfo = gzresSeven10265Two.Cainfo
  30897. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30898. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30899. //res.Infcode = infocode
  30900. } else {
  30901. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30902. utils.ErrorLog("解析失败:%v", err)
  30903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30904. return
  30905. }
  30906. }
  30907. }
  30908. }
  30909. }
  30910. utils.ErrorLog("解析失败:%v", res.Infcode)
  30911. if res.Infcode == -1 {
  30912. errlog := &models.HisOrderError{
  30913. UserOrgId: adminUser.CurrentOrgId,
  30914. Ctime: time.Now().Unix(),
  30915. Mtime: time.Now().Unix(),
  30916. Number: chrg_bchno,
  30917. ErrMsg: res.ErrMsg,
  30918. Status: 1,
  30919. PatientId: id,
  30920. RecordTime: recordDateTime,
  30921. Stage: 20,
  30922. }
  30923. service.CreateErrMsgLog(errlog)
  30924. c.ServeSuccessJSON(map[string]interface{}{
  30925. "failed_code": -10,
  30926. "msg": res.ErrMsg,
  30927. })
  30928. return
  30929. }
  30930. if res.Infcode != 0 {
  30931. errlog := &models.HisOrderError{
  30932. UserOrgId: adminUser.CurrentOrgId,
  30933. Ctime: time.Now().Unix(),
  30934. Mtime: time.Now().Unix(),
  30935. Number: chrg_bchno,
  30936. ErrMsg: res.ErrMsg,
  30937. Status: 1,
  30938. PatientId: id,
  30939. RecordTime: recordDateTime,
  30940. Stage: 20,
  30941. }
  30942. service.CreateErrMsgLog(errlog)
  30943. c.ServeSuccessJSON(map[string]interface{}{
  30944. "failed_code": -10,
  30945. "msg": res.ErrMsg,
  30946. })
  30947. return
  30948. } else {
  30949. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30950. order.OrderStatus = 1
  30951. order.IsPre = 1
  30952. order.Status = 1
  30953. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30954. order.SetlId = res.Output.Setlinfo.SetlID
  30955. order.PsnNo = res.Output.Setlinfo.PsnNo
  30956. order.PsnName = res.Output.Setlinfo.PsnName
  30957. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30958. order.Certno = res.Output.Setlinfo.Certno
  30959. order.Gend = res.Output.Setlinfo.Gend
  30960. order.Naty = res.Output.Setlinfo.Naty
  30961. order.Age = res.Output.Setlinfo.Age
  30962. order.Insutype = res.Output.Setlinfo.Insutype
  30963. order.PsnType = res.Output.Setlinfo.PsnType
  30964. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30965. order.SetlTime = res.Output.Setlinfo.SetlTime
  30966. order.AcctUsedFlag = acct_used_flag
  30967. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30968. if res.Output.Setlinfo.MedType == "140101" {
  30969. order.MedType = "14"
  30970. } else {
  30971. if res.Output.Setlinfo.MedType == "110104" {
  30972. order.MedType = "11"
  30973. } else {
  30974. order.MedType = res.Output.Setlinfo.MedType
  30975. }
  30976. }
  30977. if res.Output.Setlinfo.MedType == "992102" {
  30978. order.MedType = "992102"
  30979. }
  30980. if res.Output.Setlinfo.MedType == "140104" {
  30981. order.MedType = "140104"
  30982. }
  30983. if res.Output.Setlinfo.MedType == "140201" {
  30984. order.MedType = "140201"
  30985. }
  30986. if res.Output.Setlinfo.MedType == "14" {
  30987. order.MedType = "14"
  30988. }
  30989. if reg_type == 1112 {
  30990. order.MedType = "1112"
  30991. }
  30992. if reg_type == 1111 {
  30993. order.MedType = "1111"
  30994. }
  30995. order.ClrType = res.Output.Setlinfo.ClrType
  30996. if adminUser.CurrentOrgId == 10480 {
  30997. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30998. order.ClrType = "11"
  30999. } else {
  31000. order.ClrType = "9903"
  31001. }
  31002. }
  31003. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  31004. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  31005. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  31006. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  31007. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  31008. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  31009. order.HifpPay = res.Output.Setlinfo.HifpPay
  31010. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  31011. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  31012. order.HifesPay = res.Output.Setlinfo.HifesPay
  31013. order.HifobPay = res.Output.Setlinfo.HifobPay
  31014. order.MafPay = res.Output.Setlinfo.MafPay
  31015. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  31016. order.OthPay = res.Output.Setlinfo.OthPay
  31017. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  31018. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  31019. order.AcctPay = res.Output.Setlinfo.AcctPay
  31020. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  31021. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  31022. order.Balc = res.Output.Setlinfo.Balc
  31023. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  31024. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  31025. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  31026. order.ClrWay = res.Output.Setlinfo.ClrWay
  31027. order.Creator = order.Creator
  31028. order.Modify = roles.AdminUserId
  31029. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  31030. //detailStr := string(setlDetail)
  31031. //order.SetlDetail = detailStr
  31032. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  31033. err = service.UpDateOrder(order)
  31034. if err == nil {
  31035. c.ServeSuccessJSON(map[string]interface{}{
  31036. "msg": "预结算成功",
  31037. })
  31038. } else {
  31039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  31040. return
  31041. }
  31042. }
  31043. } else {
  31044. adminUser := c.GetAdminUserInfo()
  31045. errlog := &models.HisOrderError{
  31046. UserOrgId: adminUser.CurrentOrgId,
  31047. Ctime: time.Now().Unix(),
  31048. Mtime: time.Now().Unix(),
  31049. ErrMsg: res.ErrMsg,
  31050. Status: 1,
  31051. PatientId: id,
  31052. RecordTime: recordDateTime,
  31053. Stage: 4,
  31054. }
  31055. service.CreateErrMsgLog(errlog)
  31056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  31057. return
  31058. }
  31059. } else {
  31060. if miConfig.MdtrtareaAdmvs == "150499" {
  31061. order := &models.HisOrder{
  31062. UserOrgId: adminUser.CurrentOrgId,
  31063. HisPatientId: his.ID,
  31064. PatientId: his.PatientId,
  31065. SettleAccountsDate: recordDateTime,
  31066. Ctime: time.Now().Unix(),
  31067. Mtime: time.Now().Unix(),
  31068. MdtrtId: his.Number,
  31069. PsnNo: his.PsnNo,
  31070. MedType: strconv.FormatInt(reg_type, 10),
  31071. Status: 1,
  31072. Number: chrg_bchno,
  31073. Infcode: res.Infcode,
  31074. WarnMsg: res.WarnMsg,
  31075. Cainfo: res.Cainfo,
  31076. ErrMsg: res.ErrMsg,
  31077. RespondTime: res.RefmsgTime,
  31078. InfRefmsgid: res.InfRefmsgid,
  31079. OrderStatus: 1,
  31080. IsMedicineInsurance: 1,
  31081. SettleType: settle_accounts_type,
  31082. SettleStartTime: start_time,
  31083. SettleEndTime: end_time,
  31084. Creator: roles.AdminUserId,
  31085. Modify: roles.AdminUserId,
  31086. PType: 2,
  31087. Diagnosis: diagnosis_id,
  31088. }
  31089. err = service.CreateOrder(order)
  31090. if err != nil {
  31091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31092. return
  31093. }
  31094. }
  31095. adminUser := c.GetAdminUserInfo()
  31096. errlog := &models.HisOrderError{
  31097. UserOrgId: adminUser.CurrentOrgId,
  31098. Ctime: time.Now().Unix(),
  31099. Mtime: time.Now().Unix(),
  31100. ErrMsg: res.ErrMsg,
  31101. Status: 1,
  31102. PatientId: id,
  31103. RecordTime: recordDateTime,
  31104. Stage: 4,
  31105. }
  31106. service.CreateErrMsgLog(errlog)
  31107. c.ServeSuccessJSON(map[string]interface{}{
  31108. "failed_code": -10,
  31109. "msg": res.ErrMsg,
  31110. })
  31111. return
  31112. }
  31113. }
  31114. }
  31115. }
  31116. // 退款
  31117. func (c *HisApiController) Refund() {
  31118. order_id, _ := c.GetInt64("order_id")
  31119. admin_user_id, _ := c.GetInt64("admin_user_id")
  31120. adminUser := c.GetAdminUserInfo()
  31121. var order models.HisOrder
  31122. order, _ = service.GetHisOrderByID(order_id)
  31123. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  31124. if fapiao.ID > 0 {
  31125. c.ServeSuccessJSON(map[string]interface{}{
  31126. "failed_code": -10,
  31127. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  31128. })
  31129. return
  31130. }
  31131. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31132. if order.ID == 0 {
  31133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31134. return
  31135. }
  31136. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31137. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31138. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31139. if config.IsOpen == 1 { //对接了医保,走医保流程
  31140. var res ResultSixteen
  31141. var ahres ResultSevenAH
  31142. var resSixteen10265 ResultSixteen10265
  31143. var resSixteen10265Two ResultSixteen10265Two
  31144. var gz ResultgzSixteen10265Two
  31145. var src_resquest string
  31146. var result string
  31147. if miConfig.MdtrtareaAdmvs == "421300" {
  31148. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31149. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31150. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31151. resp3, requestErr3 := http.Get(api3)
  31152. if requestErr3 != nil {
  31153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31154. return
  31155. }
  31156. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31157. if ioErr3 != nil {
  31158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31160. return
  31161. }
  31162. var respJSON3 map[string]interface{}
  31163. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31166. return
  31167. }
  31168. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31169. userJSONBytes3, _ := json.Marshal(respJSON3)
  31170. fmt.Println("log")
  31171. fmt.Println(string(userJSONBytes3))
  31172. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31173. utils.ErrorLog("解析失败:%v", err)
  31174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31175. return
  31176. }
  31177. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31178. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31179. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31180. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31181. resp3, requestErr3 := http.Get(api3)
  31182. if requestErr3 != nil {
  31183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31184. return
  31185. }
  31186. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31187. if ioErr3 != nil {
  31188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31190. return
  31191. }
  31192. var respJSON3 map[string]interface{}
  31193. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31196. return
  31197. }
  31198. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31199. userJSONBytes3, _ := json.Marshal(respJSON3)
  31200. fmt.Println("log")
  31201. fmt.Println(string(userJSONBytes3))
  31202. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31203. utils.ErrorLog("解析失败:%v", err)
  31204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31205. return
  31206. }
  31207. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31208. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31209. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31210. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31211. resp3, requestErr3 := http.Get(api3)
  31212. if requestErr3 != nil {
  31213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31214. return
  31215. }
  31216. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31217. if ioErr3 != nil {
  31218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31220. return
  31221. }
  31222. var respJSON3 map[string]interface{}
  31223. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31226. return
  31227. }
  31228. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31229. userJSONBytes3, _ := json.Marshal(respJSON3)
  31230. fmt.Println("log")
  31231. fmt.Println(string(userJSONBytes3))
  31232. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31233. utils.ErrorLog("解析失败:%v", err)
  31234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31235. return
  31236. }
  31237. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31238. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31239. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31240. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31241. resp3, requestErr3 := http.Get(api3)
  31242. if requestErr3 != nil {
  31243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31244. return
  31245. }
  31246. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31247. if ioErr3 != nil {
  31248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31250. return
  31251. }
  31252. var respJSON3 map[string]interface{}
  31253. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31256. return
  31257. }
  31258. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31259. userJSONBytes3, _ := json.Marshal(respJSON3)
  31260. fmt.Println("log")
  31261. fmt.Println(string(userJSONBytes3))
  31262. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31263. utils.ErrorLog("解析失败:%v", err)
  31264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31265. return
  31266. }
  31267. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31268. var api3 string
  31269. if miConfig.MdtrtareaAdmvs == "320921" {
  31270. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31271. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31272. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31273. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31274. } else {
  31275. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31276. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31277. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31278. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31279. }
  31280. resp3, requestErr3 := http.Get(api3)
  31281. if requestErr3 != nil {
  31282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31283. return
  31284. }
  31285. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31286. if ioErr3 != nil {
  31287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31289. return
  31290. }
  31291. var respJSON3 map[string]interface{}
  31292. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31295. return
  31296. }
  31297. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31298. userJSONBytes3, _ := json.Marshal(respJSON3)
  31299. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31300. utils.ErrorLog("解析失败:%v", err)
  31301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31302. return
  31303. }
  31304. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31305. res.Output = resSixteen10265.Output
  31306. res.ErrMsg = resSixteen10265.ErrMsg
  31307. res.Cainfo = resSixteen10265.Cainfo
  31308. res.WarnMsg = resSixteen10265.WarnMsg
  31309. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31310. res.Infcode = infocode
  31311. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31312. var api3 string
  31313. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31314. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31315. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31316. resp3, requestErr3 := http.Get(api3)
  31317. if requestErr3 != nil {
  31318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31319. return
  31320. }
  31321. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31322. if ioErr3 != nil {
  31323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31325. return
  31326. }
  31327. var respJSON3 map[string]interface{}
  31328. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31331. return
  31332. }
  31333. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31334. userJSONBytes3, _ := json.Marshal(respJSON3)
  31335. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31336. utils.ErrorLog("解析失败:%v", err)
  31337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31338. return
  31339. }
  31340. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31341. res.Output = resSixteen10265.Output
  31342. res.ErrMsg = resSixteen10265.ErrMsg
  31343. res.Cainfo = resSixteen10265.Cainfo
  31344. res.WarnMsg = resSixteen10265.WarnMsg
  31345. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31346. res.Infcode = infocode
  31347. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31348. 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)
  31349. var dat map[string]interface{}
  31350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31351. fmt.Println(dat)
  31352. } else {
  31353. fmt.Println(err)
  31354. }
  31355. saveLog(result, src_resquest, "2208", "退费")
  31356. userJSONBytes, _ := json.Marshal(dat)
  31357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31358. utils.ErrorLog("解析失败:%v", err)
  31359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31360. return
  31361. }
  31362. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31363. 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, "")
  31364. var dat map[string]interface{}
  31365. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31366. fmt.Println(dat)
  31367. } else {
  31368. fmt.Println(err)
  31369. }
  31370. saveLog(result, src_resquest, "2208", "退费")
  31371. userJSONBytes, _ := json.Marshal(dat)
  31372. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31373. utils.ErrorLog("解析失败:%v", err)
  31374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31375. return
  31376. }
  31377. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31378. 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, "")
  31379. var dat map[string]interface{}
  31380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31381. fmt.Println(dat)
  31382. } else {
  31383. fmt.Println(err)
  31384. }
  31385. saveLog(result, src_resquest, "2208", "退费")
  31386. userJSONBytes, _ := json.Marshal(dat)
  31387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31388. utils.ErrorLog("解析失败:%v", err)
  31389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31390. return
  31391. }
  31392. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31393. var api3 string
  31394. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31395. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31396. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31397. resp3, requestErr3 := http.Get(api3)
  31398. if requestErr3 != nil {
  31399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31400. return
  31401. }
  31402. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31403. if ioErr3 != nil {
  31404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31406. return
  31407. }
  31408. var respJSON3 map[string]interface{}
  31409. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31412. return
  31413. }
  31414. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31415. if status == "0" {
  31416. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31417. c.ServeSuccessJSON(map[string]interface{}{
  31418. "failed_code": -10,
  31419. "msg": err_msg,
  31420. })
  31421. return
  31422. }
  31423. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31424. userJSONBytes3, _ := json.Marshal(respJSON3)
  31425. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31426. // utils.ErrorLog("解析失败:%v", err)
  31427. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31428. // return
  31429. //}
  31430. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31431. utils.ErrorLog("解析失败:%v", err)
  31432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31433. return
  31434. }
  31435. res.InfRefmsgid = ahres.InfRefmsgid
  31436. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31437. // 创建对应的Time类型
  31438. t := time.UnixMilli(timestamp)
  31439. // 格式化成指定的日期字符串
  31440. str := t.Format("2006-01-02 15:04:05")
  31441. res.Output.Setlinfo.SetlTime = str
  31442. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31443. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31444. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31445. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31446. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31447. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31448. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31449. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31450. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31451. //
  31452. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31453. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31454. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31455. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31456. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31457. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31458. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31459. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31460. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31461. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31462. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31463. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31464. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31465. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31466. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31467. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31468. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31469. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31470. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31471. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31472. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31473. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31474. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31475. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31476. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31477. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31478. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31479. //res.Output.Setldetail = ahres.Output.Setldetail
  31480. res.ErrMsg = ahres.ErrMsg
  31481. res.Cainfo = ahres.Cainfo
  31482. res.WarnMsg = ahres.WarnMsg
  31483. res.Infcode = ahres.Infcode
  31484. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31485. var api3 string
  31486. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31487. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31488. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31489. resp3, requestErr3 := http.Get(api3)
  31490. if requestErr3 != nil {
  31491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31492. return
  31493. }
  31494. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31495. if ioErr3 != nil {
  31496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31498. return
  31499. }
  31500. var respJSON3 map[string]interface{}
  31501. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31504. return
  31505. }
  31506. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31507. if status == "0" {
  31508. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31509. c.ServeSuccessJSON(map[string]interface{}{
  31510. "failed_code": -10,
  31511. "msg": err_msg,
  31512. })
  31513. return
  31514. }
  31515. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31516. userJSONBytes3, _ := json.Marshal(respJSON3)
  31517. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31518. // utils.ErrorLog("解析失败:%v", err)
  31519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31520. // return
  31521. //}
  31522. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31523. utils.ErrorLog("解析失败:%v", err)
  31524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31525. return
  31526. }
  31527. res.InfRefmsgid = ahres.InfRefmsgid
  31528. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31529. // 创建对应的Time类型
  31530. t := time.UnixMilli(timestamp)
  31531. // 格式化成指定的日期字符串
  31532. str := t.Format("2006-01-02 15:04:05")
  31533. res.Output.Setlinfo.SetlTime = str
  31534. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31535. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31536. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31537. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31538. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31539. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31540. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31541. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31542. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31543. //
  31544. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31545. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31546. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31547. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31548. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31549. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31550. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31551. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31552. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31553. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31554. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31555. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31556. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31557. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31558. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31559. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31560. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31561. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31562. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31563. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31564. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31565. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31566. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31567. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31568. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31569. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31570. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31571. //res.Output.Setldetail = ahres.Output.Setldetail
  31572. res.ErrMsg = ahres.ErrMsg
  31573. res.Cainfo = ahres.Cainfo
  31574. res.WarnMsg = ahres.WarnMsg
  31575. res.Infcode = ahres.Infcode
  31576. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31577. 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, "")
  31578. var dat map[string]interface{}
  31579. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31580. fmt.Println(dat)
  31581. } else {
  31582. fmt.Println(err)
  31583. }
  31584. saveLog(result, src_resquest, "2208", "退费")
  31585. userJSONBytes, _ := json.Marshal(dat)
  31586. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31587. utils.ErrorLog("解析失败:%v", err)
  31588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31589. return
  31590. }
  31591. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31592. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31593. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31594. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31595. resp3, requestErr3 := http.Get(api3)
  31596. if requestErr3 != nil {
  31597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31598. return
  31599. }
  31600. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31601. if ioErr3 != nil {
  31602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31604. return
  31605. }
  31606. var respJSON3 map[string]interface{}
  31607. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31610. return
  31611. }
  31612. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31613. userJSONBytes3, _ := json.Marshal(respJSON3)
  31614. fmt.Println("log")
  31615. fmt.Println(string(userJSONBytes3))
  31616. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31617. utils.ErrorLog("解析失败:%v", err)
  31618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31619. return
  31620. }
  31621. } else {
  31622. if miConfig.Code == "H15049901371" {
  31623. 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)
  31624. var dat map[string]interface{}
  31625. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31626. fmt.Println(dat)
  31627. } else {
  31628. fmt.Println(err)
  31629. }
  31630. saveLog(result, src_resquest, "2208", "退费")
  31631. if strings.Contains(result, "Post") {
  31632. res.Infcode = -1
  31633. res.ErrMsg = result
  31634. }
  31635. userJSONBytes, _ := json.Marshal(dat)
  31636. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31637. utils.ErrorLog("解析失败:%v", err)
  31638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31639. return
  31640. }
  31641. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31642. res.Output = resSixteen10265.Output
  31643. res.ErrMsg = resSixteen10265.ErrMsg
  31644. res.Cainfo = resSixteen10265.Cainfo
  31645. res.WarnMsg = resSixteen10265.WarnMsg
  31646. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31647. res.Infcode = infocode
  31648. } else {
  31649. 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)
  31650. var dat map[string]interface{}
  31651. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31652. fmt.Println(dat)
  31653. } else {
  31654. fmt.Println(err)
  31655. }
  31656. saveLog(result, src_resquest, "2208", "退费")
  31657. userJSONBytes, _ := json.Marshal(dat)
  31658. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31659. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31660. utils.ErrorLog("解析失败:%v", err)
  31661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31662. return
  31663. }
  31664. res.Infcode = gz.Infcode
  31665. } else {
  31666. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31667. utils.ErrorLog("解析失败:%v", err)
  31668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31669. return
  31670. }
  31671. }
  31672. if strings.Contains(result, "Post") {
  31673. res.Infcode = -1
  31674. res.ErrMsg = result
  31675. }
  31676. }
  31677. }
  31678. if res.Infcode == -1 {
  31679. c.ServeSuccessJSON(map[string]interface{}{
  31680. "failed_code": -10,
  31681. "msg": res.ErrMsg,
  31682. })
  31683. return
  31684. }
  31685. if res.Infcode != -1 {
  31686. var res2 ResultSix
  31687. var resSix10265 ResultSix10265
  31688. if miConfig.MdtrtareaAdmvs == "421300" {
  31689. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31690. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31691. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31692. resp3, requestErr3 := http.Get(api3)
  31693. if requestErr3 != nil {
  31694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31695. return
  31696. }
  31697. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31698. if ioErr3 != nil {
  31699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31701. return
  31702. }
  31703. var respJSON3 map[string]interface{}
  31704. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31707. return
  31708. }
  31709. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31710. userJSONBytes3, _ := json.Marshal(respJSON3)
  31711. fmt.Println("log")
  31712. fmt.Println(string(userJSONBytes3))
  31713. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31714. utils.ErrorLog("解析失败:%v", err)
  31715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31716. return
  31717. }
  31718. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31719. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31720. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31721. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31722. resp3, requestErr3 := http.Get(api3)
  31723. if requestErr3 != nil {
  31724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31725. return
  31726. }
  31727. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31728. if ioErr3 != nil {
  31729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31731. return
  31732. }
  31733. var respJSON3 map[string]interface{}
  31734. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31737. return
  31738. }
  31739. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31740. userJSONBytes3, _ := json.Marshal(respJSON3)
  31741. fmt.Println("log")
  31742. fmt.Println(string(userJSONBytes3))
  31743. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31744. utils.ErrorLog("解析失败:%v", err)
  31745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31746. return
  31747. }
  31748. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31749. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31750. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31751. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31752. resp3, requestErr3 := http.Get(api3)
  31753. if requestErr3 != nil {
  31754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31755. return
  31756. }
  31757. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31758. if ioErr3 != nil {
  31759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31761. return
  31762. }
  31763. var respJSON3 map[string]interface{}
  31764. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31767. return
  31768. }
  31769. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31770. userJSONBytes3, _ := json.Marshal(respJSON3)
  31771. fmt.Println("log")
  31772. fmt.Println(string(userJSONBytes3))
  31773. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31774. utils.ErrorLog("解析失败:%v", err)
  31775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31776. return
  31777. }
  31778. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31779. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31780. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31781. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31782. resp3, requestErr3 := http.Get(api3)
  31783. if requestErr3 != nil {
  31784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31785. return
  31786. }
  31787. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31788. if ioErr3 != nil {
  31789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31791. return
  31792. }
  31793. var respJSON3 map[string]interface{}
  31794. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31797. return
  31798. }
  31799. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31800. userJSONBytes3, _ := json.Marshal(respJSON3)
  31801. fmt.Println("log")
  31802. fmt.Println(string(userJSONBytes3))
  31803. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31804. utils.ErrorLog("解析失败:%v", err)
  31805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31806. return
  31807. }
  31808. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31809. var api3 string
  31810. if miConfig.MdtrtareaAdmvs == "320921" {
  31811. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31812. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31813. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31814. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31815. } else {
  31816. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31817. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31818. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31819. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31820. }
  31821. resp3, requestErr3 := http.Get(api3)
  31822. if requestErr3 != nil {
  31823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31824. return
  31825. }
  31826. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31827. if ioErr3 != nil {
  31828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31830. return
  31831. }
  31832. var respJSON3 map[string]interface{}
  31833. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31836. return
  31837. }
  31838. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31839. userJSONBytes3, _ := json.Marshal(respJSON3)
  31840. fmt.Println("log")
  31841. fmt.Println(string(userJSONBytes3))
  31842. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31843. utils.ErrorLog("解析失败:%v", err)
  31844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31845. return
  31846. }
  31847. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31848. res2.Output = resSix10265.Output
  31849. res2.ErrMsg = resSix10265.ErrMsg
  31850. res2.Cainfo = resSix10265.Cainfo
  31851. res2.WarnMsg = resSix10265.WarnMsg
  31852. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31853. res2.Infcode = infocode
  31854. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31855. var api3 string
  31856. new_chrg_bchno := order.Number
  31857. if adminUser.CurrentOrgId == 10265 {
  31858. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31859. new_chrg_bchno = "0000"
  31860. }
  31861. }
  31862. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31863. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31864. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31865. resp3, requestErr3 := http.Get(api3)
  31866. if requestErr3 != nil {
  31867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31868. return
  31869. }
  31870. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31871. if ioErr3 != nil {
  31872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31874. return
  31875. }
  31876. var respJSON3 map[string]interface{}
  31877. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31880. return
  31881. }
  31882. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31883. userJSONBytes3, _ := json.Marshal(respJSON3)
  31884. fmt.Println("log")
  31885. fmt.Println(string(userJSONBytes3))
  31886. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31887. utils.ErrorLog("解析失败:%v", err)
  31888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31889. return
  31890. }
  31891. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31892. res2.Output = resSix10265.Output
  31893. res2.ErrMsg = resSix10265.ErrMsg
  31894. res2.Cainfo = resSix10265.Cainfo
  31895. res2.WarnMsg = resSix10265.WarnMsg
  31896. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31897. res2.Infcode = infocode
  31898. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31899. 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)
  31900. var dat map[string]interface{}
  31901. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31902. fmt.Println(dat)
  31903. } else {
  31904. fmt.Println(err)
  31905. }
  31906. saveLog(result2, src_request, "2205", "撤销明细")
  31907. userJSONBytes, _ := json.Marshal(dat)
  31908. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31909. utils.ErrorLog("解析失败:%v", err)
  31910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31911. return
  31912. }
  31913. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31914. 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, "")
  31915. var dat map[string]interface{}
  31916. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31917. fmt.Println(dat)
  31918. } else {
  31919. fmt.Println(err)
  31920. }
  31921. saveLog(result2, src_request, "2205", "撤销明细")
  31922. userJSONBytes, _ := json.Marshal(dat)
  31923. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31924. utils.ErrorLog("解析失败:%v", err)
  31925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31926. return
  31927. }
  31928. } else if miConfig.MdtrtareaAdmvs == "361025" {
  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 == "341203" {
  31944. var api3 string
  31945. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31946. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31947. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31948. resp3, requestErr3 := http.Get(api3)
  31949. if requestErr3 != nil {
  31950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31951. return
  31952. }
  31953. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31954. if ioErr3 != nil {
  31955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31957. return
  31958. }
  31959. var respJSON3 map[string]interface{}
  31960. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31963. return
  31964. }
  31965. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31966. if status == "0" {
  31967. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31968. c.ServeSuccessJSON(map[string]interface{}{
  31969. "failed_code": -10,
  31970. "msg": err_msg,
  31971. })
  31972. return
  31973. }
  31974. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31975. userJSONBytes3, _ := json.Marshal(respJSON3)
  31976. fmt.Println("log")
  31977. fmt.Println(string(userJSONBytes3))
  31978. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31979. utils.ErrorLog("解析失败:%v", err)
  31980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31981. return
  31982. }
  31983. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31984. 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, "")
  31985. var dat map[string]interface{}
  31986. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31987. fmt.Println(dat)
  31988. } else {
  31989. fmt.Println(err)
  31990. }
  31991. saveLog(result2, src_request, "2205", "撤销明细")
  31992. userJSONBytes, _ := json.Marshal(dat)
  31993. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31994. utils.ErrorLog("解析失败:%v", err)
  31995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31996. return
  31997. }
  31998. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31999. 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, "")
  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 == "340699" {
  32014. var api3 string
  32015. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32016. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32017. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32018. resp3, requestErr3 := http.Get(api3)
  32019. if requestErr3 != nil {
  32020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32021. return
  32022. }
  32023. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32024. if ioErr3 != nil {
  32025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32027. return
  32028. }
  32029. var respJSON3 map[string]interface{}
  32030. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32033. return
  32034. }
  32035. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32036. if status == "0" {
  32037. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32038. c.ServeSuccessJSON(map[string]interface{}{
  32039. "failed_code": -10,
  32040. "msg": err_msg,
  32041. })
  32042. return
  32043. }
  32044. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32045. userJSONBytes3, _ := json.Marshal(respJSON3)
  32046. fmt.Println("log")
  32047. fmt.Println(string(userJSONBytes3))
  32048. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32049. utils.ErrorLog("解析失败:%v", err)
  32050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32051. return
  32052. }
  32053. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32054. 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, "")
  32055. var dat map[string]interface{}
  32056. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32057. fmt.Println(dat)
  32058. } else {
  32059. fmt.Println(err)
  32060. }
  32061. saveLog(result2, src_request, "2205", "撤销明细")
  32062. userJSONBytes, _ := json.Marshal(dat)
  32063. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32064. utils.ErrorLog("解析失败:%v", err)
  32065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32066. return
  32067. }
  32068. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32069. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  32070. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32071. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32072. resp3, requestErr3 := http.Get(api3)
  32073. if requestErr3 != nil {
  32074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32075. return
  32076. }
  32077. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32078. if ioErr3 != nil {
  32079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32081. return
  32082. }
  32083. var respJSON3 map[string]interface{}
  32084. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32087. return
  32088. }
  32089. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32090. userJSONBytes3, _ := json.Marshal(respJSON3)
  32091. fmt.Println("log")
  32092. fmt.Println(string(userJSONBytes3))
  32093. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32094. utils.ErrorLog("解析失败:%v", err)
  32095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32096. return
  32097. }
  32098. } else {
  32099. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32100. res2.Infcode = 0
  32101. } else {
  32102. 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)
  32103. var dat map[string]interface{}
  32104. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32105. fmt.Println(dat)
  32106. } else {
  32107. fmt.Println(err)
  32108. }
  32109. saveLog(result2, src_request, "2205", "撤销明细")
  32110. userJSONBytes, _ := json.Marshal(dat)
  32111. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32112. utils.ErrorLog("解析失败:%v", err)
  32113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32114. return
  32115. }
  32116. }
  32117. }
  32118. if res2.Infcode == -1 {
  32119. c.ServeSuccessJSON(map[string]interface{}{
  32120. "failed_code": -10,
  32121. "msg": res2.ErrMsg,
  32122. })
  32123. return
  32124. }
  32125. if res2.Infcode == 0 {
  32126. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  32127. if err == nil {
  32128. //当押金不为零时产生退费记录
  32129. if order.Decimal != 0 {
  32130. tmp := strconv.FormatInt(order.ID, 10)
  32131. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  32132. if err != nil {
  32133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32134. return
  32135. }
  32136. }
  32137. c.ServeSuccessJSON(map[string]interface{}{
  32138. "msg": "退费成功",
  32139. })
  32140. } else {
  32141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32142. return
  32143. }
  32144. } else {
  32145. c.ServeSuccessJSON(map[string]interface{}{
  32146. "failed_code": -10,
  32147. "msg": res2.ErrMsg,
  32148. })
  32149. }
  32150. } else {
  32151. c.ServeSuccessJSON(map[string]interface{}{
  32152. "failed_code": -10,
  32153. "msg": res.ErrMsg,
  32154. })
  32155. }
  32156. }
  32157. }
  32158. func (c *HisApiController) RefundNumber() {
  32159. record_time := c.GetString("record_time")
  32160. //patient_id, _ := c.GetInt64("patient_id")
  32161. admin_user_id, _ := c.GetInt64("admin_user_id")
  32162. his_patient_id, _ := c.GetInt64("id")
  32163. timeLayout := "2006-01-02"
  32164. loc, _ := time.LoadLocation("Local")
  32165. adminUser := c.GetAdminUserInfo()
  32166. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32167. fmt.Println(err)
  32168. if err != nil {
  32169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32170. return
  32171. }
  32172. recordDateTime := theTime.Unix()
  32173. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32174. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32175. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32176. //order, _ := service.GetHisOrderByID(order_id)
  32177. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32178. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32179. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32180. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32181. if count > 0 {
  32182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32183. return
  32184. }
  32185. if config.IsOpen == 1 { //对接了医保,走医保流程
  32186. var res2 ResultSix
  32187. var res3 GZResultSix
  32188. var resSix10265 ResultSix10265
  32189. if miConfig.MdtrtareaAdmvs == "421300" {
  32190. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32191. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32192. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32193. resp3, requestErr3 := http.Get(api3)
  32194. if requestErr3 != nil {
  32195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32196. return
  32197. }
  32198. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32199. if ioErr3 != nil {
  32200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32202. return
  32203. }
  32204. var respJSON3 map[string]interface{}
  32205. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32208. return
  32209. }
  32210. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32211. userJSONBytes3, _ := json.Marshal(respJSON3)
  32212. fmt.Println("log")
  32213. fmt.Println(string(userJSONBytes3))
  32214. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32215. utils.ErrorLog("解析失败:%v", err)
  32216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32217. return
  32218. }
  32219. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32220. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32221. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32222. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32223. resp3, requestErr3 := http.Get(api3)
  32224. if requestErr3 != nil {
  32225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32226. return
  32227. }
  32228. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32229. if ioErr3 != nil {
  32230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32232. return
  32233. }
  32234. var respJSON3 map[string]interface{}
  32235. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32238. return
  32239. }
  32240. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32241. userJSONBytes3, _ := json.Marshal(respJSON3)
  32242. fmt.Println("log")
  32243. fmt.Println(string(userJSONBytes3))
  32244. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32245. utils.ErrorLog("解析失败:%v", err)
  32246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32247. return
  32248. }
  32249. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32250. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32251. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32252. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32253. resp3, requestErr3 := http.Get(api3)
  32254. if requestErr3 != nil {
  32255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32256. return
  32257. }
  32258. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32259. if ioErr3 != nil {
  32260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32262. return
  32263. }
  32264. var respJSON3 map[string]interface{}
  32265. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32268. return
  32269. }
  32270. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32271. userJSONBytes3, _ := json.Marshal(respJSON3)
  32272. fmt.Println("log")
  32273. fmt.Println(string(userJSONBytes3))
  32274. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32275. utils.ErrorLog("解析失败:%v", err)
  32276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32277. return
  32278. }
  32279. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32280. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32281. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32282. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32283. resp3, requestErr3 := http.Get(api3)
  32284. if requestErr3 != nil {
  32285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32286. return
  32287. }
  32288. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32289. if ioErr3 != nil {
  32290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32292. return
  32293. }
  32294. var respJSON3 map[string]interface{}
  32295. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32298. return
  32299. }
  32300. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32301. userJSONBytes3, _ := json.Marshal(respJSON3)
  32302. fmt.Println("log")
  32303. fmt.Println(string(userJSONBytes3))
  32304. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32305. utils.ErrorLog("解析失败:%v", err)
  32306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32307. return
  32308. }
  32309. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32310. var api3 string
  32311. if miConfig.MdtrtareaAdmvs == "320921" {
  32312. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32313. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32314. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32315. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32316. } else {
  32317. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32318. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32319. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32320. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32321. }
  32322. resp3, requestErr3 := http.Get(api3)
  32323. if requestErr3 != nil {
  32324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32325. return
  32326. }
  32327. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32328. if ioErr3 != nil {
  32329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32331. return
  32332. }
  32333. var respJSON3 map[string]interface{}
  32334. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32337. return
  32338. }
  32339. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32340. userJSONBytes3, _ := json.Marshal(respJSON3)
  32341. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32342. utils.ErrorLog("解析失败:%v", err)
  32343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32344. return
  32345. }
  32346. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32347. res2.Output = resSix10265.Output
  32348. res2.ErrMsg = resSix10265.ErrMsg
  32349. res2.Cainfo = resSix10265.Cainfo
  32350. res2.WarnMsg = resSix10265.WarnMsg
  32351. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32352. res2.Infcode = infocode
  32353. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32354. var api3 string
  32355. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32356. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32357. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32358. resp3, requestErr3 := http.Get(api3)
  32359. if requestErr3 != nil {
  32360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32361. return
  32362. }
  32363. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32364. if ioErr3 != nil {
  32365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32367. return
  32368. }
  32369. var respJSON3 map[string]interface{}
  32370. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32373. return
  32374. }
  32375. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32376. userJSONBytes3, _ := json.Marshal(respJSON3)
  32377. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32378. utils.ErrorLog("解析失败:%v", err)
  32379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32380. return
  32381. }
  32382. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32383. res2.Output = resSix10265.Output
  32384. res2.ErrMsg = resSix10265.ErrMsg
  32385. res2.Cainfo = resSix10265.Cainfo
  32386. res2.WarnMsg = resSix10265.WarnMsg
  32387. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32388. res2.Infcode = infocode
  32389. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32390. 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)
  32391. var dat map[string]interface{}
  32392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32393. fmt.Println(dat)
  32394. } else {
  32395. fmt.Println(err)
  32396. }
  32397. saveLog(result, request, "2202", "退号")
  32398. userJSONBytes, _ := json.Marshal(dat)
  32399. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32400. utils.ErrorLog("解析失败:%v", err)
  32401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32402. return
  32403. }
  32404. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32405. 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, "")
  32406. var dat map[string]interface{}
  32407. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32408. fmt.Println(dat)
  32409. } else {
  32410. fmt.Println(err)
  32411. }
  32412. saveLog(result, request, "2202", "退号")
  32413. userJSONBytes, _ := json.Marshal(dat)
  32414. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32415. utils.ErrorLog("解析失败:%v", err)
  32416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32417. return
  32418. }
  32419. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32420. 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, "")
  32421. var dat map[string]interface{}
  32422. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32423. fmt.Println(dat)
  32424. } else {
  32425. fmt.Println(err)
  32426. }
  32427. saveLog(result, request, "2202", "退号")
  32428. userJSONBytes, _ := json.Marshal(dat)
  32429. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32430. utils.ErrorLog("解析失败:%v", err)
  32431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32432. return
  32433. }
  32434. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32435. var api3 string
  32436. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32437. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32438. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32439. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32440. resp3, requestErr3 := http.Get(api3)
  32441. if requestErr3 != nil {
  32442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32443. return
  32444. }
  32445. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32446. if ioErr3 != nil {
  32447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32449. return
  32450. }
  32451. var respJSON3 map[string]interface{}
  32452. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32455. return
  32456. }
  32457. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32458. if status == "0" {
  32459. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32460. c.ServeSuccessJSON(map[string]interface{}{
  32461. "failed_code": -10,
  32462. "msg": err_msg,
  32463. })
  32464. return
  32465. }
  32466. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32467. userJSONBytes3, _ := json.Marshal(respJSON3)
  32468. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32469. utils.ErrorLog("解析失败:%v", err)
  32470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32471. return
  32472. }
  32473. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32474. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32475. var api3 string
  32476. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32477. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32478. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32479. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32480. resp3, requestErr3 := http.Get(api3)
  32481. if requestErr3 != nil {
  32482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32483. return
  32484. }
  32485. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32486. if ioErr3 != nil {
  32487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32489. return
  32490. }
  32491. var respJSON3 map[string]interface{}
  32492. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32495. return
  32496. }
  32497. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32498. if status == "0" {
  32499. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32500. c.ServeSuccessJSON(map[string]interface{}{
  32501. "failed_code": -10,
  32502. "msg": err_msg,
  32503. })
  32504. return
  32505. }
  32506. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32507. userJSONBytes3, _ := json.Marshal(respJSON3)
  32508. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32509. utils.ErrorLog("解析失败:%v", err)
  32510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32511. return
  32512. }
  32513. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32514. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32515. 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, "")
  32516. var dat map[string]interface{}
  32517. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32518. fmt.Println(dat)
  32519. } else {
  32520. fmt.Println(err)
  32521. }
  32522. saveLog(result, request, "2202", "退号")
  32523. userJSONBytes, _ := json.Marshal(dat)
  32524. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32525. utils.ErrorLog("解析失败:%v", err)
  32526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32527. return
  32528. }
  32529. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32530. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32531. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32532. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32533. resp3, requestErr3 := http.Get(api3)
  32534. if requestErr3 != nil {
  32535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32536. return
  32537. }
  32538. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32539. if ioErr3 != nil {
  32540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32542. return
  32543. }
  32544. var respJSON3 map[string]interface{}
  32545. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32548. return
  32549. }
  32550. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32551. userJSONBytes3, _ := json.Marshal(respJSON3)
  32552. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32553. utils.ErrorLog("解析失败:%v", err)
  32554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32555. return
  32556. }
  32557. } else {
  32558. var api3 string
  32559. if miConfig.Code == "H15049901371" {
  32560. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32561. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32562. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32563. } else {
  32564. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32565. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32566. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32567. }
  32568. resp3, requestErr3 := http.Get(api3)
  32569. if requestErr3 != nil {
  32570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32571. return
  32572. }
  32573. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32574. if ioErr3 != nil {
  32575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32577. return
  32578. }
  32579. var respJSON3 map[string]interface{}
  32580. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32583. return
  32584. }
  32585. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32586. userJSONBytes3, _ := json.Marshal(respJSON3)
  32587. if miConfig.Code == "H15049901371" {
  32588. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32589. utils.ErrorLog("解析失败:%v", err)
  32590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32591. return
  32592. }
  32593. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32594. res2.Output = resSix10265.Output
  32595. res2.ErrMsg = resSix10265.ErrMsg
  32596. res2.Cainfo = resSix10265.Cainfo
  32597. res2.WarnMsg = resSix10265.WarnMsg
  32598. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32599. res2.Infcode = infocode
  32600. } else {
  32601. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32602. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32603. utils.ErrorLog("解析失败:%v", err)
  32604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32605. return
  32606. }
  32607. res2.Infcode = res3.Infcode
  32608. } else {
  32609. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32610. utils.ErrorLog("解析失败:%v", err)
  32611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32612. return
  32613. }
  32614. }
  32615. }
  32616. }
  32617. if res2.Infcode == -1 {
  32618. c.ServeSuccessJSON(map[string]interface{}{
  32619. "failed_code": -10,
  32620. "msg": res2.ErrMsg,
  32621. })
  32622. return
  32623. }
  32624. if res2.Infcode == 0 {
  32625. if err == nil {
  32626. c.ServeSuccessJSON(map[string]interface{}{
  32627. "msg": "退号成功",
  32628. })
  32629. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32630. } else {
  32631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32632. return
  32633. }
  32634. }
  32635. } else {
  32636. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32637. //if err == nil {
  32638. // c.ServeSuccessJSON(map[string]interface{}{
  32639. // "msg": "退费成功",
  32640. // })
  32641. //} else {
  32642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32643. // return
  32644. //}
  32645. }
  32646. }
  32647. func (c *HisApiController) RefundDetail() {
  32648. order_id, _ := c.GetInt64("order_id")
  32649. admin_user_id, _ := c.GetInt64("admin_user_id")
  32650. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32651. number := c.GetString("number")
  32652. record_time := c.GetString("record_time")
  32653. patient_id, _ := c.GetInt64("patient_id")
  32654. //med_type, _ := c.GetInt64("med_type")
  32655. timeLayout := "2006-01-02"
  32656. loc, _ := time.LoadLocation("Local")
  32657. adminUser := c.GetAdminUserInfo()
  32658. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32659. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32660. fmt.Println(err)
  32661. if err != nil {
  32662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32663. return
  32664. }
  32665. recordDateTime := theTime.Unix()
  32666. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32667. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32668. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32669. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32670. var order models.HisOrder
  32671. order, _ = service.GetHisOrderByID(order_id)
  32672. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32673. if config.IsOpen == 1 { //对接了医保,走医保流程
  32674. var res2 ResultSix
  32675. if miConfig.MdtrtareaAdmvs == "421300" {
  32676. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32677. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32678. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32679. resp3, requestErr3 := http.Get(api3)
  32680. if requestErr3 != nil {
  32681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32682. return
  32683. }
  32684. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32685. if ioErr3 != nil {
  32686. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32688. return
  32689. }
  32690. var respJSON3 map[string]interface{}
  32691. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32692. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32694. return
  32695. }
  32696. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32697. userJSONBytes3, _ := json.Marshal(respJSON3)
  32698. fmt.Println("log")
  32699. fmt.Println(string(userJSONBytes3))
  32700. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32701. utils.ErrorLog("解析失败:%v", err)
  32702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32703. return
  32704. }
  32705. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32706. if err == nil {
  32707. c.ServeSuccessJSON(map[string]interface{}{
  32708. "msg": "撤销明细成功",
  32709. })
  32710. return
  32711. } else {
  32712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32713. return
  32714. }
  32715. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32716. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32717. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32718. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32719. resp3, requestErr3 := http.Get(api3)
  32720. if requestErr3 != nil {
  32721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32722. return
  32723. }
  32724. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32725. if ioErr3 != nil {
  32726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32728. return
  32729. }
  32730. var respJSON3 map[string]interface{}
  32731. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32734. return
  32735. }
  32736. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32737. userJSONBytes3, _ := json.Marshal(respJSON3)
  32738. fmt.Println("log")
  32739. fmt.Println(string(userJSONBytes3))
  32740. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32741. utils.ErrorLog("解析失败:%v", err)
  32742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32743. return
  32744. }
  32745. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32746. if err == nil {
  32747. c.ServeSuccessJSON(map[string]interface{}{
  32748. "msg": "撤销明细成功",
  32749. })
  32750. return
  32751. } else {
  32752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32753. return
  32754. }
  32755. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32756. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32757. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32758. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32759. resp3, requestErr3 := http.Get(api3)
  32760. if requestErr3 != nil {
  32761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32762. return
  32763. }
  32764. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32765. if ioErr3 != nil {
  32766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32768. return
  32769. }
  32770. var respJSON3 map[string]interface{}
  32771. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32774. return
  32775. }
  32776. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32777. userJSONBytes3, _ := json.Marshal(respJSON3)
  32778. fmt.Println("log")
  32779. fmt.Println(string(userJSONBytes3))
  32780. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32781. utils.ErrorLog("解析失败:%v", err)
  32782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32783. return
  32784. }
  32785. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32786. if err == nil {
  32787. c.ServeSuccessJSON(map[string]interface{}{
  32788. "msg": "撤销明细成功",
  32789. })
  32790. return
  32791. } else {
  32792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32793. return
  32794. }
  32795. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32796. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32797. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32798. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32799. resp3, requestErr3 := http.Get(api3)
  32800. if requestErr3 != nil {
  32801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32802. return
  32803. }
  32804. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32805. if ioErr3 != nil {
  32806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32808. return
  32809. }
  32810. var respJSON3 map[string]interface{}
  32811. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32814. return
  32815. }
  32816. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32817. userJSONBytes3, _ := json.Marshal(respJSON3)
  32818. fmt.Println("log")
  32819. fmt.Println(string(userJSONBytes3))
  32820. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32821. utils.ErrorLog("解析失败:%v", err)
  32822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32823. return
  32824. }
  32825. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32826. if err == nil {
  32827. c.ServeSuccessJSON(map[string]interface{}{
  32828. "msg": "撤销明细成功",
  32829. })
  32830. return
  32831. } else {
  32832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32833. return
  32834. }
  32835. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32836. var resSix10265 ResultSix10265
  32837. var api3 string
  32838. if miConfig.MdtrtareaAdmvs == "320921" {
  32839. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32840. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32841. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32842. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32843. } else {
  32844. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32845. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32846. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32847. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32848. }
  32849. resp3, requestErr3 := http.Get(api3)
  32850. utils.ErrorLog("接口: %v", requestErr3)
  32851. if requestErr3 != nil {
  32852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32853. return
  32854. }
  32855. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32856. if ioErr3 != nil {
  32857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32859. return
  32860. }
  32861. var respJSON3 map[string]interface{}
  32862. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32865. return
  32866. }
  32867. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32868. userJSONBytes3, _ := json.Marshal(respJSON3)
  32869. fmt.Println("log")
  32870. fmt.Println(string(userJSONBytes3))
  32871. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32872. utils.ErrorLog("解析失败:%v", err)
  32873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32874. return
  32875. }
  32876. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32877. res2.Output = resSix10265.Output
  32878. res2.ErrMsg = resSix10265.ErrMsg
  32879. res2.Cainfo = resSix10265.Cainfo
  32880. res2.WarnMsg = resSix10265.WarnMsg
  32881. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32882. res2.Infcode = infocode
  32883. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32884. if err == nil {
  32885. c.ServeSuccessJSON(map[string]interface{}{
  32886. "msg": "撤销明细成功",
  32887. })
  32888. return
  32889. } else {
  32890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32891. return
  32892. }
  32893. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32894. var api3 string
  32895. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32896. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32897. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32898. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32899. resp3, requestErr3 := http.Get(api3)
  32900. utils.ErrorLog("接口: %v", requestErr3)
  32901. if requestErr3 != nil {
  32902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32903. return
  32904. }
  32905. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32906. if ioErr3 != nil {
  32907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32909. return
  32910. }
  32911. var respJSON3 map[string]interface{}
  32912. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32915. return
  32916. }
  32917. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32918. if status == "0" {
  32919. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32920. c.ServeSuccessJSON(map[string]interface{}{
  32921. "failed_code": -10,
  32922. "msg": err_msg,
  32923. })
  32924. return
  32925. }
  32926. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32927. userJSONBytes3, _ := json.Marshal(respJSON3)
  32928. fmt.Println("log")
  32929. fmt.Println(string(userJSONBytes3))
  32930. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32931. utils.ErrorLog("解析失败:%v", err)
  32932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32933. return
  32934. }
  32935. fmt.Println(res2.Infcode)
  32936. if res2.Infcode == -1 {
  32937. c.ServeSuccessJSON(map[string]interface{}{
  32938. "failed_code": -10,
  32939. "msg": res2.ErrMsg,
  32940. })
  32941. return
  32942. }
  32943. if res2.Infcode == 0 {
  32944. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32945. if err == nil {
  32946. c.ServeSuccessJSON(map[string]interface{}{
  32947. "msg": "撤销明细成功",
  32948. })
  32949. return
  32950. } else {
  32951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32952. return
  32953. }
  32954. } else {
  32955. c.ServeSuccessJSON(map[string]interface{}{
  32956. "failed_code": -10,
  32957. "msg": res2.ErrMsg,
  32958. })
  32959. }
  32960. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32961. if err == nil {
  32962. c.ServeSuccessJSON(map[string]interface{}{
  32963. "msg": "撤销明细成功",
  32964. })
  32965. return
  32966. } else {
  32967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32968. return
  32969. }
  32970. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32971. var api3 string
  32972. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32973. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32974. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32975. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32976. resp3, requestErr3 := http.Get(api3)
  32977. utils.ErrorLog("接口: %v", requestErr3)
  32978. if requestErr3 != nil {
  32979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32980. return
  32981. }
  32982. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32983. if ioErr3 != nil {
  32984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32986. return
  32987. }
  32988. var respJSON3 map[string]interface{}
  32989. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32992. return
  32993. }
  32994. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32995. if status == "0" {
  32996. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32997. c.ServeSuccessJSON(map[string]interface{}{
  32998. "failed_code": -10,
  32999. "msg": err_msg,
  33000. })
  33001. return
  33002. }
  33003. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33004. userJSONBytes3, _ := json.Marshal(respJSON3)
  33005. fmt.Println("log")
  33006. fmt.Println(string(userJSONBytes3))
  33007. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33008. utils.ErrorLog("解析失败:%v", err)
  33009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33010. return
  33011. }
  33012. fmt.Println(res2.Infcode)
  33013. if res2.Infcode == -1 {
  33014. c.ServeSuccessJSON(map[string]interface{}{
  33015. "failed_code": -10,
  33016. "msg": res2.ErrMsg,
  33017. })
  33018. return
  33019. }
  33020. if res2.Infcode == 0 {
  33021. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33022. if err == nil {
  33023. c.ServeSuccessJSON(map[string]interface{}{
  33024. "msg": "撤销明细成功",
  33025. })
  33026. return
  33027. } else {
  33028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33029. return
  33030. }
  33031. } else {
  33032. c.ServeSuccessJSON(map[string]interface{}{
  33033. "failed_code": -10,
  33034. "msg": res2.ErrMsg,
  33035. })
  33036. }
  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 == "150499" {
  33048. var resSix10265 ResultSix10265
  33049. new_chrg_bchno := order.Number
  33050. if adminUser.CurrentOrgId == 10265 {
  33051. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33052. new_chrg_bchno = "0000"
  33053. }
  33054. }
  33055. var api3 string
  33056. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33057. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33058. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33059. resp3, requestErr3 := http.Get(api3)
  33060. if requestErr3 != nil {
  33061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33062. return
  33063. }
  33064. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33065. if ioErr3 != nil {
  33066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33068. return
  33069. }
  33070. var respJSON3 map[string]interface{}
  33071. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33074. return
  33075. }
  33076. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33077. userJSONBytes3, _ := json.Marshal(respJSON3)
  33078. fmt.Println("log")
  33079. fmt.Println(string(userJSONBytes3))
  33080. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33081. utils.ErrorLog("解析失败:%v", err)
  33082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33083. return
  33084. }
  33085. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33086. res2.Output = resSix10265.Output
  33087. res2.ErrMsg = resSix10265.ErrMsg
  33088. res2.Cainfo = resSix10265.Cainfo
  33089. res2.WarnMsg = resSix10265.WarnMsg
  33090. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33091. res2.Infcode = infocode
  33092. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33093. if err == nil {
  33094. c.ServeSuccessJSON(map[string]interface{}{
  33095. "msg": "撤销明细成功",
  33096. })
  33097. return
  33098. } else {
  33099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33100. return
  33101. }
  33102. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33103. 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)
  33104. var dat map[string]interface{}
  33105. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33106. fmt.Println(dat)
  33107. } else {
  33108. fmt.Println(err)
  33109. }
  33110. saveLog(result2, src_request, "2205", "撤销明细")
  33111. userJSONBytes, _ := json.Marshal(dat)
  33112. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33113. utils.ErrorLog("解析失败:%v", err)
  33114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33115. return
  33116. }
  33117. if res2.Infcode == 0 {
  33118. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33119. if err == nil {
  33120. c.ServeSuccessJSON(map[string]interface{}{
  33121. "msg": "撤销明细成功",
  33122. })
  33123. return
  33124. } else {
  33125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33126. return
  33127. }
  33128. } else {
  33129. c.ServeSuccessJSON(map[string]interface{}{
  33130. "failed_code": -10,
  33131. "msg": res2.ErrMsg,
  33132. })
  33133. }
  33134. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33135. 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, "")
  33136. var dat map[string]interface{}
  33137. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33138. fmt.Println(dat)
  33139. } else {
  33140. fmt.Println(err)
  33141. }
  33142. saveLog(result2, src_request, "2205", "撤销明细")
  33143. userJSONBytes, _ := json.Marshal(dat)
  33144. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33145. utils.ErrorLog("解析失败:%v", err)
  33146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33147. return
  33148. }
  33149. if res2.Infcode == 0 {
  33150. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33151. if err == nil {
  33152. c.ServeSuccessJSON(map[string]interface{}{
  33153. "msg": "撤销明细成功",
  33154. })
  33155. return
  33156. } else {
  33157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33158. return
  33159. }
  33160. } else {
  33161. c.ServeSuccessJSON(map[string]interface{}{
  33162. "failed_code": -10,
  33163. "msg": res2.ErrMsg,
  33164. })
  33165. }
  33166. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33167. 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, "")
  33168. var dat map[string]interface{}
  33169. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33170. fmt.Println(dat)
  33171. } else {
  33172. fmt.Println(err)
  33173. }
  33174. saveLog(result2, src_request, "2205", "撤销明细")
  33175. userJSONBytes, _ := json.Marshal(dat)
  33176. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33177. utils.ErrorLog("解析失败:%v", err)
  33178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33179. return
  33180. }
  33181. if res2.Infcode == 0 {
  33182. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33183. if err == nil {
  33184. c.ServeSuccessJSON(map[string]interface{}{
  33185. "msg": "撤销明细成功",
  33186. })
  33187. return
  33188. } else {
  33189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33190. return
  33191. }
  33192. } else {
  33193. c.ServeSuccessJSON(map[string]interface{}{
  33194. "failed_code": -10,
  33195. "msg": res2.ErrMsg,
  33196. })
  33197. }
  33198. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33199. 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, "")
  33200. var dat map[string]interface{}
  33201. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33202. fmt.Println(dat)
  33203. } else {
  33204. fmt.Println(err)
  33205. }
  33206. saveLog(result2, src_request, "2205", "撤销明细")
  33207. userJSONBytes, _ := json.Marshal(dat)
  33208. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33209. utils.ErrorLog("解析失败:%v", err)
  33210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33211. return
  33212. }
  33213. if res2.Infcode == 0 {
  33214. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33215. if err == nil {
  33216. c.ServeSuccessJSON(map[string]interface{}{
  33217. "msg": "撤销明细成功",
  33218. })
  33219. return
  33220. } else {
  33221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33222. return
  33223. }
  33224. } else {
  33225. c.ServeSuccessJSON(map[string]interface{}{
  33226. "failed_code": -10,
  33227. "msg": res2.ErrMsg,
  33228. })
  33229. }
  33230. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33231. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33232. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33233. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33234. resp2, requestErr2 := http.Get(api2)
  33235. if requestErr2 != nil {
  33236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33237. return
  33238. }
  33239. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33240. if ioErr2 != nil {
  33241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33243. return
  33244. }
  33245. var respJSON2 map[string]interface{}
  33246. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33249. return
  33250. }
  33251. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33252. userJSONBytes3, _ := json.Marshal(respJSON2)
  33253. fmt.Println("log")
  33254. fmt.Println(string(userJSONBytes3))
  33255. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33256. utils.ErrorLog("解析失败:%v", err)
  33257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33258. return
  33259. }
  33260. if res2.Infcode == 0 {
  33261. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33262. if err == nil {
  33263. c.ServeSuccessJSON(map[string]interface{}{
  33264. "msg": "撤销明细成功",
  33265. })
  33266. return
  33267. } else {
  33268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33269. return
  33270. }
  33271. } else {
  33272. c.ServeSuccessJSON(map[string]interface{}{
  33273. "failed_code": -10,
  33274. "msg": res2.ErrMsg,
  33275. })
  33276. }
  33277. } else {
  33278. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33279. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33280. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33281. resp2, requestErr2 := http.Get(api2)
  33282. if requestErr2 != nil {
  33283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33284. return
  33285. }
  33286. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33287. if ioErr2 != nil {
  33288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33290. return
  33291. }
  33292. var respJSON2 map[string]interface{}
  33293. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33296. return
  33297. }
  33298. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33299. userJSONBytes3, _ := json.Marshal(respJSON2)
  33300. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33301. utils.ErrorLog("解析失败:%v", err)
  33302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33303. return
  33304. }
  33305. if res2.Infcode == -1 {
  33306. c.ServeSuccessJSON(map[string]interface{}{
  33307. "failed_code": -10,
  33308. "msg": res2.ErrMsg,
  33309. })
  33310. return
  33311. } else {
  33312. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33313. if err == nil {
  33314. c.ServeSuccessJSON(map[string]interface{}{
  33315. "msg": "撤销明细成功",
  33316. })
  33317. return
  33318. } else {
  33319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33320. return
  33321. }
  33322. }
  33323. }
  33324. } else {
  33325. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33326. if err == nil {
  33327. c.ServeSuccessJSON(map[string]interface{}{
  33328. "msg": "退费成功",
  33329. })
  33330. } else {
  33331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33332. return
  33333. }
  33334. }
  33335. }
  33336. // 对账
  33337. func (c *HisApiController) GetCheckAccount() {
  33338. start_time := c.GetString("start_time")
  33339. end_time := c.GetString("end_time")
  33340. insutype := c.GetString("insutype")
  33341. clr_type := c.GetString("clr_type")
  33342. clr_org := c.GetString("clr_optins")
  33343. admin_user_id, _ := c.GetInt64("admin_user_id")
  33344. adminUser := c.GetAdminUserInfo()
  33345. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33346. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33347. if len(clr_org) == 0 {
  33348. clr_org = miConfig.InsuplcAdmdvs
  33349. }
  33350. timeLayout := "2006-01-02"
  33351. loc, _ := time.LoadLocation("Local")
  33352. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33353. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33354. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33355. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33356. fixmedins_setl_cnt := int64(len(orders))
  33357. var medfee_sumamt float64
  33358. var acct_pay float64
  33359. var fund_pay_sumamt float64
  33360. for _, item := range orders {
  33361. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33362. acct_pay = acct_pay + item.AcctPay
  33363. if miConfig.MdtrtareaAdmvs == "361025" {
  33364. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  33365. } else {
  33366. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33367. }
  33368. }
  33369. var user_name string
  33370. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33371. if role.ID == 0 {
  33372. user_name = "xxx"
  33373. } else {
  33374. user_name = role.UserName
  33375. }
  33376. var res ResultEight
  33377. var res10188 ResultEightFor10188
  33378. if config.IsOpen == 1 {
  33379. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33380. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33381. "insutype=" + insutype +
  33382. "&clr_type=" + clr_type +
  33383. "&setl_optins=" + clr_org +
  33384. "&stmt_begndate=" + start_time +
  33385. "&stm_enddate=" + end_time +
  33386. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33387. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33388. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33389. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33390. "&fixmedins_code=" + miConfig.Code +
  33391. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33392. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33393. "&secret_key=" + miConfig.SecretKey +
  33394. "&org_name=" + miConfig.OrgName +
  33395. "&doctor=" + user_name +
  33396. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33397. fmt.Println(api)
  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. fmt.Println(body)
  33405. if ioErr != nil {
  33406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33408. return
  33409. }
  33410. var respJSON map[string]interface{}
  33411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33414. return
  33415. }
  33416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33417. userJSONBytes, _ := json.Marshal(respJSON)
  33418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33419. utils.ErrorLog("解析失败:%v", err)
  33420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33421. return
  33422. }
  33423. res.InfRefmsgid = res10188.InfRefmsgid
  33424. res.Output = res10188.Output
  33425. res.ErrMsg = res10188.ErrMsg
  33426. res.Cainfo = res10188.Cainfo
  33427. res.WarnMsg = res10188.WarnMsg
  33428. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33429. res.Infcode = infocode
  33430. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33431. if clr_type != "9903" {
  33432. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33433. }
  33434. if clr_type == "9903" {
  33435. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33436. }
  33437. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33438. "insutype=" + insutype +
  33439. "&clr_type=" + clr_type +
  33440. "&setl_optins=" + clr_org +
  33441. "&stmt_begndate=" + start_time +
  33442. "&stm_enddate=" + end_time +
  33443. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33444. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33445. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33446. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33447. "&fixmedins_code=" + miConfig.Code +
  33448. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33449. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33450. "&secret_key=" + miConfig.SecretKey +
  33451. "&org_name=" + miConfig.OrgName +
  33452. "&doctor=" + user_name
  33453. resp, requestErr := http.Get(api)
  33454. if requestErr != nil {
  33455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33456. return
  33457. }
  33458. body, ioErr := ioutil.ReadAll(resp.Body)
  33459. if ioErr != nil {
  33460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33462. return
  33463. }
  33464. var respJSON map[string]interface{}
  33465. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33468. return
  33469. }
  33470. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33471. result, _ := json.Marshal(respJSON)
  33472. fmt.Println("log")
  33473. fmt.Println(string(result))
  33474. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33475. utils.ErrorLog("解析失败:%v", err)
  33476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33477. return
  33478. }
  33479. res.InfRefmsgid = res10188.InfRefmsgid
  33480. res.Output = res10188.Output
  33481. res.ErrMsg = res10188.ErrMsg
  33482. res.Cainfo = res10188.Cainfo
  33483. res.WarnMsg = res10188.WarnMsg
  33484. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33485. res.Infcode = infocode
  33486. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33487. var baseParams models.BaseParams
  33488. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33489. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33490. baseParams.SecretKey = miConfig.SecretKey
  33491. baseParams.OrgName = miConfig.OrgName
  33492. baseParams.FixmedinsCode = miConfig.Code
  33493. baseParams.EncKey = miConfig.EncKey
  33494. baseParams.AppSecret = miConfig.AppSecret
  33495. baseParams.SignKey = miConfig.SignKey
  33496. baseParams.AppID = miConfig.Code
  33497. baseParams.Doctor = role.UserName
  33498. baseParams.RequestUrl = miConfig.Url
  33499. businessParams := models.BusinessParams{
  33500. Insutype: insutype,
  33501. ClrType: clr_type,
  33502. SetlOptins: clr_org,
  33503. StmtBegndate: start_time,
  33504. StmtEnddate: end_time,
  33505. MedfeeSumamt: medfee_sumamt,
  33506. FundPaySumamt: fund_pay_sumamt,
  33507. AcctPay: acct_pay,
  33508. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33509. }
  33510. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33511. fmt.Println(requestLog)
  33512. fmt.Println(result)
  33513. fmt.Println(err_msg)
  33514. var dat map[string]interface{}
  33515. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33516. fmt.Println(dat)
  33517. } else {
  33518. fmt.Println(err)
  33519. }
  33520. userJSONBytes, _ := json.Marshal(dat)
  33521. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33522. utils.ErrorLog("解析失败:%v", err)
  33523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33524. return
  33525. }
  33526. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33527. var baseParams models.BaseParams
  33528. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33529. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33530. baseParams.SecretKey = miConfig.SecretKey
  33531. baseParams.OrgName = miConfig.OrgName
  33532. baseParams.FixmedinsCode = miConfig.Code
  33533. baseParams.EncKey = miConfig.EncKey
  33534. baseParams.AppSecret = miConfig.AppSecret
  33535. baseParams.SignKey = miConfig.SignKey
  33536. baseParams.AppID = miConfig.Code
  33537. baseParams.Doctor = role.UserName
  33538. baseParams.RequestUrl = miConfig.Url
  33539. baseParams.AccessKey = miConfig.AccessKey
  33540. businessParams := models.BusinessParams{
  33541. Insutype: insutype,
  33542. ClrType: clr_type,
  33543. SetlOptins: "430822",
  33544. StmtBegndate: start_time,
  33545. StmtEnddate: end_time,
  33546. MedfeeSumamt: medfee_sumamt,
  33547. FundPaySumamt: fund_pay_sumamt,
  33548. AcctPay: acct_pay,
  33549. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33550. }
  33551. 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)
  33552. fmt.Println(requestLog)
  33553. fmt.Println(result)
  33554. var dat map[string]interface{}
  33555. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33556. fmt.Println(dat)
  33557. } else {
  33558. fmt.Println(err)
  33559. }
  33560. userJSONBytes, _ := json.Marshal(dat)
  33561. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33562. utils.ErrorLog("解析失败:%v", err)
  33563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33564. return
  33565. }
  33566. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33567. var baseParams models.BaseParams
  33568. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33569. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33570. baseParams.SecretKey = miConfig.SecretKey
  33571. baseParams.OrgName = miConfig.OrgName
  33572. baseParams.FixmedinsCode = miConfig.Code
  33573. baseParams.EncKey = miConfig.EncKey
  33574. baseParams.AppSecret = miConfig.AppSecret
  33575. baseParams.SignKey = miConfig.SignKey
  33576. baseParams.AppID = miConfig.Code
  33577. baseParams.Doctor = role.UserName
  33578. baseParams.RequestUrl = miConfig.Url
  33579. businessParams := models.BusinessParams{
  33580. Insutype: insutype,
  33581. ClrType: clr_type,
  33582. SetlOptins: clr_org,
  33583. StmtBegndate: start_time,
  33584. StmtEnddate: end_time,
  33585. MedfeeSumamt: medfee_sumamt,
  33586. FundPaySumamt: fund_pay_sumamt,
  33587. AcctPay: acct_pay,
  33588. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33589. }
  33590. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33591. fmt.Println(requestLog)
  33592. fmt.Println(result)
  33593. fmt.Println(err_msg)
  33594. var dat map[string]interface{}
  33595. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33596. fmt.Println(dat)
  33597. } else {
  33598. fmt.Println(err)
  33599. }
  33600. userJSONBytes, _ := json.Marshal(dat)
  33601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33602. utils.ErrorLog("解析失败:%v", err)
  33603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33604. return
  33605. }
  33606. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33607. if len(clr_type) == 0 {
  33608. clr_type = "11"
  33609. }
  33610. api := miConfig.Url + "gdyb/ten?" +
  33611. "insutype=" + insutype +
  33612. "&clr_type=" + clr_type +
  33613. "&setl_optins=" + clr_org +
  33614. "&stmt_begndate=" + start_time +
  33615. "&stm_enddate=" + end_time +
  33616. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33617. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33618. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33619. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33620. "&fixmedins_code=" + miConfig.Code +
  33621. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33622. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33623. "&secret_key=" + miConfig.SecretKey +
  33624. "&org_name=" + miConfig.OrgName +
  33625. "&doctor=" + user_name
  33626. fmt.Println(api)
  33627. resp, requestErr := http.Get(api)
  33628. if requestErr != nil {
  33629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33630. return
  33631. }
  33632. body, ioErr := ioutil.ReadAll(resp.Body)
  33633. fmt.Println(body)
  33634. if ioErr != nil {
  33635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33637. return
  33638. }
  33639. var respJSON map[string]interface{}
  33640. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33643. return
  33644. }
  33645. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33646. userJSONBytes, _ := json.Marshal(respJSON)
  33647. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33648. utils.ErrorLog("解析失败:%v", err)
  33649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33650. return
  33651. }
  33652. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33653. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33654. //fixmedins_setl_cnt := int64(len(orders_two))
  33655. //var medfee_sumamt float64
  33656. //var acct_pay float64
  33657. //var fund_pay_sumamt float64
  33658. //for _, item := range orders_two {
  33659. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33660. // acct_pay = acct_pay + item.AcctPay
  33661. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33662. //}
  33663. var baseParams models.BaseParams
  33664. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33665. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33666. baseParams.SecretKey = miConfig.SecretKey
  33667. baseParams.OrgName = miConfig.OrgName
  33668. baseParams.FixmedinsCode = miConfig.Code
  33669. baseParams.EncKey = miConfig.EncKey
  33670. baseParams.AppSecret = miConfig.AppSecret
  33671. baseParams.SignKey = miConfig.SignKey
  33672. baseParams.AppID = miConfig.Code
  33673. baseParams.Doctor = role.UserName
  33674. baseParams.RequestUrl = miConfig.Url
  33675. if clr_type == "9903" {
  33676. clr_type = "9994"
  33677. }
  33678. businessParams := models.BusinessParams{
  33679. Insutype: insutype,
  33680. ClrType: clr_type,
  33681. SetlOptins: "360302",
  33682. StmtBegndate: start_time,
  33683. StmtEnddate: end_time,
  33684. MedfeeSumamt: 0,
  33685. FundPaySumamt: 0,
  33686. AcctPay: 0,
  33687. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33688. }
  33689. 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))
  33690. fmt.Println(requestLog)
  33691. fmt.Println(result)
  33692. var dat map[string]interface{}
  33693. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33694. fmt.Println(dat)
  33695. } else {
  33696. fmt.Println(err)
  33697. }
  33698. userJSONBytes, _ := json.Marshal(dat)
  33699. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33700. utils.ErrorLog("解析失败:%v", err)
  33701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33702. return
  33703. }
  33704. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33705. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33706. //fixmedins_setl_cnt := int64(len(orders_two))
  33707. //var medfee_sumamt float64
  33708. //var acct_pay float64
  33709. //var fund_pay_sumamt float64
  33710. //for _, item := range orders_two {
  33711. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33712. // acct_pay = acct_pay + item.AcctPay
  33713. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33714. //}
  33715. var baseParams models.BaseParams
  33716. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33717. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33718. baseParams.SecretKey = miConfig.SecretKey
  33719. baseParams.OrgName = miConfig.OrgName
  33720. baseParams.FixmedinsCode = miConfig.Code
  33721. baseParams.EncKey = miConfig.EncKey
  33722. baseParams.AppSecret = miConfig.AppSecret
  33723. baseParams.SignKey = miConfig.SignKey
  33724. baseParams.AppID = miConfig.Code
  33725. baseParams.Doctor = role.UserName
  33726. baseParams.RequestUrl = miConfig.Url
  33727. if clr_type == "9903" {
  33728. clr_type = "9994"
  33729. }
  33730. businessParams := models.BusinessParams{
  33731. Insutype: insutype,
  33732. ClrType: clr_type,
  33733. SetlOptins: "361025",
  33734. StmtBegndate: start_time,
  33735. StmtEnddate: end_time,
  33736. MedfeeSumamt: 0,
  33737. FundPaySumamt: 0,
  33738. AcctPay: 0,
  33739. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33740. }
  33741. 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))
  33742. fmt.Println(requestLog)
  33743. fmt.Println(result)
  33744. var dat map[string]interface{}
  33745. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33746. fmt.Println(dat)
  33747. } else {
  33748. fmt.Println(err)
  33749. }
  33750. userJSONBytes, _ := json.Marshal(dat)
  33751. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33752. utils.ErrorLog("解析失败:%v", err)
  33753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33754. return
  33755. }
  33756. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33757. var api string
  33758. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33759. "&clr_type=" + clr_type +
  33760. "&setl_optins=" + clr_org +
  33761. "&stmt_begndate=" + start_time +
  33762. "&stm_enddate=" + end_time +
  33763. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33764. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33765. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33766. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33767. "&fixmedins_code=" + miConfig.Code +
  33768. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33769. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33770. "&secret_key=" + miConfig.SecretKey +
  33771. "&org_name=" + miConfig.OrgName +
  33772. "&doctor=" + user_name + "&url=" + miConfig.Url
  33773. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33774. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33775. resp, requestErr := http.Get(api)
  33776. if requestErr != nil {
  33777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33778. return
  33779. }
  33780. body, ioErr := ioutil.ReadAll(resp.Body)
  33781. if ioErr != nil {
  33782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33784. return
  33785. }
  33786. var respJSON map[string]interface{}
  33787. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33790. return
  33791. }
  33792. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33793. if status == "0" {
  33794. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33795. c.ServeSuccessJSON(map[string]interface{}{
  33796. "failed_code": -10,
  33797. "msg": err_msg,
  33798. })
  33799. return
  33800. }
  33801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33802. userJSONBytes, _ := json.Marshal(respJSON)
  33803. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33804. utils.ErrorLog("解析失败:%v", err)
  33805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33806. return
  33807. }
  33808. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33809. var api string
  33810. api = miConfig.SecretKey + "ahyb/3201?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+int64(len(orders_two)*2), 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 + "&url=" + miConfig.Url
  33825. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33826. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33827. resp, requestErr := http.Get(api)
  33828. if requestErr != nil {
  33829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33830. return
  33831. }
  33832. body, ioErr := ioutil.ReadAll(resp.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. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33845. if status == "0" {
  33846. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33847. c.ServeSuccessJSON(map[string]interface{}{
  33848. "failed_code": -10,
  33849. "msg": err_msg,
  33850. })
  33851. return
  33852. }
  33853. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33854. userJSONBytes, _ := json.Marshal(respJSON)
  33855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33856. utils.ErrorLog("解析失败:%v", err)
  33857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33858. return
  33859. }
  33860. } else {
  33861. if len(clr_type) == 0 {
  33862. clr_type = "11"
  33863. }
  33864. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33865. "insutype=" + insutype +
  33866. "&clr_type=" + clr_type +
  33867. "&setl_optins=" + clr_org +
  33868. "&stmt_begndate=" + start_time +
  33869. "&stm_enddate=" + end_time +
  33870. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33871. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33872. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33873. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33874. "&fixmedins_code=" + miConfig.Code +
  33875. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33876. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33877. "&secret_key=" + miConfig.SecretKey +
  33878. "&org_name=" + miConfig.OrgName +
  33879. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33880. fmt.Println(api)
  33881. resp, requestErr := http.Get(api)
  33882. if requestErr != nil {
  33883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33884. return
  33885. }
  33886. body, ioErr := ioutil.ReadAll(resp.Body)
  33887. fmt.Println(body)
  33888. if ioErr != nil {
  33889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33891. return
  33892. }
  33893. var respJSON map[string]interface{}
  33894. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33897. return
  33898. }
  33899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33900. userJSONBytes, _ := json.Marshal(respJSON)
  33901. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33902. utils.ErrorLog("解析失败:%v", err)
  33903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33904. return
  33905. }
  33906. }
  33907. if res.Infcode == 0 {
  33908. if res.Output.Stmtinfo.StmtRslt == "0" {
  33909. micc := &models.MedicalInsuranceCostCompare{
  33910. StartTime: startime.Unix(),
  33911. EndTime: endtime.Unix(),
  33912. Insutype: insutype,
  33913. CheckType: 1,
  33914. Num: fixmedins_setl_cnt,
  33915. Mtime: time.Now().Unix(),
  33916. Status: 1,
  33917. UserOrgId: adminUser.CurrentOrgId,
  33918. CostTotal: medfee_sumamt,
  33919. FuncTotal: fund_pay_sumamt,
  33920. PsnPay: acct_pay,
  33921. Creator: admin_user_id,
  33922. Ctime: time.Now().Unix(),
  33923. ClrType: clr_type,
  33924. }
  33925. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33926. if err == nil {
  33927. c.ServeSuccessJSON(map[string]interface{}{
  33928. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33929. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33930. })
  33931. } else {
  33932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33933. }
  33934. } else {
  33935. c.ServeSuccessJSON(map[string]interface{}{
  33936. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33937. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33938. })
  33939. }
  33940. } else {
  33941. c.ServeSuccessJSON(map[string]interface{}{
  33942. "failed_code": -10,
  33943. "msg": res.ErrMsg,
  33944. })
  33945. }
  33946. }
  33947. }
  33948. func (c *HisApiController) Check310() {
  33949. adminUser := c.GetAdminUserInfo()
  33950. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33951. var user_name string
  33952. user_name = "高慧裕"
  33953. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33954. "insutype=" + "310" +
  33955. "&clr_type=" + "" +
  33956. "&setl_optins=" + "441202" +
  33957. "&stmt_begndate=" + "2022-03-01" +
  33958. "&stm_enddate=" + "2022-03-31" +
  33959. "&medfee_sumamt=" + "194930.12" +
  33960. "&fund_pay_sumamt=" + "188741.46" +
  33961. "&acct_pay=" + "0" +
  33962. "&fixmedins_setl_cnt=" + "452" +
  33963. "&fixmedins_code=" + miConfig.Code +
  33964. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33965. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33966. "&secret_key=" + miConfig.SecretKey +
  33967. "&org_name=" + miConfig.OrgName +
  33968. "&doctor=" + user_name
  33969. fmt.Println(api)
  33970. resp, requestErr := http.Get(api)
  33971. if requestErr != nil {
  33972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33973. return
  33974. }
  33975. body, ioErr := ioutil.ReadAll(resp.Body)
  33976. fmt.Println(body)
  33977. if ioErr != nil {
  33978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33980. return
  33981. }
  33982. var respJSON map[string]interface{}
  33983. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33986. return
  33987. }
  33988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33989. userJSONBytes, _ := json.Marshal(respJSON)
  33990. var res ResultEight
  33991. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33992. utils.ErrorLog("解析失败:%v", err)
  33993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33994. return
  33995. }
  33996. }
  33997. func (c *HisApiController) Check390() {
  33998. adminUser := c.GetAdminUserInfo()
  33999. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34000. var user_name string
  34001. user_name = "高慧裕"
  34002. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34003. "insutype=" + "390" +
  34004. "&clr_type=" + "" +
  34005. "&setl_optins=" + "441202" +
  34006. "&stmt_begndate=" + "2022-03-01" +
  34007. "&stm_enddate=" + "2022-03-31" +
  34008. "&medfee_sumamt=" + "1068448.89" +
  34009. "&fund_pay_sumamt=" + "1014677.62" +
  34010. "&acct_pay=" + "0" +
  34011. "&fixmedins_setl_cnt=" + "1950" +
  34012. "&fixmedins_code=" + miConfig.Code +
  34013. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34014. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34015. "&secret_key=" + miConfig.SecretKey +
  34016. "&org_name=" + miConfig.OrgName +
  34017. "&doctor=" + user_name
  34018. fmt.Println(api)
  34019. resp, requestErr := http.Get(api)
  34020. if requestErr != nil {
  34021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34022. return
  34023. }
  34024. body, ioErr := ioutil.ReadAll(resp.Body)
  34025. fmt.Println(body)
  34026. if ioErr != nil {
  34027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34029. return
  34030. }
  34031. var respJSON map[string]interface{}
  34032. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34035. return
  34036. }
  34037. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34038. userJSONBytes, _ := json.Marshal(respJSON)
  34039. var res ResultEight
  34040. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34041. utils.ErrorLog("解析失败:%v", err)
  34042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34043. return
  34044. }
  34045. }
  34046. // 对账明细
  34047. func (c *HisApiController) GetCheckDetailAccount() {
  34048. start_time := c.GetString("start_time")
  34049. end_time := c.GetString("end_time")
  34050. admin_user_id, _ := c.GetInt64("admin_user_id")
  34051. adminUser := c.GetAdminUserInfo()
  34052. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34053. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34054. timeLayout := "2006-01-02"
  34055. loc, _ := time.LoadLocation("Local")
  34056. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34057. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34058. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34059. rand.Seed(time.Now().UnixNano())
  34060. num := rand.Intn(30000)
  34061. Mkdir(miConfig.OrgName)
  34062. file := strconv.FormatInt(int64(num), 10)
  34063. file_name := file + ".txt"
  34064. zip_name := file + ".zip"
  34065. zip_path := miConfig.OrgName + "/" + zip_name
  34066. file_path := miConfig.OrgName + "/" + file_name
  34067. decimal.DivisionPrecision = 2
  34068. var medfee_sumamt float64
  34069. var psn_cash_pay float64
  34070. var fund_pay_sumamt float64
  34071. fixmedins_setl_cnt := int64(len(orders))
  34072. for _, item := range orders {
  34073. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34074. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  34075. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34076. }
  34077. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  34078. defer f.Close()
  34079. if err != nil {
  34080. fmt.Println(err.Error())
  34081. } else {
  34082. for _, item := range orders {
  34083. var refd_setl_flag string
  34084. if item.OrderStatus == 2 {
  34085. refd_setl_flag = "0"
  34086. var str string
  34087. str = item.SetlId + " " +
  34088. item.MdtrtId + " " +
  34089. item.PsnNo + " " +
  34090. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34091. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34092. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  34093. _, err = f.Write([]byte(str))
  34094. }
  34095. if item.OrderStatus == 3 {
  34096. var str string
  34097. str = item.SetlId + " " +
  34098. item.MdtrtId + " " +
  34099. item.PsnNo + " " +
  34100. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34101. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34102. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  34103. _, err = f.Write([]byte(str))
  34104. var str2 string
  34105. str2 = item.SetlId + " " +
  34106. item.MdtrtId + " " +
  34107. item.PsnNo + " " +
  34108. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  34109. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  34110. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  34111. _, err = f.Write([]byte(str2))
  34112. }
  34113. }
  34114. }
  34115. Zip(file_path, zip_path)
  34116. fmt.Println(ReadFile(zip_path))
  34117. fmt.Println(string(ReadFile(zip_path)))
  34118. if config.IsOpen == 1 {
  34119. var user_name string
  34120. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34121. if role.ID == 0 {
  34122. user_name = "管理员"
  34123. } else {
  34124. user_name = role.UserName
  34125. }
  34126. baseParams := models.BaseParams{
  34127. SecretKey: miConfig.SecretKey,
  34128. FixmedinsCode: miConfig.Code,
  34129. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34130. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34131. OrgName: miConfig.OrgName,
  34132. Doctor: user_name,
  34133. }
  34134. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  34135. var dat map[string]interface{}
  34136. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34137. fmt.Println(dat)
  34138. } else {
  34139. fmt.Println(err)
  34140. }
  34141. userJSONBytes, _ := json.Marshal(dat)
  34142. var res ResultNine
  34143. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34144. utils.ErrorLog("解析失败:%v", err)
  34145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34146. return
  34147. }
  34148. if res.Infcode == 0 {
  34149. fileNo := res.Output.FileQuryNo
  34150. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34151. "file_qury_no=" + fileNo +
  34152. "&setl_optins=" + "定点医保中心" +
  34153. "&stmt_begndate=" + start_time +
  34154. "&stm_enddate=" + end_time +
  34155. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34156. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34157. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34158. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34159. "&fixmedins_code=" + miConfig.Code +
  34160. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34161. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34162. "&secret_key=" + miConfig.SecretKey +
  34163. "&org_name=" + miConfig.OrgName +
  34164. "&doctor=" + user_name
  34165. resp, requestErr := http.Get(api)
  34166. if requestErr != nil {
  34167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34168. return
  34169. }
  34170. body, ioErr := ioutil.ReadAll(resp.Body)
  34171. if ioErr != nil {
  34172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34174. return
  34175. }
  34176. var respJSON map[string]interface{}
  34177. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34180. return
  34181. }
  34182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34183. userJSONBytes, _ := json.Marshal(respJSON)
  34184. var res ResultTen
  34185. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34186. utils.ErrorLog("解析失败:%v", err)
  34187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34188. return
  34189. }
  34190. if res.Infcode == 0 {
  34191. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34192. micc := &models.MedicalInsuranceCostCompare{
  34193. StartTime: startime.Unix(),
  34194. EndTime: endtime.Unix(),
  34195. Insutype: "0",
  34196. CheckType: 2,
  34197. Num: fixmedins_setl_cnt,
  34198. Mtime: time.Now().Unix(),
  34199. Status: 1,
  34200. UserOrgId: adminUser.CurrentOrgId,
  34201. CostTotal: medfee_sumamt,
  34202. FuncTotal: fund_pay_sumamt,
  34203. PsnPay: psn_cash_pay,
  34204. Creator: admin_user_id,
  34205. Ctime: time.Now().Unix(),
  34206. }
  34207. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34208. c.ServeSuccessJSON(map[string]interface{}{
  34209. "msg": "明细对账成功",
  34210. })
  34211. }
  34212. } else {
  34213. }
  34214. }
  34215. }
  34216. type CustomOrderInfo struct {
  34217. Name string
  34218. Spec string
  34219. Unit string
  34220. Count float64
  34221. Price float64
  34222. Total float64
  34223. }
  34224. func (c *HisApiController) GetBatchSettleAccounts() {
  34225. admin_user_id, _ := c.GetInt64("admin_user_id")
  34226. order_ids := c.GetString("order_ids")
  34227. order_ids_arr := strings.Split(order_ids, ",")
  34228. data3 := []map[string]interface{}{}
  34229. for _, item := range order_ids_arr {
  34230. id, _ := strconv.ParseInt(item, 10, 64)
  34231. order_id := id
  34232. adminUser := c.GetAdminUserInfo()
  34233. order, _ := service.GetHisOrderByID(order_id)
  34234. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34235. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34236. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34237. orderInfos = append(orderInfos, orderInfos_two...)
  34238. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34239. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34240. var diagnosis_ids []string
  34241. if his.ID > 0 {
  34242. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34243. } else {
  34244. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34245. }
  34246. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34247. var dia_config []*models.HisXtDiagnoseConfig
  34248. var name string
  34249. for _, item := range diagnosis_ids {
  34250. id, _ := strconv.ParseInt(item, 10, 64)
  34251. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34252. dia_config = append(dia_config, &diagnosisConfig)
  34253. if len(name) == 0 {
  34254. name = diagnosisConfig.ClassName
  34255. }
  34256. //} else {
  34257. // name = name + "," + diagnosisConfig.ClassName
  34258. //}
  34259. }
  34260. var bedCostTotal float64 = 0 //床位总费
  34261. var bedCostSelfTotal float64 = 0 //床位自费
  34262. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34263. var bedSelfTotal float64 = 0 //床位部分项目自费
  34264. var bedInscpTotal float64 = 0 //床位部分项目自费
  34265. var operationCostTotal float64 = 0 //手术费
  34266. var operationCostSelfTotal float64 = 0 //手术费
  34267. var operationCostPartSelfTotal float64 = 0 //手术费
  34268. var operationSelfTotal float64 = 0 //床位部分项目自费
  34269. var operationInscpTotal float64 = 0 //床位部分项目自费
  34270. var otherCostTotal float64 = 0 //其他费用
  34271. var otherCostSelfTotal float64 = 0 //其他费用
  34272. var otherCostPartSelfTotal float64 = 0 //其他费用
  34273. var otherSelfTotal float64 = 0 //床位部分项目自费
  34274. var otherInscpTotal float64 = 0 //床位部分项目自费
  34275. var materialCostTotal float64 = 0 //材料费
  34276. var materialCostSelfTotal float64 = 0 //材料费
  34277. var materialCostPartSelfTotal float64 = 0 //材料费
  34278. var materialSelfTotal float64 = 0 //床位部分项目自费
  34279. var materialInscpTotal float64 = 0 //床位部分项目自费
  34280. var westernMedicineCostTotal float64 = 0 //西药费
  34281. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34282. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34283. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34284. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34285. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34286. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34287. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34288. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34289. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34290. var checkCostTotal float64 = 0 //检查费
  34291. var checkCostSelfTotal float64 = 0 //检查费
  34292. var checkCostPartSelfTotal float64 = 0 //检查费
  34293. var checkSelfTotal float64 = 0 //床位部分项目自费
  34294. var checkInscpTotal float64 = 0 //床位部分项目自费
  34295. var laboratoryCostTotal float64 = 0 //化验费
  34296. var laboratoryCostSelfTotal float64 = 0 //化验费
  34297. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34298. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34299. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34300. var treatCostTotal float64 = 0 //治疗费用
  34301. var treatCostSelfTotal float64 = 0 //治疗费用
  34302. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34303. var treatSelfTotal float64 = 0 //床位部分项目自费
  34304. var treatInscpTotal float64 = 0 //床位部分项目自费
  34305. decimal.DivisionPrecision = 2
  34306. for _, item := range orderInfos {
  34307. if item.MedChrgitmType == "01" { //床位费
  34308. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34309. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34310. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34311. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34312. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34313. }
  34314. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34315. if item.MedChrgitmType == "03" { //检查费
  34316. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34317. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34318. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34319. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34320. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34321. }
  34322. } else {
  34323. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34324. fmt.Println("------------")
  34325. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34326. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34327. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34328. }
  34329. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34330. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34331. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34332. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34333. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34334. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34335. }
  34336. }
  34337. if item.MedChrgitmType == "04" { //化验费
  34338. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34339. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34340. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34341. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34342. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34343. }
  34344. if item.MedChrgitmType == "05" { //治疗费
  34345. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34346. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34347. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34348. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34349. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34350. }
  34351. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34352. fmt.Println("------------")
  34353. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34354. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34355. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34356. }
  34357. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34358. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34359. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34360. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34361. }
  34362. //if item.MedChrgitmType == "06" { //手术费
  34363. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34364. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34365. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34366. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34367. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34368. //
  34369. //}
  34370. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34371. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34372. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34373. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34374. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34375. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34376. }
  34377. if item.MedChrgitmType == "09" { //西药费
  34378. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34379. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34380. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34381. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34382. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34383. }
  34384. if item.MedChrgitmType == "11" { //中成费
  34385. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34386. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34387. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34388. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34389. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34390. }
  34391. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34392. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34393. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34394. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34395. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34396. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34397. }
  34398. }
  34399. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34400. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34401. var user_name string
  34402. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34403. if role.ID == 0 {
  34404. user_name = "管理员"
  34405. } else {
  34406. user_name = role.UserName
  34407. }
  34408. baseParams := models.BaseParams{
  34409. SecretKey: miConfig.SecretKey,
  34410. FixmedinsCode: miConfig.Code,
  34411. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34412. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34413. OrgName: miConfig.OrgName,
  34414. Doctor: user_name,
  34415. RequestUrl: miConfig.Url,
  34416. AccessKey: miConfig.AccessKey,
  34417. }
  34418. businessParams := models.BusinessParams{
  34419. PsnNo: order.PsnNo,
  34420. MdtrtId: order.MdtrtId,
  34421. SetlId: order.SetlId,
  34422. }
  34423. var res ResultEleven
  34424. var resEleven10265 ResultEleven10265
  34425. if config.IsOpen == 1 {
  34426. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34427. result := service.Gdyb5203(baseParams, businessParams)
  34428. service.Gdyb5204(baseParams, businessParams)
  34429. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34430. var dat map[string]interface{}
  34431. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34432. fmt.Println(dat)
  34433. } else {
  34434. fmt.Println(err)
  34435. }
  34436. userJSONBytes, _ := json.Marshal(dat)
  34437. if miConfig.Code == "H15049901371" {
  34438. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34439. utils.ErrorLog("解析失败:%v", err)
  34440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34441. return
  34442. }
  34443. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34444. res.Output = resEleven10265.Output
  34445. res.ErrMsg = resEleven10265.ErrMsg
  34446. res.Cainfo = resEleven10265.Cainfo
  34447. res.WarnMsg = resEleven10265.WarnMsg
  34448. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34449. res.Infcode = infocode
  34450. } else {
  34451. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34452. utils.ErrorLog("解析失败:%v", err)
  34453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34454. return
  34455. }
  34456. }
  34457. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34458. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34459. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34460. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34461. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34462. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34463. var doctor_name string
  34464. if roles.ID == 0 {
  34465. doctor_name = "管理员"
  34466. } else {
  34467. doctor_name = roles.UserName
  34468. }
  34469. yiliao_leibie := ""
  34470. switch order.MedType {
  34471. case "11":
  34472. yiliao_leibie = "普通门诊"
  34473. break
  34474. case "12":
  34475. yiliao_leibie = "门诊挂号"
  34476. break
  34477. case "13":
  34478. yiliao_leibie = "急诊"
  34479. break
  34480. case "14":
  34481. yiliao_leibie = "门诊特殊病"
  34482. break
  34483. case "15":
  34484. yiliao_leibie = "门诊统筹"
  34485. break
  34486. case "16":
  34487. yiliao_leibie = "门诊慢性病"
  34488. break
  34489. case "21":
  34490. yiliao_leibie = "普通住院"
  34491. break
  34492. }
  34493. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34494. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34495. if res.Infcode == 0 {
  34496. data2 := map[string]interface{}{
  34497. "diagnosis": name,
  34498. "order_infos": orderInfos,
  34499. "number": order.MdtrtId,
  34500. "date": order.SettleAccountsDate,
  34501. "charge_admin": charge_admin,
  34502. "printor_admin": printor_admin,
  34503. "info": res.Output.Setlinfo,
  34504. "order": order,
  34505. "bedCostTotal": bedCostTotal,
  34506. "bedCostSelfTotal": bedCostSelfTotal,
  34507. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34508. "bedSelfTotal": bedSelfTotal,
  34509. "bedInscpTotal": bedInscpTotal,
  34510. "operationCostTotal": operationCostTotal,
  34511. "operationCostSelfTotal": operationCostSelfTotal,
  34512. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34513. "operationSelfTotal": operationSelfTotal,
  34514. "operationInscpTotal": operationInscpTotal,
  34515. "otherCostTotal": otherCostTotal,
  34516. "otherCostSelfTotal": otherCostSelfTotal,
  34517. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34518. "otherSelfTotal": otherSelfTotal,
  34519. "otherInscpTotal": otherInscpTotal,
  34520. "materialCostTotal": materialCostTotal,
  34521. "materialCostSelfTotal": materialCostSelfTotal,
  34522. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34523. "materialSelfTotal": materialSelfTotal,
  34524. "materialInscpTotal": materialInscpTotal,
  34525. "westernMedicineCostTotal": westernMedicineCostTotal,
  34526. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34527. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34528. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34529. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34530. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34531. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34532. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34533. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34534. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34535. "checkCostTotal": checkCostTotal,
  34536. "checkCostSelfTotal": checkCostSelfTotal,
  34537. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34538. "checkSelfTotal": checkSelfTotal,
  34539. "checkInscpTotal": checkInscpTotal,
  34540. "laboratoryCostTotal": laboratoryCostTotal,
  34541. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34542. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34543. "laboratorySelfTotal": laboratorySelfTotal,
  34544. "laboratoryInscpTotal": laboratoryInscpTotal,
  34545. "treatCostTotal": treatCostTotal,
  34546. "treatCostSelfTotal": treatCostSelfTotal,
  34547. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34548. "treatSelfTotal": treatSelfTotal,
  34549. "treatInscpTotal": treatInscpTotal,
  34550. "doctor_info": doctor_info,
  34551. "doctor_code": adminRole_two.DoctorCode,
  34552. "doctor_name": doctor_name,
  34553. "health_card_no": order.PsnNo,
  34554. "department": departments.Name,
  34555. "yiliao_leibie": yiliao_leibie,
  34556. "after_money": order.AccountPrice,
  34557. "patient": patient,
  34558. "org_name": miConfig.OrgName,
  34559. "org_code": miConfig.Code,
  34560. "order_number": order.Number,
  34561. "his_hospital": his_hospital,
  34562. "his": his,
  34563. "dia_config": dia_config,
  34564. "psn_cash_pay": order.PsnCashPay,
  34565. //"check_order_info": cus_slice,
  34566. }
  34567. data3 = append(data3, data2)
  34568. }
  34569. }
  34570. }
  34571. c.ServeSuccessJSON(map[string]interface{}{
  34572. "infos": data3,
  34573. })
  34574. }
  34575. func (c *HisApiController) GetSettleAccounts() {
  34576. //id, _ := c.GetInt64("id")
  34577. //record_time := c.GetString("record_time")
  34578. order_id, _ := c.GetInt64("order_id")
  34579. admin_user_id, _ := c.GetInt64("admin_user_id")
  34580. //timeLayout := "2006-01-02"
  34581. //loc, _ := time.LoadLocation("Local")
  34582. //
  34583. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34584. //if err != nil {
  34585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34586. // return
  34587. //}Hbyb5203
  34588. //recordDateTime := theTime.Unix()
  34589. adminUser := c.GetAdminUserInfo()
  34590. order, _ := service.GetHisOrderByID(order_id)
  34591. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34592. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34593. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34594. orderInfos = append(orderInfos, orderInfos_two...)
  34595. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34596. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34597. var diagnosis_ids []string
  34598. if his.ID > 0 {
  34599. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34600. } else {
  34601. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34602. }
  34603. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34604. var dia_config []*models.HisXtDiagnoseConfig
  34605. var name string
  34606. for _, item := range diagnosis_ids {
  34607. id, _ := strconv.ParseInt(item, 10, 64)
  34608. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34609. dia_config = append(dia_config, &diagnosisConfig)
  34610. if len(name) == 0 {
  34611. name = diagnosisConfig.ClassName
  34612. } else {
  34613. name = name + "," + diagnosisConfig.ClassName
  34614. }
  34615. }
  34616. if patient.UserOrgId == 10215 {
  34617. name = "慢性肾功能不全(血透治疗)"
  34618. }
  34619. var bedCostTotal float64 = 0 //床位总费
  34620. var bedCostSelfTotal float64 = 0 //床位自费
  34621. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34622. var bedSelfTotal float64 = 0 //床位部分项目自费
  34623. var bedInscpTotal float64 = 0 //床位部分项目自费
  34624. var operationCostTotal float64 = 0 //手术费
  34625. var operationCostSelfTotal float64 = 0 //手术费
  34626. var operationCostPartSelfTotal float64 = 0 //手术费
  34627. var operationSelfTotal float64 = 0 //床位部分项目自费
  34628. var operationInscpTotal float64 = 0 //床位部分项目自费
  34629. var otherCostTotal float64 = 0 //其他费用
  34630. var otherCostSelfTotal float64 = 0 //其他费用
  34631. var otherCostPartSelfTotal float64 = 0 //其他费用
  34632. var otherSelfTotal float64 = 0 //床位部分项目自费
  34633. var otherInscpTotal float64 = 0 //床位部分项目自费
  34634. var materialCostTotal float64 = 0 //材料费
  34635. var materialCostSelfTotal float64 = 0 //材料费
  34636. var materialCostPartSelfTotal float64 = 0 //材料费
  34637. var materialSelfTotal float64 = 0 //床位部分项目自费
  34638. var materialInscpTotal float64 = 0 //床位部分项目自费
  34639. var westernMedicineCostTotal float64 = 0 //西药费
  34640. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34641. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34642. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34643. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34644. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34645. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34646. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34647. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34648. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34649. var checkCostTotal float64 = 0 //检查费
  34650. var checkCostSelfTotal float64 = 0 //检查费
  34651. var checkCostPartSelfTotal float64 = 0 //检查费
  34652. var checkSelfTotal float64 = 0 //床位部分项目自费
  34653. var checkInscpTotal float64 = 0 //床位部分项目自费
  34654. var laboratoryCostTotal float64 = 0 //化验费
  34655. var laboratoryCostSelfTotal float64 = 0 //化验费
  34656. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34657. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34658. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34659. var treatCostTotal float64 = 0 //治疗费用
  34660. var treatCostSelfTotal float64 = 0 //治疗费用
  34661. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34662. var treatSelfTotal float64 = 0 //床位部分项目自费
  34663. var treatInscpTotal float64 = 0 //床位部分项目自费
  34664. var zcCostTotal float64 = 0 //治疗费用
  34665. var zcCostSelfTotal float64 = 0 //治疗费用
  34666. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34667. var zcSelfTotal float64 = 0 //床位部分项目自费
  34668. var zcInscpTotal float64 = 0 //床位部分项目自费
  34669. var huliCostTotal float64 = 0 //治疗费用
  34670. var huliCostSelfTotal float64 = 0 //治疗费用
  34671. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34672. var huliSelfTotal float64 = 0 //床位部分项目自费
  34673. var huliInscpTotal float64 = 0 //床位部分项目自费
  34674. decimal.DivisionPrecision = 2
  34675. for _, item := range orderInfos {
  34676. if item.MedChrgitmType == "01" { //床位费
  34677. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34678. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34679. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34680. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34681. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34682. }
  34683. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34684. if item.MedChrgitmType == "03" { //检查费
  34685. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34686. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34687. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34688. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34689. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34690. }
  34691. } else {
  34692. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34693. fmt.Println("------------")
  34694. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34695. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34696. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34697. }
  34698. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34699. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34700. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34701. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34702. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34703. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34704. }
  34705. }
  34706. if item.MedChrgitmType == "04" { //化验费
  34707. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34708. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34709. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34710. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34711. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34712. }
  34713. if item.MedChrgitmType == "05" { //治疗费
  34714. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34715. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34716. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34717. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34718. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34719. }
  34720. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34721. fmt.Println("------------")
  34722. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34723. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34724. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34725. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34726. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34727. }
  34728. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34729. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34730. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34731. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34732. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34733. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34734. }
  34735. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34736. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34737. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34738. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34739. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34740. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34741. }
  34742. if item.MedChrgitmType == "09" { //西药费
  34743. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34744. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34745. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34746. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34747. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34748. }
  34749. if item.MedChrgitmType == "11" { //中成费
  34750. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34751. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34752. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34753. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34754. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34755. }
  34756. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34757. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34758. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34759. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34760. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34761. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34762. }
  34763. if item.MedChrgitmType == "02" { //其他费
  34764. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34765. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34766. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34767. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34768. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34769. }
  34770. if item.MedChrgitmType == "07" { //其他费
  34771. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34772. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34773. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34774. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34775. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34776. }
  34777. }
  34778. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34779. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34780. var user_name string
  34781. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34782. if role.ID == 0 {
  34783. user_name = "管理员"
  34784. } else {
  34785. user_name = role.UserName
  34786. }
  34787. baseParams := models.BaseParams{
  34788. SecretKey: miConfig.SecretKey,
  34789. FixmedinsCode: miConfig.Code,
  34790. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34791. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34792. OrgName: miConfig.OrgName,
  34793. Doctor: user_name,
  34794. RequestUrl: miConfig.Url,
  34795. AccessKey: miConfig.AccessKey,
  34796. }
  34797. businessParams := models.BusinessParams{
  34798. PsnNo: order.PsnNo,
  34799. MdtrtId: order.MdtrtId,
  34800. SetlId: order.SetlId,
  34801. }
  34802. var res ResultEleven
  34803. var resah ResultElevenah
  34804. var resEleven10265 ResultEleven10265
  34805. if config.IsOpen == 1 {
  34806. if miConfig.MdtrtareaAdmvs == "421300" {
  34807. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34808. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34809. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34810. resp, requestErr := http.Get(api)
  34811. if requestErr != nil {
  34812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34813. return
  34814. }
  34815. body, ioErr := ioutil.ReadAll(resp.Body)
  34816. if ioErr != nil {
  34817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34819. return
  34820. }
  34821. var respJSON map[string]interface{}
  34822. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34825. return
  34826. }
  34827. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34828. result, _ := json.Marshal(respJSON)
  34829. fmt.Println("log")
  34830. fmt.Println(string(result))
  34831. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34832. utils.ErrorLog("解析失败:%v", err)
  34833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34834. return
  34835. }
  34836. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34837. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34838. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34839. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34840. resp, requestErr := http.Get(api)
  34841. if requestErr != nil {
  34842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34843. return
  34844. }
  34845. body, ioErr := ioutil.ReadAll(resp.Body)
  34846. if ioErr != nil {
  34847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34849. return
  34850. }
  34851. var respJSON map[string]interface{}
  34852. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34855. return
  34856. }
  34857. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34858. result, _ := json.Marshal(respJSON)
  34859. fmt.Println("log")
  34860. fmt.Println(string(result))
  34861. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34862. utils.ErrorLog("解析失败:%v", err)
  34863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34864. return
  34865. }
  34866. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34867. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34868. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34869. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34870. resp, requestErr := http.Get(api)
  34871. if requestErr != nil {
  34872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34873. return
  34874. }
  34875. body, ioErr := ioutil.ReadAll(resp.Body)
  34876. if ioErr != nil {
  34877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34879. return
  34880. }
  34881. var respJSON map[string]interface{}
  34882. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34885. return
  34886. }
  34887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34888. result, _ := json.Marshal(respJSON)
  34889. fmt.Println("log")
  34890. fmt.Println(string(result))
  34891. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34892. utils.ErrorLog("解析失败:%v", err)
  34893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34894. return
  34895. }
  34896. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34897. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34898. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34899. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34900. resp, requestErr := http.Get(api)
  34901. if requestErr != nil {
  34902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34903. return
  34904. }
  34905. body, ioErr := ioutil.ReadAll(resp.Body)
  34906. if ioErr != nil {
  34907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34909. return
  34910. }
  34911. var respJSON map[string]interface{}
  34912. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34915. return
  34916. }
  34917. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34918. result, _ := json.Marshal(respJSON)
  34919. fmt.Println("log")
  34920. fmt.Println(string(result))
  34921. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34922. utils.ErrorLog("解析失败:%v", err)
  34923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34924. return
  34925. }
  34926. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34927. var api string
  34928. if miConfig.MdtrtareaAdmvs == "320921" {
  34929. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34930. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34931. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34932. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34933. } else {
  34934. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34935. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34936. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34937. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34938. }
  34939. resp, requestErr := http.Get(api)
  34940. if requestErr != nil {
  34941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34942. return
  34943. }
  34944. body, ioErr := ioutil.ReadAll(resp.Body)
  34945. if ioErr != nil {
  34946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34948. return
  34949. }
  34950. var respJSON map[string]interface{}
  34951. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34954. return
  34955. }
  34956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34957. result, _ := json.Marshal(respJSON)
  34958. fmt.Println("log")
  34959. fmt.Println(string(result))
  34960. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34961. utils.ErrorLog("解析失败:%v", err)
  34962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34963. return
  34964. }
  34965. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34966. res.Output = resEleven10265.Output
  34967. res.ErrMsg = resEleven10265.ErrMsg
  34968. res.Cainfo = resEleven10265.Cainfo
  34969. res.WarnMsg = resEleven10265.WarnMsg
  34970. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34971. res.Infcode = infocode
  34972. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34973. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34974. saveLog(result, requestLog, "5203", "结算单")
  34975. var dat map[string]interface{}
  34976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34977. fmt.Println(dat)
  34978. } else {
  34979. fmt.Println(err)
  34980. }
  34981. userJSONBytes, _ := json.Marshal(dat)
  34982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34983. utils.ErrorLog("解析失败:%v", err)
  34984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34985. return
  34986. }
  34987. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34988. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34989. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34990. saveLog(result, requestLog, "5203", "结算单")
  34991. var dat map[string]interface{}
  34992. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34993. fmt.Println(dat)
  34994. } else {
  34995. fmt.Println(err)
  34996. }
  34997. userJSONBytes, _ := json.Marshal(dat)
  34998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34999. utils.ErrorLog("解析失败:%v", err)
  35000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35001. return
  35002. }
  35003. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35004. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35005. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35006. saveLog(result, requestLog, "5203", "结算单")
  35007. var dat map[string]interface{}
  35008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35009. fmt.Println(dat)
  35010. } else {
  35011. fmt.Println(err)
  35012. }
  35013. userJSONBytes, _ := json.Marshal(dat)
  35014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35015. utils.ErrorLog("解析失败:%v", err)
  35016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35017. return
  35018. }
  35019. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35020. var api string
  35021. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35022. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35023. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35024. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35025. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35026. resp, requestErr := http.Get(api)
  35027. if requestErr != nil {
  35028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35029. return
  35030. }
  35031. body, ioErr := ioutil.ReadAll(resp.Body)
  35032. if ioErr != nil {
  35033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35035. return
  35036. }
  35037. var respJSON map[string]interface{}
  35038. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35041. return
  35042. }
  35043. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35044. if status == "0" {
  35045. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35046. c.ServeSuccessJSON(map[string]interface{}{
  35047. "failed_code": -10,
  35048. "msg": err_msg,
  35049. })
  35050. return
  35051. }
  35052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35053. result, _ := json.Marshal(respJSON)
  35054. fmt.Println("log")
  35055. fmt.Println(string(result))
  35056. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35057. utils.ErrorLog("解析失败:%v", err)
  35058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35059. return
  35060. }
  35061. res.InfRefmsgid = resah.InfRefmsgid
  35062. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35063. // 创建对应的Time类型
  35064. t := time.UnixMilli(timestamp)
  35065. // 格式化成指定的日期字符串
  35066. str := t.Format("2006-01-02 15:04:05")
  35067. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35068. // 创建对应的Time类型
  35069. t3 := time.UnixMilli(timestamp2)
  35070. // 格式化成指定的日期字符串
  35071. str2 := t3.Format("2006-01-02 15:04:05")
  35072. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35073. // 创建对应的Time类型
  35074. t4 := time.UnixMilli(timestamp3)
  35075. // 格式化成指定的日期字符串
  35076. str3 := t4.Format("2006-01-02 15:04:05")
  35077. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35078. // 创建对应的Time类型
  35079. t5 := time.UnixMilli(timestamp4)
  35080. // 格式化成指定的日期字符串
  35081. str5 := t5.Format("2006-01-02 15:04:05")
  35082. res.Output.Setlinfo.Brdy = str2
  35083. res.Output.Setlinfo.SetlTime = str
  35084. res.Output.Setlinfo.Begndate = str3
  35085. res.Output.Setlinfo.Enddate = str5
  35086. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35087. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35088. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35089. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35090. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35091. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35092. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35093. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35094. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35095. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35096. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35097. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35098. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35099. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35100. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35101. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35102. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35103. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35104. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35105. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35106. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35107. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35108. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35109. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35110. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35111. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35112. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35113. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35114. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35115. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35116. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35117. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35118. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35119. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35120. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35121. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35122. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35123. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35124. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35125. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35126. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35127. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35128. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35129. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35130. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35131. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35132. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35133. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35134. //res.Output.Setldetail = resah.Output.Setldetail
  35135. res.ErrMsg = resah.ErrMsg
  35136. res.Cainfo = resah.Cainfo
  35137. res.WarnMsg = resah.WarnMsg
  35138. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35139. var api string
  35140. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35141. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35142. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35143. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35144. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35145. resp, requestErr := http.Get(api)
  35146. if requestErr != nil {
  35147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35148. return
  35149. }
  35150. body, ioErr := ioutil.ReadAll(resp.Body)
  35151. if ioErr != nil {
  35152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35154. return
  35155. }
  35156. var respJSON map[string]interface{}
  35157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35160. return
  35161. }
  35162. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35163. if status == "0" {
  35164. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35165. c.ServeSuccessJSON(map[string]interface{}{
  35166. "failed_code": -10,
  35167. "msg": err_msg,
  35168. })
  35169. return
  35170. }
  35171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35172. result, _ := json.Marshal(respJSON)
  35173. fmt.Println("log")
  35174. fmt.Println(string(result))
  35175. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35176. utils.ErrorLog("解析失败:%v", err)
  35177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35178. return
  35179. }
  35180. res.InfRefmsgid = resah.InfRefmsgid
  35181. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35182. // 创建对应的Time类型
  35183. t := time.UnixMilli(timestamp)
  35184. // 格式化成指定的日期字符串
  35185. str := t.Format("2006-01-02 15:04:05")
  35186. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35187. // 创建对应的Time类型
  35188. t3 := time.UnixMilli(timestamp2)
  35189. // 格式化成指定的日期字符串
  35190. str2 := t3.Format("2006-01-02 15:04:05")
  35191. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35192. // 创建对应的Time类型
  35193. t4 := time.UnixMilli(timestamp3)
  35194. // 格式化成指定的日期字符串
  35195. str3 := t4.Format("2006-01-02 15:04:05")
  35196. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35197. // 创建对应的Time类型
  35198. t5 := time.UnixMilli(timestamp4)
  35199. // 格式化成指定的日期字符串
  35200. str5 := t5.Format("2006-01-02 15:04:05")
  35201. res.Output.Setlinfo.Brdy = str2
  35202. res.Output.Setlinfo.SetlTime = str
  35203. res.Output.Setlinfo.Begndate = str3
  35204. res.Output.Setlinfo.Enddate = str5
  35205. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35206. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35207. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35208. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35209. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35210. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35211. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35212. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35213. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35214. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35215. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35216. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35217. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35218. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35219. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35220. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35221. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35222. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35223. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35224. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35225. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35226. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35227. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35228. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35229. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35230. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35231. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35232. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35233. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35234. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35235. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35236. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35237. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35238. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35239. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35240. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35241. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35242. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35243. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35244. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35245. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35246. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35247. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35248. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35249. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35250. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35251. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35252. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35253. //res.Output.Setldetail = resah.Output.Setldetail
  35254. res.ErrMsg = resah.ErrMsg
  35255. res.Cainfo = resah.Cainfo
  35256. res.WarnMsg = resah.WarnMsg
  35257. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35258. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35259. saveLog(result, requestLog, "5203", "结算单")
  35260. var dat map[string]interface{}
  35261. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35262. fmt.Println(dat)
  35263. } else {
  35264. fmt.Println(err)
  35265. }
  35266. userJSONBytes, _ := json.Marshal(dat)
  35267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35268. utils.ErrorLog("解析失败:%v", err)
  35269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35270. return
  35271. }
  35272. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35273. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35274. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35275. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35276. resp, requestErr := http.Get(api)
  35277. if requestErr != nil {
  35278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35279. return
  35280. }
  35281. body, ioErr := ioutil.ReadAll(resp.Body)
  35282. if ioErr != nil {
  35283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35285. return
  35286. }
  35287. var respJSON map[string]interface{}
  35288. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35291. return
  35292. }
  35293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35294. result, _ := json.Marshal(respJSON)
  35295. fmt.Println("log")
  35296. fmt.Println(string(result))
  35297. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35298. utils.ErrorLog("解析失败:%v", err)
  35299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35300. return
  35301. }
  35302. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35303. res.Output = resEleven10265.Output
  35304. res.ErrMsg = resEleven10265.ErrMsg
  35305. res.Cainfo = resEleven10265.Cainfo
  35306. res.WarnMsg = resEleven10265.WarnMsg
  35307. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35308. res.Infcode = infocode
  35309. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35310. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35311. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35312. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35313. resp, requestErr := http.Get(api)
  35314. if requestErr != nil {
  35315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35316. return
  35317. }
  35318. body, ioErr := ioutil.ReadAll(resp.Body)
  35319. if ioErr != nil {
  35320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35322. return
  35323. }
  35324. var respJSON map[string]interface{}
  35325. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35328. return
  35329. }
  35330. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35331. result, _ := json.Marshal(respJSON)
  35332. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35333. utils.ErrorLog("解析失败:%v", err)
  35334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35335. return
  35336. }
  35337. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35338. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35339. //return
  35340. } else {
  35341. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35342. if len(his.InsuplcAdmdvs) == 0 {
  35343. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35344. } else {
  35345. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35346. }
  35347. result := service.Gdyb5203(baseParams, businessParams)
  35348. //service.Gdyb5204(baseParams, businessParams)
  35349. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35350. var dat map[string]interface{}
  35351. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35352. fmt.Println(dat)
  35353. } else {
  35354. fmt.Println(err)
  35355. }
  35356. userJSONBytes, _ := json.Marshal(dat)
  35357. if miConfig.Code == "H15049901371" {
  35358. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35359. utils.ErrorLog("解析失败:%v", err)
  35360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35361. return
  35362. }
  35363. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35364. res.Output = resEleven10265.Output
  35365. res.ErrMsg = resEleven10265.ErrMsg
  35366. res.Cainfo = resEleven10265.Cainfo
  35367. res.WarnMsg = resEleven10265.WarnMsg
  35368. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35369. res.Infcode = infocode
  35370. } else {
  35371. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35372. utils.ErrorLog("解析失败:%v", err)
  35373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35374. return
  35375. }
  35376. }
  35377. }
  35378. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35379. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35380. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35381. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35382. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35383. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35384. var doctor_name string
  35385. if roles.ID == 0 {
  35386. doctor_name = "管理员"
  35387. } else {
  35388. doctor_name = roles.UserName
  35389. }
  35390. yiliao_leibie := ""
  35391. switch order.MedType {
  35392. case "11":
  35393. yiliao_leibie = "普通门诊"
  35394. break
  35395. case "12":
  35396. yiliao_leibie = "门诊挂号"
  35397. break
  35398. case "13":
  35399. yiliao_leibie = "急诊"
  35400. break
  35401. case "14":
  35402. yiliao_leibie = "门诊特殊病"
  35403. break
  35404. case "15":
  35405. yiliao_leibie = "门诊统筹"
  35406. break
  35407. case "16":
  35408. yiliao_leibie = "门诊慢性病"
  35409. break
  35410. case "21":
  35411. yiliao_leibie = "普通住院"
  35412. break
  35413. }
  35414. //var rf []CustomFundPay
  35415. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35416. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35417. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35418. if res.Infcode == 0 {
  35419. 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 {
  35420. c.ServeSuccessJSON(map[string]interface{}{
  35421. "diagnosis": name,
  35422. "order_infos": orderInfos,
  35423. "number": order.MdtrtId,
  35424. "date": order.SettleAccountsDate,
  35425. "charge_admin": charge_admin,
  35426. "printor_admin": printor_admin,
  35427. "info": res.Output.Setlinfo,
  35428. "order": order,
  35429. "bedCostTotal": bedCostTotal,
  35430. "bedCostSelfTotal": bedCostSelfTotal,
  35431. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35432. "bedSelfTotal": bedSelfTotal,
  35433. "bedInscpTotal": bedInscpTotal,
  35434. "operationCostTotal": operationCostTotal,
  35435. "operationCostSelfTotal": operationCostSelfTotal,
  35436. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35437. "operationSelfTotal": operationSelfTotal,
  35438. "operationInscpTotal": operationInscpTotal,
  35439. "otherCostTotal": otherCostTotal,
  35440. "otherCostSelfTotal": otherCostSelfTotal,
  35441. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35442. "otherSelfTotal": otherSelfTotal,
  35443. "otherInscpTotal": otherInscpTotal,
  35444. "materialCostTotal": materialCostTotal,
  35445. "materialCostSelfTotal": materialCostSelfTotal,
  35446. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35447. "materialSelfTotal": materialSelfTotal,
  35448. "materialInscpTotal": materialInscpTotal,
  35449. "westernMedicineCostTotal": westernMedicineCostTotal,
  35450. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35451. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35452. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35453. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35454. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35455. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35456. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35457. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35458. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35459. "checkCostTotal": checkCostTotal,
  35460. "checkCostSelfTotal": checkCostSelfTotal,
  35461. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35462. "checkSelfTotal": checkSelfTotal,
  35463. "checkInscpTotal": checkInscpTotal,
  35464. "laboratoryCostTotal": laboratoryCostTotal,
  35465. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35466. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35467. "laboratorySelfTotal": laboratorySelfTotal,
  35468. "laboratoryInscpTotal": laboratoryInscpTotal,
  35469. "treatCostTotal": treatCostTotal,
  35470. "treatCostSelfTotal": treatCostSelfTotal,
  35471. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35472. "treatSelfTotal": treatSelfTotal,
  35473. "treatInscpTotal": treatInscpTotal,
  35474. "doctor_info": doctor_info,
  35475. "doctor_code": adminRole_two.DoctorCode,
  35476. "doctor_name": doctor_name,
  35477. "health_card_no": order.PsnNo,
  35478. "department": departments.Name,
  35479. "yiliao_leibie": yiliao_leibie,
  35480. "after_money": order.AccountPrice,
  35481. "patient": patient,
  35482. "org_name": miConfig.OrgName,
  35483. "org_code": miConfig.Code,
  35484. "order_number": order.Number,
  35485. "his_hospital": his_hospital,
  35486. "his": his,
  35487. "dia_config": dia_config,
  35488. "psn_cash_pay": order.PsnCashPay,
  35489. "zcCostTotal": zcCostTotal,
  35490. "zcCostSelfTotal": zcCostSelfTotal,
  35491. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35492. "zcSelfTotal": zcSelfTotal,
  35493. "zcInscpTotal": zcInscpTotal,
  35494. "huliCostTotal": huliCostTotal,
  35495. "huliCostSelfTotal": huliCostSelfTotal,
  35496. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35497. "huliSelfTotal": huliSelfTotal,
  35498. "huliInscpTotal": huliInscpTotal,
  35499. //"funds": rf,
  35500. //"check_order_info": cus_slice,
  35501. })
  35502. } else {
  35503. c.ServeSuccessJSON(map[string]interface{}{
  35504. "diagnosis": name,
  35505. "order_infos": orderInfos,
  35506. "number": order.MdtrtId,
  35507. "date": order.SettleAccountsDate,
  35508. "charge_admin": charge_admin,
  35509. "printor_admin": printor_admin,
  35510. "info": order,
  35511. "order": order,
  35512. "bedCostTotal": bedCostTotal,
  35513. "bedCostSelfTotal": bedCostSelfTotal,
  35514. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35515. "bedSelfTotal": bedSelfTotal,
  35516. "bedInscpTotal": bedInscpTotal,
  35517. "operationCostTotal": operationCostTotal,
  35518. "operationCostSelfTotal": operationCostSelfTotal,
  35519. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35520. "operationSelfTotal": operationSelfTotal,
  35521. "operationInscpTotal": operationInscpTotal,
  35522. "otherCostTotal": otherCostTotal,
  35523. "otherCostSelfTotal": otherCostSelfTotal,
  35524. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35525. "otherSelfTotal": otherSelfTotal,
  35526. "otherInscpTotal": otherInscpTotal,
  35527. "materialCostTotal": materialCostTotal,
  35528. "materialCostSelfTotal": materialCostSelfTotal,
  35529. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35530. "materialSelfTotal": materialSelfTotal,
  35531. "materialInscpTotal": materialInscpTotal,
  35532. "westernMedicineCostTotal": westernMedicineCostTotal,
  35533. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35534. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35535. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35536. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35537. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35538. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35539. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35540. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35541. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35542. "checkCostTotal": checkCostTotal,
  35543. "checkCostSelfTotal": checkCostSelfTotal,
  35544. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35545. "checkSelfTotal": checkSelfTotal,
  35546. "checkInscpTotal": checkInscpTotal,
  35547. "laboratoryCostTotal": laboratoryCostTotal,
  35548. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35549. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35550. "laboratorySelfTotal": laboratorySelfTotal,
  35551. "laboratoryInscpTotal": laboratoryInscpTotal,
  35552. "treatCostTotal": treatCostTotal,
  35553. "treatCostSelfTotal": treatCostSelfTotal,
  35554. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35555. "treatSelfTotal": treatSelfTotal,
  35556. "treatInscpTotal": treatInscpTotal,
  35557. "doctor_info": doctor_info,
  35558. "doctor_code": adminRole_two.DoctorCode,
  35559. "doctor_name": doctor_name,
  35560. "health_card_no": order.PsnNo,
  35561. "department": departments.Name,
  35562. "yiliao_leibie": yiliao_leibie,
  35563. "after_money": order.AccountPrice,
  35564. "patient": patient,
  35565. "org_name": miConfig.OrgName,
  35566. "org_code": miConfig.Code,
  35567. "order_number": order.Number,
  35568. "his_hospital": his_hospital,
  35569. "his": his,
  35570. "dia_config": dia_config,
  35571. "psn_cash_pay": order.PsnCashPay,
  35572. "zcCostTotal": zcCostTotal,
  35573. "zcCostSelfTotal": zcCostSelfTotal,
  35574. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35575. "zcSelfTotal": zcSelfTotal,
  35576. "zcInscpTotal": zcInscpTotal,
  35577. "huliCostTotal": huliCostTotal,
  35578. "huliCostSelfTotal": huliCostSelfTotal,
  35579. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35580. "huliSelfTotal": huliSelfTotal,
  35581. "huliInscpTotal": huliInscpTotal,
  35582. //"funds": rf,
  35583. //"check_order_info": cus_slice,
  35584. })
  35585. }
  35586. }
  35587. }
  35588. }
  35589. //func (c *HisApiController) CheckTreatment() {
  35590. // patient_id, _ := c.GetInt64("patient_id")
  35591. // id_card_no := c.GetString("id_card_no")
  35592. // insutype := c.GetString("insutype")
  35593. // med_type := c.GetString("med_type")
  35594. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35595. //
  35596. // adminUser := c.GetAdminUserInfo()
  35597. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35598. //
  35599. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35600. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35601. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35602. //
  35603. // if miConfig.MdtrtareaAdmvs == "421300" {
  35604. // var res ResultTwo
  35605. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35606. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35607. // "&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)
  35608. // resp, requestErr := http.Get(api)
  35609. // if requestErr != nil {
  35610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35611. // return
  35612. // }
  35613. //
  35614. // body, ioErr := ioutil.ReadAll(resp.Body)
  35615. // if ioErr != nil {
  35616. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35617. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35618. // return
  35619. // }
  35620. // var respJSON map[string]interface{}
  35621. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35622. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35624. // return
  35625. // }
  35626. //
  35627. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35628. // result, _ := json.Marshal(respJSON)
  35629. //
  35630. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35631. // utils.ErrorLog("解析失败:%v", err)
  35632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35633. // return
  35634. // }
  35635. //
  35636. // if res.Infcode == 0 {
  35637. //
  35638. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35639. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35640. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35641. // resp, requestErr := http.Get(api)
  35642. // if requestErr != nil {
  35643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35644. // return
  35645. // }
  35646. //
  35647. // body, ioErr := ioutil.ReadAll(resp.Body)
  35648. // if ioErr != nil {
  35649. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35651. // return
  35652. // }
  35653. // var respJSON map[string]interface{}
  35654. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35655. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35657. // return
  35658. // }
  35659. // var res Result2001
  35660. //
  35661. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35662. // result2, _ := json.Marshal(respJSON)
  35663. //
  35664. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35665. // utils.ErrorLog("解析失败:%v", err)
  35666. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35667. // return
  35668. // }
  35669. //
  35670. // if res.Infcode == 0 {
  35671. // c.ServeSuccessJSON(map[string]interface{}{
  35672. // "msg": res.Output.Trtinfo,
  35673. // })
  35674. // }
  35675. //
  35676. // } else {
  35677. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35678. // return
  35679. // }
  35680. //
  35681. // } else {
  35682. //
  35683. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35684. // var dat map[string]interface{}
  35685. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35686. // fmt.Println(dat)
  35687. // } else {
  35688. // fmt.Println(err)
  35689. // }
  35690. // userJSONBytes, _ := json.Marshal(dat)
  35691. // var res ResultTwo
  35692. // var res10265 ResultTwo10265
  35693. // if miConfig.Code == "H15049901371" {
  35694. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35695. // utils.ErrorLog("解析失败:%v", err)
  35696. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35697. // return
  35698. // }
  35699. // res.ErrMsg = res10265.ErrMsg
  35700. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35701. // res.Infcode = infocode
  35702. // res.Output = res10265.Output
  35703. // res.InfRefmsgid = res10265.InfRefmsgid
  35704. // } else {
  35705. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35706. // utils.ErrorLog("解析失败:%v", err)
  35707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35708. // return
  35709. // }
  35710. // }
  35711. //
  35712. // var user_name string
  35713. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35714. // if role.ID == 0 {
  35715. // user_name = "xxx"
  35716. // } else {
  35717. // user_name = role.UserName
  35718. // }
  35719. //
  35720. // baseParams := models.BaseParams{
  35721. // SecretKey: miConfig.SecretKey,
  35722. // FixmedinsCode: miConfig.Code,
  35723. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35724. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35725. // OrgName: miConfig.OrgName,
  35726. // Doctor: user_name,
  35727. // }
  35728. //
  35729. // if config.IsOpen == 1 {
  35730. // if miConfig.Code == "H15049901371" {
  35731. // if med_type == "14" {
  35732. // if insutype == "390" {
  35733. // med_type = "9933"
  35734. // } else if insutype == "310" {
  35735. // med_type = "990502"
  35736. // }
  35737. // } else if med_type == "11" {
  35738. // med_type = "11"
  35739. // }
  35740. // }
  35741. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35742. // var dat map[string]interface{}
  35743. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35744. // fmt.Println(dat)
  35745. // } else {
  35746. // fmt.Println(err)
  35747. // }
  35748. // var res Result2001
  35749. // var res10265 Result2001Org10265
  35750. // if miConfig.Code == "H15049901371" {
  35751. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35752. // utils.ErrorLog("解析失败:%v", err)
  35753. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35754. // return
  35755. // }
  35756. // res.ErrMsg = res10265.ErrMsg
  35757. // res.Output = res10265.Output
  35758. // res.InfRefmsgid = res10265.InfRefmsgid
  35759. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35760. // res.Infcode = infocode
  35761. // } else {
  35762. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35763. // utils.ErrorLog("解析失败:%v", err)
  35764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35765. // return
  35766. // }
  35767. // }
  35768. // if res.Infcode == 0 {
  35769. // c.ServeSuccessJSON(map[string]interface{}{
  35770. // "msg": res.Output.Trtinfo,
  35771. // })
  35772. // }
  35773. // }
  35774. // }
  35775. //}
  35776. //func (c *HisApiController) PutRecord() {
  35777. // id, _ := c.GetInt64("id")
  35778. // record_time := c.GetString("record_time")
  35779. // timeLayout := "2006-01-02"
  35780. // loc, _ := time.LoadLocation("Local")
  35781. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35782. // if err != nil {
  35783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35784. // return
  35785. // }
  35786. // recordDateTime := theTime.Unix()
  35787. //
  35788. // adminInfo := c.GetAdminUserInfo()
  35789. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35790. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35791. //
  35792. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35793. //
  35794. // fmt.Println(miConfig.SecretKey)
  35795. //
  35796. // if patient == nil {
  35797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35798. // return
  35799. // }
  35800. // if len(patient.IdCardNo) == 0 {
  35801. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35802. // return
  35803. // }
  35804. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35805. // if config.IsOpen == 1 {
  35806. // 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
  35807. // resp, requestErr := http.Get(api)
  35808. // if requestErr != nil {
  35809. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35810. // return
  35811. // }
  35812. // defer resp.Body.Close()
  35813. // body, ioErr := ioutil.ReadAll(resp.Body)
  35814. // if ioErr != nil {
  35815. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35817. // return
  35818. // }
  35819. // var respJSON map[string]interface{}
  35820. //
  35821. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35822. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35824. // return
  35825. // }
  35826. //
  35827. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35828. // userJSONBytes, _ := json.Marshal(userJSON)
  35829. // var res ResultTwo
  35830. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35831. // utils.ErrorLog("解析失败:%v", err)
  35832. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35833. // return
  35834. // }
  35835. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35836. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35837. // infoStr := string(Iinfos)
  35838. // idetinfoStr := string(Idetinfos)
  35839. //
  35840. // if res.Infcode == 0 {
  35841. // his := models.VMHisPatient{
  35842. // Status: 1,
  35843. // Ctime: time.Now().Unix(),
  35844. // Mtime: time.Now().Unix(),
  35845. // PsnNo: res.Output.Baseinfo.PsnNo,
  35846. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35847. // Certno: res.Output.Baseinfo.Certno,
  35848. // PsnName: res.Output.Baseinfo.PsnName,
  35849. // Gend: res.Output.Baseinfo.Gend,
  35850. // Naty: res.Output.Baseinfo.Naty,
  35851. // Brdy: res.Output.Baseinfo.Brdy,
  35852. // Age: res.Output.Baseinfo.Age,
  35853. // Iinfo: infoStr,
  35854. // Idetinfo: idetinfoStr,
  35855. // PatientId: patient.ID,
  35856. // RecordDate: theTime.Unix(),
  35857. // UserOrgId: adminInfo.CurrentOrgId,
  35858. // AdminUserId: adminInfo.AdminUser.Id,
  35859. // IsReturn: 1,
  35860. // }
  35861. //
  35862. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35863. // //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")
  35864. // //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")
  35865. //
  35866. // //var dat map[string]interface{}
  35867. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35868. // // fmt.Println(dat)
  35869. // //} else {
  35870. // // fmt.Println(err)
  35871. // //}
  35872. //
  35873. // var dat2 map[string]interface{}
  35874. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35875. // fmt.Println(dat2)
  35876. // } else {
  35877. // fmt.Println(err)
  35878. // }
  35879. //
  35880. // } else {
  35881. // adminUser := c.GetAdminUserInfo()
  35882. // errlog := &models.HisOrderError{
  35883. // UserOrgId: adminUser.CurrentOrgId,
  35884. // Ctime: time.Now().Unix(),
  35885. // Mtime: time.Now().Unix(),
  35886. // ErrMsg: res.ErrMsg,
  35887. // Status: 1,
  35888. // PatientId: id,
  35889. // RecordTime: recordDateTime,
  35890. // Stage: 1,
  35891. // }
  35892. // service.CreateErrMsgLog(errlog)
  35893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35894. // return
  35895. // }
  35896. // }
  35897. //
  35898. //}
  35899. //func (c *HisApiController) GetUploadDiag() {
  35900. // id, _ := c.GetInt64("id")
  35901. // record_time := c.GetString("record_time")
  35902. //
  35903. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35904. // sick_type, _ := c.GetInt64("sick_type")
  35905. // reg_type, _ := c.GetInt64("reg_type")
  35906. //
  35907. // timeLayout := "2006-01-02"
  35908. // loc, _ := time.LoadLocation("Local")
  35909. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35910. // if err != nil {
  35911. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35912. // return
  35913. // }
  35914. //
  35915. // var patientPrescription models.HisPrescriptionInfo
  35916. // recordDateTime := theTime.Unix()
  35917. // adminInfo := c.GetAdminUserInfo()
  35918. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35919. //
  35920. // if patientPrescription.ID == 0 {
  35921. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35922. // }
  35923. //
  35924. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35925. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35926. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35927. // sickConfig, _ := service.FindSickById(sick_type)
  35928. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35929. //
  35930. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35931. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35932. // "&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 +
  35933. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35934. // resp2, requestErr2 := http.Get(api2)
  35935. // if requestErr2 != nil {
  35936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35937. // return
  35938. // }
  35939. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35940. // if ioErr2 != nil {
  35941. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35943. // return
  35944. // }
  35945. // var respJSON2 map[string]interface{}
  35946. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35947. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35948. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35949. // return
  35950. // }
  35951. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35952. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35953. //
  35954. // var res2 ResultSix
  35955. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35956. // utils.ErrorLog("解析失败:%v", err)
  35957. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35958. // return
  35959. // }
  35960. // if res2.Infcode != 0 {
  35961. // adminUser := c.GetAdminUserInfo()
  35962. // errlog := &models.HisOrderError{
  35963. // UserOrgId: adminUser.CurrentOrgId,
  35964. // Ctime: time.Now().Unix(),
  35965. // Mtime: time.Now().Unix(),
  35966. // ErrMsg: res2.ErrMsg,
  35967. // Status: 1,
  35968. // PatientId: id,
  35969. // RecordTime: recordDateTime,
  35970. // Stage: 3,
  35971. // }
  35972. // service.CreateErrMsgLog(errlog)
  35973. //
  35974. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35975. // return
  35976. // }
  35977. //
  35978. // c.ServeSuccessJSON(map[string]interface{}{
  35979. // "msg": "上传成功",
  35980. // })
  35981. //
  35982. //}
  35983. type QueryResult struct {
  35984. ID int64
  35985. Name string
  35986. Code string
  35987. List_type_code string
  35988. }
  35989. func (c *HisApiController) GetCheckCode() {
  35990. ids_str := c.GetString("ids")
  35991. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35992. ids_arr := strings.Split(ids_str, ",")
  35993. var queryResult []QueryResult
  35994. ids := make([]int64, 0)
  35995. for _, item := range ids_arr {
  35996. id, _ := strconv.ParseInt(item, 10, 64)
  35997. ids = append(ids, id)
  35998. }
  35999. if record_type == 1 {
  36000. drugs, _ := service.GetBatchDrugList(ids)
  36001. for _, item := range drugs {
  36002. result := QueryResult{
  36003. ID: item.ID,
  36004. Name: item.DrugName,
  36005. Code: item.MedicalInsuranceNumber,
  36006. List_type_code: "101",
  36007. }
  36008. queryResult = append(queryResult, result)
  36009. }
  36010. } else if record_type == 2 {
  36011. goods, _ := service.GetBatchGoodInformationList(ids)
  36012. fmt.Println(goods)
  36013. for _, item := range goods {
  36014. result := QueryResult{
  36015. ID: item.ID,
  36016. Name: item.GoodName,
  36017. Code: item.SocialSecurityDirectoryCode,
  36018. List_type_code: "301",
  36019. }
  36020. queryResult = append(queryResult, result)
  36021. }
  36022. } else if record_type == 3 {
  36023. projects, _ := service.GetBathchMyPorjecgList(ids)
  36024. for _, item := range projects {
  36025. result := QueryResult{
  36026. ID: item.ID,
  36027. Name: item.ProjectName,
  36028. Code: item.MedicalCode,
  36029. List_type_code: "201",
  36030. }
  36031. queryResult = append(queryResult, result)
  36032. }
  36033. }
  36034. admin_user_id, _ := c.GetInt64("admin_user_id")
  36035. adminUser := c.GetAdminUserInfo()
  36036. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36037. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36038. var user_name string
  36039. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36040. if role.ID == 0 {
  36041. user_name = "管理员"
  36042. } else {
  36043. user_name = role.UserName
  36044. }
  36045. baseParams := models.BaseParams{
  36046. SecretKey: miConfig.SecretKey,
  36047. FixmedinsCode: miConfig.Code,
  36048. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36049. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36050. OrgName: miConfig.OrgName,
  36051. Doctor: user_name,
  36052. }
  36053. var result string
  36054. if miConfig.MdtrtareaAdmvs == "430800" {
  36055. for _, item := range queryResult {
  36056. if record_type == 1 {
  36057. 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)
  36058. } else if record_type == 2 {
  36059. fmt.Println(item.Code)
  36060. 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)
  36061. } else if record_type == 3 {
  36062. 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)
  36063. }
  36064. var dat map[string]interface{}
  36065. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36066. fmt.Println(dat)
  36067. } else {
  36068. fmt.Println(err)
  36069. }
  36070. userJSONBytes, _ := json.Marshal(dat)
  36071. var res ResultSix
  36072. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36073. utils.ErrorLog("解析失败:%v", err)
  36074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36075. return
  36076. }
  36077. if res.Infcode == 0 {
  36078. if record_type == 1 {
  36079. service.UpdateBaseDrugById(item.ID)
  36080. } else if record_type == 2 {
  36081. service.UpdateGoodInformaitonByDetail(item.ID)
  36082. } else if record_type == 3 {
  36083. service.UpdateProjectById(item.ID)
  36084. }
  36085. c.ServeSuccessJSON(map[string]interface{}{
  36086. "failed_code": 0,
  36087. "msg": "目录对照成功",
  36088. })
  36089. } else {
  36090. c.ServeSuccessJSON(map[string]interface{}{
  36091. "failed_code": -10,
  36092. "msg": res.ErrMsg,
  36093. })
  36094. }
  36095. }
  36096. } else {
  36097. for _, item := range queryResult {
  36098. var result string
  36099. if record_type == 1 {
  36100. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36101. } else if record_type == 2 {
  36102. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36103. } else if record_type == 3 {
  36104. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36105. }
  36106. var dat map[string]interface{}
  36107. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36108. fmt.Println(dat)
  36109. } else {
  36110. fmt.Println(err)
  36111. }
  36112. userJSONBytes, _ := json.Marshal(dat)
  36113. var res ResultSix
  36114. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36115. utils.ErrorLog("解析失败:%v", err)
  36116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36117. return
  36118. }
  36119. if res.Infcode == 0 {
  36120. if record_type == 1 {
  36121. service.UpdateBaseDrugById(item.ID)
  36122. } else if record_type == 2 {
  36123. service.UpdateGoodInformaitonByDetail(item.ID)
  36124. } else if record_type == 3 {
  36125. service.UpdateProjectById(item.ID)
  36126. }
  36127. c.ServeSuccessJSON(map[string]interface{}{
  36128. "failed_code": 0,
  36129. "msg": "目录对照成功",
  36130. })
  36131. } else {
  36132. c.ServeSuccessJSON(map[string]interface{}{
  36133. "failed_code": -10,
  36134. "msg": res.ErrMsg,
  36135. })
  36136. }
  36137. }
  36138. }
  36139. }
  36140. func (c *HisApiController) UnCheckCode() {
  36141. ids_str := c.GetString("ids")
  36142. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36143. admin_user_id, _ := c.GetInt64("admin_user_id")
  36144. ids_arr := strings.Split(ids_str, ",")
  36145. var queryResult []QueryResult
  36146. ids := make([]int64, 0)
  36147. for _, item := range ids_arr {
  36148. id, _ := strconv.ParseInt(item, 10, 64)
  36149. ids = append(ids, id)
  36150. }
  36151. if record_type == 1 {
  36152. drugs, _ := service.GetBatchDrugList(ids)
  36153. for _, item := range drugs {
  36154. result := QueryResult{
  36155. ID: item.ID,
  36156. Name: item.DrugName,
  36157. Code: item.MedicalInsuranceNumber,
  36158. List_type_code: "101",
  36159. }
  36160. queryResult = append(queryResult, result)
  36161. }
  36162. } else if record_type == 2 {
  36163. goods, _ := service.GetBatchGoodInformationList(ids)
  36164. for _, item := range goods {
  36165. result := QueryResult{
  36166. ID: item.ID,
  36167. Name: item.GoodName,
  36168. Code: item.SocialSecurityDirectoryCode,
  36169. List_type_code: "301",
  36170. }
  36171. queryResult = append(queryResult, result)
  36172. }
  36173. } else if record_type == 3 {
  36174. projects, _ := service.GetBathchMyPorjecgList(ids)
  36175. for _, item := range projects {
  36176. result := QueryResult{
  36177. ID: item.ID,
  36178. Name: item.ProjectName,
  36179. Code: item.MedicalCode,
  36180. List_type_code: "201",
  36181. }
  36182. queryResult = append(queryResult, result)
  36183. }
  36184. }
  36185. adminUser := c.GetAdminUserInfo()
  36186. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36187. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36188. var user_name string
  36189. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36190. if role.ID == 0 {
  36191. user_name = "xxx"
  36192. } else {
  36193. user_name = role.UserName
  36194. }
  36195. baseParams := &models.BaseParams{
  36196. SecretKey: miConfig.SecretKey,
  36197. FixmedinsCode: miConfig.Code,
  36198. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36199. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36200. OrgName: miConfig.OrgName,
  36201. Doctor: user_name,
  36202. }
  36203. if config.IsOpen == 1 {
  36204. if miConfig.MdtrtareaAdmvs == "430800" {
  36205. for _, item := range queryResult {
  36206. var result string
  36207. if record_type == 1 {
  36208. 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)
  36209. } else if record_type == 2 {
  36210. fmt.Println(item.Code)
  36211. 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)
  36212. } else if record_type == 3 {
  36213. 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)
  36214. }
  36215. var dat map[string]interface{}
  36216. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36217. fmt.Println(dat)
  36218. } else {
  36219. fmt.Println(err)
  36220. }
  36221. userJSONBytes, _ := json.Marshal(dat)
  36222. var res ResultSix
  36223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36224. utils.ErrorLog("解析失败:%v", err)
  36225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36226. return
  36227. }
  36228. if res.Infcode == 0 {
  36229. if record_type == 1 {
  36230. service.UpdateBaseDrugById(item.ID)
  36231. } else if record_type == 2 {
  36232. service.UpdateGoodInformaitonByDetail(item.ID)
  36233. } else if record_type == 3 {
  36234. service.UpdateProjectById(item.ID)
  36235. }
  36236. c.ServeSuccessJSON(map[string]interface{}{
  36237. "failed_code": 0,
  36238. "msg": "目录对照成功",
  36239. })
  36240. } else {
  36241. c.ServeSuccessJSON(map[string]interface{}{
  36242. "failed_code": -10,
  36243. "msg": res.ErrMsg,
  36244. })
  36245. }
  36246. }
  36247. } else {
  36248. for _, item := range queryResult {
  36249. var result string
  36250. if record_type == 1 {
  36251. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36252. } else if record_type == 2 {
  36253. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36254. } else if record_type == 3 {
  36255. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36256. }
  36257. var dat2 map[string]interface{}
  36258. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36259. fmt.Println(dat2)
  36260. } else {
  36261. fmt.Println(err)
  36262. }
  36263. userJSONBytes, _ := json.Marshal(dat2)
  36264. var res ResultSix
  36265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36266. utils.ErrorLog("解析失败:%v", err)
  36267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36268. return
  36269. }
  36270. if res.Infcode == 0 {
  36271. if record_type == 1 {
  36272. service.UpdateDrugByIdDetail(item.ID)
  36273. } else if record_type == 2 {
  36274. service.UpdateGoodInfoById(item.ID)
  36275. } else if record_type == 3 {
  36276. service.UpdateMyProjectById(item.ID)
  36277. }
  36278. c.ServeSuccessJSON(map[string]interface{}{
  36279. "failed_code": 0,
  36280. "msg": "撤销目录对照成功",
  36281. })
  36282. } else {
  36283. c.ServeSuccessJSON(map[string]interface{}{
  36284. "failed_code": -10,
  36285. "msg": res.ErrMsg,
  36286. })
  36287. }
  36288. }
  36289. }
  36290. }
  36291. }
  36292. func (c *HisApiController) GetPatientInfo() {
  36293. id_card_no := c.GetString("id_card_no")
  36294. admin_user_id, _ := c.GetInt64("admin_user_id")
  36295. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36296. if patient.ID == 0 {
  36297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36298. return
  36299. }
  36300. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36301. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36302. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36303. var res ResultTwo
  36304. var res10265 ResultTwo10265
  36305. if config.IsOpen == 1 {
  36306. if miConfig.MdtrtareaAdmvs == "150499" {
  36307. //请求内网数据
  36308. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36309. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36310. "&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
  36311. resp, requestErr := http.Get(api)
  36312. if requestErr != nil {
  36313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36314. return
  36315. }
  36316. body, ioErr := ioutil.ReadAll(resp.Body)
  36317. if ioErr != nil {
  36318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36320. return
  36321. }
  36322. var respJSON map[string]interface{}
  36323. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36326. return
  36327. }
  36328. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36329. result_byte, _ := json.Marshal(respJSON)
  36330. result := string(result_byte)
  36331. var dat map[string]interface{}
  36332. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36333. fmt.Println(dat)
  36334. } else {
  36335. fmt.Println(err)
  36336. }
  36337. userJSONBytes, _ := json.Marshal(dat)
  36338. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36339. utils.ErrorLog("解析失败:%v", err)
  36340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36341. return
  36342. }
  36343. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36344. res.Infcode = Infcode
  36345. res.ErrMsg = res10265.ErrMsg
  36346. res.Output = res10265.Output
  36347. res.InfRefmsgid = res10265.InfRefmsgid
  36348. res.RespondTime = res10265.RespondTime
  36349. res.WarnInfo = res10265.WarnInfo
  36350. } else {
  36351. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36352. var dat map[string]interface{}
  36353. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36354. fmt.Println(dat)
  36355. } else {
  36356. fmt.Println(err)
  36357. }
  36358. userJSONBytes, _ := json.Marshal(dat)
  36359. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36360. utils.ErrorLog("解析失败:%v", err)
  36361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36362. return
  36363. }
  36364. }
  36365. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36366. // utils.ErrorLog("解析失败:%v", err)
  36367. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36368. // return
  36369. //}
  36370. for index, item := range res.Output.Iinfo {
  36371. if item.PsnInsuStas == "2" {
  36372. fmt.Println("--------")
  36373. res.Output.Iinfo[index].Insutype = "300"
  36374. res.Output.Iinfo[index].PsnInsuStas = "1"
  36375. }
  36376. }
  36377. fmt.Println(res.Output.Iinfo)
  36378. if res.Infcode != 0 {
  36379. c.ServeSuccessJSON(map[string]interface{}{
  36380. "failed_code": -10,
  36381. "msg": res.ErrMsg,
  36382. })
  36383. } else {
  36384. c.ServeSuccessJSON(map[string]interface{}{
  36385. "failed_code": 0,
  36386. "info": res,
  36387. })
  36388. }
  36389. }
  36390. }
  36391. func (c *HisApiController) PsnPutOnRecord() {
  36392. record_type, _ := c.GetInt64("type")
  36393. patient_id, _ := c.GetInt64("patient_id")
  36394. admin_user_id, _ := c.GetInt64("admin_user_id")
  36395. start_time := c.GetString("start_time")
  36396. end_time := c.GetString("end_time")
  36397. adminUser := c.GetAdminUserInfo()
  36398. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36399. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36400. var patients []*models.Patients
  36401. if record_type == 1 { //全部备案
  36402. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36403. patients = append(patients, patient...)
  36404. } else { //单个备案
  36405. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36406. patients = append(patients, patient)
  36407. }
  36408. var user_name string
  36409. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36410. if role.ID == 0 {
  36411. user_name = "xxx"
  36412. } else {
  36413. user_name = role.UserName
  36414. }
  36415. if config.IsOpen == 1 {
  36416. for _, item := range patients {
  36417. 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
  36418. resp, requestErr := http.Get(api)
  36419. if requestErr != nil {
  36420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36421. return
  36422. }
  36423. defer resp.Body.Close()
  36424. body, ioErr := ioutil.ReadAll(resp.Body)
  36425. if ioErr != nil {
  36426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36428. return
  36429. }
  36430. var respJSON map[string]interface{}
  36431. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36434. return
  36435. }
  36436. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36437. userJSONBytes, _ := json.Marshal(userJSON)
  36438. var res ResultTwo
  36439. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36440. utils.ErrorLog("解析失败:%v", err)
  36441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36442. return
  36443. }
  36444. if res.Infcode == 0 {
  36445. 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)
  36446. var dat map[string]interface{}
  36447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36448. fmt.Println(dat)
  36449. } else {
  36450. fmt.Println(err)
  36451. }
  36452. userJSONBytes, _ := json.Marshal(dat)
  36453. var res2 ResultThirteen
  36454. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36455. utils.ErrorLog("解析失败:%v", err)
  36456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36457. return
  36458. }
  36459. if res2.Infcode == 0 {
  36460. psnResult := &models.GdybPsnRecord{
  36461. UserOrgId: adminUser.CurrentOrgId,
  36462. PatientId: item.ID,
  36463. PsnNo: res.Output.Baseinfo.PsnNo,
  36464. Ctime: time.Now().Unix(),
  36465. Mtime: time.Now().Unix(),
  36466. Status: 1,
  36467. IsCancel: 1,
  36468. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36469. }
  36470. service.CreatePsnRecord(psnResult)
  36471. } else {
  36472. c.ServeSuccessJSON(map[string]interface{}{
  36473. "failed_code": -10,
  36474. "msg": res2.ErrMsg,
  36475. })
  36476. return
  36477. }
  36478. }
  36479. }
  36480. }
  36481. }
  36482. func (c *HisApiController) PsnUnPutOnRecord() {
  36483. id, _ := c.GetInt64("id")
  36484. //record_type, _ := c.GetInt64("type")
  36485. admin_user_id, _ := c.GetInt64("admin_user_id")
  36486. adminUser := c.GetAdminUserInfo()
  36487. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36488. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36489. var user_name string
  36490. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36491. if role.ID == 0 {
  36492. user_name = "xxx"
  36493. } else {
  36494. user_name = role.UserName
  36495. }
  36496. psn_record, _ := service.GetPsnRecordById(id)
  36497. if psn_record.ID == 0 {
  36498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36499. return
  36500. }
  36501. if config.IsOpen == 1 {
  36502. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36503. var dat map[string]interface{}
  36504. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36505. fmt.Println(dat)
  36506. } else {
  36507. fmt.Println(err)
  36508. }
  36509. userJSONBytes, _ := json.Marshal(dat)
  36510. var res ResultFourteen
  36511. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36512. utils.ErrorLog("解析失败:%v", err)
  36513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36514. return
  36515. }
  36516. if res.Infcode == 0 {
  36517. psn_record.IsCancel = 2
  36518. service.CreatePsnRecord(&psn_record)
  36519. } else {
  36520. c.ServeSuccessJSON(map[string]interface{}{
  36521. "failed_code": -10,
  36522. "msg": res.ErrMsg,
  36523. })
  36524. return
  36525. }
  36526. }
  36527. }
  36528. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36529. patient_id, _ := c.GetInt64("patient_id")
  36530. insutype_two := c.GetString("insutype")
  36531. psn_no := c.GetString("psn_no")
  36532. doctor_id, _ := c.GetInt64("doctor_id")
  36533. sick_id, _ := c.GetInt64("sick_id")
  36534. department_id, _ := c.GetInt64("department_id")
  36535. start_time := c.GetString("start_time")
  36536. end_time := c.GetString("end_time")
  36537. check_time := c.GetString("check_time")
  36538. hospital_code := c.GetString("hospital_code")
  36539. hospital_name := c.GetString("hospital_name")
  36540. adminUser := c.GetAdminUserInfo()
  36541. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36542. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36543. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36544. sick, _ := service.FindSickById(sick_id)
  36545. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36546. if len(hospital_code) == 0 {
  36547. hospital_code = miConfig.Code
  36548. }
  36549. if len(hospital_name) == 0 {
  36550. hospital_name = miConfig.OrgName
  36551. }
  36552. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36553. var res ResultTwo
  36554. var res10265 ResultTwo10265
  36555. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36556. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36557. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36558. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36559. "&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
  36560. resp, requestErr := http.Get(api)
  36561. if requestErr != nil {
  36562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36563. return
  36564. }
  36565. body, ioErr := ioutil.ReadAll(resp.Body)
  36566. if ioErr != nil {
  36567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36569. return
  36570. }
  36571. var respJSON map[string]interface{}
  36572. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36575. return
  36576. }
  36577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36578. result, _ := json.Marshal(respJSON)
  36579. fmt.Println("log")
  36580. fmt.Println(string(result))
  36581. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36582. utils.ErrorLog("解析失败:%v", err)
  36583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36584. return
  36585. }
  36586. res.ErrMsg = res10265.ErrMsg
  36587. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36588. res.Infcode = infocode
  36589. res.Output = res10265.Output
  36590. res.InfRefmsgid = res10265.InfRefmsgid
  36591. } else {
  36592. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36593. if miConfig.Code == "H15049901371" {
  36594. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36595. utils.ErrorLog("解析失败:%v", err)
  36596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36597. return
  36598. }
  36599. res.ErrMsg = res10265.ErrMsg
  36600. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36601. res.Infcode = infocode
  36602. res.Output = res10265.Output
  36603. res.InfRefmsgid = res10265.InfRefmsgid
  36604. } else {
  36605. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36606. utils.ErrorLog("解析失败:%v", err)
  36607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36608. return
  36609. }
  36610. }
  36611. }
  36612. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36613. infoStr := string(Iinfos)
  36614. var rf []*ResultFive
  36615. json.Unmarshal([]byte(infoStr), &rf)
  36616. var insuplc_admdvs string
  36617. var insutype string
  36618. var is390 int = 0
  36619. var is310 int = 0
  36620. var insutypes []*ResultFive
  36621. for _, item := range rf {
  36622. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36623. insutypes = append(insutypes, item)
  36624. }
  36625. }
  36626. if len(insutypes) == 1 {
  36627. insutype = insutypes[0].Insutype
  36628. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36629. } else {
  36630. for _, i := range insutypes {
  36631. if i.Insutype == "390" {
  36632. is390 = 1
  36633. }
  36634. if i.Insutype == "310" {
  36635. is310 = 1
  36636. }
  36637. }
  36638. }
  36639. if is390 == 1 {
  36640. insutype = "390"
  36641. }
  36642. if is310 == 1 {
  36643. insutype = "310"
  36644. }
  36645. if len(insutypes) == 2 {
  36646. insutype = insutype_two
  36647. }
  36648. if len(insutypes) == 0 {
  36649. insutype = "310"
  36650. }
  36651. insutype = insutype_two
  36652. fmt.Println(insutype)
  36653. for _, item := range rf {
  36654. fmt.Println(item.Insutype)
  36655. fmt.Println(insutype)
  36656. if item.Insutype == insutype {
  36657. fmt.Println(item.Insutype)
  36658. fmt.Println(insutype)
  36659. insuplc_admdvs = item.InsuplcAdmdvs
  36660. }
  36661. }
  36662. fmt.Println(insuplc_admdvs)
  36663. var res2 ResultThirteen
  36664. var res10265_2 ResultThirteen10265
  36665. if config.IsOpen == 1 {
  36666. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36667. } else {
  36668. if miConfig.MdtrtareaAdmvs == "150499" {
  36669. //
  36670. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36671. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36672. // "&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
  36673. //resp, requestErr := http.Get(api)
  36674. //if requestErr != nil {
  36675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36676. // return
  36677. //}
  36678. //
  36679. //body, ioErr := ioutil.ReadAll(resp.Body)
  36680. //if ioErr != nil {
  36681. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36682. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36683. // return
  36684. //}
  36685. //var respJSON map[string]interface{}
  36686. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36687. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36689. // return
  36690. //}
  36691. //
  36692. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36693. //result, _ := json.Marshal(respJSON)
  36694. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36695. // utils.ErrorLog("解析失败:%v", err)
  36696. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36697. // return
  36698. //}
  36699. //infocode = resThree.Infcode
  36700. //result, _ := json.Marshal(respJSON)
  36701. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36702. // utils.ErrorLog("解析失败:%v", err)
  36703. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36704. // return
  36705. //}
  36706. //
  36707. //resThree.ErrMsg = resThree10265.ErrMsg
  36708. //
  36709. //resThree.Output = resThree10265.Output
  36710. //
  36711. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36712. //
  36713. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36714. //
  36715. } else {
  36716. 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)
  36717. var dat map[string]interface{}
  36718. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36719. fmt.Println(dat)
  36720. } else {
  36721. fmt.Println(err)
  36722. }
  36723. userJSONBytes, _ := json.Marshal(dat)
  36724. if miConfig.Code == "H15049901371" {
  36725. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36726. utils.ErrorLog("解析失败:%v", err)
  36727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36728. return
  36729. }
  36730. res2.ErrMsg = res10265_2.ErrMsg
  36731. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36732. res2.Infcode = infocode
  36733. res2.Output = res10265_2.Output
  36734. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36735. } else {
  36736. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36737. utils.ErrorLog("解析失败:%v", err)
  36738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36739. return
  36740. }
  36741. }
  36742. }
  36743. }
  36744. if res2.Infcode == 0 {
  36745. psnResult := &models.GdybPsnNcdsRecord{
  36746. UserOrgId: adminUser.CurrentOrgId,
  36747. PatientId: patient.ID,
  36748. PsnNo: psn_no,
  36749. DoctorId: doctor.AdminUserId,
  36750. DepartmentId: department_id,
  36751. SickType: sick_id,
  36752. Insutype: insutype,
  36753. Ctime: time.Now().Unix(),
  36754. Mtime: time.Now().Unix(),
  36755. Status: 1,
  36756. IsCancel: 1,
  36757. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36758. }
  36759. service.CreatePsnNCDSRecord(psnResult)
  36760. c.ServeSuccessJSON(map[string]interface{}{
  36761. "failed_code": 0,
  36762. "msg": "备案成功",
  36763. "result": psnResult,
  36764. })
  36765. } else {
  36766. c.ServeSuccessJSON(map[string]interface{}{
  36767. "failed_code": -10,
  36768. "msg": res2.ErrMsg,
  36769. })
  36770. return
  36771. }
  36772. }
  36773. }
  36774. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36775. id, _ := c.GetInt64("id")
  36776. admin_user_id, _ := c.GetInt64("admin_user_id")
  36777. adminUser := c.GetAdminUserInfo()
  36778. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36779. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36780. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36781. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36782. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36783. //var user_name string
  36784. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36785. //if role.ID == 0 {
  36786. // user_name = "xxx"
  36787. //} else {
  36788. // user_name = role.UserName
  36789. //}
  36790. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36791. if psn_record.ID == 0 {
  36792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36793. return
  36794. }
  36795. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36796. var res ResultTwo
  36797. var res10265 ResultTwo10265
  36798. if miConfig.Code == "H15049901371" {
  36799. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36800. utils.ErrorLog("解析失败:%v", err)
  36801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36802. return
  36803. }
  36804. res.ErrMsg = res10265.ErrMsg
  36805. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36806. res.Infcode = infocode
  36807. res.Output = res10265.Output
  36808. res.InfRefmsgid = res10265.InfRefmsgid
  36809. } else {
  36810. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36811. utils.ErrorLog("解析失败:%v", err)
  36812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36813. return
  36814. }
  36815. }
  36816. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36817. infoStr := string(Iinfos)
  36818. var rf []*ResultFive
  36819. json.Unmarshal([]byte(infoStr), &rf)
  36820. var insuplc_admdvs string
  36821. var insutype string
  36822. var is390 int = 0
  36823. var is310 int = 0
  36824. var insutypes []*ResultFive
  36825. for _, item := range rf {
  36826. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36827. insutypes = append(insutypes, item)
  36828. }
  36829. }
  36830. if len(insutypes) == 1 {
  36831. insutype = insutypes[0].Insutype
  36832. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36833. } else {
  36834. for _, i := range insutypes {
  36835. if i.Insutype == "390" {
  36836. is390 = 1
  36837. }
  36838. if i.Insutype == "310" {
  36839. is310 = 1
  36840. }
  36841. }
  36842. }
  36843. if is390 == 1 {
  36844. insutype = "390"
  36845. }
  36846. if is310 == 1 {
  36847. insutype = "310"
  36848. }
  36849. if len(insutypes) == 0 {
  36850. insutype = "310"
  36851. }
  36852. insutype = psn_record.Insutype
  36853. for _, item := range rf {
  36854. if item.Insutype == insutype {
  36855. insuplc_admdvs = item.InsuplcAdmdvs
  36856. }
  36857. }
  36858. if config.IsOpen == 1 {
  36859. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36860. var dat map[string]interface{}
  36861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36862. fmt.Println(dat)
  36863. } else {
  36864. fmt.Println(err)
  36865. }
  36866. userJSONBytes, _ := json.Marshal(dat)
  36867. var res ResultFourteen
  36868. var res10265 ResultFourteen10265
  36869. if miConfig.Code == "H15049901371" {
  36870. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36871. utils.ErrorLog("解析失败:%v", err)
  36872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36873. return
  36874. }
  36875. res.ErrMsg = res10265.ErrMsg
  36876. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36877. res.Infcode = infocode
  36878. res.Output = res10265.Output
  36879. res.InfRefmsgid = res10265.InfRefmsgid
  36880. } else {
  36881. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36882. utils.ErrorLog("解析失败:%v", err)
  36883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36884. return
  36885. }
  36886. }
  36887. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36888. // utils.ErrorLog("解析失败:%v", err)
  36889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36890. // return
  36891. //}
  36892. if res.Infcode == 0 {
  36893. psn_record.IsCancel = 2
  36894. service.CreatePsnNCDSRecord(&psn_record)
  36895. c.ServeSuccessJSON(map[string]interface{}{
  36896. "failed_code": 0,
  36897. "msg": "撤销备案成功",
  36898. })
  36899. } else {
  36900. c.ServeSuccessJSON(map[string]interface{}{
  36901. "failed_code": -10,
  36902. "msg": res.ErrMsg,
  36903. })
  36904. return
  36905. }
  36906. }
  36907. }
  36908. func (c *HisApiController) TestTest() {
  36909. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36910. fmt.Println(patient.Iinfo)
  36911. }
  36912. type CustomData struct {
  36913. MsgId string
  36914. PsnNo string
  36915. Info string
  36916. }
  36917. func (c *HisApiController) ReversalData() {
  36918. var customData []*CustomData
  36919. custom := &CustomData{
  36920. MsgId: "H44022900158202103301714472004",
  36921. PsnNo: "44020000001101329945",
  36922. Info: "2207",
  36923. }
  36924. customData = append(customData, custom)
  36925. custom1 := &CustomData{
  36926. MsgId: "H4402290015820210330172057803",
  36927. PsnNo: "44020000001101161813",
  36928. Info: "2207",
  36929. }
  36930. customData = append(customData, custom1)
  36931. custom2 := &CustomData{
  36932. MsgId: "H44022900158202103301705198813",
  36933. PsnNo: "44190000133097375417",
  36934. Info: "2207",
  36935. }
  36936. customData = append(customData, custom2)
  36937. custom3 := &CustomData{
  36938. MsgId: "H44022900158202103301715524756",
  36939. PsnNo: "44020000001100187221",
  36940. Info: "2207",
  36941. }
  36942. customData = append(customData, custom3)
  36943. custom4 := &CustomData{
  36944. MsgId: "H44022900158202103301730376224",
  36945. PsnNo: "44020000001101959155",
  36946. Info: "2207",
  36947. }
  36948. customData = append(customData, custom4)
  36949. custom5 := &CustomData{
  36950. MsgId: "H44022900158202103301748008725",
  36951. PsnNo: "44020000001104246641",
  36952. Info: "2207",
  36953. }
  36954. customData = append(customData, custom5)
  36955. custom6 := &CustomData{
  36956. MsgId: "H44022900158202103301718096755",
  36957. PsnNo: "44020000001102211860",
  36958. Info: "2207",
  36959. }
  36960. customData = append(customData, custom6)
  36961. custom7 := &CustomData{
  36962. MsgId: "H44022900158202103301736551640",
  36963. PsnNo: "44020000001102687718",
  36964. Info: "2207",
  36965. }
  36966. customData = append(customData, custom7)
  36967. custom8 := &CustomData{
  36968. MsgId: "H44022900158202103301743097676",
  36969. PsnNo: "44020000001102127785",
  36970. Info: "2207",
  36971. }
  36972. customData = append(customData, custom8)
  36973. custom9 := &CustomData{
  36974. MsgId: "H44022900158202103301712304203",
  36975. PsnNo: "44020000001101518097",
  36976. Info: "2207",
  36977. }
  36978. customData = append(customData, custom9)
  36979. custom10 := &CustomData{
  36980. MsgId: "H44022900158202103301738448785",
  36981. PsnNo: "44020000001100500813",
  36982. Info: "2207",
  36983. }
  36984. customData = append(customData, custom10)
  36985. custom11 := &CustomData{
  36986. MsgId: "H44022900158202103301732455843",
  36987. PsnNo: "44020000001102690557",
  36988. Info: "2207",
  36989. }
  36990. customData = append(customData, custom11)
  36991. custom12 := &CustomData{
  36992. MsgId: "H44022900158202103301745421708",
  36993. PsnNo: "44020000001102211928",
  36994. Info: "2207",
  36995. }
  36996. customData = append(customData, custom12)
  36997. custom1212 := &CustomData{
  36998. MsgId: "H440229001582021033017351627",
  36999. PsnNo: "44020000001102481733",
  37000. Info: "2207",
  37001. }
  37002. customData = append(customData, custom1212)
  37003. custom13 := &CustomData{
  37004. MsgId: "H44022900158202103301740327951",
  37005. PsnNo: "44020000001103174866",
  37006. Info: "2207",
  37007. }
  37008. customData = append(customData, custom13)
  37009. custom14 := &CustomData{
  37010. MsgId: "H4402290015820210330174922668",
  37011. PsnNo: "44020000001102927272",
  37012. Info: "2207",
  37013. }
  37014. customData = append(customData, custom14)
  37015. custom15 := &CustomData{
  37016. MsgId: "H44022900158202103301752362273",
  37017. PsnNo: "44020000001102942890",
  37018. Info: "2207",
  37019. }
  37020. customData = append(customData, custom15)
  37021. custom16 := &CustomData{
  37022. MsgId: "H44022900158202103301751082917",
  37023. PsnNo: "44020000001101662162",
  37024. Info: "2207",
  37025. }
  37026. customData = append(customData, custom16)
  37027. custom17 := &CustomData{
  37028. MsgId: "H44022900158202103301754147728",
  37029. PsnNo: "44020000000229014511",
  37030. Info: "2207",
  37031. }
  37032. customData = append(customData, custom17)
  37033. adminUser := c.GetAdminUserInfo()
  37034. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37035. for _, item := range customData {
  37036. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37037. fmt.Println(result)
  37038. }
  37039. }
  37040. func (c *HisApiController) GetAllopatry() {
  37041. year := c.GetString("year")
  37042. month := c.GetString("month")
  37043. admin_user_id, _ := c.GetInt64("admin_user_id")
  37044. adminUser := c.GetAdminUserInfo()
  37045. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37046. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37047. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37048. var dat map[string]interface{}
  37049. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37050. fmt.Println(dat)
  37051. } else {
  37052. fmt.Println(err)
  37053. }
  37054. userJSONBytes, _ := json.Marshal(dat)
  37055. var res models.Result9001
  37056. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37057. utils.ErrorLog("解析失败:%v", err)
  37058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37059. return
  37060. }
  37061. fmt.Println(res.Output.Signinoutb)
  37062. fmt.Println(res.Output.Signinoutb.SignNo)
  37063. fmt.Println(string(userJSONBytes))
  37064. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37065. var dat3 map[string]interface{}
  37066. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  37067. fmt.Println(dat3)
  37068. } else {
  37069. fmt.Println(err)
  37070. }
  37071. userJSONBytes3, _ := json.Marshal(dat3)
  37072. var res3 models.Result3260
  37073. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  37074. utils.ErrorLog("解析失败:%v", err)
  37075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37076. return
  37077. }
  37078. var curpage int
  37079. var pagesize int = 100
  37080. var start int = 1
  37081. //var stop int
  37082. //pagecount := 10
  37083. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  37084. var res22 []models.Result3260
  37085. for curpage = 1; curpage <= pagecount; curpage++ {
  37086. if curpage == 1 {
  37087. start = 0
  37088. } else {
  37089. start = (curpage-1)*pagesize + 1
  37090. }
  37091. fmt.Println(start)
  37092. //stop = curpage * pagesize
  37093. //if stop > int(res3.Output.Totalrow) {
  37094. // stop =int(res3.Output.Totalrow)
  37095. //}
  37096. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  37097. var dat2 map[string]interface{}
  37098. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37099. fmt.Println(dat)
  37100. } else {
  37101. fmt.Println(err)
  37102. }
  37103. userJSONBytes2, _ := json.Marshal(dat2)
  37104. var res2 models.Result3260
  37105. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37106. utils.ErrorLog("解析失败:%v", err)
  37107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37108. return
  37109. }
  37110. if res2.Infcode == 0 {
  37111. res22 = append(res22, res2)
  37112. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37113. //var dat2 map[string]interface{}
  37114. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37115. // fmt.Println(dat)
  37116. //} else {
  37117. // fmt.Println(err)
  37118. //}
  37119. //c.ServeSuccessJSON(map[string]interface{}{
  37120. // "list": res2.Output.Data,
  37121. //})
  37122. //continue
  37123. }
  37124. }
  37125. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37126. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37127. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  37128. //var dat2 map[string]interface{}
  37129. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37130. // fmt.Println(dat)
  37131. //} else {
  37132. // fmt.Println(err)
  37133. //}
  37134. //userJSONBytes2, _ := json.Marshal(dat2)
  37135. //var res2 models.Result3260
  37136. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37137. // utils.ErrorLog("解析失败:%v", err)
  37138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37139. // return
  37140. //}
  37141. //if res2.Infcode == 0 {
  37142. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37143. // var dat2 map[string]interface{}
  37144. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37145. // fmt.Println(dat)
  37146. // } else {
  37147. // fmt.Println(err)
  37148. // }
  37149. // c.ServeSuccessJSON(map[string]interface{}{
  37150. // "list": res2.Output.Data,
  37151. // })
  37152. //}
  37153. }
  37154. func (c *HisApiController) ComfirmAllopatry() {
  37155. year := c.GetString("year")
  37156. month := c.GetString("month")
  37157. admin_user_id, _ := c.GetInt64("admin_user_id")
  37158. adminUser := c.GetAdminUserInfo()
  37159. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37160. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37161. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37162. var dat map[string]interface{}
  37163. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37164. fmt.Println(dat)
  37165. } else {
  37166. fmt.Println(err)
  37167. }
  37168. userJSONBytes, _ := json.Marshal(dat)
  37169. var res models.Result9001
  37170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37171. utils.ErrorLog("解析失败:%v", err)
  37172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37173. return
  37174. }
  37175. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37176. var dat2 map[string]interface{}
  37177. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37178. fmt.Println(dat)
  37179. } else {
  37180. fmt.Println(err)
  37181. }
  37182. userJSONBytes2, _ := json.Marshal(dat2)
  37183. var res2 models.Result3260
  37184. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37185. utils.ErrorLog("解析失败:%v", err)
  37186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37187. return
  37188. }
  37189. //if res2.Infcode == 0 {
  37190. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37191. // var dat map[string]interface{}
  37192. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37193. // fmt.Println(dat)
  37194. // } else {
  37195. // fmt.Println(err)
  37196. // }
  37197. // userJSONBytes, _ := json.Marshal(dat)
  37198. // var res3 models.Result3261
  37199. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37200. // utils.ErrorLog("解析失败:%v", err)
  37201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37202. // return
  37203. // }
  37204. //
  37205. // if res3.Infcode == 0 {
  37206. // record := &models.HisYidiClearRecord{
  37207. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37208. // Ctime: time.Now().Unix(),
  37209. // Mtime: time.Now().Unix(),
  37210. // Status: 1,
  37211. // MsgId: msgId,
  37212. // }
  37213. // service.SaveClearRecord(record)
  37214. // c.ServeSuccessJSON(map[string]interface{}{
  37215. // "msg": "提取成功",
  37216. // })
  37217. // }
  37218. //}
  37219. }
  37220. func (c *HisApiController) RefundAllopatry() {
  37221. year := c.GetString("year")
  37222. month := c.GetString("month")
  37223. //id, _ := c.GetInt64("id")
  37224. admin_user_id, _ := c.GetInt64("admin_user_id")
  37225. adminUser := c.GetAdminUserInfo()
  37226. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37227. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37228. //record, _ := service.GetClearRecordById(id)
  37229. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37230. var dat map[string]interface{}
  37231. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37232. fmt.Println(dat)
  37233. } else {
  37234. fmt.Println(err)
  37235. }
  37236. userJSONBytes, _ := json.Marshal(dat)
  37237. var res models.Result9001
  37238. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37239. utils.ErrorLog("解析失败:%v", err)
  37240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37241. return
  37242. }
  37243. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37244. var dat2 map[string]interface{}
  37245. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37246. fmt.Println(dat)
  37247. } else {
  37248. fmt.Println(err)
  37249. }
  37250. userJSONBytes2, _ := json.Marshal(dat2)
  37251. var empty ResultFourteen
  37252. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37253. utils.ErrorLog("解析失败:%v", err)
  37254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37255. return
  37256. }
  37257. if empty.Infcode == 0 {
  37258. c.ServeSuccessJSON(map[string]interface{}{
  37259. "msg": "撤销成功",
  37260. })
  37261. return
  37262. }
  37263. }
  37264. func (c *HisApiController) ReversalOtherData() {
  37265. var customData []*CustomData
  37266. custom := &CustomData{
  37267. MsgId: "H44022900158202103301714472004",
  37268. PsnNo: "44020000001101329945",
  37269. Info: "2208",
  37270. }
  37271. customData = append(customData, custom)
  37272. custom1 := &CustomData{
  37273. MsgId: "H4402290015820210330172057803",
  37274. PsnNo: "44020000001101161813",
  37275. Info: "2208",
  37276. }
  37277. customData = append(customData, custom1)
  37278. custom2 := &CustomData{
  37279. MsgId: "H44022900158202103301705198813",
  37280. PsnNo: "44190000133097375417",
  37281. Info: "2208",
  37282. }
  37283. customData = append(customData, custom2)
  37284. custom3 := &CustomData{
  37285. MsgId: "H44022900158202103301715524756",
  37286. PsnNo: "44020000001100187221",
  37287. Info: "2208",
  37288. }
  37289. customData = append(customData, custom3)
  37290. custom4 := &CustomData{
  37291. MsgId: "H44022900158202103301730376224",
  37292. PsnNo: "44020000001101959155",
  37293. Info: "2208",
  37294. }
  37295. customData = append(customData, custom4)
  37296. custom5 := &CustomData{
  37297. MsgId: "H44022900158202103301748008725",
  37298. PsnNo: "44020000001104246641",
  37299. Info: "2208",
  37300. }
  37301. customData = append(customData, custom5)
  37302. custom6 := &CustomData{
  37303. MsgId: "H44022900158202103301718096755",
  37304. PsnNo: "44020000001102211860",
  37305. Info: "2208",
  37306. }
  37307. customData = append(customData, custom6)
  37308. custom7 := &CustomData{
  37309. MsgId: "H44022900158202103301736551640",
  37310. PsnNo: "44020000001102687718",
  37311. Info: "2208",
  37312. }
  37313. customData = append(customData, custom7)
  37314. custom8 := &CustomData{
  37315. MsgId: "H44022900158202103301743097676",
  37316. PsnNo: "44020000001102127785",
  37317. Info: "2208",
  37318. }
  37319. customData = append(customData, custom8)
  37320. custom9 := &CustomData{
  37321. MsgId: "H44022900158202103301712304203",
  37322. PsnNo: "44020000001101518097",
  37323. Info: "2208",
  37324. }
  37325. customData = append(customData, custom9)
  37326. custom10 := &CustomData{
  37327. MsgId: "H44022900158202103301738448785",
  37328. PsnNo: "44020000001100500813",
  37329. Info: "2208",
  37330. }
  37331. customData = append(customData, custom10)
  37332. custom11 := &CustomData{
  37333. MsgId: "H44022900158202103301732455843",
  37334. PsnNo: "44020000001102690557",
  37335. Info: "2208",
  37336. }
  37337. customData = append(customData, custom11)
  37338. custom12 := &CustomData{
  37339. MsgId: "H44022900158202103301745421708",
  37340. PsnNo: "44020000001102211928",
  37341. Info: "2208",
  37342. }
  37343. customData = append(customData, custom12)
  37344. custom1212 := &CustomData{
  37345. MsgId: "H440229001582021033017351627",
  37346. PsnNo: "44020000001102481733",
  37347. Info: "2208",
  37348. }
  37349. customData = append(customData, custom1212)
  37350. custom13 := &CustomData{
  37351. MsgId: "H44022900158202103301740327951",
  37352. PsnNo: "44020000001103174866",
  37353. Info: "2208",
  37354. }
  37355. customData = append(customData, custom13)
  37356. custom14 := &CustomData{
  37357. MsgId: "H4402290015820210330174922668",
  37358. PsnNo: "44020000001102927272",
  37359. Info: "2208",
  37360. }
  37361. customData = append(customData, custom14)
  37362. custom15 := &CustomData{
  37363. MsgId: "H44022900158202103301752362273",
  37364. PsnNo: "44020000001102942890",
  37365. Info: "2208",
  37366. }
  37367. customData = append(customData, custom15)
  37368. custom16 := &CustomData{
  37369. MsgId: "H44022900158202103301751082917",
  37370. PsnNo: "44020000001101662162",
  37371. Info: "2208",
  37372. }
  37373. customData = append(customData, custom16)
  37374. custom17 := &CustomData{
  37375. MsgId: "H44022900158202103301754147728",
  37376. PsnNo: "44020000000229014511",
  37377. Info: "2208",
  37378. }
  37379. customData = append(customData, custom17)
  37380. adminUser := c.GetAdminUserInfo()
  37381. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37382. for _, item := range customData {
  37383. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37384. fmt.Println(result)
  37385. }
  37386. }
  37387. func PathExists(path string) (bool, error) {
  37388. _, err := os.Stat(path)
  37389. if err == nil {
  37390. return true, nil
  37391. }
  37392. if os.IsNotExist(err) {
  37393. return false, nil
  37394. }
  37395. return false, err
  37396. }
  37397. // 创建文件夹
  37398. func Mkdir(dir string) {
  37399. // 创建文件夹
  37400. exist, err := PathExists(dir)
  37401. if err != nil {
  37402. fmt.Println(err.Error())
  37403. } else {
  37404. if exist {
  37405. fmt.Println(dir + "文件夹已存在!")
  37406. } else {
  37407. // 文件夹名称,权限
  37408. err := os.Mkdir(dir, os.ModePerm)
  37409. if err != nil {
  37410. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37411. } else {
  37412. fmt.Println(dir + "文件夹创建成功!")
  37413. }
  37414. }
  37415. }
  37416. }
  37417. // 压缩文件
  37418. func Zip(srcFile string, destZip string) error {
  37419. zipfile, err := os.Create(destZip)
  37420. if err != nil {
  37421. return err
  37422. }
  37423. defer zipfile.Close()
  37424. archive := zip.NewWriter(zipfile)
  37425. defer archive.Close()
  37426. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37427. if err != nil {
  37428. return err
  37429. }
  37430. header, err := zip.FileInfoHeader(info)
  37431. if err != nil {
  37432. return err
  37433. }
  37434. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37435. // header.Name = path
  37436. if info.IsDir() {
  37437. header.Name += "/"
  37438. } else {
  37439. header.Method = zip.Deflate
  37440. }
  37441. writer, err := archive.CreateHeader(header)
  37442. if err != nil {
  37443. return err
  37444. }
  37445. if !info.IsDir() {
  37446. file, err := os.Open(path)
  37447. if err != nil {
  37448. return err
  37449. }
  37450. defer file.Close()
  37451. _, err = io.Copy(writer, file)
  37452. }
  37453. return err
  37454. })
  37455. return err
  37456. }
  37457. func ReadFile(filePath string) []byte {
  37458. f, err := os.Open(filePath)
  37459. if err != nil {
  37460. fmt.Println("read file fail", err)
  37461. return nil
  37462. }
  37463. defer f.Close()
  37464. fd, err := ioutil.ReadAll(f)
  37465. if err != nil {
  37466. fmt.Println("read to fd fail", err)
  37467. return nil
  37468. }
  37469. return fd
  37470. }
  37471. func saveLogq(result string, request string, infno string, desc string) {
  37472. dir := "日志"
  37473. utils.Mkdir(dir)
  37474. month := time.Unix(1557042972, 0).Format("1")
  37475. year := time.Now().Format("2006")
  37476. month = time.Now().Format("01")
  37477. day := time.Now().Format("02")
  37478. hour := time.Now().Format("15")
  37479. min := time.Now().Format("04")
  37480. sec := time.Now().Format("05")
  37481. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37482. file := year + month + day + "_log"
  37483. file_name := file + ".txt"
  37484. file_path := "日志" + "/" + file_name
  37485. exist, _ := utils.PathExists(file_path)
  37486. if exist { //存在
  37487. fmt.Println("存在")
  37488. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37489. if err != nil {
  37490. fmt.Println("read fail")
  37491. }
  37492. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37493. n, _ := f.Seek(0, 2)
  37494. _, err = f.WriteAt([]byte(content), n)
  37495. } else { //不存在
  37496. fmt.Println("文件不存在,创建文件")
  37497. f, err := os.Create("日志" + "/" + file_name)
  37498. defer f.Close()
  37499. if err != nil {
  37500. } else {
  37501. _, err = f.Write([]byte("记录日志"))
  37502. }
  37503. }
  37504. }
  37505. func saveLog(result string, request string, infno string, desc string) {
  37506. org_id, _ := beego.AppConfig.Int64("org_id")
  37507. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37508. dir := miConfig.OrgName + "日志"
  37509. utils.Mkdir(dir)
  37510. month := time.Unix(1557042972, 0).Format("1")
  37511. year := time.Now().Format("2006")
  37512. month = time.Now().Format("01")
  37513. day := time.Now().Format("02")
  37514. hour := time.Now().Format("15")
  37515. min := time.Now().Format("04")
  37516. sec := time.Now().Format("05")
  37517. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37518. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37519. file_name := file + ".txt"
  37520. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37521. exist, _ := utils.PathExists(file_path)
  37522. if exist { //存在
  37523. fmt.Println("存在")
  37524. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37525. if err != nil {
  37526. fmt.Println("read fail")
  37527. }
  37528. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37529. n, _ := f.Seek(0, 2)
  37530. _, err = f.WriteAt([]byte(content), n)
  37531. } else { //不存在
  37532. fmt.Println("文件不存在,创建文件")
  37533. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37534. defer f.Close()
  37535. if err != nil {
  37536. } else {
  37537. _, err = f.Write([]byte("记录日志"))
  37538. }
  37539. }
  37540. }
  37541. type Charset string
  37542. const (
  37543. UTF8 = Charset("UTF-8")
  37544. GB18030 = Charset("GB18030")
  37545. )
  37546. func ConvertToString(src string, srcCode string, tagCode string) string {
  37547. srcCoder := mahonia.NewDecoder(srcCode)
  37548. srcResult := srcCoder.ConvertString(src)
  37549. tagCoder := mahonia.NewDecoder(tagCode)
  37550. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37551. result := string(cdata)
  37552. return result
  37553. }
  37554. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37555. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37556. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37557. var token string
  37558. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37559. var api string
  37560. if miConfig.MdtrtareaAdmvs == "320921" {
  37561. 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 +
  37562. "&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
  37563. fmt.Println(api)
  37564. } else {
  37565. 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 +
  37566. "&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
  37567. }
  37568. resp, requestErr := http.Get(api)
  37569. if requestErr != nil {
  37570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37571. return ""
  37572. }
  37573. body, ioErr := ioutil.ReadAll(resp.Body)
  37574. if ioErr != nil {
  37575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37577. return ""
  37578. }
  37579. var respJSON map[string]interface{}
  37580. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37583. return ""
  37584. }
  37585. var status string
  37586. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37587. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37588. var res ResultTwo //1101结果
  37589. var res10265 ResultTwo10265 //1101结果
  37590. if status == "0" { //读卡成功
  37591. var card_info string //卡信息
  37592. var busi_card_info string
  37593. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37594. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37595. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37596. fmt.Println(card_info)
  37597. fmt.Println(busi_card_info)
  37598. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37599. result, _ := json.Marshal(respJSON)
  37600. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37601. utils.ErrorLog("解析失败:%v", err)
  37602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37603. return ""
  37604. }
  37605. res.ErrMsg = res10265.ErrMsg
  37606. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37607. res.Infcode = infocode
  37608. res.Output = res10265.Output
  37609. res.InfRefmsgid = res10265.InfRefmsgid
  37610. if res.Infcode == 0 {
  37611. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37612. if err == gorm.ErrRecordNotFound {
  37613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37614. return ""
  37615. } else if err != nil {
  37616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37617. return ""
  37618. } else {
  37619. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37620. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37621. infoStr := string(Iinfos)
  37622. idetinfoStr := string(Idetinfos)
  37623. psn := &models.HisPsn{
  37624. PsnNo: res.Output.Baseinfo.PsnNo,
  37625. PatientId: patient.ID,
  37626. Certno: res.Output.Baseinfo.Certno,
  37627. Gend: res.Output.Baseinfo.Gend,
  37628. Naty: res.Output.Baseinfo.Naty,
  37629. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37630. PsnName: res.Output.Baseinfo.PsnName,
  37631. Idetinfo: idetinfoStr,
  37632. Insuinfo: infoStr,
  37633. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37634. CardInfo: card_info,
  37635. VerifyNumber: token,
  37636. }
  37637. service.CreateHisPsn(psn)
  37638. return token
  37639. }
  37640. }
  37641. } else {
  37642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37643. return ""
  37644. }
  37645. } else { //读卡失败
  37646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37647. return ""
  37648. }
  37649. return token
  37650. }
  37651. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37652. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37653. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37654. var token string
  37655. var api string
  37656. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37657. "&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
  37658. fmt.Println(api)
  37659. resp, requestErr := http.Get(api)
  37660. if requestErr != nil {
  37661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37662. return ""
  37663. }
  37664. body, ioErr := ioutil.ReadAll(resp.Body)
  37665. if ioErr != nil {
  37666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37668. return ""
  37669. }
  37670. var respJSON map[string]interface{}
  37671. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37674. return ""
  37675. }
  37676. var status string
  37677. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37678. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37679. var res ResultTwo //1101结果
  37680. if status == "1" { //读卡成功
  37681. var card_info string //卡信息
  37682. var busi_card_info string
  37683. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37684. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37685. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37686. fmt.Println(card_info)
  37687. fmt.Println(busi_card_info)
  37688. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37689. result, _ := json.Marshal(respJSON)
  37690. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37691. utils.ErrorLog("解析失败:%v", err)
  37692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37693. return ""
  37694. }
  37695. if res.Infcode == 0 {
  37696. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37697. if err == gorm.ErrRecordNotFound {
  37698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37699. return ""
  37700. } else if err != nil {
  37701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37702. return ""
  37703. } else {
  37704. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37705. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37706. infoStr := string(Iinfos)
  37707. idetinfoStr := string(Idetinfos)
  37708. psn := &models.HisPsn{
  37709. PsnNo: res.Output.Baseinfo.PsnNo,
  37710. PatientId: patient.ID,
  37711. Certno: res.Output.Baseinfo.Certno,
  37712. Gend: res.Output.Baseinfo.Gend,
  37713. Naty: res.Output.Baseinfo.Naty,
  37714. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37715. PsnName: res.Output.Baseinfo.PsnName,
  37716. Idetinfo: idetinfoStr,
  37717. Insuinfo: infoStr,
  37718. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37719. CardInfo: card_info,
  37720. VerifyNumber: token,
  37721. }
  37722. service.CreateHisPsn(psn)
  37723. return token
  37724. }
  37725. }
  37726. } else {
  37727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37728. return ""
  37729. }
  37730. return token
  37731. }
  37732. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37733. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37734. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37735. var token string
  37736. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37737. var api string
  37738. if miConfig.MdtrtareaAdmvs == "320921" {
  37739. 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 +
  37740. "&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
  37741. fmt.Println(api)
  37742. } else {
  37743. 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 +
  37744. "&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
  37745. }
  37746. resp, requestErr := http.Get(api)
  37747. if requestErr != nil {
  37748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37749. return ""
  37750. }
  37751. body, ioErr := ioutil.ReadAll(resp.Body)
  37752. if ioErr != nil {
  37753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37755. return ""
  37756. }
  37757. var respJSON map[string]interface{}
  37758. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37761. return ""
  37762. }
  37763. var status string
  37764. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37765. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37766. var res ResultTwo //1101结果
  37767. var res10265 ResultTwo10265 //1101结果
  37768. if status == "0" { //读卡成功
  37769. var card_info string //卡信息
  37770. var busi_card_info string
  37771. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37772. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37773. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37774. fmt.Println(card_info)
  37775. fmt.Println(busi_card_info)
  37776. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37777. result, _ := json.Marshal(respJSON)
  37778. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37779. utils.ErrorLog("解析失败:%v", err)
  37780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37781. return ""
  37782. }
  37783. res.ErrMsg = res10265.ErrMsg
  37784. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37785. res.Infcode = infocode
  37786. res.Output = res10265.Output
  37787. res.InfRefmsgid = res10265.InfRefmsgid
  37788. if res.Infcode == 0 {
  37789. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37790. if err == gorm.ErrRecordNotFound {
  37791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37792. return ""
  37793. } else if err != nil {
  37794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37795. return ""
  37796. } else {
  37797. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37798. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37799. infoStr := string(Iinfos)
  37800. idetinfoStr := string(Idetinfos)
  37801. psn := &models.HisPsn{
  37802. PsnNo: res.Output.Baseinfo.PsnNo,
  37803. PatientId: patient.ID,
  37804. Certno: res.Output.Baseinfo.Certno,
  37805. Gend: res.Output.Baseinfo.Gend,
  37806. Naty: res.Output.Baseinfo.Naty,
  37807. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37808. PsnName: res.Output.Baseinfo.PsnName,
  37809. Idetinfo: idetinfoStr,
  37810. Insuinfo: infoStr,
  37811. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37812. CardInfo: card_info,
  37813. VerifyNumber: token,
  37814. }
  37815. service.CreateHisPsn(psn)
  37816. return token
  37817. }
  37818. }
  37819. } else {
  37820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37821. return ""
  37822. }
  37823. } else { //读卡失败
  37824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37825. return ""
  37826. }
  37827. return token
  37828. }
  37829. func DeleteExtraSpaceTwo(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. func Remove0000(s string) string {
  37844. str := make([]rune, 0, len(s))
  37845. for _, v := range []rune(s) {
  37846. if v == 0 {
  37847. continue
  37848. }
  37849. str = append(str, v)
  37850. }
  37851. return string(str)
  37852. }
  37853. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37854. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37855. readCard := DllDef.MustFindProc("EcQuery")
  37856. pCardInfo := make([]byte, 8192)
  37857. pBusiCardInfo := make([]byte, 8192)
  37858. data := make(map[string]interface{})
  37859. //pData := make(map[string]interface{})
  37860. inputData := make(map[string]interface{})
  37861. inputData["orgId"] = code
  37862. inputData["businessType"] = "01101"
  37863. inputData["operatorId"] = operator_id
  37864. inputData["operatorName"] = operator_name
  37865. inputData["officeId"] = "001"
  37866. inputData["officeName"] = "血透室"
  37867. //
  37868. data["data"] = inputData
  37869. data["transType"] = "ec.query"
  37870. data["orgId"] = code
  37871. bytesData, _ := json.Marshal(data)
  37872. pCardInfo = bytesData
  37873. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37874. fmt.Println(ret2)
  37875. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37876. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37877. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37878. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37879. if ret2 != 0 {
  37880. return "", ""
  37881. }
  37882. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37883. }
  37884. func DeleteExtraSpace(s string) string {
  37885. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37886. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37887. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37888. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37889. s2 := make([]byte, len(s1)) //定义字符数组切片
  37890. copy(s2, s1) //将字符串复制到切片
  37891. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37892. for len(spc_index) > 0 { //找到适配项
  37893. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37894. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37895. }
  37896. return string(s2)
  37897. }
  37898. // 对账
  37899. func (c *HisApiController) Post3202() {
  37900. start_time := c.GetString("start_time")
  37901. end_time := c.GetString("end_time")
  37902. //insutype := c.GetString("insutype")
  37903. clr_type := c.GetString("clr_type")
  37904. clr_org := c.GetString("clr_optins")
  37905. admin_user_id, _ := c.GetInt64("admin_user_id")
  37906. adminUser := c.GetAdminUserInfo()
  37907. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37908. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37909. if len(clr_org) == 0 {
  37910. clr_org = miConfig.MdtrtareaAdmvs
  37911. }
  37912. timeLayout := "2006-01-02"
  37913. loc, _ := time.LoadLocation("Local")
  37914. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37915. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37916. var orders []*models.HisOrder
  37917. if clr_org == "421300" {
  37918. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37919. } else if clr_org == "420902" {
  37920. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37921. } else {
  37922. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37923. }
  37924. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37925. //fixmedins_setl_cnt := int64(len(orders))
  37926. var medfee_sumamt float64
  37927. var acct_pay float64
  37928. var fund_pay_sumamt float64
  37929. for _, item := range orders {
  37930. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37931. acct_pay = acct_pay + item.AcctPay
  37932. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37933. }
  37934. //var medfee_sumamt_two float64
  37935. //var acct_pay_two float64
  37936. //var fund_pay_sumamt_two float64
  37937. //for _, item := range orders_two {
  37938. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37939. // acct_pay_two = acct_pay_two + item.AcctPay
  37940. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37941. //}
  37942. //var user_name string
  37943. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37944. //if role.ID == 0 {
  37945. // user_name = "xxx"
  37946. //} else {
  37947. // user_name = role.UserName
  37948. //}
  37949. var res ResultSix
  37950. if config.IsOpen == 1 {
  37951. var bps []*models.BusinessParamsTwo
  37952. var bp models.BusinessParamsTwo
  37953. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37954. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37955. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37956. bp.MedfeeSumamt = medfee_sumamt_str
  37957. bp.AcctPay = acct_pay_str
  37958. bp.FundPaySumamt = fund_pay_sumamt_str
  37959. bp.Insutype = ""
  37960. bp.StmtBegndate = start_time
  37961. bp.ClrType = clr_type
  37962. bp.SetlOptins = clr_org
  37963. bp.StmtEnddate = end_time
  37964. bps = append(bps, &bp)
  37965. data := make(map[string]interface{})
  37966. data["bps"] = bps
  37967. data["org_name"] = miConfig.OrgName
  37968. data["doctor"] = role.UserName
  37969. data["fixmedins_code"] = miConfig.Code
  37970. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37971. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37972. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37973. if miConfig.MdtrtareaAdmvs == "421300" {
  37974. client := &http.Client{}
  37975. bytesData, _ := json.Marshal(data)
  37976. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37977. resp, _ := client.Do(req)
  37978. defer resp.Body.Close()
  37979. body, ioErr := ioutil.ReadAll(resp.Body)
  37980. if ioErr != nil {
  37981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37983. return
  37984. }
  37985. var respJSON map[string]interface{}
  37986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37989. return
  37990. }
  37991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37992. userJSONBytes, _ := json.Marshal(respJSON)
  37993. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37994. utils.ErrorLog("解析失败:%v", err)
  37995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37996. return
  37997. }
  37998. }
  37999. if miConfig.MdtrtareaAdmvs == "420200" {
  38000. client := &http.Client{}
  38001. bytesData, _ := json.Marshal(data)
  38002. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  38003. resp, _ := client.Do(req)
  38004. defer resp.Body.Close()
  38005. body, ioErr := ioutil.ReadAll(resp.Body)
  38006. if ioErr != nil {
  38007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38009. return
  38010. }
  38011. var respJSON map[string]interface{}
  38012. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38015. return
  38016. }
  38017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38018. userJSONBytes, _ := json.Marshal(respJSON)
  38019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38020. utils.ErrorLog("解析失败:%v", err)
  38021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38022. return
  38023. }
  38024. }
  38025. if miConfig.MdtrtareaAdmvs == "421182" {
  38026. client := &http.Client{}
  38027. bytesData, _ := json.Marshal(data)
  38028. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38029. resp, _ := client.Do(req)
  38030. defer resp.Body.Close()
  38031. body, ioErr := ioutil.ReadAll(resp.Body)
  38032. if ioErr != nil {
  38033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38035. return
  38036. }
  38037. var respJSON map[string]interface{}
  38038. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38041. return
  38042. }
  38043. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38044. userJSONBytes, _ := json.Marshal(respJSON)
  38045. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38046. utils.ErrorLog("解析失败:%v", err)
  38047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38048. return
  38049. }
  38050. }
  38051. if miConfig.MdtrtareaAdmvs == "420902" {
  38052. client := &http.Client{}
  38053. bytesData, _ := json.Marshal(data)
  38054. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38055. resp, _ := client.Do(req)
  38056. defer resp.Body.Close()
  38057. body, ioErr := ioutil.ReadAll(resp.Body)
  38058. if ioErr != nil {
  38059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38061. return
  38062. }
  38063. var respJSON map[string]interface{}
  38064. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38067. return
  38068. }
  38069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38070. userJSONBytes, _ := json.Marshal(respJSON)
  38071. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38072. utils.ErrorLog("解析失败:%v", err)
  38073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38074. return
  38075. }
  38076. }
  38077. if res.Infcode == 0 {
  38078. c.ServeSuccessJSON(map[string]interface{}{
  38079. "msg": "发起成功",
  38080. })
  38081. } else {
  38082. c.ServeSuccessJSON(map[string]interface{}{
  38083. "failed_code": -10,
  38084. "msg": res.ErrMsg,
  38085. })
  38086. }
  38087. }
  38088. }
  38089. func (c *HisApiController) Post3204a() {
  38090. start_time := c.GetString("start_time")
  38091. end_time := c.GetString("end_time")
  38092. //insutype := c.GetString("insutype")
  38093. clr_type := c.GetString("clr_type")
  38094. clr_org := c.GetString("clr_optins")
  38095. admin_user_id, _ := c.GetInt64("admin_user_id")
  38096. adminUser := c.GetAdminUserInfo()
  38097. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38098. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38099. if len(clr_org) == 0 {
  38100. clr_org = miConfig.MdtrtareaAdmvs
  38101. }
  38102. timeLayout := "2006-01-02"
  38103. loc, _ := time.LoadLocation("Local")
  38104. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38105. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38106. var orders []*models.HisOrder
  38107. if clr_org == "421300" {
  38108. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38109. } else if clr_org == "420902" {
  38110. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38111. } else {
  38112. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38113. }
  38114. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38115. //fixmedins_setl_cnt := int64(len(orders))
  38116. var medfee_sumamt float64
  38117. var acct_pay float64
  38118. var fund_pay_sumamt float64
  38119. for _, item := range orders {
  38120. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38121. acct_pay = acct_pay + item.AcctPay
  38122. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38123. }
  38124. //var medfee_sumamt_two float64
  38125. //var acct_pay_two float64
  38126. //var fund_pay_sumamt_two float64
  38127. //for _, item := range orders_two {
  38128. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38129. // acct_pay_two = acct_pay_two + item.AcctPay
  38130. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38131. //}
  38132. //var user_name string
  38133. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38134. //if role.ID == 0 {
  38135. // user_name = "xxx"
  38136. //} else {
  38137. // user_name = role.UserName
  38138. //}
  38139. var res ResultSix
  38140. if config.IsOpen == 1 {
  38141. var bps []*models.BusinessParamsTwo
  38142. var bp models.BusinessParamsTwo
  38143. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38144. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38145. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38146. bp.MedfeeSumamt = medfee_sumamt_str
  38147. bp.AcctPay = acct_pay_str
  38148. bp.FundPaySumamt = fund_pay_sumamt_str
  38149. bp.Insutype = ""
  38150. bp.StmtBegndate = start_time
  38151. bp.ClrType = clr_type
  38152. bp.SetlOptins = clr_org
  38153. bp.StmtEnddate = end_time
  38154. bps = append(bps, &bp)
  38155. data := make(map[string]interface{})
  38156. data["bps"] = bps
  38157. data["org_name"] = miConfig.OrgName
  38158. data["doctor"] = role.UserName
  38159. data["fixmedins_code"] = miConfig.Code
  38160. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38161. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38162. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38163. if miConfig.MdtrtareaAdmvs == "421300" {
  38164. client := &http.Client{}
  38165. bytesData, _ := json.Marshal(data)
  38166. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38167. resp, _ := client.Do(req)
  38168. defer resp.Body.Close()
  38169. body, ioErr := ioutil.ReadAll(resp.Body)
  38170. if ioErr != nil {
  38171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38173. return
  38174. }
  38175. var respJSON map[string]interface{}
  38176. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38179. return
  38180. }
  38181. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38182. userJSONBytes, _ := json.Marshal(respJSON)
  38183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38184. utils.ErrorLog("解析失败:%v", err)
  38185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38186. return
  38187. }
  38188. }
  38189. if miConfig.MdtrtareaAdmvs == "420200" {
  38190. client := &http.Client{}
  38191. bytesData, _ := json.Marshal(data)
  38192. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38193. resp, _ := client.Do(req)
  38194. defer resp.Body.Close()
  38195. body, ioErr := ioutil.ReadAll(resp.Body)
  38196. if ioErr != nil {
  38197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38199. return
  38200. }
  38201. var respJSON map[string]interface{}
  38202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38205. return
  38206. }
  38207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38208. userJSONBytes, _ := json.Marshal(respJSON)
  38209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38210. utils.ErrorLog("解析失败:%v", err)
  38211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38212. return
  38213. }
  38214. }
  38215. if miConfig.MdtrtareaAdmvs == "421182" {
  38216. client := &http.Client{}
  38217. bytesData, _ := json.Marshal(data)
  38218. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38219. resp, _ := client.Do(req)
  38220. defer resp.Body.Close()
  38221. body, ioErr := ioutil.ReadAll(resp.Body)
  38222. if ioErr != nil {
  38223. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38225. return
  38226. }
  38227. var respJSON map[string]interface{}
  38228. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38229. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38231. return
  38232. }
  38233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38234. userJSONBytes, _ := json.Marshal(respJSON)
  38235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38236. utils.ErrorLog("解析失败:%v", err)
  38237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38238. return
  38239. }
  38240. }
  38241. if miConfig.MdtrtareaAdmvs == "420902" {
  38242. client := &http.Client{}
  38243. bytesData, _ := json.Marshal(data)
  38244. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38245. resp, _ := client.Do(req)
  38246. defer resp.Body.Close()
  38247. body, ioErr := ioutil.ReadAll(resp.Body)
  38248. if ioErr != nil {
  38249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38251. return
  38252. }
  38253. var respJSON map[string]interface{}
  38254. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38257. return
  38258. }
  38259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38260. userJSONBytes, _ := json.Marshal(respJSON)
  38261. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38262. utils.ErrorLog("解析失败:%v", err)
  38263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38264. return
  38265. }
  38266. }
  38267. if res.Infcode == 0 {
  38268. c.ServeSuccessJSON(map[string]interface{}{
  38269. "msg": "撤销成功",
  38270. })
  38271. } else {
  38272. c.ServeSuccessJSON(map[string]interface{}{
  38273. "failed_code": -10,
  38274. "msg": res.ErrMsg,
  38275. })
  38276. }
  38277. }
  38278. }
  38279. func (c *HisApiController) Post3204() {
  38280. admin_user_id, _ := c.GetInt64("admin_user_id")
  38281. id := c.GetString("id")
  38282. adminUser := c.GetAdminUserInfo()
  38283. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38284. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38285. //clr_org := miConfig.MdtrtareaAdmvs
  38286. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38287. var res ResultSix
  38288. if config.IsOpen == 1 {
  38289. data := make(map[string]interface{})
  38290. data["id"] = id
  38291. data["org_name"] = miConfig.OrgName
  38292. data["doctor"] = role.UserName
  38293. data["fixmedins_code"] = miConfig.Code
  38294. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38295. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38296. client := &http.Client{}
  38297. bytesData, _ := json.Marshal(data)
  38298. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38299. resp, _ := client.Do(req)
  38300. defer resp.Body.Close()
  38301. body, ioErr := ioutil.ReadAll(resp.Body)
  38302. if ioErr != nil {
  38303. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38305. return
  38306. }
  38307. var respJSON map[string]interface{}
  38308. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38311. return
  38312. }
  38313. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38314. userJSONBytes, _ := json.Marshal(respJSON)
  38315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38316. utils.ErrorLog("解析失败:%v", err)
  38317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38318. return
  38319. }
  38320. if res.Infcode == 0 {
  38321. c.ServeSuccessJSON(map[string]interface{}{
  38322. "msg": "发起成功",
  38323. })
  38324. } else {
  38325. c.ServeSuccessJSON(map[string]interface{}{
  38326. "failed_code": -10,
  38327. "msg": res.ErrMsg,
  38328. })
  38329. }
  38330. }
  38331. }
  38332. func (c *HisApiController) Post8404() {
  38333. admin_user_id, _ := c.GetInt64("admin_user_id")
  38334. month := c.GetString("month")
  38335. adminUser := c.GetAdminUserInfo()
  38336. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38337. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38338. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38339. var res ResultSix
  38340. if config.IsOpen == 1 {
  38341. data := make(map[string]interface{})
  38342. data["month"] = month
  38343. data["org_name"] = miConfig.OrgName
  38344. data["doctor"] = role.UserName
  38345. data["fixmedins_code"] = miConfig.Code
  38346. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38347. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38348. client := &http.Client{}
  38349. bytesData, _ := json.Marshal(data)
  38350. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38351. resp, _ := client.Do(req)
  38352. defer resp.Body.Close()
  38353. body, ioErr := ioutil.ReadAll(resp.Body)
  38354. if ioErr != nil {
  38355. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38357. return
  38358. }
  38359. var respJSON map[string]interface{}
  38360. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38363. return
  38364. }
  38365. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38366. userJSONBytes, _ := json.Marshal(respJSON)
  38367. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38368. utils.ErrorLog("解析失败:%v", err)
  38369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38370. return
  38371. }
  38372. if res.Infcode == 0 {
  38373. c.ServeSuccessJSON(map[string]interface{}{
  38374. "msg": "查询成功",
  38375. })
  38376. } else {
  38377. c.ServeSuccessJSON(map[string]interface{}{
  38378. "failed_code": -10,
  38379. "msg": res.ErrMsg,
  38380. })
  38381. }
  38382. }
  38383. }
  38384. func (c *HisApiController) Post3202b() {
  38385. start_time := c.GetString("start_time")
  38386. end_time := c.GetString("end_time")
  38387. //insutype := c.GetString("insutype")
  38388. clr_type := c.GetString("clr_type")
  38389. clr_org := c.GetString("clr_optins")
  38390. admin_user_id, _ := c.GetInt64("admin_user_id")
  38391. adminUser := c.GetAdminUserInfo()
  38392. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38393. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38394. if len(clr_org) == 0 {
  38395. clr_org = miConfig.MdtrtareaAdmvs
  38396. }
  38397. timeLayout := "2006-01-02"
  38398. loc, _ := time.LoadLocation("Local")
  38399. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38400. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38401. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38402. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38403. //fixmedins_setl_cnt := int64(len(orders))
  38404. var medfee_sumamt float64
  38405. var acct_pay float64
  38406. var fund_pay_sumamt float64
  38407. for _, item := range orders {
  38408. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38409. acct_pay = acct_pay + item.AcctPay
  38410. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38411. }
  38412. //var medfee_sumamt_two float64
  38413. //var acct_pay_two float64
  38414. //var fund_pay_sumamt_two float64
  38415. //for _, item := range orders_two {
  38416. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38417. // acct_pay_two = acct_pay_two + item.AcctPay
  38418. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38419. //}
  38420. //var user_name string
  38421. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38422. //if role.ID == 0 {
  38423. // user_name = "xxx"
  38424. //} else {
  38425. // user_name = role.UserName
  38426. //}
  38427. var res ResultSix
  38428. if config.IsOpen == 1 {
  38429. var bps []*models.BusinessParamsTwo
  38430. var bp models.BusinessParamsTwo
  38431. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38432. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38433. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38434. bp.MedfeeSumamt = medfee_sumamt_str
  38435. bp.AcctPay = acct_pay_str
  38436. bp.FundPaySumamt = fund_pay_sumamt_str
  38437. bp.Insutype = "390"
  38438. bp.StmtBegndate = start_time
  38439. bp.ClrType = clr_type
  38440. bp.SetlOptins = clr_org
  38441. bp.StmtEnddate = end_time
  38442. bps = append(bps, &bp)
  38443. data := make(map[string]interface{})
  38444. data["bps"] = bps
  38445. data["org_name"] = miConfig.OrgName
  38446. data["doctor"] = role.UserName
  38447. data["fixmedins_code"] = miConfig.Code
  38448. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38449. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38450. if miConfig.MdtrtareaAdmvs == "421300" {
  38451. client := &http.Client{}
  38452. bytesData, _ := json.Marshal(data)
  38453. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38454. resp, _ := client.Do(req)
  38455. defer resp.Body.Close()
  38456. body, ioErr := ioutil.ReadAll(resp.Body)
  38457. if ioErr != nil {
  38458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38460. return
  38461. }
  38462. var respJSON map[string]interface{}
  38463. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38466. return
  38467. }
  38468. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38469. userJSONBytes, _ := json.Marshal(respJSON)
  38470. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38471. utils.ErrorLog("解析失败:%v", err)
  38472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38473. return
  38474. }
  38475. }
  38476. if miConfig.MdtrtareaAdmvs == "420200" {
  38477. client := &http.Client{}
  38478. bytesData, _ := json.Marshal(data)
  38479. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38480. resp, _ := client.Do(req)
  38481. defer resp.Body.Close()
  38482. body, ioErr := ioutil.ReadAll(resp.Body)
  38483. if ioErr != nil {
  38484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38486. return
  38487. }
  38488. var respJSON map[string]interface{}
  38489. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38492. return
  38493. }
  38494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38495. userJSONBytes, _ := json.Marshal(respJSON)
  38496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38497. utils.ErrorLog("解析失败:%v", err)
  38498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38499. return
  38500. }
  38501. }
  38502. if miConfig.MdtrtareaAdmvs == "421182" {
  38503. client := &http.Client{}
  38504. bytesData, _ := json.Marshal(data)
  38505. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38506. resp, _ := client.Do(req)
  38507. defer resp.Body.Close()
  38508. body, ioErr := ioutil.ReadAll(resp.Body)
  38509. if ioErr != nil {
  38510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38512. return
  38513. }
  38514. var respJSON map[string]interface{}
  38515. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38518. return
  38519. }
  38520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38521. userJSONBytes, _ := json.Marshal(respJSON)
  38522. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38523. utils.ErrorLog("解析失败:%v", err)
  38524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38525. return
  38526. }
  38527. }
  38528. if res.Infcode == 0 {
  38529. c.ServeSuccessJSON(map[string]interface{}{
  38530. "msg": "发起成功",
  38531. })
  38532. } else {
  38533. c.ServeSuccessJSON(map[string]interface{}{
  38534. "failed_code": -10,
  38535. "msg": res.ErrMsg,
  38536. })
  38537. }
  38538. }
  38539. }
  38540. func (c *HisApiController) Post1608() {
  38541. start_time := c.GetString("start_time")
  38542. end_time := c.GetString("end_time")
  38543. admin_user_id, _ := c.GetInt64("admin_user_id")
  38544. adminUser := c.GetAdminUserInfo()
  38545. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38546. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38547. timeLayout := "2006-01-02"
  38548. loc, _ := time.LoadLocation("Local")
  38549. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38550. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38551. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38552. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38553. fixmedins_setl_cnt := int64(len(orders))
  38554. var medfee_sumamt float64
  38555. var func_smamt float64
  38556. for _, item := range orders {
  38557. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38558. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38559. }
  38560. times := strings.Split(start_time, "-")
  38561. time_tows := strings.Split(end_time, "-")
  38562. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38563. var res ResultSix
  38564. if config.IsOpen == 1 {
  38565. //var bps []*models.BusinessParamsTwo
  38566. //var bp models.BusinessParamsTwo
  38567. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38568. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38569. data := make(map[string]interface{})
  38570. data["org_name"] = miConfig.OrgName
  38571. data["doctor"] = role.UserName
  38572. data["func_smamt"] = func_smamt_str
  38573. data["fixmedins_code"] = miConfig.Code
  38574. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38575. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38576. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38577. data["medfee_sumamt"] = medfee_sumamt_str
  38578. data["start_time"] = times[0] + times[1] + times[2]
  38579. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38580. if miConfig.MdtrtareaAdmvs == "421300" {
  38581. client := &http.Client{}
  38582. bytesData, _ := json.Marshal(data)
  38583. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38584. resp, _ := client.Do(req)
  38585. defer resp.Body.Close()
  38586. body, ioErr := ioutil.ReadAll(resp.Body)
  38587. if ioErr != nil {
  38588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38590. return
  38591. }
  38592. var respJSON map[string]interface{}
  38593. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38596. return
  38597. }
  38598. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38599. userJSONBytes, _ := json.Marshal(respJSON)
  38600. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38601. utils.ErrorLog("解析失败:%v", err)
  38602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38603. return
  38604. }
  38605. }
  38606. if miConfig.MdtrtareaAdmvs == "420200" {
  38607. client := &http.Client{}
  38608. bytesData, _ := json.Marshal(data)
  38609. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38610. resp, _ := client.Do(req)
  38611. defer resp.Body.Close()
  38612. body, ioErr := ioutil.ReadAll(resp.Body)
  38613. if ioErr != nil {
  38614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38616. return
  38617. }
  38618. var respJSON map[string]interface{}
  38619. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38622. return
  38623. }
  38624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38625. userJSONBytes, _ := json.Marshal(respJSON)
  38626. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38627. utils.ErrorLog("解析失败:%v", err)
  38628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38629. return
  38630. }
  38631. }
  38632. if miConfig.MdtrtareaAdmvs == "421182" {
  38633. client := &http.Client{}
  38634. bytesData, _ := json.Marshal(data)
  38635. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38636. resp, _ := client.Do(req)
  38637. defer resp.Body.Close()
  38638. body, ioErr := ioutil.ReadAll(resp.Body)
  38639. if ioErr != nil {
  38640. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38642. return
  38643. }
  38644. var respJSON map[string]interface{}
  38645. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38648. return
  38649. }
  38650. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38651. userJSONBytes, _ := json.Marshal(respJSON)
  38652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38653. utils.ErrorLog("解析失败:%v", err)
  38654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38655. return
  38656. }
  38657. }
  38658. if res.Infcode == 0 {
  38659. c.ServeSuccessJSON(map[string]interface{}{
  38660. "msg": "发起成功",
  38661. })
  38662. } else {
  38663. c.ServeSuccessJSON(map[string]interface{}{
  38664. "failed_code": -10,
  38665. "msg": res.ErrMsg,
  38666. })
  38667. }
  38668. }
  38669. }
  38670. // 5.11.1.1【5262】结算信息按时间段查询
  38671. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38672. admin_user_id, _ := c.GetInt64("admin_user_id")
  38673. adminUser := c.GetAdminUserInfo()
  38674. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38675. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38676. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38677. var res Result5262
  38678. if config.IsOpen == 1 {
  38679. if miConfig.MdtrtareaAdmvs == "421300" {
  38680. data := make(map[string]interface{})
  38681. data["bps"] = bp
  38682. data["org_name"] = miConfig.OrgName
  38683. data["doctor"] = role.UserName
  38684. data["fixmedins_code"] = miConfig.Code
  38685. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38686. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38687. data["page"] = strconv.FormatInt(page, 10)
  38688. data["limit"] = strconv.FormatInt(limit, 10)
  38689. fmt.Println(data)
  38690. client := &http.Client{}
  38691. bytesData, _ := json.Marshal(data)
  38692. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38693. resp, _ := client.Do(req)
  38694. defer resp.Body.Close()
  38695. body, ioErr := ioutil.ReadAll(resp.Body)
  38696. if ioErr != nil {
  38697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38699. return
  38700. }
  38701. var respJSON map[string]interface{}
  38702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38705. return
  38706. }
  38707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38708. userJSONBytes, _ := json.Marshal(respJSON)
  38709. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38710. utils.ErrorLog("解析失败:%v", err)
  38711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38712. return
  38713. }
  38714. }
  38715. if miConfig.MdtrtareaAdmvs == "420200" {
  38716. data := make(map[string]interface{})
  38717. data["bps"] = bp
  38718. data["org_name"] = miConfig.OrgName
  38719. data["doctor"] = role.UserName
  38720. data["fixmedins_code"] = miConfig.Code
  38721. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38722. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38723. data["page"] = strconv.FormatInt(page, 10)
  38724. data["limit"] = strconv.FormatInt(limit, 10)
  38725. fmt.Println(data)
  38726. client := &http.Client{}
  38727. bytesData, _ := json.Marshal(data)
  38728. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38729. resp, _ := client.Do(req)
  38730. defer resp.Body.Close()
  38731. body, ioErr := ioutil.ReadAll(resp.Body)
  38732. if ioErr != nil {
  38733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38735. return
  38736. }
  38737. var respJSON map[string]interface{}
  38738. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38741. return
  38742. }
  38743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38744. userJSONBytes, _ := json.Marshal(respJSON)
  38745. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38746. utils.ErrorLog("解析失败:%v", err)
  38747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38748. return
  38749. }
  38750. }
  38751. if miConfig.MdtrtareaAdmvs == "421182" {
  38752. data := make(map[string]interface{})
  38753. data["bps"] = bp
  38754. data["org_name"] = miConfig.OrgName
  38755. data["doctor"] = role.UserName
  38756. data["fixmedins_code"] = miConfig.Code
  38757. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38758. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38759. data["page"] = strconv.FormatInt(page, 10)
  38760. data["limit"] = strconv.FormatInt(limit, 10)
  38761. fmt.Println(data)
  38762. client := &http.Client{}
  38763. bytesData, _ := json.Marshal(data)
  38764. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38765. resp, _ := client.Do(req)
  38766. defer resp.Body.Close()
  38767. body, ioErr := ioutil.ReadAll(resp.Body)
  38768. if ioErr != nil {
  38769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38771. return
  38772. }
  38773. var respJSON map[string]interface{}
  38774. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38777. return
  38778. }
  38779. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38780. userJSONBytes, _ := json.Marshal(respJSON)
  38781. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38782. utils.ErrorLog("解析失败:%v", err)
  38783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38784. return
  38785. }
  38786. }
  38787. if miConfig.MdtrtareaAdmvs == "420902" {
  38788. data := make(map[string]interface{})
  38789. data["bps"] = bp
  38790. data["org_name"] = miConfig.OrgName
  38791. data["doctor"] = role.UserName
  38792. data["fixmedins_code"] = miConfig.Code
  38793. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38794. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38795. data["page"] = strconv.FormatInt(page, 10)
  38796. data["limit"] = strconv.FormatInt(limit, 10)
  38797. fmt.Println(data)
  38798. client := &http.Client{}
  38799. bytesData, _ := json.Marshal(data)
  38800. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38801. resp, _ := client.Do(req)
  38802. defer resp.Body.Close()
  38803. body, ioErr := ioutil.ReadAll(resp.Body)
  38804. if ioErr != nil {
  38805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38807. return
  38808. }
  38809. var respJSON map[string]interface{}
  38810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38813. return
  38814. }
  38815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38816. userJSONBytes, _ := json.Marshal(respJSON)
  38817. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38818. utils.ErrorLog("解析失败:%v", err)
  38819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38820. return
  38821. }
  38822. }
  38823. if res.Infcode == 0 {
  38824. c.ServeSuccessJSON(map[string]interface{}{
  38825. "order": res.Output.Result,
  38826. "total": res.Output.PageInfo.RecordCounts,
  38827. })
  38828. } else {
  38829. c.ServeSuccessJSON(map[string]interface{}{
  38830. "failed_code": -10,
  38831. "msg": res.ErrMsg,
  38832. })
  38833. }
  38834. }
  38835. }
  38836. // 5.11.1.2【5267】异地结算信息时间段查询
  38837. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38838. admin_user_id, _ := c.GetInt64("admin_user_id")
  38839. adminUser := c.GetAdminUserInfo()
  38840. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38841. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38842. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38843. var res Result5267
  38844. if config.IsOpen == 1 {
  38845. if miConfig.MdtrtareaAdmvs == "421300" {
  38846. data := make(map[string]interface{})
  38847. data["bps"] = bp
  38848. data["org_name"] = miConfig.OrgName
  38849. data["doctor"] = role.UserName
  38850. data["fixmedins_code"] = miConfig.Code
  38851. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38852. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38853. data["page"] = page
  38854. data["limit"] = limit
  38855. fmt.Println(data)
  38856. client := &http.Client{}
  38857. bytesData, _ := json.Marshal(data)
  38858. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38859. resp, _ := client.Do(req)
  38860. defer resp.Body.Close()
  38861. body, ioErr := ioutil.ReadAll(resp.Body)
  38862. if ioErr != nil {
  38863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38865. return
  38866. }
  38867. var respJSON map[string]interface{}
  38868. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38871. return
  38872. }
  38873. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38874. userJSONBytes, _ := json.Marshal(respJSON)
  38875. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38876. utils.ErrorLog("解析失败:%v", err)
  38877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38878. return
  38879. }
  38880. }
  38881. if miConfig.MdtrtareaAdmvs == "420200" {
  38882. data := make(map[string]interface{})
  38883. data["bps"] = bp
  38884. data["org_name"] = miConfig.OrgName
  38885. data["doctor"] = role.UserName
  38886. data["fixmedins_code"] = miConfig.Code
  38887. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38888. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38889. data["page"] = page
  38890. data["limit"] = limit
  38891. fmt.Println(data)
  38892. client := &http.Client{}
  38893. bytesData, _ := json.Marshal(data)
  38894. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38895. resp, _ := client.Do(req)
  38896. defer resp.Body.Close()
  38897. body, ioErr := ioutil.ReadAll(resp.Body)
  38898. if ioErr != nil {
  38899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38901. return
  38902. }
  38903. var respJSON map[string]interface{}
  38904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38907. return
  38908. }
  38909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38910. userJSONBytes, _ := json.Marshal(respJSON)
  38911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38912. utils.ErrorLog("解析失败:%v", err)
  38913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38914. return
  38915. }
  38916. }
  38917. if miConfig.MdtrtareaAdmvs == "421182" {
  38918. data := make(map[string]interface{})
  38919. data["bps"] = bp
  38920. data["org_name"] = miConfig.OrgName
  38921. data["doctor"] = role.UserName
  38922. data["fixmedins_code"] = miConfig.Code
  38923. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38924. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38925. data["page"] = page
  38926. data["limit"] = limit
  38927. fmt.Println(data)
  38928. client := &http.Client{}
  38929. bytesData, _ := json.Marshal(data)
  38930. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38931. resp, _ := client.Do(req)
  38932. defer resp.Body.Close()
  38933. body, ioErr := ioutil.ReadAll(resp.Body)
  38934. if ioErr != nil {
  38935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38937. return
  38938. }
  38939. var respJSON map[string]interface{}
  38940. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38943. return
  38944. }
  38945. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38946. userJSONBytes, _ := json.Marshal(respJSON)
  38947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38948. utils.ErrorLog("解析失败:%v", err)
  38949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38950. return
  38951. }
  38952. }
  38953. if res.Infcode == 0 {
  38954. c.ServeSuccessJSON(map[string]interface{}{
  38955. "order": res.Output.Result,
  38956. "total": res.Output.PageInfo.RecordCounts,
  38957. })
  38958. } else {
  38959. c.ServeSuccessJSON(map[string]interface{}{
  38960. "failed_code": -10,
  38961. "msg": res.ErrMsg,
  38962. })
  38963. }
  38964. }
  38965. }
  38966. func (c *HisApiController) Post3501() {
  38967. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38968. data := make(map[string]interface{})
  38969. var struct3501s []models.Struct3501
  38970. var struct3501 models.Struct3501
  38971. struct3501.OrgName = miConfig.OrgName
  38972. struct3501.AccessKey = miConfig.AccessKey
  38973. struct3501.RequestUrl = miConfig.Url
  38974. struct3501.SecretKey = miConfig.SecretKey
  38975. struct3501.ManuDate = "2022-08-17"
  38976. struct3501.FixmedinsBchno = ""
  38977. struct3501.ManuLotnum = ""
  38978. struct3501.RxFlag = "0"
  38979. struct3501.ExpyEnd = "2022-08-17"
  38980. struct3501.Invdate = "2022-08-17"
  38981. struct3501.InvCnt = "20.25"
  38982. struct3501.Memo = ""
  38983. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38984. struct3501.FixmedinsHilistId = miConfig.Code
  38985. struct3501.FixmedinsHilistName = miConfig.OrgName
  38986. struct3501s = append(struct3501s, struct3501)
  38987. data["struct_3501s"] = struct3501s
  38988. client := &http.Client{}
  38989. bytesData, _ := json.Marshal(data)
  38990. var req *http.Request
  38991. if miConfig.MdtrtareaAdmvs == "320921" {
  38992. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38993. } else {
  38994. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38995. }
  38996. resp, _ := client.Do(req)
  38997. defer resp.Body.Close()
  38998. body, ioErr := ioutil.ReadAll(resp.Body)
  38999. if ioErr != nil {
  39000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39002. return
  39003. }
  39004. var respJSON map[string]interface{}
  39005. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39008. return
  39009. }
  39010. var res ResultSix
  39011. var resSix10265 ResultSix10265 //1101结果
  39012. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39013. result, _ := json.Marshal(respJSON)
  39014. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39015. utils.ErrorLog("解析失败:%v", err)
  39016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39017. return
  39018. }
  39019. res.InfRefmsgid = resSix10265.InfRefmsgid
  39020. res.Output = resSix10265.Output
  39021. res.ErrMsg = resSix10265.ErrMsg
  39022. res.Cainfo = resSix10265.Cainfo
  39023. res.WarnMsg = resSix10265.WarnMsg
  39024. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39025. res.Infcode = infocode
  39026. if infocode == 0 {
  39027. c.ServeSuccessJSON(map[string]interface{}{
  39028. "msg": "上传成功",
  39029. })
  39030. return
  39031. } else {
  39032. c.ServeSuccessJSON(map[string]interface{}{
  39033. "failed_code": -10,
  39034. "msg": res.ErrMsg,
  39035. })
  39036. return
  39037. }
  39038. }
  39039. func (c *HisApiController) Post3502() {
  39040. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39041. data := make(map[string]interface{})
  39042. var struct3502s []models.Struct3502
  39043. var struct3502 models.Struct3502
  39044. struct3502.OrgName = miConfig.OrgName
  39045. struct3502.AccessKey = miConfig.AccessKey
  39046. struct3502.RequestUrl = miConfig.Url
  39047. struct3502.SecretKey = miConfig.SecretKey
  39048. struct3502.ManuDate = "2022-08-15"
  39049. struct3502.FixmedinsBchno = ""
  39050. struct3502.ManuLotnum = ""
  39051. struct3502.RxFlag = "0"
  39052. struct3502.ExpyEnd = "2022-08-15"
  39053. struct3502.Invdate = "2022-08-15"
  39054. struct3502.InvCnt = "20.25"
  39055. struct3502.Memo = ""
  39056. struct3502.MedListCodg = "XB01ABD056B002020200517"
  39057. struct3502.FixmedinsHilistId = miConfig.Code
  39058. struct3502.FixmedinsHilistName = miConfig.OrgName
  39059. struct3502s = append(struct3502s, struct3502)
  39060. data["struct_3502s"] = struct3502s
  39061. client := &http.Client{}
  39062. bytesData, _ := json.Marshal(data)
  39063. var req *http.Request
  39064. if miConfig.MdtrtareaAdmvs == "320921" {
  39065. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39066. } else {
  39067. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39068. }
  39069. resp, _ := client.Do(req)
  39070. defer resp.Body.Close()
  39071. body, ioErr := ioutil.ReadAll(resp.Body)
  39072. if ioErr != nil {
  39073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39075. return
  39076. }
  39077. var respJSON map[string]interface{}
  39078. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39081. return
  39082. }
  39083. var res ResultSix
  39084. var resSix10265 ResultSix10265 //1101结果
  39085. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39086. result, _ := json.Marshal(respJSON)
  39087. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39088. utils.ErrorLog("解析失败:%v", err)
  39089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39090. return
  39091. }
  39092. res.InfRefmsgid = resSix10265.InfRefmsgid
  39093. res.Output = resSix10265.Output
  39094. res.ErrMsg = resSix10265.ErrMsg
  39095. res.Cainfo = resSix10265.Cainfo
  39096. res.WarnMsg = resSix10265.WarnMsg
  39097. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39098. res.Infcode = infocode
  39099. if infocode == 0 {
  39100. c.ServeSuccessJSON(map[string]interface{}{
  39101. "msg": "上传成功",
  39102. })
  39103. return
  39104. } else {
  39105. c.ServeSuccessJSON(map[string]interface{}{
  39106. "failed_code": -10,
  39107. "msg": res.ErrMsg,
  39108. })
  39109. return
  39110. }
  39111. }
  39112. func (c *HisApiController) Post3503() {
  39113. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39114. data := make(map[string]interface{})
  39115. var struct3501s []models.Struct3501
  39116. var struct3501 models.Struct3501
  39117. struct3501.OrgName = miConfig.OrgName
  39118. struct3501.AccessKey = miConfig.AccessKey
  39119. struct3501.RequestUrl = miConfig.Url
  39120. struct3501.SecretKey = miConfig.SecretKey
  39121. struct3501.ManuDate = "2022-08-15"
  39122. struct3501.FixmedinsBchno = ""
  39123. struct3501.ManuLotnum = ""
  39124. struct3501.RxFlag = "0"
  39125. struct3501.ExpyEnd = "2022-08-15"
  39126. struct3501.Invdate = "2022-08-15"
  39127. struct3501.InvCnt = "20.25"
  39128. struct3501.Memo = ""
  39129. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39130. struct3501.FixmedinsHilistId = miConfig.Code
  39131. struct3501.FixmedinsHilistName = miConfig.OrgName
  39132. struct3501s = append(struct3501s, struct3501)
  39133. data["struct_3501s"] = struct3501s
  39134. client := &http.Client{}
  39135. bytesData, _ := json.Marshal(data)
  39136. var req *http.Request
  39137. if miConfig.MdtrtareaAdmvs == "320921" {
  39138. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39139. } else {
  39140. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39141. }
  39142. resp, _ := client.Do(req)
  39143. defer resp.Body.Close()
  39144. body, ioErr := ioutil.ReadAll(resp.Body)
  39145. if ioErr != nil {
  39146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39148. return
  39149. }
  39150. var respJSON map[string]interface{}
  39151. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39154. return
  39155. }
  39156. var res ResultSix
  39157. var resSix10265 ResultSix10265 //1101结果
  39158. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39159. result, _ := json.Marshal(respJSON)
  39160. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39161. utils.ErrorLog("解析失败:%v", err)
  39162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39163. return
  39164. }
  39165. res.InfRefmsgid = resSix10265.InfRefmsgid
  39166. res.Output = resSix10265.Output
  39167. res.ErrMsg = resSix10265.ErrMsg
  39168. res.Cainfo = resSix10265.Cainfo
  39169. res.WarnMsg = resSix10265.WarnMsg
  39170. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39171. res.Infcode = infocode
  39172. if infocode == 0 {
  39173. c.ServeSuccessJSON(map[string]interface{}{
  39174. "msg": "上传成功",
  39175. })
  39176. return
  39177. } else {
  39178. c.ServeSuccessJSON(map[string]interface{}{
  39179. "failed_code": -10,
  39180. "msg": res.ErrMsg,
  39181. })
  39182. return
  39183. }
  39184. }
  39185. func (c *HisApiController) Post3504() {
  39186. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39187. data := make(map[string]interface{})
  39188. var struct3501s []models.Struct3501
  39189. var struct3501 models.Struct3501
  39190. struct3501.OrgName = miConfig.OrgName
  39191. struct3501.AccessKey = miConfig.AccessKey
  39192. struct3501.RequestUrl = miConfig.Url
  39193. struct3501.SecretKey = miConfig.SecretKey
  39194. struct3501.ManuDate = "2022-08-15"
  39195. struct3501.FixmedinsBchno = ""
  39196. struct3501.ManuLotnum = ""
  39197. struct3501.RxFlag = "0"
  39198. struct3501.ExpyEnd = "2022-08-15"
  39199. struct3501.Invdate = "2022-08-15"
  39200. struct3501.InvCnt = "20.25"
  39201. struct3501.Memo = ""
  39202. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39203. struct3501.FixmedinsHilistId = miConfig.Code
  39204. struct3501.FixmedinsHilistName = miConfig.OrgName
  39205. struct3501s = append(struct3501s, struct3501)
  39206. data["struct_3501s"] = struct3501s
  39207. client := &http.Client{}
  39208. bytesData, _ := json.Marshal(data)
  39209. var req *http.Request
  39210. if miConfig.MdtrtareaAdmvs == "320921" {
  39211. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39212. } else {
  39213. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39214. }
  39215. resp, _ := client.Do(req)
  39216. defer resp.Body.Close()
  39217. body, ioErr := ioutil.ReadAll(resp.Body)
  39218. if ioErr != nil {
  39219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39221. return
  39222. }
  39223. var respJSON map[string]interface{}
  39224. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39227. return
  39228. }
  39229. var res ResultSix
  39230. var resSix10265 ResultSix10265 //1101结果
  39231. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39232. result, _ := json.Marshal(respJSON)
  39233. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39234. utils.ErrorLog("解析失败:%v", err)
  39235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39236. return
  39237. }
  39238. res.InfRefmsgid = resSix10265.InfRefmsgid
  39239. res.Output = resSix10265.Output
  39240. res.ErrMsg = resSix10265.ErrMsg
  39241. res.Cainfo = resSix10265.Cainfo
  39242. res.WarnMsg = resSix10265.WarnMsg
  39243. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39244. res.Infcode = infocode
  39245. if infocode == 0 {
  39246. c.ServeSuccessJSON(map[string]interface{}{
  39247. "msg": "上传成功",
  39248. })
  39249. return
  39250. } else {
  39251. c.ServeSuccessJSON(map[string]interface{}{
  39252. "failed_code": -10,
  39253. "msg": res.ErrMsg,
  39254. })
  39255. return
  39256. }
  39257. }
  39258. func (c *HisApiController) Post3505() {
  39259. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39260. data := make(map[string]interface{})
  39261. var struct3501s []models.Struct3501
  39262. var struct3501 models.Struct3501
  39263. struct3501.OrgName = miConfig.OrgName
  39264. struct3501.AccessKey = miConfig.AccessKey
  39265. struct3501.RequestUrl = miConfig.Url
  39266. struct3501.SecretKey = miConfig.SecretKey
  39267. struct3501.ManuDate = "2022-08-15"
  39268. struct3501.FixmedinsBchno = ""
  39269. struct3501.ManuLotnum = ""
  39270. struct3501.RxFlag = "0"
  39271. struct3501.ExpyEnd = "2022-08-15"
  39272. struct3501.Invdate = "2022-08-15"
  39273. struct3501.InvCnt = "20.25"
  39274. struct3501.Memo = ""
  39275. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39276. struct3501.FixmedinsHilistId = miConfig.Code
  39277. struct3501.FixmedinsHilistName = miConfig.OrgName
  39278. struct3501s = append(struct3501s, struct3501)
  39279. data["struct_3501s"] = struct3501s
  39280. client := &http.Client{}
  39281. bytesData, _ := json.Marshal(data)
  39282. var req *http.Request
  39283. if miConfig.MdtrtareaAdmvs == "320921" {
  39284. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39285. } else {
  39286. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39287. }
  39288. resp, _ := client.Do(req)
  39289. defer resp.Body.Close()
  39290. body, ioErr := ioutil.ReadAll(resp.Body)
  39291. if ioErr != nil {
  39292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39294. return
  39295. }
  39296. var respJSON map[string]interface{}
  39297. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39300. return
  39301. }
  39302. var res ResultSix
  39303. var resSix10265 ResultSix10265 //1101结果
  39304. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39305. result, _ := json.Marshal(respJSON)
  39306. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39307. utils.ErrorLog("解析失败:%v", err)
  39308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39309. return
  39310. }
  39311. res.InfRefmsgid = resSix10265.InfRefmsgid
  39312. res.Output = resSix10265.Output
  39313. res.ErrMsg = resSix10265.ErrMsg
  39314. res.Cainfo = resSix10265.Cainfo
  39315. res.WarnMsg = resSix10265.WarnMsg
  39316. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39317. res.Infcode = infocode
  39318. if infocode == 0 {
  39319. c.ServeSuccessJSON(map[string]interface{}{
  39320. "msg": "上传成功",
  39321. })
  39322. return
  39323. } else {
  39324. c.ServeSuccessJSON(map[string]interface{}{
  39325. "failed_code": -10,
  39326. "msg": res.ErrMsg,
  39327. })
  39328. return
  39329. }
  39330. }
  39331. func (c *HisApiController) Post3506() {
  39332. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39333. data := make(map[string]interface{})
  39334. var struct3501s []models.Struct3501
  39335. var struct3501 models.Struct3501
  39336. struct3501.OrgName = miConfig.OrgName
  39337. struct3501.AccessKey = miConfig.AccessKey
  39338. struct3501.RequestUrl = miConfig.Url
  39339. struct3501.SecretKey = miConfig.SecretKey
  39340. struct3501.ManuDate = "2022-08-15"
  39341. struct3501.FixmedinsBchno = ""
  39342. struct3501.ManuLotnum = ""
  39343. struct3501.RxFlag = "0"
  39344. struct3501.ExpyEnd = "2022-08-15"
  39345. struct3501.Invdate = "2022-08-15"
  39346. struct3501.InvCnt = "20.25"
  39347. struct3501.Memo = ""
  39348. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39349. struct3501.FixmedinsHilistId = miConfig.Code
  39350. struct3501.FixmedinsHilistName = miConfig.OrgName
  39351. struct3501s = append(struct3501s, struct3501)
  39352. data["struct_3501s"] = struct3501s
  39353. client := &http.Client{}
  39354. bytesData, _ := json.Marshal(data)
  39355. var req *http.Request
  39356. if miConfig.MdtrtareaAdmvs == "320921" {
  39357. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39358. } else {
  39359. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39360. }
  39361. resp, _ := client.Do(req)
  39362. defer resp.Body.Close()
  39363. body, ioErr := ioutil.ReadAll(resp.Body)
  39364. if ioErr != nil {
  39365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39367. return
  39368. }
  39369. var respJSON map[string]interface{}
  39370. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39373. return
  39374. }
  39375. var res ResultSix
  39376. var resSix10265 ResultSix10265 //1101结果
  39377. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39378. result, _ := json.Marshal(respJSON)
  39379. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39380. utils.ErrorLog("解析失败:%v", err)
  39381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39382. return
  39383. }
  39384. res.InfRefmsgid = resSix10265.InfRefmsgid
  39385. res.Output = resSix10265.Output
  39386. res.ErrMsg = resSix10265.ErrMsg
  39387. res.Cainfo = resSix10265.Cainfo
  39388. res.WarnMsg = resSix10265.WarnMsg
  39389. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39390. res.Infcode = infocode
  39391. if infocode == 0 {
  39392. c.ServeSuccessJSON(map[string]interface{}{
  39393. "msg": "上传成功",
  39394. })
  39395. return
  39396. } else {
  39397. c.ServeSuccessJSON(map[string]interface{}{
  39398. "failed_code": -10,
  39399. "msg": res.ErrMsg,
  39400. })
  39401. return
  39402. }
  39403. }
  39404. func (c *HisApiController) Post3507() {
  39405. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39406. data := make(map[string]interface{})
  39407. var struct3501s []models.Struct3501
  39408. var struct3501 models.Struct3501
  39409. struct3501.OrgName = miConfig.OrgName
  39410. struct3501.AccessKey = miConfig.AccessKey
  39411. struct3501.RequestUrl = miConfig.Url
  39412. struct3501.SecretKey = miConfig.SecretKey
  39413. struct3501.ManuDate = "2022-08-15"
  39414. struct3501.FixmedinsBchno = ""
  39415. struct3501.ManuLotnum = ""
  39416. struct3501.RxFlag = "0"
  39417. struct3501.ExpyEnd = "2022-08-15"
  39418. struct3501.Invdate = "2022-08-15"
  39419. struct3501.InvCnt = "20.25"
  39420. struct3501.Memo = ""
  39421. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39422. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39423. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39424. struct3501s = append(struct3501s, struct3501)
  39425. data["struct_3501s"] = struct3501s
  39426. client := &http.Client{}
  39427. bytesData, _ := json.Marshal(data)
  39428. var req *http.Request
  39429. if miConfig.MdtrtareaAdmvs == "320921" {
  39430. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39431. } else {
  39432. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39433. }
  39434. resp, _ := client.Do(req)
  39435. defer resp.Body.Close()
  39436. body, ioErr := ioutil.ReadAll(resp.Body)
  39437. if ioErr != nil {
  39438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39440. return
  39441. }
  39442. var respJSON map[string]interface{}
  39443. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39446. return
  39447. }
  39448. var res ResultSix
  39449. var resSix10265 ResultSix10265 //1101结果
  39450. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39451. result, _ := json.Marshal(respJSON)
  39452. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39453. utils.ErrorLog("解析失败:%v", err)
  39454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39455. return
  39456. }
  39457. res.InfRefmsgid = resSix10265.InfRefmsgid
  39458. res.Output = resSix10265.Output
  39459. res.ErrMsg = resSix10265.ErrMsg
  39460. res.Cainfo = resSix10265.Cainfo
  39461. res.WarnMsg = resSix10265.WarnMsg
  39462. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39463. res.Infcode = infocode
  39464. if infocode == 0 {
  39465. c.ServeSuccessJSON(map[string]interface{}{
  39466. "msg": "上传成功",
  39467. })
  39468. return
  39469. } else {
  39470. c.ServeSuccessJSON(map[string]interface{}{
  39471. "failed_code": -10,
  39472. "msg": res.ErrMsg,
  39473. })
  39474. return
  39475. }
  39476. }
  39477. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39478. // WebSocket服务器地址
  39479. serverURL := "ws://127.0.0.1:8899"
  39480. // 解析WebSocket服务器地址
  39481. u, err := url.Parse(serverURL)
  39482. if err != nil {
  39483. }
  39484. // 建立WebSocket连接
  39485. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39486. if err != nil {
  39487. }
  39488. defer conn.Close()
  39489. input2 := make(map[string]interface{})
  39490. input := make(map[string]interface{})
  39491. inputData := make(map[string]interface{})
  39492. inputData["orgId"] = code
  39493. inputData["businessType"] = "01101"
  39494. inputData["operatorId"] = operator_id
  39495. inputData["operatorName"] = operator_name
  39496. inputData["officeId"] = "001"
  39497. inputData["officeName"] = "血透室"
  39498. inputData["deviceType"] = ""
  39499. input["data"] = inputData
  39500. input["orgId"] = code
  39501. input["transType"] = "ec.query"
  39502. //if md == ""
  39503. if md[:4] == "4403" {
  39504. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39505. } else if md[:4] == "4401" {
  39506. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39507. } else {
  39508. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39509. }
  39510. input2["indata"] = input
  39511. fmt.Println(input2)
  39512. bytesData, _ := json.Marshal(input2)
  39513. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39514. if err != nil {
  39515. fmt.Println(err)
  39516. }
  39517. // 接收消息
  39518. _, receivedMessage, err := conn.ReadMessage()
  39519. if err != nil {
  39520. fmt.Println(err)
  39521. }
  39522. return "", string(receivedMessage)
  39523. }
  39524. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39525. // WebSocket服务器地址
  39526. serverURL := "ws://127.0.0.1:8899"
  39527. // 解析WebSocket服务器地址
  39528. u, err := url.Parse(serverURL)
  39529. if err != nil {
  39530. }
  39531. // 建立WebSocket连接
  39532. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39533. if err != nil {
  39534. }
  39535. defer conn.Close()
  39536. input2 := make(map[string]interface{})
  39537. input := make(map[string]interface{})
  39538. inputData := make(map[string]interface{})
  39539. inputData["orgId"] = code
  39540. inputData["businessType"] = "01101"
  39541. inputData["operatorId"] = operator_id
  39542. inputData["operatorName"] = operator_name
  39543. inputData["officeId"] = "001"
  39544. inputData["officeName"] = "血透室"
  39545. inputData["deviceType"] = ""
  39546. input["data"] = inputData
  39547. input["orgId"] = code
  39548. input["transType"] = "ec.query"
  39549. //if md == ""
  39550. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39551. input2["indata"] = input
  39552. fmt.Println(input2)
  39553. bytesData, _ := json.Marshal(input2)
  39554. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39555. if err != nil {
  39556. fmt.Println(err)
  39557. }
  39558. // 接收消息
  39559. _, receivedMessage, err := conn.ReadMessage()
  39560. if err != nil {
  39561. fmt.Println(err)
  39562. }
  39563. return "", string(receivedMessage)
  39564. }
  39565. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39566. // WebSocket服务器地址
  39567. serverURL := "ws://127.0.0.1:8899"
  39568. // 解析WebSocket服务器地址
  39569. u, err := url.Parse(serverURL)
  39570. if err != nil {
  39571. }
  39572. // 建立WebSocket连接
  39573. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39574. if err != nil {
  39575. }
  39576. defer conn.Close()
  39577. input2 := make(map[string]interface{})
  39578. input := make(map[string]interface{})
  39579. inputData := make(map[string]interface{})
  39580. inputData["orgId"] = code
  39581. inputData["businessType"] = "01301"
  39582. inputData["operatorId"] = operator_id
  39583. inputData["operatorName"] = operator_name
  39584. inputData["officeId"] = "001"
  39585. inputData["officeName"] = "血透室"
  39586. inputData["deviceType"] = ""
  39587. input["data"] = inputData
  39588. input["orgId"] = code
  39589. input["transType"] = "ec.query"
  39590. //if md == ""
  39591. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39592. input2["indata"] = input
  39593. fmt.Println(input2)
  39594. bytesData, _ := json.Marshal(input2)
  39595. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39596. if err != nil {
  39597. fmt.Println(err)
  39598. }
  39599. // 接收消息
  39600. _, receivedMessage, err := conn.ReadMessage()
  39601. if err != nil {
  39602. fmt.Println(err)
  39603. }
  39604. return "", string(receivedMessage)
  39605. }
  39606. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39607. // WebSocket服务器地址
  39608. serverURL := "ws://127.0.0.1:8899"
  39609. // 解析WebSocket服务器地址
  39610. u, err := url.Parse(serverURL)
  39611. if err != nil {
  39612. }
  39613. // 建立WebSocket连接
  39614. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39615. if err != nil {
  39616. }
  39617. defer conn.Close()
  39618. input2 := make(map[string]interface{})
  39619. input := make(map[string]interface{})
  39620. inputData := make(map[string]interface{})
  39621. inputData["orgId"] = code
  39622. inputData["businessType"] = "01103"
  39623. inputData["operatorId"] = operator_id
  39624. inputData["operatorName"] = operator_name
  39625. inputData["officeId"] = "001"
  39626. inputData["officeName"] = "血透室"
  39627. inputData["deviceType"] = ""
  39628. input["data"] = inputData
  39629. input["orgId"] = code
  39630. input["transType"] = "ec.query"
  39631. //if md ==
  39632. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39633. input2["indata"] = input
  39634. fmt.Println(input2)
  39635. bytesData, _ := json.Marshal(input2)
  39636. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39637. if err != nil {
  39638. fmt.Println(err)
  39639. }
  39640. // 接收消息
  39641. _, receivedMessage, err := conn.ReadMessage()
  39642. if err != nil {
  39643. fmt.Println(err)
  39644. }
  39645. return "", string(receivedMessage)
  39646. }
  39647. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39648. // WebSocket服务器地址
  39649. serverURL := "ws://127.0.0.1:8899"
  39650. // 解析WebSocket服务器地址
  39651. u, err := url.Parse(serverURL)
  39652. if err != nil {
  39653. }
  39654. // 建立WebSocket连接
  39655. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39656. if err != nil {
  39657. }
  39658. defer conn.Close()
  39659. input2 := make(map[string]interface{})
  39660. input := make(map[string]interface{})
  39661. inputData := make(map[string]interface{})
  39662. inputData["orgId"] = code
  39663. inputData["businessType"] = "01101"
  39664. inputData["operatorId"] = operator_id
  39665. inputData["operatorName"] = operator_name
  39666. inputData["officeId"] = "001"
  39667. inputData["officeName"] = "血透室"
  39668. inputData["deviceType"] = ""
  39669. input["data"] = inputData
  39670. input["orgId"] = code
  39671. input["transType"] = "ec.query"
  39672. //if md == ""
  39673. if md[:4] == "4403" {
  39674. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39675. } else if md[:4] == "4401" {
  39676. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39677. } else {
  39678. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39679. }
  39680. input2["indata"] = input
  39681. fmt.Println(input2)
  39682. bytesData, _ := json.Marshal(input2)
  39683. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39684. if err != nil {
  39685. fmt.Println(err)
  39686. }
  39687. // 接收消息
  39688. _, receivedMessage, err := conn.ReadMessage()
  39689. if err != nil {
  39690. fmt.Println(err)
  39691. }
  39692. return "", string(receivedMessage)
  39693. }
  39694. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39695. // WebSocket服务器地址
  39696. serverURL := "ws://127.0.0.1:8899"
  39697. // 解析WebSocket服务器地址
  39698. u, err := url.Parse(serverURL)
  39699. if err != nil {
  39700. }
  39701. // 建立WebSocket连接
  39702. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39703. if err != nil {
  39704. }
  39705. defer conn.Close()
  39706. input2 := make(map[string]interface{})
  39707. input := make(map[string]interface{})
  39708. inputData := make(map[string]interface{})
  39709. inputData["orgId"] = code
  39710. inputData["businessType"] = "01301"
  39711. inputData["operatorId"] = operator_id
  39712. inputData["operatorName"] = operator_name
  39713. inputData["officeId"] = "001"
  39714. inputData["officeName"] = "血透室"
  39715. inputData["deviceType"] = ""
  39716. input["data"] = inputData
  39717. input["orgId"] = code
  39718. input["transType"] = "ec.query"
  39719. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39720. input2["indata"] = input
  39721. bytesData, _ := json.Marshal(input2)
  39722. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39723. if err != nil {
  39724. fmt.Println(err)
  39725. }
  39726. // 接收消息
  39727. _, receivedMessage, err := conn.ReadMessage()
  39728. if err != nil {
  39729. fmt.Println(err)
  39730. }
  39731. return "", string(receivedMessage)
  39732. }
  39733. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39734. newArr = make([]string, 0)
  39735. for i := 0; i < len(arr); i++ {
  39736. repeat := false
  39737. for j := i + 1; j < len(arr); j++ {
  39738. if arr[i] == arr[j] {
  39739. repeat = true
  39740. break
  39741. }
  39742. }
  39743. if !repeat {
  39744. newArr = append(newArr, arr[i])
  39745. }
  39746. }
  39747. return
  39748. }
  39749. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39750. if len(idNumber) != 18 {
  39751. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39752. }
  39753. // 提取出生日期
  39754. year, err := strconv.Atoi(idNumber[6:10])
  39755. if err != nil {
  39756. return "", 0, err
  39757. }
  39758. month, err := strconv.Atoi(idNumber[10:12])
  39759. if err != nil {
  39760. return "", 0, err
  39761. }
  39762. day, err := strconv.Atoi(idNumber[12:14])
  39763. if err != nil {
  39764. return "", 0, err
  39765. }
  39766. // 格式化生日字符串
  39767. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39768. birthdateFormatted := birthdate.Format("2006-01-02")
  39769. // 计算年龄
  39770. today := time.Now()
  39771. age := today.Year() - birthdate.Year()
  39772. if today.YearDay() < birthdate.YearDay() {
  39773. age--
  39774. }
  39775. return birthdateFormatted, age, nil
  39776. }
  39777. // 从身份证号码中提取出生年月日
  39778. func getBirthDateFromIDCard(idCard string) (string, error) {
  39779. // 身份证号码长度应为18位
  39780. if len(idCard) != 18 {
  39781. return "", fmt.Errorf("身份证号码长度应为18位")
  39782. }
  39783. // 提取出生日期部分 (YYYYMMDD)
  39784. birthDateStr := idCard[6:14]
  39785. // 解析出生日期
  39786. birthDate, err := time.Parse("20060102", birthDateStr)
  39787. if err != nil {
  39788. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39789. }
  39790. // 格式化出生日期为 YYYY-MM-DD
  39791. formattedDate := birthDate.Format("2006-01-02")
  39792. return formattedDate, nil
  39793. }